From Discrimination to Generation: Knowledge Graph Completion with Generative Transformer

Xin Xie, Ningyu Zhang, Zhoubo Li, Shumin Deng, Hui Chen, Feiyu Xiong, Mosha Chen, Huajun Chen

Introduction

Knowledge Graph Completion (KGC) aims to predict missing facts in structured databases, typically represented as triples $(subject, relation, object)$. Traditional approaches generally fall into two categories: embedding-based methods and discriminative pre-trained language model (PLM) methods. While embedding-based methods like TransE are fast, they suffer from high memory requirements for large-scale graphs and often fail to capture rich textual information. Conversely, discriminative PLM methods like KG-BERT offer better textual understanding but are computationally expensive, requiring the scoring of every candidate entity during inference.

The GenKGC Approach

GenKGC addresses these challenges by reframing KGC as a sequence-to-sequence generation task. Instead of scoring a list of candidates, the model directly generates the text of the missing entity.

Overview of the GenKGC architecture, featuring relation-guided demonstration and hierarchical decoding.

The framework utilizes a BART-based architecture with three key innovations:

  • Link Prediction as Generation: The model takes the head entity and relation descriptions as input to generate the tail entity's name.
  • Relation-guided Demonstration: To leverage in-context learning, the input is prepended with a few examples of the same relation, helping the model specialize for specific link types.
  • Entity-aware Hierarchical Decoding: To ensure the model generates valid entities and to accelerate the search, a prefix tree (trie) constrains the decoding process. This prevents hallucination and significantly prunes the search space by using entity types to guide the generation.

Experimental Evaluation

The authors evaluated GenKGC on three benchmarks: WN18RR (lexical), FB15k-237 (general knowledge), and the large-scale OpenBG500 dataset. OpenBG500, released by Alibaba, contains over 260,000 entities and 500 relations, providing a rigorous test for scalability in a real-world e-commerce context.

Results and Efficiency

GenKGC demonstrates a significant advantage in inference efficiency. As shown in the complexity analysis, while discriminative models scale linearly with the number of entities $|E|$, GenKGC's complexity is independent of the total entity count, depending instead on the beam search size and description length.

Comparison of training and inference complexity and time for different KGC methods.

On the OpenBG500 dataset, GenKGC achieves an inference time of 0.96 seconds per triple, compared to over 10,100 seconds for KG-BERT—a speedup of approximately 10,000x. Furthermore, GenKGC maintains a smaller memory footprint than embedding-based methods, requiring only 110 million parameters compared to the 260 million needed by TransE for entity vectors on the same dataset.

In terms of accuracy, GenKGC remains competitive with state-of-the-art graph embedding methods like RotatE and TuckER, and outperforms discriminative PLM approaches across various metrics like Hits@1 and Hits@10.

Conclusion

By shifting from a discriminative to a generative paradigm, GenKGC overcomes the scalability bottlenecks of previous PLM-based KGC methods. Its combination of in-context learning and constrained decoding provides a robust and efficient solution for large-scale knowledge graph completion, making it suitable for real-world applications with millions of entities.

Summary updated

BibTeX
@inproceedings{xie2022from,
  author = {Xin Xie and Ningyu Zhang and Zhoubo Li and Shumin Deng and Hui Chen and Feiyu Xiong and Mosha Chen and Huajun Chen},
  title = {{From Discrimination to Generation: Knowledge Graph Completion with Generative Transformer}},
  booktitle = {The Web Conference},
  year = {2022},
  doi = {10.1145/3487553.3524238},
}
Figure