Recent advancements in Large Language Models (LLMs) have attracted considerable interest among researchers to leverage these models to enhance Recommender Systems (RSs). Existing work predominantly utilizes LLMs to generate knowledge-rich texts or to utilize LLM-derived embeddings as features to improve RSs. Although the extensive world knowledge embedded in LLMs generally benefits RSs, the application is still limited due to the constraints in leveraging a large number of users/items in a single prompt. Considering its crucial role in RSs, one key challenge in enhancing RSs with LLMs lies in providing better collaborative filtering information through LLMs. In this paper, drawing inspiration from the in-context learning and chain of thought reasoning in LLMs, we propose the Large Language Models enhanced Collaborative Filtering (LLM-CF) framework, which distils the world knowledge and reasoning capabilities of LLMs into collaborative filtering through an in-context, chain of thought methodology. We also explored a concise and efficient instruction-tuning method, which improves the recommendation capabilities of LLMs while preserving their general functionalities. Our framework is model-agnostic and efficient for deployment. Comprehensive experiments on three real-world datasets demonstrate that LLM-CF significantly enhances several backbone recommendation models and consistently outperforms competitive baselines, showcasing its effectiveness in distilling the world knowledge and reasoning capabilities of LLM into collaborative filtering.
The training process of RecGen-LLaMA is based on the open-sourced LLaMA-Factory.
The LLaMA-2-7b-chat can be downloaded from huggingface.
cd LLaMA-Factory/
bash run_sfts.sh
The matching model can be downloaded from huggingface.
cd LLaMA-Factory/generate/
LLM-CF does not require generating CoT Reasoning for all the historical data. We adopted uniform random sampling to obtain 1/10 of the data from the training set for the generation.
bash run_gen_beauty.sh run_gen_sports.sh run_gen_toys.sh
bash run_score_beauty.sh run_score_sports.sh run_score_toys.sh
python analysis_score.py
python add_user_pos.py
python retrieval_ICL.py
python retrieval_ICL_retrieval.py
python convert_cot_embedding.py
cd ranking_task/src_code
bash run_beauty.sh run_sports.sh run_toys.sh
cd retrieval_task/src_code
bash run_beauty.sh run_sports.sh run_toys.sh
The parameters used in above code are shown in their own files as default parameters.
@article{sun2024large,
title={Large Language Models Enhanced Collaborative Filtering},
author={Sun, Zhongxiang and Si, Zihua and Zang, Xiaoxue and Zheng, Kai and Song, Yang and Zhang, Xiao and Xu, Jun},
journal={arXiv preprint arXiv:2403.17688},
year={2024}
}