DeepWalk: Online Learning of Social Representations

DeepWalk banner Kaggle

Summary

DeepWalk learns a vector (an embedding) for every node in a graph. It runs short random walks on the graph, treats each walk like a sentence and each node like a word, and trains the Skip-gram language model on these “sentences”. Nodes that often appear close together in walks get similar vectors (Abstract, Section 4).

On multi-label classification of BlogCatalog, Flickr and YouTube users, the paper reports F1 scores up to 10% higher than competing methods when labelled data is sparse, and in some experiments it beats all baselines with 60% less training data (Abstract, Section 6.1). It is also online and easy to run in parallel (Sections 4.3 and 4.4).

What Problem Does It Solve

Imagine you want to guess the interests of people in a social network, but only a few of them have filled in their profile. Friends often share interests, so the network itself holds useful clues. The hard part is turning “who is connected to whom” into numbers a normal classifier can use.

The baselines in the paper build features from the whole graph at once, for example from eigenvectors of the graph Laplacian or the modularity matrix (Section 5.2). DeepWalk learns the numbers from local information only, one short walk at a time, and the result can be fed into any statistical model (Abstract, Section 2).

Core Idea

  • Walks as sentences: a truncated random walk W_vi starts at node v_i and moves to a uniformly random neighbour at each step (Section 3.1).
  • Why language models fit: if the graph’s degree distribution follows a power law, node frequencies in short walks also follow a power law, like word frequencies in text (Section 3.2, Figure 2).
  • Skip-gram objective: for each node in a walk, maximise the probability of the nodes within a window of w on both sides, given the node’s embedding Φ(v) (Section 3.3, Algorithm 2).
  • Algorithm 1: γ times, shuffle the nodes, start one walk of length t at every node, and update Φ with Skip-gram on each walk (Section 4.2).

Key Method Details

  • Hierarchical Softmax: the nodes are the leaves of a binary tree, so a probability is computed along a path of length O(log |V|) instead of over all nodes (Section 4.2.2).
  • Settings for the main results: γ = 80 walks per node, window w = 10, d = 128 dimensions (Section 6.1); walk length t = 40 (Section 6.2).
  • Evaluation: a share of the nodes is labelled, one-vs-rest logistic regression is trained on their embeddings, and Micro-F1 and Macro-F1 are averaged over 10 random splits (Section 6.1).
  • Scaling: updates are sparse, so asynchronous SGD with several workers works without locks (Section 4.3). A streaming variant can learn without seeing the whole graph (Section 4.4.1).

Simplifications in This Notebook

  • Graph: a synthetic graph with 75 nodes in 3 communities of 25, joined by 6 bridge edges, instead of graphs with 10,312 to 1,138,499 nodes.
  • Training: 10 walks of length 20 per node, window 3, 16 dimensions and 5 epochs; negative sampling (5 negatives) instead of Hierarchical Softmax.
  • Single label: each node has one community label, so accuracy is used instead of Micro-F1 and Macro-F1.
  • Extra comparison: node2vec walks (a later method) with q = 2 and q = 0.5, plus a random-embedding baseline.

What the Notebook Result Shows

  • Communities recovered: K-Means on the DeepWalk embeddings matched the 3 communities exactly (NMI 1.0000); with 10% of nodes labelled, accuracy was 0.979 ± 0.016 over 10 splits.
  • The test is meaningful but easy: a random embedding scored NMI 0.0194 and accuracy 0.338 ± 0.042, about chance. The graph is tiny with very clear communities, so near-perfect scores are expected.
  • No winner: DeepWalk and both node2vec settings all reached NMI 1.0000 and accuracies of 0.969 to 0.979, inside one standard deviation of each other.

Influence

The authors released their code as phanein/deepwalk. node2vec, published two years later, describes DeepWalk’s sampling as “a special case of node2vec with p = 1 and q = 1” (Grover and Leskovec, 2016, Section 4.2). OpenAlex lists about 11,700 citations (11,715 when checked on 3 December 2026).


Resources

File Description
README.md This overview — a 5-minute read covering the paper’s summary, core idea, key method details, influence, and a plain-English explanation of the problem it solves
solution.ipynb From-scratch NumPy DeepWalk (uniform random walks + Skip-gram with negative sampling) on a synthetic 3-community graph, compared with node2vec walks and a random baseline
CODE_ARCHITECTURE.md Section-by-section breakdown of the notebook — what each cell does, data flow, tensor shapes, and key design decisions
TALK.md Press coverage, Q&A (answers from the paper), citations, and common misconceptions about the paper

Table of contents