22
33This project is a Tensorflow 2.0 implementation of Hyperbolic KG embeddings [ 6]
44as well as multiple state-of-the-art KG embedding models which can be trained
5- for the link prediction task.
5+ for the link prediction task. A PyTorch implementation is also available at:
6+ [ https://github.com/HazyResearch/KGEmb ] ( https://github.com/HazyResearch/KGEmb )
67
78## Library Overview
89
910This implementation includes the following models:
1011
11- Complex embeddings:
12+ #### Complex embeddings:
1213
1314* Complex [ 1]
1415* Complex-N3 [ 2]
1516* RotatE [ 3]
1617
17- Euclidean embeddings:
18+ #### Euclidean embeddings:
1819
1920* CTDecomp [ 2]
2021* TransE [ 4]
@@ -23,14 +24,14 @@ Euclidean embeddings:
2324* RefE [ 6]
2425* AttE [ 6]
2526
26- Hyperbolic embeddings:
27+ #### Hyperbolic embeddings:
2728
2829* TransH [ 6]
2930* RotH [ 6]
3031* RefH [ 6]
3132* AttH [ 6]
3233
33- ## Usage
34+ ## Installation
3435
3536First, create a python 3.7 environment and install dependencies: From kgemb/
3637
@@ -66,6 +67,8 @@ KG_DIR=$(pwd)/..
6667export PYTHONPATH=" $KG_DIR :$PYTHONPATH "
6768```
6869
70+ ## Example usage
71+
6972Then, train a model using the ` train.py ` script. We provide an example to train
7073RefE on FB15k-237:
7174
@@ -75,6 +78,27 @@ python train.py --max_epochs 100 --dataset FB237 --model RefE --loss_fn SigmoidC
7578
7679This model achieves 54% Hits@10 on the FB237 test set.
7780
81+ ## New models
82+
83+ To add a new (complex/hyperbolic/Euclidean) Knowledge Graph embedding model,
84+ implement the corresponding query embedding under models/, e.g.:
85+
86+ ```
87+ def get_queries(self, input_tensor):
88+ entity = self.entity(input_tensor[:, 0])
89+ rel = self.rel(input_tensor[:, 1])
90+ result = ### Do something here ###
91+ return return result
92+ ```
93+
94+ ## Citation
95+
96+ If you use the codes, please cite the following paper [ 6] :
97+
98+ ```
99+ TODO: add bibtex
100+ ```
101+
78102## References
79103
80104[ 1] Trouillon, Théo, et al. "Complex embeddings for simple link prediction."
0 commit comments