This project implements a self-supervised learning approach for recommendation systems that combines Graph Neural Networks (GNNs), disentangled intent modeling, and contrastive learning.
project/
├── data/
│ └── gowalla/ # Gowalla dataset
├── data_processing/
│ └── dataset.py # Dataset loading and processing
├── model/
│ ├── intentgcl.py # Main model implementation
│ └── utils.py # Utility functions
└── run_training_testing.py # Main training script
-
Intent-Aware GNN
- Multiple GNN layers for message passing
- Learnable intent prototypes
- Attention-based intent aggregation
-
Disentangled Representations
- Intent prototype learning
- Multi-intent attention mechanism
- SVD-enhanced message passing
-
Contrastive Learning
- InfoNCE loss with temperature scaling
- Local and global view contrasting
- Intent-aware negative sampling
The model combines three key components:
- Graph Neural Network Layers
# Message passing aggregation
msg_user = torch.spmm(adj_norm, item_embeddings)
msg_item = torch.spmm(adj_norm.t(), user_embeddings)
- Intent Modeling
# Intent attention computation
attention = softmax(embeddings @ intent_prototypes.t() / temp)
intent_aware_emb = attention @ intent_prototypes
- Contrastive Learning
# Contrastive loss with temperature scaling
pos_score = (intent_emb * user_emb).sum(1) / temp
neg_score = log(exp(intent_emb @ all_emb.t() / temp).sum(1))
-
Data Preparation
- The Gowalla dataset is used
- Processed into training and testing matrices
- Normalized adjacency matrix computation
-
Training
python run_training_testing.py
- Configuration
- Embedding dimension: 64
- Number of GNN layers: 2
- Number of intents: 128
- Temperature: 0.2
- Learning rate: 0.001
The model is evaluated using standard recommendation metrics:
- Recall@20, NDCG@20
- Recall@40, NDCG@40
Results are saved after training with timestamp.
The implementation is based on:
- LightGCL: Simple Yet Effective Graph Contrastive Learning for Recommendation
- Learning intents behind interactions with knowledge graph for recommendation
- Neural Graph Collaborative Filtering