TransE is a popular method to model relationships by interpreting them as translations operating on the low-dimensional embeddings of the entities. In knowledge graphs, a tuple is in the form of (head, relation, tail). Negative tuples are sampled by corrupting heads or tails in a positive training example.
- Get training samples using sample functions.
- Encode entity and relation and use triplet loss to train.
-
Prepare Data
cd ../../data/ python fb15k_237.py
-
Train
python train.py
-
Evaluate
python eval.py
FB15k-237 is a leakage-free version of FB15k, which is usually adopted as one of the benchmark datasets in literature.
Dataset | hit@10 |
---|---|
FB15k-237 | 0.41 |