Giter Club home page Giter Club logo

cce's Introduction

Code for our work: Effective and Efficient Training for Sequential Recommendation Using Cumulative Cross-Entropy Loss

The following is a brief directory structure and description of this example:

├── data
    ├── data_process.py # the data process file.
    ├── generate_test.py # generate the negative example for BCE loss.
    ├── Beauty_item2attributes.json # Item attributes for S3-Rec pre-training task.
    ├── Beauty_sample.txt # Negative sampling for binary cross-entropy loss in advance.
    ├── Beauty.txt # The user interaction records after data process.
    ├── ...
├── final_result # the model training log folder.
    ├── GRU4Rec # unzip the GRU4Rec.zip file here.
    ├── S3Rec # unzip the S3Rec.zip file here.
    ├── SASRec # unzip the SASRec.zip file here.
    ├── RQ2_data # This data is downloaded by the tensorbord of the above files.
├── imgs
    ├── Intruduction.svg # image in paper introduction.
    ├── RQ1.png 
    ├── RQ2.svg
    ├── RQ3.svg
├── README.md
├── datasets.py
├── loss.py
├── models.py
├── modules.py
├── pre_exam.ipynb # generate the experiments result of RQ3.
├── run_finetune_full.py
├── run_pretrain.py  # for the pre-training task of S3-Rec.
├── SR_fig_process.ipynb # draw image file.
├── trainers.py
├── utils.py

Note that the GRU4Rec.zip, S3Rec.zip, and SASRec.zip files are the training log run by ourselves. And due to the limitation of file size, we upload separately.

Environment

torch == 1.11.0 numpy==1.19.1 scipy==1.5.2 tqdm==4.48.2

python 3.7.3

os: windows/linux

Reproduce

Here we give a example:

python run_finetune_full.py --data_name LastFM --output_dir final_result/ --model_name GRU4Rec --istb 1 --loss_type CE_ALL

This example code means using CCE loss train GRU4Rec in LastFM datasets.

For data_name here are five choice: [Sports_and_Outdoors, Toys_and_Games, Yelp, Beauty, LastFM].

For loss_type [CE, PointwiseCE, CE_ALL], where CE reprensent the CE loss; PointwiseCE represent the BCE loss; CE_ALL represent the CCE loss.

Therefore, the result in Table 2 and Fig 2 can reproduce by runing the code below:

#GRU4Rec
python run_finetune_full.py --data_name LastFM --output_dir final_result/ --model_name GRU4Rec --istb 1 --loss_type CE_ALL
python run_finetune_full.py --data_name LastFM --output_dir final_result/ --model_name GRU4Rec --istb 1 --loss_type CE
python run_finetune_full.py --data_name LastFM --output_dir final_result/ --model_name GRU4Rec --istb 1 --loss_type PointwiseCE
#To get the full result of GRU4Rec, need to change the data_name. This is similar to SASRec and S3Rec.

#SASRec
python run_finetune_full.py --data_name LastFM --output_dir final_result/ --model_name SASRec --istb 1 --loss_type CE_ALL
python run_finetune_full.py --data_name LastFM --output_dir final_result/ --model_name SASRec --istb 1 --loss_type CE
python run_finetune_full.py --data_name LastFM --output_dir final_result/ --model_name SASRec --istb 1 --loss_type PointwiseCE

#S3Rec
python run_finetune_full.py --data_name LastFM --output_dir final_result/ --model_name S3Rec --istb 1 --loss_type CE_ALL --ckp 150
python run_finetune_full.py --data_name Beauty --output_dir final_result/ --model_name S3Rec --istb 1 --loss_type CE_ALL --ckp 150
python run_finetune_full.py --data_name Sports_and_Outdoors --output_dir final_result/ --model_name S3Rec --istb 1 --loss_type CE_ALL --ckp 100
python run_finetune_full.py --data_name Toys_and_Games --output_dir final_result/ --model_name S3Rec --istb 1 --loss_type CE_ALL --ckp 150
python run_finetune_full.py --data_name Yelp --output_dir final_result/ --model_name S3Rec --istb 1 --loss_type CE_ALL --ckp 100
# Note that here has an additional parameter ckp, which depends on the pre-training model in reproduce folder.
# Besides, those pre-training models are offered by the source code of S3Rec.

Then, the training log is all saved in the final_result folder. And the experiment results in Table 2 and Fig 2 all came from the training log.

The experiment of Fig 3

Just run the code in pre_exam.ipynb, then will get the .csv file at final_result folder.

Run SR_fig_process.ipynb file to get the images in Fig2 and 3.

Our code is based on S3Rec's source code to experiment. We are particularly grateful to it for providing the source code.

cce's People

Contributors

li-fangyu avatar

Watchers

 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.