Skip to content

"PersonalizedRouter: A Personalized LLM Router Based on User Preferences", Zhongjie Dai*, Tao Feng*, Jiaxuan You

License

Notifications You must be signed in to change notification settings

ulab-uiuc/PersonalizedRouter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PersonalizedRouter: A Personalized LLM Router Based on User Preferences

Build Build Build License
Build Build Build

🌐 Project Page | 📜 arXiv | 📮 Twitter Post

GoR

🛠️Preliminary

Environment Setup

# create a new conda environment
conda create -n personalizedrouter python=3.10
conda activate personalizedrouter

# install pytorch. Modify the command to align with your own CUDA version.
pip3 install torch  --index-url https://download.pytorch.org/whl/cu118

# install related libraries
pip install -r requirements.txt

# install pyg
pip install torch_geometric
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.1.0+cu118.html

Notation

In the project files, the suffix v1 refers to the Multi-cost-efficiency Simulation Strategy described in the paper, while v2 refers to the LLM-as-a-Judge Strategy.

Dataset Preparation

First, generate data/unified_qa_data.csv.

python data_processing/multidata_unify.py

Then, generate data/router_data_v1(v2).csv and configs/llm_description_embedding_v1(v2).pkl by setting your api_key in configs/config.yaml.

python data_processing/construct_router_data.py

For the LLM-as-a-Judge setting, generate llm_judge_results.csv

python data_processing/construct_llm_judge.py

In addition, we need to introduce user nodes to generate router_user_data_v1(v2).csv

python data_processing/add_user_data_v1.py

or

python data_processing/add_user_data_v2.py

For your convenience, we have provided the pre-generated files in the data folder, including all the files mentioned above. We also provide a Hugging Face dataset page, where you can directly download the data.

📝Experiments

Training and Evaluation

Run experiments and print/save evaluation results on metrics Performance, Cost, and Reward. You can edit the hyperparameters in configs/config.yaml or using your own config_file.

python run_exp.py --config_file [config]

About

"PersonalizedRouter: A Personalized LLM Router Based on User Preferences", Zhongjie Dai*, Tao Feng*, Jiaxuan You

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages