Home

Awesome

TiM4Rec: An Efficient Sequential Recommendation Model Based on Time-Aware Structured State Space Duality Model

PWC PWC PWC

Stars

Due to the laboratory regulations, the article has not been officially published before the model source code is not allowed to be published, so the current repository is not complete, but do not worry, we will supplement the complete model code immediately after the article is officially published. You can also first check the performance of the TiM4Rec model by using the training log files we published. 😊

ε¦‚ζžœζ‚¨ζƒ³ι˜…θ―»δΈ­ζ–‡η‰ˆζœ¬οΌŒθ―·η‚Ήε‡»README_CN.md 。

1. Introduction

<p align="center"> <img src="assert/tim4rec.png" alt="overview_of_tim4rec"/> </p>

TiM4Rec: An Efficient Sequential Recommendation Model Based on Time-Aware Structured State Space Duality Model
Hao Fan, Mengyi Zhu, Yanrong Hu, Hailin Feng, Zhijie He, Hongjiu Liu, Qingyang Liu
Paper: https://arxiv.org/abs/2409.16182v2

We propose TiM4Rec(Time-aware Mamba For Recommendation), an efficient sequential recommendation model based on Time-aware SSD. We conducted a pioneering exploration of the time-aware enhancement methods of the Mamba architecture in the field of sequential recommendation. Through an in-depth analysis of SSM and SSD, we propose, for the first time, a time-aware enhancement method with linear computational complexity that is applicable to the SSD architecture.

In the following, we will guide you how to use this repository step by step. πŸ€—

2. Preparation

git clone https://github.com/AlwaysFHao/TiM4Rec.git
cd TiM4Rec/

2.1 Environment Requirements

The following are the main runtime environment dependencies for running the repository:

If you are having trouble installing Mamba, please refer to the installation tutorial we wrote: https://github.com/AlwaysFHao/Mamba-Install.

You can also view detailed environment information in File environment.yaml.

2.2 DataSets

This work utilizes the following three datasets, among which 🎦 MovieLens-1M and πŸ›’ Amazon-Beauty dataset is provided by RecBole, πŸ“± KuaiRand dataset is provided by the author of SSD4Rec.

All dataset files can be obtained from the cloud storage: Quark Drive (password: SVzs) / BaiDu Cloud Drive (password: 1296).

2.3 Project Structure

In this section, you can learn about our project structure.

You can click on the directory below to expand and view the project structure:

<details><summary>πŸ“ TiM4Rec</summary> <ul> <li>πŸ“ assert | (Store readme related images) </li> <li>πŸ“ baseline | (The baseline model is covered in the paper) </li> <ul> <li>πŸ“ BERT4Rec</li> <ul> <li>πŸ“œ config.yaml</li> <li>🐍 run.py</li> </ul> <li>πŸ“ ...</li> </ul> <li>πŸ“ config | (Configuration file for TiM4Rec model) </li> <ul> <li>πŸ“œ config4beauty_64d.yaml</li> <li>πŸ“œ config4kuai_64d.yaml</li> <li>πŸ“œ config4movie_64d.yaml</li> <li>πŸ“œ config4movie_256d.yaml</li> </ul> <li>πŸ“ dataset | (Store dataset files) </li> <ul> <li>πŸ“ amazon-beauty</li> <ul> <li>πŸ“– amazon-beauty.inter</li> <li>πŸ“– amazon-beauty.item</li> </ul> <li>πŸ“ ... </li> </ul> <li>πŸ“ log | (Training log file)</li> <li>πŸ“ log_tensorboard | (Training log file of tensorboard)</li> <li>πŸ“ saved | (Saved model weight file)</li> <li>πŸ“œ environment.yaml</li> <li>🐍 run.py</li> <li>🐍 ssd.py</li> <li>🐍 test.py</li> <li>🐍 tim4rec.py</li> </ul> </details>

You can download files from the cloud storage and put them in the corresponding folder. Quark Drive (password: SVzs) / BaiDu Cloud Drive (password: 1296).

3. Run

Ok, congratulations πŸŽ‡, you have finished all the preparation πŸ‘, let's start training the model! πŸ˜„

This section will introduce the training methods of the model.

3.1 TiM4Rec

After preparing all the necessary files and runtime environment, please modify the configuration file path in 🐍 run.py in the following format:

config = Config(model=TiM4Rec, config_file_list=['config/config4{dataset_name}_{dim}d.yaml'])

Just run it directly:

python run.py

If you want to continue checkpoint training, you need to add the model weight path to the checkpoint_path configuration item in the corresponding configuration file.

checkpoint_path: saved/model_weight_name.pth

3.2 Baseline(Optional)

You can directly select the baseline model we have organized in the πŸ“ baseline folder for training, taking SASRec as an example.

cd ./baseline/SASRec
python run.py

3.3 Model testing

If you want to directly test the performance of a specified model weight, you can refer to the method in section 3.1, modify the configuration file name in the 🐍 test.py file and add the checkpoint_path item in the corresponding configuration file, and then perform the test:

python test.py

4. Acknowledgements

Our code implementation is based on the RecBole and Pytorch frameworks, and references the work of Mamba4Rec and Mamba. The replication of the baseline model is referenced from TiSASRec.pytorch and LRURec. In addition, our readme document was written with reference to MISSRec.

5. References

If you find this code useful or use the toolkit in your work, please consider citing:

@article{fan2024tim4rec,
  title={TiM4Rec: An Efficient Sequential Recommendation Model Based on Time-Aware Structured State Space Duality Model},
  author={Fan, Hao and Zhu, Mengyi and Hu, Yanrong and Feng, Hailin and He, Zhijie and Liu, Hongjiu and Liu, Qingyang},
  journal={arXiv preprint arXiv:2409.16182},
  year={2024}
}