THUwangcy / ReChorus

“Chorus” of recommendation models: a light and flexible PyTorch framework for Top-K recommendation.
MIT License
545 stars 91 forks source link

Add random permutation to the indices. #44

Closed SASRec closed 1 year ago

SASRec commented 1 year ago

Creating this pull request for Issue #43 . I have added random permutation to the fit function and predict function so that the models cannot remember the first item being the target.

I have created a new directory for this pull request because I have changed too many things in the original directory, and it might contain sensitive contents. However, I have tested the diff using the following two models and the results seem to be fine. In my original directory, the code works fine with KDA, SASRec, ComiRec and many other models. Please let me know if you observe otherwise.

python main.py --model_name TiSASRec --emb_size 64 --num_layers 1 --num_heads 1 --lr 1e-4 --l2 1e-6 --history_max 20 --dataset 'Grocery_and_Gourmet_Food'

python main.py --model_name TiMiRec --emb_size 64 --lr 1e-4 --l2 1e-6 --history_max 20 --K 6 --add_pos 1 --add_trm 1 --stage pretrain --dataset 'Grocery_and_Gourmet_Food'

I have added some comments to make the code easier to understand.

THUwangcy commented 1 year ago

Thanks for your contribution! I have tested and it seems to work well. Although the final results will be a little different from previous ones (cause the random process has been changed), the differences are generally negligible.

One question is whether it is fine to only add random permutation to the fit function. It seems to be enough to prevent the model to remember the position.

SASRec commented 1 year ago

Hi I guess adding random permutation to the fit function should also be enough. Could you check the updated pull request? Thanks.