liveBook · Manning

Chapter 11: Graph representation learning and graph neural networks

What you will learn in chapter 11 of Knowledge Graphs and LLMs in Action

The introduction explains why graph representation learning can replace hard-to-scale manual feature engineering with learned embeddings and introduces GNNs as a way to learn them.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction explains why graph representation learning can replace hard-to-scale manual feature engineering with learned embeddings and introduces GNNs as a way to learn them.

Key terms: manual feature engineering, interpretability, knowledge graphs, graph representation learning, embeddings, graph structure, node attributes, dense vector representations, graph neural networks, neighboring nodes

11.1 Embeddings in graph representation learning

This section traces three generations of graph representation learning, from simplifying graph structure to learning meaningful node representations and patterns automatically.

Key terms: graph representation learning, traditional graph embedding, dimensionality reduction, Node2Vec, graph neural networks

11.1.1 Understanding graph embeddings: From discrete to continuous

This section introduces graph embeddings and explains how graph structure, geometric space, preserved patterns, new-node requirements, and supervision shape embedding choices.

Key terms: graph embeddings, discrete graph structures, continuous vector representations, neighborhood structure, irregularity, Euclidean space, non-Euclidean space, hyperbolic space, hierarchical structure, positional embeddings

11.1.2 Real-world applications and examples

The section uses social, biological, and medical networks to show how embedding choices depend on a problem’s structure, available data, and goals.

Key terms: structural embeddings, positional embeddings, hyperbolic embeddings, inductive learning, supervised learning, expert-labeled data

11.2 The encoder–decoder model

This section introduces the encoder–decoder model as a way to understand how graph embeddings represent graph structure and reconstruct meaningful properties.

Key terms: encoder–decoder model, graph embedding, discrete graph structure, continuous vector representations

11.2.1 The encoder: Converting graph structure to vectors

This section explains how an encoder turns graph structure and node features into node embeddings, and how encoding methods differ.

Key terms: encoder, graph structure, adjacency matrix, node features, embeddings, global structure, relative positions, local neighborhood patterns, lookup table, neural network

11.2.2 The decoder: Reconstructing graph properties

The section explains how a decoder tests what graph information embeddings preserve and provides a signal for improving the encoder.

Key terms: decoder, embeddings, graph structure, node similarity, neighborhood overlap, node labels, reconstruction task, training signal, decoder’s predictions, actual graph properties

11.2.3 The power of the framework

The section presents the encoder–decoder framework as a common way to understand and compare graph representation learning methods.

Key terms: encoder–decoder framework, GRL, encode–decode pattern, simpler encoders, neural network-based encoders, representations

11.2.4 Node2Vec: An example of an encoder–decoder framework

The section uses the karate club network to show how Node2Vec encodes graph structure as vectors and decodes those vectors to predict relationships.

Key terms: Node2Vec, encoder, random walks, vector representations, decoder, softmax function, community structure, bridge members, faction membership, encoder–decoder framework

11.3 Shallow embeddings: A first approach to graph representation

Introduces shallow embeddings as the simplest implementation of the graph embedding encoder–decoder framework and notes that their limitations motivated more sophisticated approaches.

Key terms: shallow embeddings, graph embeddings, encoder–decoder framework

11.3.1 Understanding shallow embeddings

This subsection explains how shallow embeddings assign each node a learned vector through a lookup table and use graph-property reconstruction to train those vectors.

Key terms: shallow embeddings, encoder, embedding vector, matrix, decoder, reconstruct, embedding vectors, graph structure

11.3.2 Limitations of shallow embeddings

This section explains four limitations of shallow embeddings and why they remain useful as a baseline for small, static graphs.

Key terms: shallow embeddings, parameter inefficiency, no parameter sharing, feature blindness, node features, transductive nature, lookup table, GRL, baseline

11.4 Embeddings in knowledge graphs

This section explains why embeddings for knowledge graphs must represent relationship types, not just connections between entities.

Key terms: multirelational graphs, embeddings, KG completion

