This repository implements a self-attention-based recommender system, AttRec, for next-item recommendation. The project includes model implementation, evaluation, and tuning scripts, alongside Jupyter notebooks for detailed experimentation.
Link: https://arxiv.org/pdf/1808.06414
- Project Overview
- Project Structure
- Setup and Installation
- Experimentation
- References
- Acknowledgments
AttRec uses a self-attention mechanism to model sequential user behavior for accurate next-item predictions. It is designed for flexibility, scalability, and ease of experimentation.
Key features:
- End-to-end pipeline: Data preprocessing, model training, and evaluation scripts.
- Pretrained models: Included checkpoint files for quick testing.
- Jupyter notebooks: For visual exploration and detailed analyses.
.
├── attrec.ipynb # Main notebook demonstrating AttRec implementation
├── ncf_deep_dive.ipynb # Notebook exploring Neural Collaborative Filtering
├── processed_data/ # Preprocessed training and test datasets
│ ├── info.pkl
│ ├── test.csv
│ └── train.csv
├── pyproject.toml # Python project configuration
├── recommenders/ # Core implementation directory (From https://github.com/recommenders-team/recommenders)
│ ├── README.md # Detailed documentation for this module
│ ├── datasets/ # Data loading and processing scripts
│ ├── evaluation/ # Evaluation metrics and scripts
│ ├── models/ # Model architecture definitions
│ ├── tuning/ # Hyperparameter tuning scripts
│ └── utils/ # Utility functions
├── requirements.txt # Dependencies for the project
├── save_path/ # Directory for saving model checkpoints
└── setup.py # Setup script for the project
- Python 3.8 or higher
- GPU-enabled machine (recommended for training)
For environment management, we recommend using conda, and for development, VS Code is suggested. Follow these steps to install the recommenders package and run a sample notebook on Linux/WSL:
-
Install GCC
If GCC is not already installed, you can install it on Ubuntu with:sudo apt install gcc
-
Set Up a Conda Environment
Create and activate a new Conda environment:conda create -n <environment_name> python=3.9 conda activate <environment_name>
-
Install the Recommenders Package
Install the corerecommenders
package to run all CPU-compatible notebooks:pip install recommenders
-
Create a Jupyter Kernel
Set up a Jupyter kernel for the environment:python -m ipykernel install --user --name <environment_name> --display-name <kernel_name>
-
Clone the Repository
Clone the repository using VS Code or the command line:git clone https://github.com/recommenders-team/recommenders.git
-
Run an Example Notebook in VS Code
- Open a notebook, such as
attrec.ipynb
. - Select the Jupyter kernel
<kernel_name>
. - Run the notebook.
- Open a notebook, such as
This setup ensures you have everything needed to start working with the recommenders
package efficiently.
Use the included notebooks for interactive exploration:
attrec.ipynb
: Full implementation walkthrough for AttRec.ncf_deep_dive.ipynb
: Insights into Neural Collaborative Filtering. (From https://github.com/recommenders-team/recommenders)
- Shuai Zhang et al., "Next Item Recommendation with Self-Attention."
- S. Ge, "AttRec: A Recommender System with Self-Attention Mechanism," slientGe/AttRec
- This project is inspired by and adapted from the AttRec implementation by S. Ge.
- Special thanks to the authors of Next Item Recommendation with Self-Attention for the foundational research.
- Special thanks to the recommenders-team for the recommender template recommenders-team/recommenders
- This project is part of the 2301491 SPECIAL TOPICS IN COMPUTER SCIENCE (Popular Techniques in Recommender Systems) course at Chulalongkorn University in 2024.