Skip to content
Nishikata97Public

About

This is the source code for the Paper: Semantic Relation Guided Dual-view Contrastive Learning for Session-based Recommendations.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

DIREC

PyTorch implementation for the Paper: Semantic Relation Guided Dual-view Contrastive Learning for Session-based Recommendations.

Dual-view from the data source perspective: (user-item) intent view and (item) attribute view: In the intent-view of users, users tend to demand items that complement their historical sequences rather than substitutable ones. Therefore, the intent information included in complementary items should exhibit similarity, while the intent included in substitutable items should demonstrate dissimilarity. In the attribute-view of items, substitutable items should have similar attribute information, while attribute information included in complementary items should be dissimilar.

intro

Figure 1. Illustration of positive and negative signals observed between substitutable and complementary items from intent and attribute views.

model

Figure 2. Overview of SCL-SR.

Fold

├─ DIREC/ 
    ├── experiments  # Experimental results and visualizations of model performance
    ├── models/  # Code for model architectures, contrastive learning, and attention mechanisms.
        ├── attention.py/
        ...
    ├── preprocess/  # Scripts for data preprocessing and sample extraction.
    ├── utils/  # Code for dataset loading, model configuration, and training.
    main.py  # Scripts for training/testing the model on the Tmall/E-Commerce dataset.
    main_cosmetics.py  # Scripts for training/testing the model on the cosmetics dataset.
    parse.py  # Parses command-line arguments for configuring the dataset, model, training, and hyper-parameters.

Requirements

  • Python 3.9
  • PyTorch 1.12

Best Hyperparameter:

  • Tmall: alpha=0.02, beta=100, num_coarse_sampling=90
  • E-Commerce (CIKM19): alpha=0.02, beta=150, num_coarse_sampling=90
  • Cosmetics: alpha=0.02, beta=100, num_coarse_sampling=90

Datasets:

Dataset URLs
Tmall https://tianchi.aliyun.com/dataset/dataDetail?dataId=42
Cosmetics https://www.kaggle.com/datasets/mkechinov/ecommerce-events-history-in-cosmetics-shop
E-Commerce https://tianchi.aliyun.com/competition/entrance/231721/information

Code running process:

  1. Step 1: Data preprocessing

    python preprocess.py --dataset Tmall
    python preprocess.py --dataset Cosmetics
    python preprocess.py --dataset CIKM19
  2. Step 2: Negative sampling

    python get_samples.py --dataset Tmall
    python get_samples.py --dataset Cosmetics
    python get_samples.py --dataset CIKM19
  3. Step 3: Train & Test:

  • For Tmall and E-Commerce(CIKM19):
    python main.py --dataset Tmall --alpha 0.02 --beta 100
    python main.py --dataset CIKM19 --alpha 0.02 --beta 150
  • For Cosmetics:
    python main_cosmetics.py --dataset Cosmetics --alpha 0.02 --beta 100

Preprocessed data:

The datasets have been preprocessed and encoded with pickle, which can be downloaded from the link (password: v3bj)

Trained models:

To enhance the reproducibility of the model, we provide the trained model files in this link.

Experiments

1. How do the primary components of the SCL-SR impact its recommendation performance?

ablation

Figure 3. Comparison of prediction accuracy with different variants of our model.

2. How do different hyper-parameter configurations, such as the weight of the contrastive loss $(\alpha)$, impact the performance of SCL-SR?

hyper_tmall hyper_e-commerce negatives

Figure 4. Hyper-parameter analysis and negative sample quantity analysis on different datasets.

3. How do item representations benefit from the intent-attribute disentangler?

Visualization

Figure 5: Visualization of the learned item embeddings on Tmall dataset with and without intent-attribute disentangler.

Reference

If you find our work useful to your research, we kindly ask that you cite the following paper:

@article{qian2025semantic,
  title   = {Semantic Relation Guided Dual-view Contrastive Learning for Session-based Recommendations},
  author  = {Zhang, Qian and Wang, Shoujin and Cao, Longbing and Lian, Defu and Zhang, Haibo and Lu, Wenpeng},
  journal = {ACM Transactions on Information Systems},
  year    = {2025}
}

About

This is the source code for the Paper: Semantic Relation Guided Dual-view Contrastive Learning for Session-based Recommendations.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages