This repository releases the code of paper UniTRec: A Unified Text-to-Text Transformer and Joint Contrastive Learning Framework for Text-based Recommendation (ACL-2023 Short Paper).
Our code will download and pre-tokenize the datasets automatically. Also refer to setup.sh.
cd textRec_datasets
python newsrec_tokenize.py
python quoterec_tokenize.py
python engagerec_tokenize.py
Suppose that two GPUs are available for training.
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 newsrec.py
CUDA_VISIBLE_DEVICES=2,3 python -m torch.distributed.launch --nproc_per_node=2 quoterec.py
CUDA_VISIBLE_DEVICES=4,5 python -m torch.distributed.launch --nproc_per_node=2 engagerec.py
The transformer codebase is adapted from Huggingface Transoformers. The UniTRec Model is written at transformers/models/UniTRec/modeling_unitrec.py.
The codes are now using two GPUs for training and one for inference. Acceleration can be achieved by distributed inference.
@inproceedings{mao-etal-2023-unitrec,
title = "UniTRec: A Unified Text-to-Text Transformer and Joint Contrastive Learning Framework for Text-based Recommendation",
author = "Mao, Zhiming and
Wang, Huimin and
Du, Yiming and
Wong, Kam-Fai",
booktitle = "Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers)",
month = jul,
year = "2023",
address = "Toronto, Canada",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2023.acl-short.100",
pages = "1160--1170"
}