liveBook · Manning

Query encoder

As explained in Retrieval Augmented Generation, The Foundational Ideas

A query encoder is a model component that converts a search query into a representation suitable for matching indexed documents.

A query encoder converts a user question into a vector representation that supports similarity search over indexed document vectors. In a RAG system, it forms the retrieval boundary: the encoded query selects passages, which the generator then uses with the original question to produce an answer. section 4.1 section 4.6

Figure 4.3 An end-to-end RAG pipeline for question answering, in which a user question is embedded for vector search, top-k documents are retrieved, and a generator produces an answer using the retrieved context.

Trace the online path from a user question through query embedding and top-k retrieval to answer generation. section 4.6

Separate the query encoder’s online role from the document-side and training-side decisions:

  • At query time, encode the question, search the vector index, retrieve document chunks, and pass them with the question to the generator. section 4.6
  • In canonical RAG, keep the document encoder and prebuilt index fixed while fine-tuning the query encoder alongside the generator. section 4.1
  • For low-data adaptation, query-side fine-tuning is efficient and can regularize against overfitting by leaving the document encoder unchanged. section 6.5

A basic retrieval call

A RAG question-answering function passes a question to similarity search, joins the returned passages as context, and invokes the generator. The query encoder is implicit in the configured embedding and vector-store components; the returned page numbers support inspection of retrieval quality. section 4.6

How Retrieval Augmented Generation, The Foundational Ideas covers it

How deep it goes
Explains vector mapping, fixed-index architecture, query-side fine-tuning, and query-time retrieval, but not encoder internals.
Examples
Demonstrates similarity search over chunk embeddings, retrieved page citations, and an end-to-end RAG question-answering pipeline.
What it assumes
Assumes vector indexes and document embeddings, while teaching the query-to-retrieval-to-generation flow explicitly.
What you can do after
Apply it via a RAG retrieval stage that embeds questions, searches an index, and supplies retrieved passages to a generator.
How it connects
Connects query encoding to dense passage retrieval, document encoders, vector search, RAG generators, BART, and REALM.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Retrieval Augmented Generation, The Foundational Ideas. The section links point to the parts of the book it draws on.