liveBook · Manning

Encoder

As explained in Generative AI in Action

A text encoder is a neural-network component that converts textual input into an internal vector representation.

An encoder turns an input into an internal representation that another component can use. In a transformer encoder–decoder pipeline, text is tokenized, converted to embedding vectors, and processed into hidden states for the decoder. Not every language model uses this arrangement: GPT-3 is described as decoder-only. section 2.8 section 2.3

The input and the purpose of its representation depend on the application:

  • In Stable Diffusion, a text encoder converts an image prompt into a vector representation used within the image-generation system. section 4.1.4
  • In retrieval-augmented generation (RAG), a query encoder converts a question into a vector so a retriever can find relevant, pre-encoded documents. section 7.3
  • Encoders also process images: a variational autoencoder maps an image into a latent representation, while a vision transformer learns relationships among image patches. section 4.1.1 section 4.1.3

Finding context for an enterprise question

A RAG system encodes an employee’s question as a query vector. Its retriever compares that vector with a precompiled index of document vectors, selects relevant documents, and passes their information to the LLM to generate an answer. section 7.3

When choosing an architecture, distinguish the encoder’s job from the system’s final output: encoding prepares a representation; a decoder, retriever, or image-generation component uses it. Resource needs also matter—transformers can require substantial computation, and vision transformers face training and inference costs. section 2.3 section 4.1.3

Figure 2.3 Conceptual architecture of an LLM
figure

The architecture diagram shows where token embeddings enter the encoder and how its hidden states feed the decoder. section 2.8

How Generative AI in Action covers it

How deep it goes
Explains input-to-hidden-state and query-vector flows without deriving training methods or layer mathematics.
Examples
Uses Stable Diffusion image prompts and RAG questions matched against an index of document vectors.
What it assumes
Introduces tokenization and embeddings before describing the encoder pipeline, without requiring a mathematical derivation.
What you can do after
Evaluate/understand how encoded inputs support image generation or retrieval-backed answers.
How it connects
Connects tokenization, embeddings, decoders, and retrieval-augmented generation.

Also explained in

Compare how 21 books explain encoder →

Related concepts

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