Relation-dependent contrastive learning with cluster sampling for inductive relation prediction

Jianfeng Wu, Aolin Xiong, Sijie Mai, Haifeng Hu

TL;DR

ReCoLe (Relation-dependent Contrastive Learning) introduces a fully inductive relation prediction framework for knowledge graphs by combining contrastive learning with semantic cluster sampling. By training dedicated Graph Neural Network (GNN) encoders for clusters of semantically similar relations, it successfully predicts completely unseen relations and significantly boosts performance on rare, long-tail relations.

What Problem Does This Paper Address?

Knowledge graphs (KGs) are massive networks of real-world facts represented as triplets: (head entity, relation, tail entity). Because KGs are perpetually incomplete, researchers use machine learning to predict missing links.

Recent "subgraph-based" models excel at predicting links for unseen entities by analyzing the local graph structure surrounding a pair. However, they suffer from two major flaws:

  1. They are not fully inductive: If a relation (e.g., aunt_of) was never seen during training, traditional models cannot predict it because they rely on learning a static, fixed embedding matrix for each specific relation.
  2. The Long-Tail Problem: Rare relations receive very few parameter updates during training, leading to weak representations and inaccurate predictions.

ReCoLe addresses these gaps by shifting the focus from learning isolated relation embeddings to understanding the deep semantic and structural commonalities shared between different relations.

Methods

ReCoLe abandons the standard practice of learning independent parameters for every single relation. Instead, it introduces a multi-step pipeline centered around Cluster Sampling and Contrastive Learning:

  1. Semantic Clustering: The model extracts text descriptions of all relations, converts them into vector representations using GloVe word embeddings, reduces dimensions via t-SNE, and groups them into $n_c$ clusters using K-Means. Semantically similar relations (like uncle_of and aunt_of) end up in the same cluster.
  2. Cluster Sampling: For a given target triplet, a positive sample is randomly drawn from the same relation cluster, while negative samples are drawn from entirely different clusters.
  3. Relation-Specific GNN Encoders: ReCoLe allocates a dedicated GNN-based encoder to each relation cluster. This encoder processes the local directed enclosing subgraph around the entities.
  4. Contrastive Pre-training: The encoders are trained using a contrastive loss function. This forces the model to maximize representation agreement between semantically similar relations and minimize it for dissimilar ones.
The schematic diagram of ReCoLe pipeline

Because relations in the same cluster share an encoder, knowledge is naturally transferred from well-studied relations to rare, long-tail ones. Furthermore, when a completely unseen relation appears at test time, ReCoLe simply maps it to the closest semantic cluster and utilizes that cluster's pre-trained encoder to make a zero-shot prediction.

Datasets

The authors evaluated ReCoLe on the refined inductive versions of two standard benchmarks:

  • FB15k-237
  • NELL-995

Each dataset contains four distinct split versions (v1–v4). These "refined" benchmarks are notable because they explicitly filter out empty-subgraph triplets, ensuring a more rigorous and meaningful evaluation for subgraph-based architectures.

Key Insights and Ideas

  • Structural Homology in Relations: The core insight is that semantically similar relations share highly similar local subgraph structures. For example, the graph neighborhood proving someone is an uncle_of looks almost identical to the neighborhood proving someone is an aunt_of.
  • Contrastive Learning as a Structural Regularizer: Pre-training via contrastive learning allows the GNNs to map raw graph structures into a well-behaved semantic space before fine-tuning on the actual link prediction task. As shown via t-SNE visualizations, contrastive learning transforms scattered structural representations into clean, distinct semantic clusters.
t-SNE visualization of features from untrained vs pre-trained encoders

Key Results

ReCoLe consistently outperformed state-of-the-art inductive baselines (including GraIL, CoMPILE, and Meta-iKG) across nearly all metrics:

  • Overall Performance: On the FB15k-237 dataset, ReCoLe achieved an absolute Hits@10 improvement of up to 4.78% over Meta-iKG. On NELL-995, it outperformed CoMPILE by up to 11.75% in Hits@10.
  • Long-Tail Robustness: In experiments isolating rare relations (appearing fewer than 20–50 times in training), ReCoLe achieved up to a 10% AUC improvement over the PathCon baseline, proving that cluster-based knowledge sharing successfully mitigates data scarcity.
  • Ablation Studies: Removing the Cluster Sampling component caused the most severe performance drops (e.g., AUC-PR falling from 82.77 to 75.44 on FB15k-237-v1), validating that semantic grouping is the primary driver behind the model's strong generalization.

Limitations and Future Work

While ReCoLe achieves fully inductive relation prediction, its performance is fundamentally bounded by the quality of the initial text descriptions used for clustering. If a relation has an ambiguous or poorly written description, it may be sorted into the wrong cluster, degrading the encoder's accuracy.

The authors suggest that future work could explore leveraging more powerful, context-aware language models (such as BERT or modern LLMs) to generate richer relation representations, or developing dynamic clustering mechanisms that update iteratively during training.

Summary updated

BibTeX
@article{wu2024relation,
  author = {Jianfeng Wu and Aolin Xiong and Sijie Mai and Haifeng Hu},
  title = {{Relation-dependent contrastive learning with cluster sampling for inductive relation prediction}},
  journal = {Neurocomputing},
  year = {2024},
  doi = {10.1016/j.neucom.2024.127425},
}
Figure