NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Comprehend DeepWalk as Matrix Factorization

Cheng Yang, Zhiyuan LiuarXiv 2015

Introduction

The emergence of DeepWalk in 2014 marked a significant shift in graph representation learning. By adapting the Word2vec (Skip-Gram) model from Natural Language Processing to the domain of graphs, DeepWalk provided a powerful heuristic for generating node embeddings. It treated random walks across a network as "sentences" and nodes as "words," allowing researchers to leverage neural architectures to capture structural information. However, despite its empirical success, the mathematical objective DeepWalk optimized remained largely opaque. This research demystifies the algorithm by proving that DeepWalk is not merely a neural heuristic but is mathematically equivalent to a specific form of Matrix Factorization (MF).

Theoretical Framework

The authors bridge the gap between neural embeddings and classical linear algebra by analyzing the stationary points of the DeepWalk objective function. The core of the proof involves determining the point where the derivative of the loss function with respect to node embeddings reaches zero. This reveals the underlying matrix $M$ that the product of learned node vectors ($W H^T$) seeks to approximate.

The analysis distinguishes between the two primary output layers used in Skip-Gram models:

  1. Skip-Gram with Negative Sampling (SGNS): Building on the work of Levy and Goldberg, the authors demonstrate that DeepWalk with SGNS implicitly factorizes a matrix of Shifted Pointwise Mutual Information (PMI).
  2. Softmax: The authors derive a parallel proof for the Softmax-based version of the model, identifying a distinct matrix structure related to transition probabilities.

The Connection to Matrix Factorization

The fundamental insight of this work is the link between a node's "context" and the graph's transition matrix. If $A$ represents the transition matrix of a graph, the probability of reaching node $j$ from node $i$ in exactly $t$ steps is given by the $j$-th entry of the vector $e_i A^t$.

DeepWalk does not consider a single step but rather a window of size $t$. The paper proves that the algorithm implicitly factorizes a matrix containing the logarithm of the average probability that a random walk starting at node $i$ will visit node $j$ within that window. This finding connects "Deep Learning on Graphs" with "Spectral Graph Theory," suggesting that neural embedding methods are essentially stochastic, efficient implementations of matrix decomposition on structural data.

Formal Results

The research provides two definitive formulas for the matrix $M$ that DeepWalk approximates:

1. Negative Sampling (SGNS)

For the SGNS variant, the matrix entry $M_{ij}$ is defined as: $$M_{ij} = \log \left( \frac{\#(v_i, c_j) \cdot |D|}{\#(v_i) \cdot \#(c_j)} \right) - \log k$$ Here, $k$ represents the number of negative samples, and the first term corresponds to the PMI between node $v_i$ and its context $c_j$.

2. Softmax

For the Softmax variant, the matrix entry $M_{ij}$ is defined as: $$M_{ij} = \log \left( \frac{[e_i(A + A^2 + \dots + A^t)]_j}{t} \right)$$ This formula explicitly shows that the embedding captures the average reachability of node $j$ from node $i$ over a window of $t$ steps.

Discussion and Limitations

While this theoretical grounding provides a rigorous basis for DeepWalk, it relies on certain idealized assumptions:

  • Dimensionality: The proof assumes the embedding dimension $d$ is sufficiently large to capture $M$ perfectly. In practice, $d$ is typically much smaller than the number of nodes, resulting in a low-rank approximation.
  • Sampling Noise: The proof assumes an infinite number of random walks. Real-world implementations use finite walks, introducing sampling noise that the pure matrix form does not fully account for.

Conclusion

By revealing the implicit matrix factorization within DeepWalk, this paper provides a unifying perspective on graph embeddings. This theoretical foundation paves the way for developing explicit matrix factorization algorithms that may offer greater stability or computational efficiency than stochastic, walk-based approaches.

Summary updated

BibTeX
@misc{yang2015comprehend,
  author = {Cheng Yang and Zhiyuan Liu},
  title = {{Comprehend DeepWalk as Matrix Factorization}},
  year = {2015},
  eprint = {1501.00358},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1501.00358},
}
Figure