awslabs / dgl-ke

High performance, easy-to-use, and scalable package for learning large-scale knowledge graph embeddings.
https://dglke.dgl.ai/doc/
Apache License 2.0
1.28k stars 196 forks source link

[Feature] Support invoking score infer and emb_sim using API. #153

Closed classicsong closed 4 years ago

classicsong commented 4 years ago

This PR introduce a general framework named BasicGEModel (Basic graph embedding model) following the discussion in #82 . Graph Embedding models, either knowledge graph embedding models or GNN based graph embedding models will follow this framework.

This PR focus on providing Python API support for model inference. To do edge score inference, one can follow the following operations:

gamma = 2.0
transe_model = TransEModel('cpu', gamma)
transe_model.load(PATH_TO_MODEL)
transe_model.attach_graph(PATH_TO_GRAPH)
result = transe_model.link_predict(...)

To do embedding similarity inference, one can follow the following operations:

gamma = 2.0
transe_model = TransEModel('cpu', gamma)
transe_model.load(PATH_TO_MODEL)
# we omit attach_graph, as the graph structure is not used
result = transe_model.embed_sim(...)

Further, in the link_predict inference, we will support different edge excluding mode:

This PR also fix #151