Skip to content

1149722739/RecCocktail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RecCocktail: A Generalizable and Efficient Framework for LLM-Based Recommendation

1. Introduction


We propose a generalizable and efficient LLM-based recommendation framework RecCocktail. Our approach begins with fine-tuning a "base spirit" LoRA module using domain-general recommendation instruction data to align LLM with recommendation knowledge. Next, given users' behavior of a specific domain, we construct a domain-specific "ingredient" LoRA module. We then provide an entropy-guided adaptive merging method to mix the "base spirit" and the "ingredient" in the weight space. Please note that, RecCocktail combines the advantages of the existing two paradigms without introducing additional time or space overhead during the inference phase. Moreover, RecCocktail is efficient with plug and play, as the "base spirit" LoRA is trained only once, and any domain-specific "ingredient" can be efficiently mixed with only domain-specific fine-tuning.

In the following, we will guide you how to use this repository step by step. 🤗

2. Preparation

2.1 Requirements

You can use the following commands to configure the environment required for codes.

conda create -n molorec python=3.11.9  
conda activate molorec
sh scripts\env.sh

2.2 Data Preparation

You can use the following commands to download and process the dataset.

sh scripts\download_data.sh
sh scripts\make_data.sh

Of course, you can also directly download the processed data from the [Google Drive]. Note that the cold start test dataset does not have processing code and needs to be downloaded.

3. Training

3.1 module training

First, download Qwen2-7B-Instruct into folder models, then use the following commands to get general module and specific module.

sh scripts\train_lora.sh

Since the dataset involves random sampling, it may lead to fluctuations in the results, so you can download the module we provide from the [Google Drive]

3.2 Weights learning

First, replace the files in models\Qwen2-7B-Instruct with the files in models\Qwen2-7B-Instruct-edit, then use the following commands to learn the weights of module fusion.

sh scripts\beauty_weights.sh
sh scripts\toys_weights.sh
sh scripts\sports_weights.sh

4. Test and Metrics

You can use the following commands to test model

sh scripts\test_weights.sh

And use the following commands to find best fusion weights and output the metrics

sh scripts\metrics.sh

5. Acknowledgements

Our code is based on the implementation of peft and transformers.
We also leverage LLaMA-Factory and vllm to better perform large model fine-tuning and inference.
Thanks for their wonderful works.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published