The objective of this project is to develop MM4Rec, a unified framework that enhances recommendation system performance by effectively integrating multi-source and multi-scenario data. MM4Rec aims to address the limitations of traditional recommendation systems, which treat different interaction scenarios (e.g., browsing vs. push notifications) and content source (e.g., news, ads) separately, hindering information sharing across these contexts.
The framework introduces several key components:
- Source-Aware Transformer Encoder (SATE) – Integrates data from various sources through shared and source-specific feedforward networks and source-adaptive gates.
- Multi-Scenario Behavior Extraction Layer – Leverages a multi-mixture-of-experts model to adapt to the distinct characteristics of each scenario.
- Trend-Aware Learner – Further refines the integrated representation to excel in next-item prediction across multiple contexts.
The project also aims to release two real-world datasets featuring user interactions across multiple scenarios and sources, facilitating further research and development in recommendation systems.
conda create -n env_name python=3.9
conda activate env_name
pip3 install -r requirements.txt
pip3 install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
Make sure to install a compatible version of PyTorch that matches your CUDA version.
- You can download our released datasets (AviviD_DatasetA and AviviD_DatasetB) at here. Put them in
./data. - You can download the checkpoint at here. Put them in
./ckpt.
./data
|─ AviviD_DatasetA
| |─ Push_Ads
|-click_seq_train.pkl
|-click_seq_val.pkl
|-click_seq_test.pkl
| |─ Browse_Ads
| |─ Push_News
| |─ Browse_Ads
| |─ banner_id_data.pkl
| |─ news_article_data.pkl
|─ AviviD_DatasetB
| |─ Push_Ads
|-click_seq_train.pkl
|-click_seq_val.pkl
|-click_seq_test.pkl
| |─ Browse_Ads
| |─ Push_News
| |─ Browse_Ads
| |─ banner_id_data.pkl
| |─ news_article_data.pkl
./ckpt
|─ AviviD_DatasetA
|- best_ckpt_1fe94
|─ AviviD_DatasetB
|- best_ckpt_2bcb3
The preprocess.py script ensures:
- Consistent sequence lengths through padding and truncation.
- Effective training through negative sampling of non-interacted items.
You need to run 16 preprocessing tasks—8 for AviviD_DatasetA and 8 for AviviD_DatasetB.
Steps to Run preprocess.py :
- Update the variables (
media,source, andscenario) in preprocess.py. - Run the script to generate new pickle files with a
_v.pklsuffix. - Verify the output files for correctness.
By following these steps, you will successfully preprocess all subsets for both datasets.
| File | Description |
|---|---|
| preprocess.py | The script is responsible for preparing and transforming raw data into a format suitable for model training and evaluation. |
| util.py | Useful data structures for implementing search and evaluation algorithms. |
| Dataset.py | Handles loading, preprocessing, and management of datasets for training and evaluation. |
| transformer.py | Implements the transformer architecture for sequence modeling and feature extraction. |
| model.py | Defines the MM4Rec model architecture used for training and inference. |
| train.py | Contains the training pipeline, including model training, validation, and logging. |
| main.py | The script to execute the end-to-end training and evaluation process. |
| inference.py | The script to execute the end-to-end evaluation process. |
python3 main.py
--model_name "${1}"
--dataset "${2}"
--ckpt_path "${3}"
--seed "${4}"
--learning_rate "${5}"
--weight_decay "${6}"
--num_epoch "${7}"
--batch_size "${8}"
--pad_id "${9}"
--d_model "${10}"
--nhead "${11}"
--num_encoder_layers "${12}"
--num_expert "${13}"
--ff_dim "${14}" \
bash run.sh MM4Rec AviviD_DatasetA './ckpt/' 100 3e-4 1e-3 60 2048 128 16 2 3 128
bash run.sh MM4Rec AviviD_DatasetB './ckpt/' 100 3e-4 1e-3 60 2048 256 32 3 3 128
python3 inference.py
--model_name "${1}"
--dataset "${2}"
--ckpt_path "${3}"
--seed "${4}"
--d_model "${5}"
--nhead "${6}"
--num_encoder_layers "${7}"
--num_expert "${8}"
--ff_dim "${9}" \
bash inference.sh MM4Rec AviviD_DatasetA '../ckpt/AviviD_DatasetA/best_ckpt_1fe94' 100 128 16 2 3 128
bash inference.sh MM4Rec AviviD_DatasetB '../ckpt/AviviD_DatasetB/best_ckpt_2bcb3' 100 256 32 3 3 128
Due to the randomness involved in negative sampling, the inference results may slightly differ across runs, even with the same configuration.
