Home

Awesome

RDRec (ACL'24)

Paper - [ArXiv] [ACL Anthology]

Note

Instruction

Step. 1 distill rationale before running RDRec

(a) Install llama 2 (download model weights and tokenizer)

    get the License from [the site](https://llama.meta.com/llama-downloads/)
    >> cd llama 
    >> ./download.sh (License required)
    >> pip install -e .

(b) Test llama 2 environment (under ./llama )

    >> torchrun --nproc_per_node 1 example_chat_completion.py \
      --ckpt_dir llama-2-7b-chat/ \
      --tokenizer_path tokenizer.model \
      --max_seq_len 512 --max_batch_size 6

(c) Rationale distillation ({dataset}: beauty, sports, and toys.) (under ./RDRec )

    >> torchrun --nproc_per_node 1 data/{dataset}/distillation_{dataset}.py \
      --ckpt_dir llama/llama-2-7b-chat/ \
      --tokenizer_path llama/tokenizer.model \
      --max_seq_len 512 --max_batch_size 6

Step. 2 train and test RDRec

(a) Install requirement

    >> pip install -r requirements.txt

(b) Pre-training ({dataset}: beauty, sports, and toys.) (under ./RDRec )

    >> python pretrain.py --data_dir ./data/{dataset}/ --cuda --batch_size 64 --checkpoint ./checkpoint/{dataset}/

(c) Recommendation inference

    >> python seq.py --data_dir ./data/{dataset}/ --cuda --batch_size 32 --checkpoint ./checkpoint/{dataset}/
    >> python topn.py --data_dir ./data/{dataset}/ --cuda --batch_size 32 --checkpoint ./checkpoint/{dataset}/
    >> python exp.py --data_dir ./data/{dataset}/ --cuda --batch_size 32 --checkpoint ./checkpoint/{dataset}/

Others

Code Reference

Citation

If this repository helps you, please cite:

@article{wang2024rdrec,
  title={RDRec: Rationale Distillation for LLM-based Recommendation},
  author={Wang, Xinfeng and Cui, Jin and Suzuki, Yoshimi and Fukumoto, Fumiyo},
  journal={arXiv preprint arXiv:2405.10587},
  year={2024}
}

More Recent Paper - [ArXiv] [Code]