This is a pytorch implement of Explainable Knowledge Graph-based Recommendation via Deep Reinforcement Learning.
- python3
- pytorch 1.0.1
- CUDA 8.0+ (for GPU)
For the details of data format, see data/README.md
.
run the following command to preprocess the data
./run.sh <dataset> process <gpu-ID>
<dataset>
is the name of any dataset folder in the ./data
directory.
- Train embedding-based models.
./run.sh <dataset> <embedding models> <gpu-ID>
<embedding models>
include conve
, complex
and distmult
.
- Train naive RL model. (policy gradient)
./run.sh <dataset> rl <gpu-ID>
- Train Ekar. (policy gradient + reward shaping)
./run.sh <dataset> rl.rs <gpu-ID>
-
Note
- you can also directly use
experiment.sh
/experiment-conve.sh
/experiment-emb.sh
/experiment-rs.sh
and change some flags to train the models. - To train the RL models using reward shaping, make sure 1) you have pre-trained the embedding-based models and 2) set the file path pointers to the pre-trained embedding-based models correctly (example configuration file).
- you can also directly use
To change the hyperparameters and other experiment set up, start from the configuration files. You can also change the flags on the command of training.
This implementation is based on implementation from salesforce's MultiHopKG.