This repository contains the code for the paper TILP: Differentiable Learning of Temporal Logical Rules on Knowledge Graphs.
A follow-up work for time prediction over temporal knowledge graphs via logical reasoning is available here.
We propose TILP, a differentiable framework for temporal logical rules learning. By designing a constrained random walk mechanism and the introduction of temporal operators, we ensure the efficiency of our model. We present temporal features modeling in tKG, e.g., recurrence, temporal order, interval between pair of relations, and duration, and incorporate it into our learning process.
Rule 1:
Grounding:
Rule 2:
Grounding:
To run the code, you need to first set up the environment given in requirements.txt.
It is recommended to use anaconda for installation.
After the installation, you need to create a file folder for experiments.
The structure of the file folder should be like
TILP/
│
├── src/
│
├── data/
│ ├── WIKIDATA12k/
│ └── YAGO11k/
│
└── output/
├── found_paths/
├── found_time_gaps/
├── train_weights/
├── train_weights_tfm/
├── learned_rules/
└── rank_dict/
To run the code, use the command.
All the settings and corresponding explanations are provided as in-context comments.
cd src
python main.py --dataset YAGO --find_rules --train_model --rule_summary --predict --rule_len 5
python main.py --dataset wiki --find_rules --train_model --rule_summary --predict --rule_len 3
Print rules:
# Find the rules and scores in output/learned_rules/{$dataset name}_all_rules_{$query relation}.json.
# Format: {rule length: [{support num: int, rule: list, score: float}]}
# rule: a list of relations and temporal relations (Example in YAGO: query relation 0, rule length: 3, rule: [1, 16, 0, 1, 1, -1, 0, 1, 1]; Translation: wasBornIn(x, y, I_q) <- worksAt(x, e1, I_1) and graduatedFrom^{-1}(e1, e2, I_2) and wasBornIn(e2, y, I_3) and after(I_q, I_1) and after(I_q, I_2) and before(I_q, I_3) and touching(I_1, I_2) and after(I_1, I_3) and after(I_2, I_3))
If you have any inquiries, please feel free to raise an issue or reach out to sxiong45@gatech.edu.
@inproceedings{xiongtilp,
title={TILP: Differentiable Learning of Temporal Logical Rules on Knowledge Graphs},
author={Xiong, Siheng and Yang, Yuan and Fekri, Faramarz and Kerce, James Clayton},
booktitle={The Eleventh International Conference on Learning Representations}
}