Graph neural network (GNN)

A graph neural network is a neural network built for data shaped as a graph, such as atoms joined by bonds or points on a mesh around the globe, which learns by passing messages between connected nodes.

Much real-world data is a graph: a set of things, called nodes, joined by relationships, called edges. A molecule is atoms joined by bonds; a social network is people joined by friendships. Ordinary neural networks expect a fixed grid, like an image, or a sequence, like a sentence. Graphs have neither a fixed size nor a natural order, so graph neural networks are built to give the same answer however the nodes happen to be listed.

Most GNNs work by message passing. In each layer, every node collects messages from its neighbours, combines them with an operation such as a sum, mean or maximum, and updates its own representation. One layer lets information travel one hop; ten layers let a node take in its neighbourhood ten hops away. The network can then make a prediction about each node, each edge or the whole graph. A typical example is drug design, where a model reads a molecule as a graph and predicts whether it will act against a bacterium such as E. coli.

The original graph neural network model was published by Franco Scarselli and colleagues in 2009. Graph convolutional networks, from Thomas Kipf and Max Welling in 2017, and graph attention networks, from Petar Veličković and colleagues in 2018, made the approach popular. There is a close link to language models: a transformer layer can be seen as a GNN on a graph in which every token is connected to every other.

GNNs appear often in AI-for-science news. Google DeepMind's GraphCast, presented in November 2023 in a paper in Science, is a weather forecasting system based on graph neural networks. It produces a 10-day global forecast at 0.25-degree resolution in under a minute on a single TPU v4 machine, and it was more accurate than the European Centre for Medium-Range Weather Forecasts' HRES system on more than 90% of 1,380 test variables and lead times. GNNs are also used to predict the properties of molecules and crystals, to recommend content on social platforms and to spot anomalies in computer security logs.

They have known limits. Stacking many layers tends to make all node representations look alike, a problem called oversmoothing, and squeezing information from distant nodes into fixed-size vectors loses detail. Standard message-passing GNNs also cannot tell apart some graphs that differ in structure. For some node-level tasks, such as anomaly detection, boosting methods can still do better, so a GNN is a specialist tool for relational data rather than a general-purpose model.

Common questions

What is a graph neural network used for?

GNNs are used wherever data is naturally a network of connected things: molecules and materials in chemistry and drug discovery, weather on a mesh around the globe, social and recommendation networks, and security logs. They predict properties of individual nodes, of connections between them, or of a whole graph.

How is a GNN different from a CNN or a transformer?

A convolutional network assumes a regular grid such as an image, and a transformer usually treats its input as a sequence in which every token can attend to every other. A GNN follows whatever connections the graph actually has. In fact, a CNN can be seen as a GNN on a pixel grid and a transformer as a GNN on a fully connected graph.

What is message passing?

Message passing is the core step of most GNNs. Each node gathers information from its directly connected neighbours, combines it, and updates its own representation. Repeating this over several layers spreads information further across the graph.

Does Google DeepMind's GraphCast use a graph neural network?

Yes. DeepMind described GraphCast in November 2023 as a weather forecasting system based on machine learning and graph neural networks. It forecasts hundreds of weather variables 10 days ahead in under a minute on one TPU v4 machine.

Finding more

Search for "graph neural network introduction", "message passing neural network" or "GNN drug discovery" depending on your interest. Reliable sources include review articles and the original papers on arXiv, university course notes on machine learning with graphs, and peer-reviewed journals for scientific applications such as weather and materials. Treat claims that a GNN outperforms established methods with care until you have checked which baselines and test sets were used.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.