Giter VIP home page Giter VIP logo

facebookresearch / generative-recommenders Goto Github PK

View Code? Open in Web Editor NEW
239.0 16.0 33.0 50 KB

Repository hosting code used to reproduce results in "Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations" (https://arxiv.org/abs/2402.17152, ICML'24).

License: Apache License 2.0

Python 100.00%
actions-speak-louder-than-words recommendations recsys generative-recommenders hstu recommender-systems

generative-recommenders's Introduction

Generative Recommenders

Repository hosting code for Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations (https://arxiv.org/abs/2402.17152, to appear in ICML'24).

Currently only code for reproducing public experiments listed in the paper (Section 4.1.1) are included. We plan to release custom kernels for HSTU needed for throughput/performance benchmarks at a later point in time.

Getting started

Public experiments

To reproduce the public experiments (traditional sequential recommender setting, Section 4.1.1) on MovieLens and Amazon Reviews in the paper, please follow these steps:

Install dependencies.

Install PyTorch based on official instructions. Then,

pip3 install gin-config absl-py scikit-learn scipy matplotlib numpy apex hypothesis pandas fbgemm_gpu iopath

Download and preprocess data.

mkdir -p tmp/ && python3 preprocess_public_data.py

Run model training.

A GPU with 24GB or more HBM should work for most datasets.

CUDA_VISIBLE_DEVICES=0 python3 train.py --gin_config_file=configs/ml-1m/hstu-sampled-softmax-n128-large-final.gin --master_port=12345

Other configurations are included in configs/ml-1m, configs/ml-20m, and configs/amzn-books to make reproducing these experiments easier.

Verify results.

By default we write experimental logs to exps/. We can launch tensorboard with something like the following:

tensorboard --logdir ~/generative-recommenders/exps/ml-1m-l200/ --port 24001 --bind_all
tensorboard --logdir ~/generative-recommenders/exps/ml-20m-l200/ --port 24001 --bind_all
tensorboard --logdir ~/generative-recommenders/exps/amzn-books-l50/ --port 24001 --bind_all

With the provided configuration (.gin) files, you should be able to reproduce the following results (verified as of 04/15/2024):

MovieLens-1M (ML-1M):

Method HR@10 NDCG@10 HR@50 NDCG@50 HR@200 NDCG@200
SASRec 0.2853 0.1603 0.5474 0.2185 0.7528 0.2498
BERT4Rec 0.2843 (-0.4%) 0.1537 (-4.1%)
GRU4Rec 0.2811 (-1.5%) 0.1648 (+2.8%)
HSTU 0.3097 (+8.6%) 0.1720 (+7.3%) 0.5754 (+5.1%) 0.2307 (+5.6%) 0.7716 (+2.5%) 0.2606 (+4.3%)
HSTU-large 0.3294 (+15.5%) 0.1893 (+18.1%) 0.5935 (+8.4%) 0.2481 (+13.5%) 0.7839 (+4.1%) 0.2771 (+10.9%)

MovieLens-20M (ML-20M):

Method HR@10 NDCG@10 HR@50 NDCG@50 HR@200 NDCG@200
SASRec 0.2889 0.1621 0.5503 0.2199 0.7661 0.2527
BERT4Rec 0.2816 (-2.5%) 0.1703 (+5.1%)
GRU4Rec 0.2813 (-2.6%) 0.1730 (+6.7%)
HSTU 0.3273 (+13.3%) 0.1895 (+16.9%) 0.5889 (+7.0%) 0.2473 (+12.5%) 0.7952 (+3.8%) 0.2787 (+10.3%)
HSTU-large 0.3556 (+23.1%) 0.2098 (+29.4%) 0.6143 (+11.6%) 0.2671 (+21.5%) 0.8074 (+5.4%) 0.2965 (+17.4%)

Amazon Reviews (Books):

Method HR@10 NDCG@10 HR@50 NDCG@50 HR@200 NDCG@200
SASRec 0.0306 0.0164 0.0754 0.0260 0.1431 0.0362
HSTU 0.0416 (+36.4%) 0.0227 (+39.3%) 0.0957 (+27.1%) 0.0344 (+32.3%) 0.1735 (+21.3%) 0.0461 (+27.7%)
HSTU-large 0.0478 (+56.7%) 0.0262 (+60.7%) 0.1082 (+43.7%) 0.0393 (+51.2%) 0.1908 (+33.4%) 0.0517 (+43.2%)

for all three tables above, the SASRec rows are based on Self-Attentive Sequential Recommendation but with the original binary cross entropy loss replaced with sampled softmax losses proposed in Revisiting Neural Retrieval on Accelerators. These rows are reproducible with configs/*/sasrec-*-final.gin. The BERT4Rec and GRU4Rec rows are based on results reported by Turning Dross Into Gold Loss: is BERT4Rec really better than SASRec? - note that the comparison slightly favors these two, due to them using full negatives whereas the other rows used 128/512 sampled negatives. The HSTU and HSTU-large rows are based on Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations; in particular, HSTU rows utilize identical configurations as SASRec. HSTU and HSTU-large results can be reproduced with configs/*/hstu-*-final.gin.

Efficiency experiments

To be added at a later point in time.

License

This codebase is Apache 2.0 licensed, as found in the LICENSE file.

Contributors

The overall project is made possible thanks to the joint work from many technical contributors (listed in alphabetical order):

Adnan Akhundov, Bugra Akyildiz, Shabab Ayub, Alex Bao, Renqin Cai, Jennifer Cao, Xuan Cao, Guoqiang Jerry Chen, Lei Chen, Sean Chen, Xianjie Chen, Huihui Cheng, Weiwei Chu, Ted Cui, Shiyan Deng, Nimit Desai, Fei Ding, Shilin Ding, Francois Fagan, Lu Fang, Leon Gao, Zhaojie Gong, Fangda Gu, Liang Guo, Liz Guo, Jeevan Gyawali, Yuchen Hao, Daisy Shi He, Michael Jiayuan He, Samuel Hsia, Jie Hua, Yanzun Huang, Hongyi Jia, Rui Jian, Jian Jin, Rahul Kindi, Changkyu Kim, Yejin Lee, Fu Li, Hong Li, Shen Li, Rui Li, Wei Li, Zhijing Li, Lucy Liao, Xueting Liao, Emma Lin, Hao Lin, Jingzhou Liu, Xing Liu, Xingyu Liu, Kai Londenberg, Yinghai Lu, Liang Luo, Linjian Ma, Matt Ma, Yun Mao, Bert Maher, Ajit Mathews, Matthew Murphy, Satish Nadathur, Min Ni, Jongsoo Park, Jing Qian, Lijing Qin, Alex Singh, Timothy Shi, Yu Shi, Dennis van der Staay, Xiao Sun, Colin Taylor, Shin-Yeh Tsai, Rohan Varma, Omkar Vichare, Alyssa Wang, Pengchao Wang, Shengzhi Wang, Wenting Wang, Xiaolong Wang, Yueming Wang, Zhiyong Wang, Wei Wei, Bin Wen, Carole-Jean Wu, Yanhong Wu, Eric Xu, Bi Xue, Hong Yan, Zheng Yan, Chao Yang, Junjie Yang, Wen-Yun Yang, Zimeng Yang, Chunxing Yin, Daniel Yin, Yiling You, Jiaqi Zhai, Keke Zhai, Yanli Zhao, Zhuoran Zhao, Hui Zhang, Jingjing Zhang, Lu Zhang, Lujia Zhang, Na Zhang, Rui Zhang, Xiong Zhang, Ying Zhang, Zhiyun Zhang, Charles Zheng, Erheng Zhong, Xin Zhuang.

For the initial paper describing the Generative Recommender problem formulation and the HSTU architecture, please refer to Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations (https://arxiv.org/abs/2402.17152, ICML'24). More documentations, including an extended technical report, will follow later.

generative-recommenders's People

Contributors

facebook-github-bot avatar jiaqizhai avatar kitstar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

generative-recommenders's Issues

rank demo

Hey, guys. I saw the code here just work for Retrieval situation, when will you open the code for Ranking situation.

user-item interaction question

hi, guys, I have a question about user-item interaction here.

I want to test HSTU in our application, we have a lot of user-item impression, click and buy action. I want to construct the sequence with these action. If I just simple construct the sequence with the order of action timestamp, because for same user-time pair, we have more than one impression action, we'll have many same user-item-impression with different timestamp within one user sequence in one day.

I want to ask for the situation above, whether we need to deduplicate the impression action? Whether we should guarantee one user-item impression with the latest timestamp in one day.

TypeError: __call__() got an unexpected keyword argument 'target_ids'

when I run CUDA_VISIBLE_DEVICES=0 python3 train.py --gin_config_file=configs/ml-1m/hstu-sampled-softmax-n128-large-final.gin --master_port=12345 i got this error:

-- Process 0 terminated with the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/torch/multiprocessing/spawn.py", line 69, in _wrap
fn(i, *args)
File "/opt/tiger/demo_codes/generative-recommenders/train.py", line 497, in mp_train_fn
train_fn(rank, world_size, master_port)
File "/home/tiger/.local/lib/python3.9/site-packages/gin/config.py", line 1605, in gin_wrapper
utils.augment_exception_message_and_reraise(e, err_str)
File "/home/tiger/.local/lib/python3.9/site-packages/gin/utils.py", line 41, in augment_exception_message_and_reraise
raise proxy.with_traceback(exception.traceback) from None
File "/home/tiger/.local/lib/python3.9/site-packages/gin/config.py", line 1582, in gin_wrapper
return fn(*new_args, **new_kwargs)
File "/opt/tiger/demo_codes/generative-recommenders/train.py", line 334, in train_fn
eval_dict = eval_metrics_v2_from_tensors(
TypeError: call() got an unexpected keyword argument 'target_ids'
In call to configurable 'train_fn' (<function train_fn at 0x7f20346f44c0>)

Stochastic Length

Great Work! However, there doesn't appear to be any implement of the Stochastic Length and Sampling Technique ฮ“(S, L) in the paper.

question about the action part

Hello, this is a great piece of work! However, the current public experimental results seem to be based on not incorporating action into the input. The author appears to have defined the input ( in the CombinedItemAndRatingInputFeaturesPreprocessor part )but there is no specific implementation part. Could you release code of this part?

run error

hi, guys, I try to run the demo, and met some error here.

Traceback (most recent call last):
  File "/data/anaconda3/envs/pytorch3d/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 69, in _wrap
    fn(i, *args)
  File "/data/generative-recommenders/train.py", line 466, in mp_train_fn
    train_fn(rank, world_size, master_port)
  File "/data/anaconda3/envs/pytorch3d/lib/python3.8/site-packages/gin/config.py", line 1605, in gin_wrapper
    utils.augment_exception_message_and_reraise(e, err_str)
  File "/data/anaconda3/envs/pytorch3d/lib/python3.8/site-packages/gin/utils.py", line 41, in augment_exception_message_and_reraise
    raise proxy.with_traceback(exception.__traceback__) from None
  File "/data/anaconda3/envs/pytorch3d/lib/python3.8/site-packages/gin/config.py", line 1582, in gin_wrapper
    return fn(*new_args, **new_kwargs)
  File "/data/generative-recommenders/train.py", line 300, in train_fn
    eval_dict = eval_metrics_v2_from_tensors(
TypeError: __call__() got an unexpected keyword argument 'target_ids'

my python version is 3.8.17 , pytorch version is torch==2.0.1+cu117,

Run error

Hi team, which continer are you using ? I tried the "nvcr.io/nvidia/pytorch:23.11-py3" continer, but there has always been an issue with "RuntimeError: No such operator fbgem:: jagged_2d_to_dense"

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.