What is retrieval in RAG?

What is it?

Retrieval is the process of selecting relevant information from a Knowledge Base (or index) in response to a query. In RAG, retrieval happens before the LLM generates an answer.

Retrieval answers: "What content should the model see?"

Why does it exist?

The LLM cannot read your entire Knowledge Base on every request. Retrieval narrows millions of tokens down to the most relevant chunks — typically a small set (top-K) that fits in the context window.

Poor retrieval leads to wrong or missing context, which leads to wrong answers even when the LLM is powerful.

How does it work conceptually?

Query (user question) ↓ Search index (vector similarity, optionally filters) ↓ Rank and select top-K chunks ↓ Retrieved set passed to next stage (context assembly / display)

Top-K means "return the K best matches" (e.g., top 5 chunks). K is a system parameter — not usually exposed to end users in Noulek's MVP UI.

Example

Question: "Maintenance after 500 operating hours?"

Retrieval returns chunks from the maintenance schedule section — not chunks about shipping, warranties, or unrelated equipment.

Search Retrieval
User sees Results list, snippets Often invisible — feeds Chat
Purpose Find information Select context for generation
Output Ranked results for display Chunk set for LLM or UI

In Noulek, Search shows retrieval results to the user. Chat uses retrieval internally, then generates a conversational answer.

Both rely on the same indexed Knowledge Base and vector index.

Where does it fit in a RAG pipeline?

Index (ready) → Query → Retrieve → Context → Generate

Retrieval quality is one of the most important engineering levers in RAG. Future concepts cover reranking, hybrid search, and metadata filtering.

How this relates to Noulek

When a visitor uses Search or Chat on a Noulek-enabled site:

  1. The question is embedded and compared against Weaviate.
  2. Noulek retrieves the most relevant indexed chunks.
  3. Search displays matching content.
  4. Chat sends retrieved chunks to the OpenAI model as context.

If retrieval fails, Activity log may show NX_RETRIEVAL_FAILED with guidance about API keys, dimension mismatch, or Weaviate issues. Empty Chat answers often trace back to retrieval or missing Ready documents.

See Search or Chat no results for diagnosis.