Watch Your Step: Learning Node Embeddings via Graph Attention

Sami Abu-El-Haija, Bryan Perozzi, Rami Al-Rfou', Alexander A. AlemiNeurIPS 2018

TL;DR

Instead of manually tuning how far a random walk should "look" to learn graph embeddings, this paper introduces a way to automatically learn the optimal context distribution using an attention mechanism. By treating the hop-distance as a trainable parameter, the model—aptly named "Watch Your Step"—significantly outperforms state-of-the-art methods like node2vec and DeepWalk, reducing link prediction error by up to 40%.

What Problem Does This Paper Address?

Graph embedding methods (like DeepWalk or node2vec) aim to turn nodes in a network into vectors while preserving the graph's structure. Most of these methods rely on random walks: a "surfer" starts at a node and hops to neighbors for $C$ steps.

The problem is that the choice of $C$ (the walk length or "window size") is a critical hyperparameter that changes for every single graph. A social network might require looking at friends-of-friends (2 hops), while a citation network might need a much broader view. Currently, researchers have to manually "grid-search" for the best $C$, which is computationally expensive and often results in sub-optimal embeddings.

Dataset statistics and the varying optimal context window size (c) across different networks.

As seen in the performance curves above, the optimal window size $c$ varies drastically depending on the dataset. This paper asks: Can we just let the model learn how far it needs to look?

Methods

The authors propose a shift from simulating discrete random walks to using a closed-form expectation of the co-occurrence matrix.

  1. The Power Series Approach: They show that the probability of visiting a node at distance $k$ is related to the $k$-th power of the transition matrix ($T^k$).
  2. Graph Attention: They introduce a trainable vector $q$. By applying a softmax to $q$, they create a "context distribution" $Q$. This distribution assigns a weight to each hop distance (1-hop, 2-hops, ..., $C$-hops).
  3. End-to-End Learning: During training, the model uses backpropagation to adjust both the node embeddings and the attention weights $Q$ simultaneously.
  4. Attention on Data, Not Inference: Unlike standard attention (e.g., in Transformers) which helps a model decide what to focus on during a prediction, this attention guides the learning process itself. It tells the algorithm which parts of the graph structure are most informative for the specific dataset at hand.

Key Insights and Ideas

  • The "Aha" Moment: The authors realized that the "window size" in word2vec-style graph embeddings is actually just a coefficient in a power series of the transition matrix. By making these coefficients trainable, they turned a discrete tuning problem into a continuous optimization problem.
  • Graph-Specific Personalities: The learned attention weights $Q$ act as a "fingerprint" for the graph.
Learned attention probability mass across different datasets, showing how the model adapts its focus to the specific graph structure.

As illustrated above, in the PPI (biological) network, the model learned to focus heavily on immediate neighbors ($Q_1$). In contrast, for wiki-vote, it learned that longer-range dependencies were equally or more useful.

  • Robustness: Because the model learns its own hyperparameters, it is much less sensitive to the initial setup than traditional methods. You can set a very large maximum walk length, and the model will simply "attend" to zero for the hops it doesn't need.

Key Results

  • Link Prediction: "Watch Your Step" consistently outperformed baselines like SVD, DeepWalk, and node2vec. It reduced the error rate by 20% to 40% across almost all datasets (which included social, collaboration, and biological networks).
  • Node Classification: On the Cora and Citeseer datasets, the learned embeddings provided better separation of classes in latent space (visualized via t-SNE) and higher classification accuracy compared to node2vec.
  • Efficiency: While calculating matrix powers can be slow, the authors note that because most real-world graphs are low-rank, this can be approximated efficiently. In their experiments, the algorithm ran significantly faster than the multi-step process of simulating walks and then running word2vec.

Limitations and Future Work

  • Computational Complexity: The naive computation of $T^k$ is $O(V^3)$, which doesn't scale to massive graphs with millions of nodes. While the authors suggest using SVD or other approximations to bring this down to $O(E)$, these approximations weren't the primary focus of this paper.
  • Static Graphs: The current model is designed for static graphs. Extending this "learning to walk" approach to dynamic or temporal graphs (where edges change over time) remains an open challenge.
  • Beyond Random Walks: The authors briefly mention that this framework could be extended to learn weights for other types of node similarity, like Personalized PageRank or Adamic-Adar, which could lead to even more expressive embeddings.

Summary updated

BibTeX
@inproceedings{abuelhaija2018watch,
  author = {Sami Abu-El-Haija and Bryan Perozzi and Rami Al-Rfou' and Alexander A. Alemi},
  title = {{Watch Your Step: Learning Node Embeddings via Graph Attention}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2018},
  url = {https://openreview.net/forum?id=rkWaJYWuZS},
}
Figure