Contents
TB-Net is a knowledge graph based explainable recommender system.
Paper: Shendi Wang, Haoyang Li, Xiao-Hui Li, Caleb Chen Cao, Lei Chen. Tower Bridge Net (TB-Net): Bidirectional Knowledge Graph Aware Embedding Propagation for Explainable Recommender Systems
TB-Net constructs subgraphs in knowledge graph based on the interaction between users and items as well as the feature of items, and then calculates paths in the graphs using bidirectional conduction algorithm. Finally we can obtain explainable recommendation results.
We provide an example dataset that created from
Interaction of users and games and games' feature data of the game platform Steam that are publicly available on Kaggle.
Please refer to Downloading Data Package for the way of obtaining the example dataset and the file format descriptions.
- Hardware
- Framework
- For more information, please check the resources below:
Please refer to Using TB-Net for the quick start guide.
.
└─tbnet
├─README.md
├─README_CN.md
├─data
│ └─steam
│ ├─LICENSE
│ ├─config.json # hyper-parameters and training configuration
│ ├─src_infer.csv # source datafile for inference
│ ├─src_test.csv # source datafile for evaluation
│ └─src_train.csv # source datafile for training
├─src
│ ├─dataset.py # dataset loader
│ ├─embedding.py # embedding module
│ ├─metrics.py # model metrics
│ ├─path_gen.py # data preprocessor
│ ├─recommend.py # result aggregator
│ └─tbnet.py # TB-Net architecture
├─export.py # export MINDIR/AIR script
├─preprocess.py # data pre-processing script
├─eval.py # evaluation script
├─infer.py # inference and explaining script
└─train.py # training script
--dataset <DATASET> 'steam' dataset is supported currently (default 'steam')
--same_relation only generate paths that relation1 is same as relation2
--dataset <DATASET> 'steam' dataset is supported currently (default 'steam')
--train_csv <TRAIN_CSV> the train csv datafile inside the dataset folder (default 'train.csv')
--test_csv <TEST_CSV> the test csv datafile inside the dataset folder (default 'test.csv')
--epochs <EPOCHS> number of training epochs (default 20)
--device_id <DEVICE_ID> device id (default 0)
--run_mode <MODE> run model in 'GRAPH' mode or 'PYNATIVE' mode (default 'GRAPH')
--checkpoint_id <CKPT_ID> the id of the checkpoint(.ckpt) to be used
--dataset <DATASET> 'steam' dataset is supported currently (default 'steam')
--csv <CSV> the test csv datafile inside the dataset folder (default 'test.csv')
--device_id <DEVICE_ID> device id (default 0)
--run_mode <MODE> run model in 'GRAPH' mode or 'PYNATIVE' mode (default 'GRAPH')
--checkpoint_id <CKPT_ID> the id of the checkpoint(.ckpt) to be used
--dataset <DATASET> 'steam' dataset is supported currently (default 'steam')
--csv <CSV> the infer csv datafile inside the dataset folder (default 'infer.csv')
--items <ITEMS> no. of items to be recommended (default 3)
--explanations <EXP> no. of recommendation reasons to be shown (default 3)
--device_id <DEVICE_ID> device id (default 0)
--run_mode <MODE> run model in 'GRAPH' mode or 'PYNATIVE' mode (default 'GRAPH')
--config_path <CFG_PATH> config (config.json) file path
--checkpoint_path <CKPT_PATH> checkpoint (.ckpt) file path
--file_name <FILENAME> export filename
--file_format <FORMAT> export format 'MINDIR' or 'AIR' (default 'MINDIR')
--device_id <DEVICE_ID> device id (default 0)
--run_mode <MODE> run model in 'GRAPH' mode or 'PYNATIVE' mode (default 'GRAPH')
Training Performance
Parameters |
GPU |
Model Version |
TB-Net |
Resource |
Tesla V100-SXM2-32GB |
Uploaded Date |
2021-08-01 |
MindSpore Version |
1.3.0 |
Dataset |
steam |
Training Parameter |
epoch=20, batch_size=1024, lr=0.001 |
Optimizer |
Adam |
Loss Function |
Sigmoid Cross Entropy |
Outputs |
AUC=0.8596, Accuracy=0.7761 |
Loss |
0.57 |
Speed |
1pc: 90ms/step |
Total Time |
1pc: 297s |
Checkpoint for Fine Tuning |
104.66M (.ckpt file) |
Evaluation Performance
Parameters |
GPU |
Model Version |
TB-Net |
Resource |
Tesla V100-SXM2-32GB |
Uploaded Date |
2021-08-01 |
MindSpore Version |
1.3.0 |
Dataset |
steam |
Batch Size |
1024 |
Outputs |
AUC=0.8252, Accuracy=0.7503 |
Total Time |
1pc: 5.7s |
Inference and Explaining Performance
Parameters |
GPU |
Model Version |
TB-Net |
Resource |
Tesla V100-SXM2-32GB |
Uploaded Date |
2021-08-01 |
MindSpore Version |
1.3.0 |
Dataset |
steam |
Outputs |
Recommendation Result and Explanation |
Total Time |
1pc: 3.66s |
- Initialization of embedding matrix in
tbnet.py
and embedding.py
.