Graph Neural Networks
A graph neural network learns by having every node repeatedly gather and combine information from its direct neighbors, so a node's final representation is shaped by the structure of the network around it, not just its own features.
Prerequisites: The Multilayer Perceptron, Linear Algebra for Quants
Most models assume a data point stands alone: a row of features in, a prediction out, with rows treated as interchangeable and unrelated. But a lot of financial data isn't like that. A company sits inside a supply chain of suppliers and customers; a trader's counterparties form a network; correlated stocks form clusters. Ignoring that structure means throwing away exactly the information that would tell you why one company's earnings miss dragged three others down with it.
A graph neural network treats data as nodes connected by edges — companies and their supply relationships, say — and instead of scoring each node in isolation, it lets nodes talk to their neighbors. Picture a room of people at a mixer, each holding a card describing themselves. In each round, everyone reads the cards held by the people standing next to them, and rewrites their own card to summarize both what it already said and what the neighbors said. After a few rounds, a person's card reflects not just who they are, but the flavor of the people around them, and the people around those people.
The mechanics, one symbol at a time
Let be node 's representation after rounds of this "read and rewrite" process (its feature vector at layer ), and let be the set of 's direct neighbors in the graph. One standard update rule:
In words: the new representation for node is built from two pieces — its own current representation, passed through weights , and the sum of its neighbors' current representations, passed through a separate weight matrix — added together and squashed through a nonlinearity , the same as an ordinary neural network layer. This is called message passing: at each round, every node sends its current representation to its neighbors as a "message," and every node aggregates the messages it received to update itself. Stack such layers and a node's final representation has absorbed information from every node reachable within hops — its neighbors, its neighbors' neighbors, and so on.
Worked example 1: one round of message passing by hand
A tiny 3-node graph: node A (a bank) connects to node B (a hedge fund counterparty) and node C (another bank). Initial 1-dimensional features (a simplified "risk score"): , , . Weights: , , no bias, identity for simplicity.
Node A's neighbors are B and C, so the neighbor sum is .
Node A's risk score rose from 2.0 to 2.8 after one round, purely from being connected to a higher-risk counterparty (B, at 5.0) — its own features didn't change, but its representation shifted because of who it's linked to. A node with the exact same original features but safer neighbors would end up with a lower updated score. That's the entire value proposition of a GNN: identical raw features can lead to different learned representations depending on network position.
Worked example 2: information reaching a 2-hop neighbor
Extend the graph: node D connects only to node C (D is a counterparty of C, not directly of A). After round 1 (computed the same way as above), suppose (using and original ).
Now run round 2 for node A, using round-1 values: (from above) and , plus computed similarly, say .
Node D never directly touched node A, yet D's original value of has now flowed into A's representation — through C, over two rounds. This is exactly how a GNN captures second-order exposure: a bank's risk score can rise because of a counterparty's counterparty, without a single direct edge between them, purely from stacking two message-passing layers.
Each round of message passing is, at its core, a matrix operating on a vector — the explorer above shows how a single linear map reshapes a simple 2-D space; a GNN layer is the same kind of operation, applied per node and mixed with each node's neighbors, repeated layer after layer.
What this means in practice
GNNs are used in finance for counterparty risk contagion (whose default would ripple where), fraud detection on transaction networks, supply-chain risk propagation, and modeling correlated baskets of securities as a graph rather than treating each independently. The number of message-passing layers controls how many hops of the network a prediction can see — too few and distant but relevant risk is invisible, too many and every node's representation starts blending toward the same "average of the whole graph" value, a known failure mode called over-smoothing. Building the graph itself (deciding which edges exist and how strong they are) is often the hardest and most consequential modeling choice, arguably more important than the GNN architecture on top of it.
A GNN updates every node's representation by combining it with its neighbors' representations, and stacking such layers lets information propagate hops across the graph — capturing relational structure a row-by-row model cannot see at all.
The classic confusion: stacking many GNN layers expecting strictly better long-range reasoning, the same intuition that works for depth in ordinary networks. Past a handful of layers, node representations tend to over-smooth — every node's vector converges toward a similar average of the whole (or a whole connected component of the) graph, and the model actually loses the ability to distinguish nodes it could tell apart with fewer layers.
Related concepts
Practice in interviews
Further reading
- Hamilton, Graph Representation Learning
- Kipf & Welling, Semi-Supervised Classification with Graph Convolutional Networks