Giter VIP home page Giter VIP logo

llm-cf's Introduction

LLM-CF

This is the implementation for the paper "Large Language Model Enhanced Collaborative Filtering".

Overview

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.

Trainining and Evaluation

Train RecGen-LLaMA

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

CoT Reasoning Generation and In-context CoT Examples Retrieval

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

ranking task

cd ranking_task/src_code
bash run_beauty.sh run_sports.sh  run_toys.sh 

retrieval task

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}
}

llm-cf's People

Contributors

jeryi-sun avatar

Stargazers

Zihua Si avatar  avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.