11.4.1 Loss function

This subsection explains why knowledge graph embedding losses use negative sampling, how the loss scores true and sampled relationships, and why the choice of negative examples matters.

Key terms: loss function, sparsity, negative sampling, decoder, positive part, negative part, cross-entropy loss, γ, false negatives, type-constrained sampling

11.4.2 Multirelationship decoder

This section explains the relationship patterns knowledge graph embedding decoders must represent and compares three approaches to decoding them.

Key terms: symmetric, asymmetric, compositional patterns, inverse relations, TransE, RESCAL, DistMult, ComplEx, translation-based, matrix-based

11.5 Message passing and graph neural networks

Introduces GNNs as an alternative to shallow embeddings when graphs are large or relationship patterns are complex.

Key terms: shallow embeddings, GNNs, neural message passing, neighborhoods

11.5.1 The message-passing framework: A neural conversation

This subsection explains how GNN nodes update their representations by exchanging information with neighbors over successive rounds.

Key terms: message passing, AGGREGATE, UPDATE, node’s representation, rounds, iterative updates, friends-of-friends, broader graph structure

11.5.2 Motivation and intuition: Why message passing works

This section explains why repeated message passing gives nodes representations that reflect both graph structure and neighboring features.

Key terms: message passing, k-hop neighborhood, graph topology, features of their neighbors

11.5.3 The basic GNN model

This section introduces the basic GNN node-update rule and explains how summing neighbor representations lets it handle nodes with different numbers of neighbors.

Key terms: node representation, Wself, Wneigh, nonlinear activation function, bias term, summation operation, varying numbers of neighbors, fixed-size inputs

11.5.4 Message passing with self-loops

This section explains how self-loops simplify neural message passing and when that simplification is worth its trade-off.

Key terms: self-loops, AGGREGATE, UPDATE, message passing, parameter sharing, overfitting, model stability, standard message passing, self-loop variant

11.6 Generalized aggregation and update methods

This section introduces architectural enhancements that help GNNs aggregate neighborhood information and update node representations despite the irregular structure of graphs.

Key terms: skip connections, residual connections, over-smoothing, gradient flow, attention mechanisms, neighborhood aggregation, importance weights, normalization layers, layer normalization, batch normalization

11.6.1 Neighborhood normalization

This section explains how neighborhood normalization keeps graph message aggregation on a manageable scale, compares mean and symmetric normalization, and identifies a tradeoff between stability and structural information.

Key terms: neighborhood normalization, mean normalization, neighbor features, symmetric normalization, source and target nodes’ degrees, message strength, learned embedding, node degrees, structural information, lossy operation

11.6.2 Neighborhood attention

This section explains how neighborhood attention lets a GNN give more weight to relevant neighbors during aggregation instead of treating their normalized contributions equally.

Key terms: attention mechanisms, attention weights, weighted sum, neighborhood aggregation, task or context, noisy or irrelevant connections, complex, nonlinear relationships

11.6.3 Multihead attention and transformer connections

This section connects graph attention to transformer attention, explaining multihead attention and the use of structural encodings in GNNs.

Key terms: transformers, graph attention networks, query (Q), key (K), value (V), attention weights, multihead attention, attention head, neighborhood relationships, positional encodings

11.6.4 Generalized update methods

This section explains how GNN update methods balance a node’s existing representation with neighborhood information, and what affects the choice among them.

Key terms: GraphSAGE, skip connections, concatenation-based update, gradient flow, gated updates, gating mechanism, node representation, neighborhood information, jumping knowledge networks, multiple layers

11.7 The synergy of GNNs and LLMs

The section explains why GNNs and LLMs complement each other and describes three ways to combine them for knowledge graph tasks.

Key terms: GNNs, LLMs, message passing, graph structure, LLMs as predictors, graph embeddings, LLMs as encoders, feature representations, structural processing, LLMs as aligners

11.8 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 10: Graph feature engineering: Manual and semiautomated approaches Chapter 12: Node classification and link prediction with GNNs →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.