Abstract
Graph representation learning (GRL) typically focuses on defining positive node pairs to capture similarity. However, negative sampling—the process of selecting dissimilar nodes—is equally vital for model performance. This paper explores the theoretical foundations of negative sampling, identifying a "Goldilocks zone" for negative distributions. We introduce Markov Chain Monte Carlo Negative Sampling (MCNS), a scalable algorithm that leverages graph topology via Depth First Search (DFS) to efficiently sample informative negatives. Empirical results across recommendation and link prediction tasks demonstrate that MCNS consistently outperforms standard heuristics and complex generative models.
Introduction
In graph representation learning, nodes are mapped into a low-dimensional vector space where proximity reflects structural or semantic similarity. Most modern frameworks employ contrastive learning, where the model learns to distinguish between "positive" pairs (e.g., adjacent nodes) and "negative" pairs (e.g., non-adjacent nodes). While significant research has optimized positive sampling strategies, negative sampling has often relied on simple heuristics, such as the $deg^{0.75}$ distribution popularized by word2vec.
The authors argue that negative sampling is not merely a secondary component but a critical driver of embedding quality. If negative samples are too "easy" (highly dissimilar), the model fails to learn fine-grained boundaries. Conversely, "hard" negatives (similar but unconnected nodes) can provide more informative gradients but risk introducing noise if they are too similar. This work provides a theoretical basis for optimal negative sampling and proposes a practical, scalable solution.
Methodology
The paper's contributions are twofold: a theoretical framework for negative distribution and the MCNS algorithm.
Theoretical Foundation: Sub-linear Correlation
Through a rigorous analysis of optimization objectives and variance, the authors prove that the ideal negative sampling distribution $p_n$ should be positively but sub-linearly correlated with the positive distribution $p_d$: $$p_n(u|v) \propto p_d(u|v)^\alpha, \text{ where } 0 < \alpha < 1$$ This relationship ensures that the sampler focuses on "hard" negatives—nodes that the current model perceives as somewhat similar—thereby maximizing the information gain during training.
MCNS: Markov Chain Monte Carlo Negative Sampling
To implement this theory efficiently, the authors propose MCNS. Calculating the full similarity distribution for every node is computationally prohibitive ($O(N)$). MCNS addresses this through:
- Self-contrast Approximation: The model uses its own current embeddings to estimate the positive distribution.
- Metropolis-Hastings Sampling: An MCMC approach is used to sample from the estimated distribution without full enumeration.
- DFS Traversal Trick: To eliminate the "burn-in" period typical of MCMC, MCNS uses a Depth First Search (DFS) traversal. By passing the Markov chain state along the DFS path, the algorithm exploits graph homophily—the tendency of neighboring nodes to have similar distributions—making the sampling process extremely fast.
Experimental Evaluation
The effectiveness of MCNS was evaluated across five datasets (MovieLens, Amazon Electronics, Alibaba, Arxiv GR-QC, and BlogCatalog) spanning recommendation, link prediction, and node classification tasks. These datasets vary in scale, from thousands to millions of edges.
Key Results
- Performance Gains: MCNS consistently outperformed eight baselines, including the standard $deg^{0.75}$ heuristic and GAN-based samplers like IRGAN. In recommendation tasks, it achieved a 2% to 13% improvement in Mean Reciprocal Ranking (MRR).
- Architectural Robustness: The method is encoder-agnostic, providing significant performance boosts when paired with various architectures such as DeepWalk, GCN, and GraphSAGE.
- Efficiency: MCNS is significantly faster than complex generative models. For instance, it was at least 2x faster than KBGAN on the MovieLens dataset while maintaining superior accuracy.
Discussion and Conclusion
The study highlights that the negative distribution is as influential as the positive one in GRL. The "hard negative" paradox is resolved by showing that nodes "nearby but not connected" provide the best gradients for defining clear decision boundaries. The use of DFS to accelerate MCMC is a key engineering contribution that leverages graph topology to overcome traditional sampling bottlenecks.
Future work includes addressing hyperparameter sensitivity (e.g., the power $\alpha$ and hinge loss margin $\gamma$) and extending the framework to dynamic graphs. While the DFS trick is highly effective in clustered unipartite graphs, its performance in extremely sparse or strictly hierarchical structures warrants further investigation.
Summary updated