KRACL: Contrastive Learning with Graph Context Modeling for Sparse Knowledge Graph Completion

Zhaoxuan Tan, Zilong Chen, Shangbin Feng, Qingyue Zhang, Qinghua Zheng, Jundong Li, Minnan Luo

Abstract

Knowledge Graph Completion (KGC) faces a significant "sparsity challenge," where entities with few connections are difficult to model accurately. This paper introduces KRACL, a framework combining a multi-operator relational attention network (KRAT) with a novel knowledge contrastive loss (KCL). KRACL captures diverse semantic nuances through an ensemble of relational operators and enriches training signals for sparse entities via contrastive learning. Experimental results on benchmarks like WN18RR and NELL-995 demonstrate that KRACL outperforms state-of-the-art models by up to 9.6% in Mean Reciprocal Rank (MRR), showing particular robustness in low-data scenarios.

Introduction

Knowledge Graphs (KGs) such as Freebase and WordNet serve as foundational structures for various AI applications by storing facts as (subject, relation, object) triples. Despite their size, these graphs are often incomplete. The task of Knowledge Graph Completion (KGC) aims to predict missing links to enhance graph utility.

A primary obstacle in KGC is data sparsity. In real-world KGs, a substantial portion of entities are "long-tail," appearing in only a handful of triples. Traditional embedding-based models often fail to learn meaningful representations for these entities due to the lack of contextual "signal." When an entity has minimal connectivity, mapping it accurately into a high-dimensional latent space becomes problematic, leading to poor predictive performance for the majority of the graph's entities.

Methodology

KRACL (Knowledge Relational Attention Network with Contrastive Learning) addresses the sparsity problem through two primary components:

Knowledge Relational Attention Network (KRAT)

Unlike standard Graph Neural Networks (GNNs) that rely on a single mathematical operator for message passing, KRAT ensembles multiple popular operators: Subtraction (TransE), Multiplication (DistMult), Rotation (RotatE), and Circular-correlation (HolE). By integrating these within an attention-based GNN, the model can capture a wider array of semantic nuances from an entity's neighborhood, leveraging the specific inductive biases of each operator (e.g., handling symmetry or composition).

Knowledge Contrastive Loss (KCL)

To overcome the limitations of simple negative sampling, KRACL introduces a contrastive learning objective. KCL treats other entities within a training batch as negative samples for a given triple. This approach provides a much richer feedback signal, effectively teaching the model what an entity is not. For sparse entities with few positive examples, this additional contrastive signal is crucial for anchoring their embeddings firmly in the latent space.

Experimental Evaluation

The authors evaluated KRACL on five standard benchmarks, categorized by density:

  • Sparse: WN18RR and NELL-995 (average entity in-degree ≈ 2).
  • Dense: FB15k-237, Kinship, and UMLS.

Key Results and Sparsity Resilience

KRACL achieved state-of-the-art results on the sparse datasets. On WN18RR, it improved MRR from 0.481 (CompGCN) to 0.527, representing a 9.6% relative improvement.

Performance across different entity in-degree bins for four benchmark datasets. The blue bars represent MRR, while the yellow bars indicate entity frequency.

As shown in the figure above, KRACL maintains strong performance even in bins with low in-degree (high sparsity). In stress tests involving the random removal of up to 90% of training triples from FB15k-237, KRACL’s performance degraded significantly more slowly than competitive baselines like RotatE or ConvE.

Discussion and Conclusion

The success of KRACL highlights two critical insights: the importance of operator diversity in GNNs and the power of contrastive learning as a "feedback intensifier" for sparse data. By contrasting sparse entities against a wide variety of negatives, the model receives richer gradients that compensate for the lack of positive triples.

While KRACL excels in sparse environments and simple relations, modeling complex Many-to-Many (N-N) relations remains a challenge. On the dense FB15k-237 dataset, KRACL is competitive but does not show the same transformative gains seen in sparse graphs. Future work will focus on developing more expressive schemes for complex relationships while preserving the benefits of contrastive learning for long-tail entities.

Summary updated

BibTeX
@inproceedings{tan2022kracl,
  author = {Zhaoxuan Tan and Zilong Chen and Shangbin Feng and Qingyue Zhang and Qinghua Zheng and Jundong Li and Minnan Luo},
  title = {{KRACL: Contrastive Learning with Graph Context Modeling for Sparse Knowledge Graph Completion}},
  booktitle = {The Web Conference},
  year = {2022},
}
Figure