Core concept

The evaluation loop

A retrieval design is a claim that a metric will move. The loop is how you check the claim: a frozen set of questions, one change, the same three scores, and a token count beside them.

Baseline before any clever retrieverSame rows, every design

The baseline The number you beat

Naive RAG is the control. Fixed-size chunks, an embedding, top-k, a prompt, an answer.

DocumentsFixed chunksEmbed + indexTop-k + promptquery embedded tooAnswerTriad on the same questions
Score this pipeline before you change chunking. Later designs are comparisons, not fresh demos.

Record four numbers per question, not a vibe: context relevance, groundedness, answer relevance, and how many tokens of context the model saw. The last number is the cost of the design. A prettier answer that doubles the prompt is a different system.

The loop One change at a time

The set stays fixed so a chunking change is the only thing that can move the score.

Frozen eval setquestions + passagesOne designbaseline, window, or mergeThree scoresplus token countKeep or revertfailing leg onlynext design, same questions
Change the retriever or the prompt, never both in the same run. A joint change cannot tell you which one moved the score.

The artifact is a table with one row per question per design. Pass and fail come from the definition of wrong you wrote before the run, not from rereading the answer until it feels acceptable.

QuestionDesignContext relevanceGroundednessAnswer relevanceContext tokensDecision
q17Baseline, 512-token chunksFailPassPass480Control
q17Sentence windowPassPassPass140Keep
q17Auto-merge, low thresholdPassFailPass1100Revert

q17 is a single fact question. The window fixed the leg that was failing and spent fewer tokens. The merge also “found something related,” then failed groundedness and blew the budget. Related is not the same result.

The evaluation set Before you tune

Three columns, written while the retriever is still the boring one.

Questions

  • Fact questions whose answer is one sentence inside a long document.
  • Procedure questions whose answer is a section, not a sentence.
  • Questions the corpus cannot answer, so a refusal can pass.

Source passages

  • For every in-scope question, the span that contains the answer.
  • Marked in the corpus, so retrieval can be checked against a known passage.
  • Out-of-scope questions have no span. Inventing one would reward a hallucination.

What “wrong” means

  • The right passage never arrived.
  • The answer states something those passages do not support.
  • The answer addresses a different question, or fails to refuse an impossible one.

Those three wrongs are the triad. Writing them down first is what makes a later score a decision. A set you grow after you have stared at failures mostly confirms the design you already prefer.

Architect's lens

Fifty questions with a marked passage and a written failure mode will outrank five hundred questions you generated after the chunk size was chosen. The set is the test suite. You do not edit the tests to make the build green.

Retrieval or generation Without fifty transcripts

Read the aggregates first. Open a transcript only for rows on the leg that moved.

What the scores sayWhere the bug isWhat you open
Context relevance is the leg that is down.Retrieval. The right passage never reached the model.Retrieved chunks against the marked source passage. Chunking, embedding, top-k, query rewrite, hybrid search.
Context relevance holds. Groundedness is down.Generation, or the context you packed around a good hit.The prompt, the packed window or parent, citation rules, the model. The extra text is a suspect.
Context relevance and groundedness hold. Answer relevance is down.The system answered a different question, or the question is out of scope.Query understanding and routing. A richer retriever will not teach the system to refuse.

The full diagnostic, including a walk-through where a merge drops groundedness while context relevance stays fine, is on the RAG triad.

When to stop Refuse the clever retriever

Complexity is earned by a failing leg that this pattern can move, inside a latency and token budget.

Keep the baseline when all three are true

  • The bar is already met. Context relevance, groundedness, and answer relevance clear the definition of wrong on the frozen set.
  • The residual misses are the wrong shape. They are out-of-scope questions, or groundedness failures. A fancier chunker feeds the model more text.
  • The budget is the constraint that is binding. A wider window or a parent section would add tokens and latency for a metric that is already flat.

Sentence-window and auto-merging are justified when the baseline loses answers for a reason that pattern addresses: a fact buried in a long document, or a procedure that lives in a section. They are not a second stage you always turn on.

What you must be able to do

  • Name the four numbers you record for every design, including tokens.
  • Write an evaluation set with questions, source passages, and a definition of wrong before changing chunk size.
  • Decide from the triad which stage to open, and leave the other transcripts unread.
  • Refuse a more complex retriever when the baseline already fits the bar and the budget.

Key takeaways

  • The baseline is the control. Every later retriever is a row in the same table.
  • Freeze questions, the passage that should have been retrieved, and what wrong means. Then tune.
  • A design stays when the leg that was failing moves, and the token count still fits.