Enhancing Knowledge Graph Completion with Entity Neighborhood and Relation Context

Jianfang Chen, Kai Zhang, Aoran Gan, Shiwei Tong, Shuanghong Shen, Qi Liu

TL;DR

KGC-ERC is a new framework that improves Knowledge Graph Completion (KGC) by providing generative language models with two types of vital context: the local neighborhood of an entity and broader examples of how a specific relation behaves across the graph. By using a specialized "Selector" module to sample the most relevant data within strict token limits, the model achieves state-of-the-art results on massive datasets like Wikidata5M using significantly fewer parameters than traditional methods.

What Problem Does This Paper Address?

Knowledge Graphs (KGs) are the backbone of modern AI, powering everything from recommendation engines to question-answering systems. However, KGs are notoriously incomplete. KGC is the task of predicting these missing links—essentially filling in the blank for a triple like (LeBron James, plays_for, ?).

Traditional "structure-based" methods map entities to high-dimensional vectors (embeddings). While effective, they struggle to scale because they must score every single entity in the graph for every prediction. Recent "text-based" methods use models like T5 or BERT to treat KGC as a translation task, which scales better. However, these models usually only look at the "neighborhood" of the head entity (e.g., other facts about LeBron James). They often ignore relation context—examples of how the plays_for relation works elsewhere in the graph. The authors argue that understanding the "behavior" of a relation is just as important as knowing the entity.

Methods

The authors introduce KGC-ERC (Entity neighborhood and Relation Context), which enriches the input to a generative language model (specifically T5). The core innovation is the Selector module, which manages the "token limit" problem. Since you can't feed an entire graph into a language model, the Selector uses two strategies:

  1. Entity Neighborhood Sampling: Instead of just picking random neighbors, it groups neighbors by relation type and selects diverse pairs. This ensures the model sees a broad spectrum of an entity's attributes (e.g., both LeBron's "occupation" and his "children") rather than getting 50 examples of the same relationship.
  2. Relation Context Sampling: This retrieves other triples from the graph that use the same relation as the query. Crucially, the sampling logic changes based on the cardinality of the relation:
  3. 1-n (One-to-Many): Prioritizes triples sharing the same head entity.
  4. n-1 (Many-to-One): Focuses on diversity in tail entities to avoid repetitive patterns.
  5. n-n (Many-to-Many): Uses a hybrid of the above.
  6. 1-1 (One-to-One): Uses random sampling.

These sampled facts are "verbalized" into a natural language string and appended to the query, providing the model with a rich, descriptive prompt to generate the missing entity.

Datasets

The model was evaluated on three benchmark datasets:

  • FB15K-237-N: A standard benchmark with ~13,000 entities and 93 relations.
  • Wiki27K: A medium-sized dataset with ~27,000 entities.
  • Wikidata5M: A massive, industrial-scale dataset containing nearly 5 million entities and 20 million triples, testing the model's true scalability.

Key Insights and Ideas

  • Relations Need Context Too: Most KGC research focuses on entity representation. This paper highlights that relations are not static; seeing how a relation connects other entities helps the model "reason" by analogy.
  • Smart Sampling > Raw Volume: Because language models have a limited "context window" (usually 512 tokens), what you include is more important than how much you include. The cardinality-aware sampling ensures the most informative examples make the cut.
  • Parameter Efficiency: KGC-ERC (using a 60M parameter T5-small) outperformed structure-based models that use billions of parameters. This suggests that textual reasoning is a more efficient way to store and retrieve graph knowledge than dense embeddings.

Key Results

  • State-of-the-Art Performance: On the massive Wikidata5M dataset, KGC-ERC achieved a Mean Reciprocal Rank (MRR) of 0.433 (when including entity descriptions), outperforming previous leaders like KnowC and KGT5-context.
  • Consistency: The model consistently beat or matched baselines across all three datasets in metrics like Hits@1, Hits@3, and Hits@10.
  • Ablation Success: The authors proved their components worked: removing the "relation context" caused a noticeable drop in performance, and replacing their "Selector" logic with random sampling also degraded the results.

Limitations and Future Work

  • Fixed Sampling Limits: The current model uses a hard cap (e.g., 50 triples) for context. In very dense parts of the graph, this might still leave out important information, while in sparse parts, it might be overkill.
  • Computational Overhead: While more scalable than embedding-based scoring, generating text for every query is still more computationally expensive than simple vector math during the inference phase.
  • Future Directions: The authors suggest developing adaptive sampling techniques that can dynamically decide how much and what kind of context is needed based on the complexity of the specific query.

Summary updated

BibTeX
@inproceedings{chen2025enhancing,
  author = {Jianfang Chen and Kai Zhang and Aoran Gan and Shiwei Tong and Shuanghong Shen and Qi Liu},
  title = {{Enhancing Knowledge Graph Completion with Entity Neighborhood and Relation Context}},
  booktitle = {DASFAA},
  year = {2025},
  doi = {10.1007/978-981-95-3830-0\_40},
}

Loading related content...

Figure