liveBook · Manning

Encoder

As explained in Knowledge Graphs and LLMs in Action

An encoder is a model component that transforms input data into a learned representation, such as vectors.

An encoder transforms graph structure and node features into dense vector representations, or embeddings, that capture useful relational information. It may be a simple node-vector lookup or a neural network that processes connections and features. section 11.2.1

A graph encoder commonly follows this pipeline:

  • Read the adjacency structure and available node features. section 11.2.1
  • Generate or update node embeddings, preserving either global position, local neighborhoods, or both. section 11.2.1 section 12.2.4
  • Pass the embeddings to a decoder that reconstructs links, similarity, labels, or other graph properties, providing a training signal. section 11.2.2

Node2Vec on the karate club network

Node2Vec generates random walks such as 0 → 1 → 2 → 3, converts recurring node contexts into vectors, and uses vector similarity to predict friendship likelihood. Similar vectors reveal factions, bridge members, and leadership positions. section 11.2.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

Use the recommendation pipeline to trace an encoder from user and movie embeddings through heterogeneous neighbor aggregation to dot-product link scores. section 12.2.4

How Knowledge Graphs and LLMs in Action covers it

How deep it goes
Explains inputs, representation choices, random walks, neighbor aggregation, and encoder–decoder training, but not detailed optimization mathematics.
Examples
Uses Node2Vec on the karate club network and heterogeneous user–movie recommendation with learned and genre-based embeddings.
What it assumes
Assumes graph structure and node features, while demonstrating both simple vector lookup and learned graph-based representations.
What you can do after
Builds encoders that combine embeddings with graph neural networks and supplies representations to a decoder for link prediction.
How it connects
Connects embeddings with graph neural networks, node features, decoders, link prediction, heterogeneous graphs, and neighbor aggregation.

Also explained in

Compare how 21 books explain encoder →

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.