A Knowledge Graph Enhanced Hybrid Geometric Recommendation System that integrates SVD decomposition, hyperbolic geometry, and knowledge graph embeddings for improved recommendation performance.
SPARK_Rec is a hybrid recommendation system that combines SVD decomposition, hyperbolic geometry, and knowledge graph embeddings for improved recommendation accuracy.
- Hybrid Geometric Spaces: Euclidean and hyperbolic space fusion
- Knowledge Graph Integration: Entity and relation embeddings
- Adaptive Fusion: Popularity-aware mixing strategies
- Graph Neural Networks: Message passing on interaction and KG graphs
- Contrastive Learning: SVD and KG embedding alignment
Python >= 3.7
PyTorch >= 1.8.0
RecBole >= 1.1.1
numpy >= 1.19.0
scipy >= 1.6.0
pandas >= 1.2.0- Clone the repository
git clone <repository-url>
cd SPARK_Rec- Install dependencies
pip install -r requirements.txt- Install RecBole (if not already installed)
pip install recboleOrganize your dataset in the following format:
dataset/
├── [dataset_name]/
│ ├── [dataset_name].inter # User-item interactions
│ ├── [dataset_name].kg # Knowledge graph triples
│ └── [dataset_name].link # Item-entity alignments
Run SVD decomposition on the interaction matrix:
python preprocess_svd.py --dataset amazon-book --output_path ./preprocessedIf you have pretrained KG embeddings:
kg_embeddings/
├── entity_embeddings.npy
└── relation_embeddings.npy
python run_kg_model.py \
--dataset yelp2018 \
--embedding_size 64 \
--kg_embedding_size 64 \
--epochs 200python run_kg_model.py \
--dataset amazon-book \
--embedding_size 64 \
--kg_embedding_size 64 \
--hyperbolic_ratio 0.3 \
--curvature 0.8 \
--tucker_weight 0.5 \
--use_tucker \
--cl_weight 0.1 \
--epochs 200 \
--gpu_id 0| Parameter | Description | Default |
|---|---|---|
--embedding_size |
Dimension of recommendation embeddings | 64 |
--kg_embedding_size |
Dimension of KG embeddings | 64 |
--hyperbolic_ratio |
Weight for hyperbolic space | 0.3 |
--curvature |
Curvature of hyperbolic space | 0.8 |
--tucker_weight |
Weight for TuckER scoring | 0.5 |
--use_tucker |
Enable TuckER framework | False |
--cl_weight |
Contrastive learning weight | 0.1 |
--kg_weight |
Knowledge graph loss weight | 0.01 |
SPARK_Rec/
├── KG_model_v2.py # Main model implementation
├── run_kg_model.py # Training and evaluation script
├── preprocess_svd.py # SVD preprocessing utility
├── requirements.txt # Python dependencies
├── dataset/ # Dataset directory
├── preprocessed/ # SVD decomposition results
├── logs/ # Training logs
└── README.md # This file
The model consists of several key components:
- SVD Embeddings: User and item latent factors from matrix factorization
- Lorentz Manifold: Hyperbolic space operations for hierarchical modeling
- Knowledge Graph Networks: Entity and relation embedding learning
- Hybrid GNN: Message passing in both Euclidean and hyperbolic spaces
- TuckER Scoring: Tensor decomposition for KG completion
- Adaptive Fusion: Popularity-aware mixing of different signals
The model supports standard recommendation metrics:
- Recall@K
- NDCG@K
- MRR
- Hit@K
- Precision@K
Results are automatically logged during training and saved to the logs/ directory.
The model has been tested on the following datasets:
- Amazon-Book
- Alibaba-iFashion
- Yelp2018
Ensure your dataset follows the RecBole format specifications.
- CUDA out of memory: Reduce
--batch_sizeor--embedding_size - SVD files not found: Run the preprocessing script first
- Knowledge graph not loaded: Check file formats and paths
python run_kg_model.py --batch_debug --dataset yelp2018This project is available for academic and research purposes.