family Β· backbone
graph neural networks (GNNs)
Neural networks that operate on graph-structured data by passing messages between connected nodes. The objective varies β node classification, link prediction, or graph classification β making GNNs a backbone, not a single model.
primitives, wired directly + objective: varies
βΈ open this recipe in the builder
Standard neural networks expect fixed-size vectors or grids. Graphs break both assumptions: a molecule has a variable number of atoms, a social network has a variable number of friends, and both have explicit topology β who is connected to whom. Graph neural networks (GNNs) learn directly from that topology alongside node and edge features, making them the natural choice for chemistry, recommendation systems, knowledge-base reasoning, and any domain where relationships are first-class data.
How it works
Most GNNs follow the message-passing paradigm. In each layer, every node does three things: (1) collects messages from its immediate neighbors, (2) aggregates them β typically by sum, mean, or max β and (3) updates its own representation by combining the aggregated message with its current state via a small MLP (a feed-forward network). Each node starts as an embedding of its raw features; after k layers of message passing, it encodes information from its k-hop neighborhood.
Key architectures differ mainly in how they aggregate:
- GCN (Graph Convolutional Network) β aggregates using a normalized adjacency matrix. Connects to spectral graph theory: the operation filters signals on the graphβs Laplacian.
- GAT (Graph Attention Network) β weighs neighbors with learned attention scores instead of treating all neighbors equally.
- GraphSAGE β samples a fixed number of neighbors rather than using all of them, enabling inductive generalization to unseen nodes.
- GIN (Graph Isomorphism Network) β designed to match the theoretical expressiveness of the Weisfeiler-Lehman graph isomorphism test.
Node embeddings can be pooled to produce graph-level representations for classifying whole graphs (for example, predicting molecular properties).
Variants and limits
A known weakness is over-smoothing: stack too many layers and every nodeβs representation converges toward the same vector, because each layer widens the neighborhood until every node has seen the entire graph. In practice, GNNs are capped at 2β5 layers, unlike CNNs or transformers that benefit from much greater depth.
Graph transformers blur the line between GNNs and attention: rather than restricting messages to graph neighbors, they apply self-attention across all nodes β sacrificing inductive bias for expressiveness.
Where youβll see it
Drug discovery (predicting molecular properties and protein interactions), recommendation engines (social and item graphs), traffic and route prediction, and knowledge-graph link prediction are the dominant applications. Any time the data is naturally a set of entities with typed relationships, a GNN is the first architecture to consider.
Related concepts
- feed-forward networks β the MLP inside each message-passing update
- embeddings β the per-node vectors GNNs learn and transform
- attention mechanisms β GAT applies attention to graph neighborhoods; graph transformers extend this further
- convolutional neural networks β CNNs convolve over grids; GNNs generalize convolution to arbitrary topology