Message Passing Neural Networks
A graph neural network learns by having every node send a summary of itself to its neighbors, collect what its neighbors sent back, and update its own representation accordingly — repeat this a few times and each node ends up knowing about its wider neighborhood, not just itself.
Prerequisites: The Multilayer Perceptron, Graph Traversal — BFS and DFS
A standard neural network expects a fixed-size vector as input — a row of features. A company's supplier network, a portfolio's correlation graph, or a molecule's bond structure isn't naturally a row of features; it's a set of nodes connected by edges, with no fixed size and no natural ordering. Feeding a graph into an ordinary network means throwing away the very thing that makes it a graph — who's connected to whom. Message passing is the mechanism that lets a network learn directly on the graph structure itself, by having each node repeatedly gather information from its immediate neighbors.
The analogy: office gossip, formalized
Picture an office where nobody reads a company-wide memo — everyone only ever talks to their direct desk-neighbors. On day one, everyone knows only their own situation. At the end of day one, everyone has swapped a short update with their immediate neighbors, so now everyone's understanding includes a summary of their direct neighbors' situations too, folded into their own. On day two, they swap updates again — but this time, since everyone's "situation" already includes what they learned yesterday, a two-hop chain of gossip effectively reaches them: they now know something about their neighbors' neighbors, without ever talking to them directly. Run this for a few more days and information from a whole local neighborhood eventually reaches every desk, purely through repeated local exchanges — no one ever needed the company-wide memo. Message passing does exactly this with vectors instead of gossip: each node's internal representation gets updated, layer by layer, using only what its direct neighbors currently know.
The mechanism: aggregate, then update
At layer , every node has a current representation vector — a summary, in numbers, of what node "knows" after rounds of message passing (at , this is just the node's own raw features). One layer of message passing does two things:
Here is the set of node 's direct neighbors in the graph, is some order-independent combining function — commonly a sum, mean, or max — that squashes the (variable-length, unordered) set of neighbor vectors into a single fixed-size message , and is a small neural network layer that combines the node's own previous representation with the incoming message to produce its new representation. In words: every node collects a combined summary of what its neighbors currently know, then blends that summary with its own current knowledge to form an updated self. Stacking layers of this lets information reach nodes up to hops away, because each layer only reaches one hop further than the last.
The choice of AGGREGATE has to be order-independent — a node's set of neighbors has no natural ordering, so summing or averaging (which don't care what order the numbers arrive in) work, but something order-sensitive like concatenation in a fixed sequence would not, since which neighbor is "first" is meaningless on a graph.
Worked example 1: two nodes, one layer, by hand
Take a tiny 3-node graph: connects to and . Give each node a 1-dimensional starting feature: , , . Use AGGREGATE = mean, and UPDATE = "average the old value with the message."
Node 's neighbors are and : aggregated message . New representation: . Node 's value moved from toward , pulled by its neighbors' average of — exactly what "gossip" should do: shift a node's self-knowledge partway toward what its neighbors reported.
Worked example 2: two layers reach two hops
Extend the graph: connects only to (so and are two hops apart, not directly connected), with . After layer 1, 's neighbors are and : , so .
Now layer 2 for node : its neighbors' layer-1 values are (computed similarly, say it comes out to ) and . So , and . Node 's final value, , has been pulled by node 's original value of even though and are never directly connected — it arrived indirectly, through , exactly two layers after node started, matching the two-hop graph distance between them.
A node's representation after layers of message passing has been influenced by every node within hops, and by no node farther away than that — the number of layers is a direct, literal dial on how far information is allowed to travel across the graph.
What this means in practice
Message passing networks are the foundation for learning on any graph-structured financial data: a supplier-customer network, a syndicate-loan network, an order-book limit-price ladder treated as a graph, or a portfolio's correlation network. They let a model learn features like "how exposed is this company to distress two supply-chain tiers away" directly from graph structure, rather than requiring an analyst to hand-engineer that feature. Graph convolutional networks and graph attention networks are both specific choices of AGGREGATE and UPDATE within this same message-passing template.
Stacking many message-passing layers to reach a wider neighborhood sounds like it should only help, but pushing past a handful of layers commonly causes over-smoothing: every node's representation gets repeatedly averaged with its neighbors' until, after enough rounds, distant and distinct nodes converge toward nearly the same value and the network loses its ability to tell nodes apart at all. Unlike depth in a standard feedforward network, more message-passing layers is not simply "more capacity" — it actively erodes node-level distinctiveness past a certain point.
Practice
- In a 5-node chain graph ––––, how many message-passing layers are needed before 's representation depends at all on 's original features?
- Explain why AGGREGATE must be an order-independent function like sum or mean, using the office-gossip analogy's notion of "neighbors with no natural ordering."
- A model uses 10 stacked message-passing layers on a densely connected graph. Predict, using the over-smoothing idea, what is likely to happen to how distinguishable two arbitrary nodes' final representations are.
Related concepts
Practice in interviews
Further reading
- Gilmer et al., Neural Message Passing for Quantum Chemistry (2017)
- Hamilton, Graph Representation Learning (2020)