liveBook · Manning

Encoder-decoder architecture

As explained in Knowledge Graphs and LLMs in Action

An encoder-decoder architecture is a model design in which an encoder transforms input data into a learned representation and a decoder transforms that representation into predictions or reconstructed outputs.

An encoder–decoder architecture separates representation learning from prediction. For graph data, the encoder transforms discrete structure and features into continuous node embeddings; the decoder reconstructs graph properties or produces task-specific predictions. section 11.2 section 12.3

A graph-based implementation typically follows this pipeline:

  • Encode neighborhood information with a GNN such as GCN, GAT, or GraphSAGE; message passing updates each node representation using neighboring nodes. section 12.1.4 section 12.3
  • Decode the learned representations with a task-specific function: log_softmax produces node-classification values, while a dot product scores possible links. section 12.1.4 section 12.2.4
  • Choose the encoder according to the graph and operational trade-offs: simpler methods use fewer resources, while richer neural encoders require more data and computation. section 11.2.3

From karate-club walks to predictions

Node2Vec generates random walks through the karate-club friendship network, balancing broad exploration with deeper movement through tightly connected groups. It converts walk context into member vectors, then estimates how likely two members are to connect using vector similarity. Similar vectors can reveal factions, bridge members, and leadership-related structure. section 11.2.4

Figure 12.4 Overview of the main steps of the encoder–decoder architecture. Homogeneous graph data, consisting of transactions (nodes) and Bitcoin flows (edges), is processed using three GNN encoders: GCN, GAT, and SAGE. Each encoder generates unique node representations by aggregating neighbor features. Then these representations are transformed into probability values, which are used to classify transactions as licit or illicit.
figure

Trace homogeneous transaction data through GCN, GAT, and SAGE encoders into probabilities classifying transactions as licit or illicit. section 12.1.4

Figure 12.9 Pipeline for processing heterogeneous graph data in a link prediction system for movie recommendations. The data consists of users and movies as node types and user–movie ratings as edges. Embeddings are generated, with user embeddings learned by the model and movie embeddings initialized from genre features. The data is processed using three heterogeneous GNN encoders (H-GraphConv, H-GAT, and H-SAGE), which aggregate neighbor features to generate node representations. A dot product then quantifies the compatibility between users and movies, with higher scores indicating a greater likelihood of interaction. The scores are finally converted into probabilities representing the likelihood of a link between users and movies.
figure

Compare heterogeneous recommendation processing: learned user embeddings and genre-initialized movie embeddings pass through a heterogeneous GNN, then a dot product estimates interaction likelihood. section 12.2.4

How Knowledge Graphs and LLMs in Action covers it

How deep it goes
Explains embeddings, message passing, decoder choices, and reusable PyTorch Geometric implementations without detailing training objectives.
Examples
Uses Node2Vec on the karate-club network, transaction classification, and MovieLens user–movie link prediction.
What it assumes
Assumes graph data and GNN concepts, while demonstrating representation learning and decoding through concrete network and recommendation examples.
What you can do after
Build graph predictors with PyTorch and PyTorch Geometric by selecting an encoder and pairing it with a classification or link-scoring decoder.
How it connects
Connects graph embeddings, random walks, matrix factorization, GNNs, node classification, link prediction, fraud detection, and recommendation systems.

Also explained in

Compare how 10 books explain encoder-decoder architecture →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Knowledge Graphs and LLMs in Action. The section links point to the parts of the book it draws on.