Structure Aware Negative Sampling in Knowledge Graphs

Kian Ahrabian, Aarash Feizi, Yasmin Salehi, William L. Hamilton, Avishek Joey Bose

Introduction

Knowledge Graphs (KGs) are structured representations of facts, typically stored as triples in the form (head, relation, tail). Despite their utility in downstream AI tasks, KGs are often incomplete. To address this, researchers use Knowledge Graph Embeddings (KGEs) to map entities and relations into a low-dimensional vector space, allowing for link prediction and fact completion.

Training KGEs relies on contrastive learning, where a model learns to distinguish between true facts (positive samples) and false ones (negative samples). The effectiveness of this training is heavily dependent on the quality of negative samples. Randomly selected negatives (e.g., "The capital of France is a toaster") are often too easy for the model to identify, leading to poor generalization. Conversely, "hard negatives" (e.g., "The capital of France is Lyon") force the model to learn more nuanced semantic features. While complex methods like Generative Adversarial Networks (GANs) can generate hard negatives, they are computationally expensive and difficult to stabilize. This paper introduces Structure Aware Negative Sampling (SANS), a simpler, more efficient approach that leverages the graph's existing topology to find high-quality negative samples.

The SANS Framework

The core hypothesis of SANS is that an entity's local graph neighborhood serves as a reliable proxy for semantic similarity. Entities within a $k$-hop radius of a center node are likely related but may not share a specific relation, making them ideal candidates for hard negative samples.

Overview of the Structure Aware Negative Sampling (SANS) workflow, illustrating the selection of negative triplets from the k-hop neighborhood.

The authors propose two implementations of this concept:

  1. Vanilla SANS: This method explicitly computes the $k$-hop neighborhood for every node using the adjacency matrix. While precise, it can be memory-intensive for large, dense graphs.
  2. RW-SANS (Random Walk SANS): To improve scalability, random walks are used to approximate the neighborhood. This approach is faster and introduces a natural weighting mechanism, as nodes reachable via multiple paths are sampled more frequently, acting as an implicit filter for relevance.

SANS is designed to be "plug-and-play," compatible with various scoring functions such as TransE, DistMult, and RotatE. It can also be integrated with self-adversarial weighting to further prioritize the most challenging samples within the local neighborhood.

Experimental Evaluation

The researchers evaluated SANS on three standard benchmarks: FB15K-237 (real-world facts), WN18 (lexical data), and WN18RR (a version of WN18 designed to eliminate simple inverse relation leakage).

Key Results

SANS consistently outperformed uniform sampling across all datasets and scoring functions. Notably, on the challenging WN18RR dataset using the TransE model, RW-SANS improved the Hit@10 metric by +3.78% over the uniform baseline.

Performance comparison of SANS and RW-SANS against uniform sampling and SOTA baselines across three datasets.

As shown in the results table, SANS achieves performance competitive with, and often superior to, sophisticated state-of-the-art methods like NSCaching and KBGAN. Crucially, it achieves these results without the implementation complexity or additional parameter overhead required by adversarial training methods.

Discussion and Insights

Several key insights emerged from the study:

  • Structure as Semantics: The success of SANS confirms that graph distance is a powerful proxy for semantic similarity. By sampling from the $k$-hop neighborhood, the model encounters "near-miss" negatives that are semantically plausible but factually incorrect.
  • The Role of $k$: The choice of the neighborhood radius $k$ involves a trade-off. A small $k$ may provide too few candidates, while a large $k$ eventually causes the neighborhood to encompass the entire graph, causing SANS to converge back toward uniform sampling. For example, in FB15K-237, a 5-hop neighborhood already covers 99% of the graph.
  • Efficiency of Random Walks: RW-SANS often outperformed explicit neighborhood computation. The authors suggest that the natural frequency of nodes in random walks provides a better-curated set of negatives than a flat list of all neighbors.

Conclusion and Future Work

SANS provides a robust and efficient alternative to complex negative sampling strategies. By utilizing the inherent structure of the Knowledge Graph, it generates high-quality training signals at a fraction of the computational cost of GAN-based methods. Future research may explore dynamic $k$ values that adapt during training or biased random walk strategies to further refine the quality of negative samples in extremely dense graphs.

Summary updated

BibTeX
@inproceedings{ahrabian2020structure,
  author = {Kian Ahrabian and Aarash Feizi and Yasmin Salehi and William L. Hamilton and Avishek Joey Bose},
  title = {{Structure Aware Negative Sampling in Knowledge Graphs}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2020},
  url = {https://openreview.net/forum?id=wRPN4Pa-vxm},
}
Figure