A cross-domain recommendation system that combines knowledge graph embeddings, graph attention networks, and prompt tuning to transfer user preferences across Amazon product categories.
- Overview
- Architecture
- Results
- Project Structure
- Getting Started
- Dataset
- Technical Details
- References
- Authors
Cross-domain recommendation addresses the data sparsity problem by transferring knowledge from a data-rich source domain to a target domain. Traditional approaches require retraining the full model for each domain pair. This project proposes adaptive prompt tuning — small learnable modules that adapt frozen graph embeddings — to efficiently bridge domains without costly retraining.
The system constructs a unified knowledge graph across two Amazon product categories, learns structural and semantic embeddings via TransE and a Graph Attention Network, and applies prompt-based adaptation for the final recommendation task.
┌─────────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ ┌───────────────┐
│ Amazon Reviews │────►│ Knowledge │────►│ TransE │────►│ GAT Encoder │────►│ Prompt Tuning │
│ (Two Domains) │ │ Graph (KG) │ │ (Embeddings) │ │ (Contrastive) │ │ + BPR Ranker │
└─────────────────┘ └──────────────┘ └──────────────┘ └──────────────────┘ └───────────────┘
- Identifies overlapping users between two Amazon product categories
- Constructs triples with three relation types:
- Purchase (user → item)
- Produced by (item → brand, from product metadata)
- Described as (item → keyword, via TF-IDF extraction)
- Learns 64-dimensional entity and relation embeddings
- Trained with margin ranking loss and negative sampling over 20 epochs
- 2-layer Graph Attention Network with contrastive self-supervised learning
- Dual-view generation via stochastic edge dropout
- Gradient checkpointing for GPU memory efficiency
Three prompt strategies are compared in an ablation study:
- Baseline (No Prompt): Raw GAT embeddings fed to the BPR predictor
- Static Prompt: A single learnable vector added uniformly to all user embeddings
- Adaptive Prompt (Ours): A density-aware gating mechanism that blends global domain knowledge with personalized user signals derived from neighbor item aggregation
| Method | HR@10 | Improvement |
|---|---|---|
| Baseline (Pure GAT) | 0.3403 | — |
| Static Prompt | 0.3452 | +1.45% |
| Adaptive Prompt (Ours) | 0.4033 | +18.53% |
| Method | HR@10 | Improvement |
|---|---|---|
| Baseline (Pure GAT) | 0.4662 | — |
| Static Prompt | 0.4701 | +0.83% |
| Adaptive Prompt (Ours) | 0.4667 | +0.09% |
- The adaptive prompt achieves a significant +18.53% improvement on the Electronics ↔ Cell Phones pair, where domain overlap is structurally strong (both are technology categories).
- On the more distant Electronics ↔ Beauty pair, all methods perform similarly, suggesting that prompt tuning benefits are largest when domains share meaningful structural and semantic connections.
├── WSC_Cell_Phones_electronics.ipynb # Experiment 1: Electronics ↔ Cell Phones
├── WSC_Electronics_Beauty.ipynb # Experiment 2: Electronics ↔ Beauty
├── assets/ # Result visualizations
│ ├── results_cell_phones_electronics.png
│ └── results_electronics_beauty.png
├── requirements.txt # Python dependencies
└── README.md
- Python 3.9+
- CUDA-compatible GPU (recommended for training)
git clone https://github.com/deepanshu-prog/Recommendation_System.git
cd Recommendation_System
pip install -r requirements.txtThe notebooks are designed for Google Colab with a GPU runtime:
- Open either notebook in Google Colab
- Set runtime to GPU (
Runtime → Change runtime type → T4 GPU) - Run all cells sequentially
The notebooks handle data download, preprocessing, training, and evaluation end-to-end.
All data is sourced from the Amazon Reviews 2023 dataset (McAuley Lab, UCSD).
| Domain Pair | Overlapping Users | Items | KG Triples |
|---|---|---|---|
| Electronics ↔ Cell Phones | 100,000 (capped) | 249,277 | 826,177 |
| Electronics ↔ Beauty | 355,607 | 467,363 | 3,253,649 |
Data files are downloaded automatically within the notebooks. No manual setup is required.
| Component | Configuration |
|---|---|
| Embedding Dimension | 64 |
| TransE Epochs | 20 |
| GAT Layers | 2 (1 attention head each) |
| GAT Training | 10 epochs, contrastive loss |
| Dropout | 0.2 |
| BPR Batch Size | 2048 |
| Optimizer | Adam |
| Evaluation Metric | HR@10 (99 negative samples) |
| Seed | 42 |
- Warmup Phase: Train only the BPR predictor with frozen embeddings (10–20 epochs)
- Joint Phase: Train prompt module and predictor jointly with differential learning rates (25 epochs)
- Knowledge-Aware Graph Prompt Tuning for Cross-Domain Recommendation
- Amazon Reviews 2023 Dataset
- Bordes et al., Translating Embeddings for Modeling Multi-relational Data (TransE)
- Velickovic et al., Graph Attention Networks (GAT)
- Rendle et al., BPR: Bayesian Personalized Ranking from Implicit Feedback
- Deepanshu — @deepanshu-prog
- Zaed Rizwan — @ZR12345
IT752 Term Project — Group 13

