← Overview

RAG FIELD GUIDE · MODULE 01

The machinery

Each layer has a job, a cost, and a characteristic failure. The goal is not more stages; it is the right stage for the failure you actually have.

RAG FIELD GUIDE · READER · 6 sections

Think of a RAG system as two loops: an indexing loop that prepares evidence, and a query loop that spends a small attention budget. Every layer below exists to keep one of those loops from failing quietly.

RAG / FLOW

The whole machine, on one page.

Indexing happens before the question arrives. Retrieval happens after. Most RAG confusion comes from mixing the two.

01Offline / indexing

  1. Sources
  2. Parse
  3. ChunkPC
  4. Metadata
  5. IndexHY · GR

02Online / query

  1. Query
  2. RewriteQW
  3. RetrieveHY
  4. FuseHY
  5. RerankRR
  6. ContextPC
  7. Generate
  8. Cite

The index built offline is what the query path retrieves from.

Badges mark where advanced techniques plug in: QW query rewrite · HY hybrid · RR rerank · PC parent-child · GR graph.

PART I

Prepare

What should enter the index?

01

Chunking

Split documents into units that are specific enough to retrieve and complete enough to answer from. Overlap trades context for duplication; parent-child trades precision for a larger context.

02

Indexing

Build the lookup structure: inverted index for BM25, embeddings plus ANN for dense retrieval, or both. The index is a snapshot; freshness is a separate design problem.

After this partYou can now judge a chunking and indexing choice by what it lets retrieval find, not by how tidy the store looks.

PART II

Retrieve

What should enter the context?

03

Retrieval

Map a query to candidates. BM25 is lexical and inspectable; dense retrieval handles paraphrase; hybrid fusion combines both. Top-k is a tradeoff between recall and noise.

04

Context

Deduplicate, order and fit selected evidence into a token budget. More context is not automatically better: conflicting or repetitive chunks can hurt the answer.

After this partYou can now treat retrieval and context assembly as one budget: more evidence helps only when it is relevant, ordered and affordable.

PART III

Answer

What should you trust?

05

Generation

Write an answer grounded in the context, or extract from it. Citations make failures inspectable but do not make an answer automatically true.

06

Evaluation

Measure retrieval (recall, MRR, nDCG) and generation (faithfulness, relevance, citation quality) separately. A fluent answer can still be unsupported.

After this partYou can now separate a fluent answer from a supported one, and name which stage failed when they disagree.