Closed derik-roby closed 11 months ago
Dear @derik-roby,
Predicting missing links based on unseen entities and/or relations is currently an open research question.
Soon, we will implement the idea introduced in Out-of-Sample Representation Learning for Knowledge Graphs. By this, we aim to perform link prediction on unseen entities and/or relations.
Dear @Demirrr,
Thanks for the reference and reply. I will keep this issue active
@derik-roby
Good news for you! Now, we can train a KGE to do prediction in the inductive setting :)
from dicee import Execute
from dicee import KGE
from dicee.config import Namespace
# (1) Train a KGE model
args = Namespace()
args.model = 'Keci'
args.p = 0
args.q = 1
args.optim = 'Adam'
args.dataset_dir = "KGs/Countries-S1"
args.backend = "pandas"
args.neg_ratio = 100
args.lr = 0.1
args.num_epochs = 100
args.embedding_dim = 4
# Inductive Setting is enabled
args.byte_pair_encoding = True
result = Execute(args).start()
# (2) Load the pre-trained model
pre_trained_kge = KGE(path=result['path_experiment_folder'])
# h, r, and t are seen during training.
print(pre_trained_kge.predict(h="germany", r="neighbor", t="netherlands"))
# h not seen but r and t are seen during training.
print(pre_trained_kge.predict(h="germany belgium", r="neighbor", t="netherlands"))
# h,r, and t are not seen during training.
print(pre_trained_kge.predict(h="I", r="love", t="knowledge graphs"))
Let me know if this works out for you
Dear @Demirrr,
Thank You for the update. Happy to know that this has been implemented.
Is it possible for the model to give/predict embeddings for unseen entities or relations that are not there in the train, test and valid datasets.