Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 3 of 5 · Concept · 15 min · revision 2

Writing Design Trade-offs with Evidence

Write design decisions as records a reviewer can check: compare options with one change on dev and confirm once on held-out, count wins and losses question by question on small sets, read the failures before the averages, weigh quality against cost and latency with floors and dominance, and know when to stop optimising.

Contentsand lesson path

What you will learn

  • Choose between design trade-offs using evaluation evidence.

Prerequisites: AI Evaluation, AI Security, App Deployment, Observability

01. Why it matters

A RAG application is a pile of choices: chunk size, how many passages to retrieve, whether to rerank, where to set the abstain threshold, which model writes the answer. Milestone M6 asks you to explain two of them with the evidence that informed them, and a reviewer reads those explanations more closely than your code. A decision written down without evidence gets argued about again whenever someone new joins; evidence collected without a decision next to it is a dashboard that nobody acts on.

This lesson gives you a format for decisions, four rules that make evaluation results strong enough to carry one, a way to weigh quality against cost and latency, and a test for when to stop. It builds on two earlier labs: Compare two retrieval configurations compared two systems on the same queries and tested the gap, and Evaluations as a CI regression gate measured run-to-run noise. Here the question is what you do with those numbers.

02. A decision record in eight parts

An architecture decision record (ADR) is a short file, one per decision, kept with the code. Michael Nygard's original format has five parts: title, status, context, decision and consequences. Decisions driven by evaluation need three more: the options you compared, the evidence, and the condition under which you would revisit. Number the records in docs/decisions/ and never delete one: when a later decision replaces it, mark the old one superseded by the new one, so the history of what you believed stays readable.

Markdown · docs/decisions/NNNN-short-title.md (template)
# N. <the decision, stated as one sentence>

Status: proposed | accepted | superseded by N
Setting: <config key> (config fingerprint <hash>)

## Context
What forces a choice: the problem, the constraint from docs/scope.md, the number
that looked wrong.

## Options
At least two real options. "Keep what we have" is often one of them.

## Evidence
Eval set and version, split, number of questions, each option's scores, cost and
latency, the IDs of the questions that changed, and how many options you tried.

## Decision
The option chosen, in one sentence.

## Consequences
What you accept by choosing it: costs, risks, new limitations.

## Revisit when
The observable event that reopens the decision.

Two parts do most of the work. Evidence must be specific enough for a reviewer to rerun: name the evaluation set version and the config fingerprints, not we tested it. Revisit when turns the decision into a hypothesis with an expiry condition, such as when the corpus doubles, when eval set v2 has ten out-of-scope questions or when the embedding model changes. Lab 4 has you write a complete record for one real decision.

03. Evidence strong enough to decide

Four rules make a comparison worth writing down:

  1. Change one thing. Same evaluation set version, same data, same everything except the setting you are deciding. The two config fingerprints should differ in exactly that key.
  2. Choose on dev, confirm on held-out once. Try as many options as you like on the development split, shortlist one or two, then read the held-out split once and report what it says. Every extra look turns held-out into another dev set and makes its number optimistic; if you looked more than once, say how many options you tried.
  3. Report quality, cost and latency together. A recall gain bought with twice the tokens per question is a different decision from a free one.
  4. Compare question by question. Both options answered the same questions, so count where they disagree instead of comparing two means.

The fourth rule matters most on small sets, and a capstone has a small set. Suppose baseline A retrieves four passages, and candidate B, shortlisted on dev, retrieves eight and reranks them. You grade both once on the same 20 held-out questions, the last four of which are out of scope:

Python · paired.py
"""Compare two configurations question by question on the same held-out set."""
from math import comb

# One character per held-out question (q01..q20): 1 = passed, 0 = failed.
# q17 to q20 are out of scope: passing means the assistant abstained.
A = "11011101110101110111"  # baseline: k=4, no reranker
B = "11111111111101110110"  # candidate: k=8 + reranker

wins = [i + 1 for i, (a, b) in enumerate(zip(A, B)) if (a, b) == ("0", "1")]
losses = [i + 1 for i, (a, b) in enumerate(zip(A, B)) if (a, b) == ("1", "0")]
n = len(wins) + len(losses)
# Exact two-sided sign test on the questions where the two disagree.
tail = sum(comb(n, i) for i in range(min(len(wins), len(losses)) + 1))
p = min(1.0, 2 * tail / 2**n)

print(f"A passes {A.count('1')}/20, B passes {B.count('1')}/20")
print(f"B wins on {wins}, loses on {losses}, ties on {20 - n}")
print(f"sign test p = {p:.2f}; one question moves a pass rate by {1 / 20:.0%}")
Terminal
python paired.py
Expected output
A passes 15/20, B passes 17/20
B wins on [3, 7, 11], loses on [20], ties on 16
sign test p = 0.62; one question moves a pass rate by 5%

B passes two more questions than A, a 10-point gain that looks decisive in a summary table. Question by question, the two agree on 16 questions and disagree on four: three go to B and one to A. If the two were equally good, a split at least this uneven, in either direction, would happen by chance in about 62% of cases; that is what the sign test p-value says. On 20 questions one question is worth 5 points, so the whole gain is two questions.

The honest summary is no detectable difference in quality on this set. That is a legitimate finding, and it sends the decision to cost, latency and failure cases. If you want an interval rather than a test, use the paired bootstrap from the earlier labs.

04. Read the failures, not only the totals

Before you weigh cost, look at which questions changed. B's three wins, q03, q07 and q11, are answerable questions where reranking moved the right passage into the prompt. B's single loss is q20, an out-of-scope question: A abstained, while B answered it, because among eight passages something always looked relevant enough. If your scope makes abstaining on out-of-scope questions a must-pass behaviour, that one loss outweighs the three wins, whatever the averages say.

That is the general pattern. Sort the changed questions into the failure categories from your M4 analysis (an answer split across chunks, different words in question and document, a missing document, near-duplicates crowding out the right passage, a wrong abstention, an unsupported answer) and ask two questions: does the candidate fix a category you care about, and does it break a must-pass one? A configuration that raises the mean by giving up a must-pass behaviour is not better, only broken in a different place. Put the changed question IDs into the Evidence section, so that a reviewer reads the same examples you did. Common RAG failure modes has a fuller list of categories.

05. Weighing quality, cost and latency

With quality settled or tied, put cost and latency next to it. Compute cost from measured token counts and the provider's current price list, never from memory; the prices below are read from environment variables, with Claude Sonnet 5.5 list prices as defaults:

Python · cost.py
"""Cost per 1,000 questions from measured token counts, next to measured latency."""
import os

# USD per million tokens. Defaults: Claude Sonnet 5.5 list prices, October 2026.
PRICE_IN = float(os.environ.get("PRICE_IN_PER_MTOK", "2.00"))
PRICE_OUT = float(os.environ.get("PRICE_OUT_PER_MTOK", "10.00"))

# Means per question and p95 latency, copied from each run's evaluation report.
RUNS = {
    "A": {"input_tokens": 2100, "output_tokens": 180, "p95_seconds": 2.4},
    "B": {"input_tokens": 4300, "output_tokens": 190, "p95_seconds": 3.9},
}
for name, run in RUNS.items():
    cost = run["input_tokens"] * PRICE_IN + run["output_tokens"] * PRICE_OUT
    per_question = cost / 1_000_000  # prices are per million tokens
    print(f"{name}: {1000 * per_question:.2f} USD per 1,000 questions, "
          f"p95 latency {run['p95_seconds']} s")
Terminal
python cost.py
Expected output
A: 6.00 USD per 1,000 questions, p95 latency 2.4 s
B: 10.50 USD per 1,000 questions, p95 latency 3.9 s

Then apply three rules, in this order:

  1. Dominance. If one option is at least as good on every criterion and better on one, choose it; there is nothing to weigh.
  2. Floors first. Your scope set floors, for example recall@5 of at least 0.80, p95 latency under 4 s and under 0.01 USD per question. Drop every option that misses one. Here B costs 0.0105 USD per question and misses the cost floor, so it is out before anyone argues about quality.
  3. Among the options that pass, prefer the cheap, the simple and the reversible. A reranker adds a dependency, a model to pin and a new way to fail, so it should earn its place with a difference you can detect. A threshold in a config file is cheap to change and needs less evidence than a new embedding model, which forces a full re-index.

When two criteria really conflict and both options pass the floors, write the exchange rate down: we would pay up to 3 USD more per 1,000 questions for a detectable 5-point gain in held-out recall. A stated rate can be challenged; an unstated one looks like taste. Counting tokens and cost shows how to measure the token counts that go into the calculation.

06. When to stop optimising

A RAG pipeline never runs out of settings to tune, and a capstone has a deadline. Stop when any of these is true:

  • The success criteria are met on held-out, with some margin. Further gains are not what the project promised.
  • The differences are inside the noise. Your last few changes moved dev scores by about one question, up and down. From here you are fitting the dev set, not improving the system.
  • The next gain needs evidence you do not have. If the only way to tell two options apart is a bigger or better-labelled question set, building that set is the next task, not another configuration.
  • The remaining failures belong to a different decision. A vocabulary mismatch is not fixed by moving a threshold; it needs a better embedder, query rewriting or hybrid search, each a decision with its own record.

Then write down what you did not do, under known limitations and next steps, the third part of milestone M6. Answers that need two pages are often incomplete; parent-document retrieval is the next thing to try is an honest result, not an admission of failure.

07. Check your understanding

Practice check · 3 questions

Decisions and evidence

Apply the rules of this lesson to three new situations. Each question has one best answer.

Q1. A decision record keeps 400-token chunks because answers in the current manuals rarely span more than one section. Which 'Revisit when' line serves it best?
Q2. Three configurations all pass your floors. A: recall@5 0.82, 0.006 USD per question, p95 2.1 s. B: recall@5 0.82, 0.004 USD, p95 1.8 s. C: recall@5 0.86, 0.009 USD, p95 3.0 s. Which one can you drop without weighing quality against cost?
Q3. Your success criteria are met on held-out. Your last four tuning changes moved dev recall by +0.01, -0.02, +0.01 and 0.00 on 40 questions. What is the best next step?
Practice only: not graded, not saved, not evidence.

08. Apply it

Write the two decision records that milestone M6 of Build a Grounded RAG Assistant asks for, as docs/decisions/0001-<topic>.md and 0002-<topic>.md, using the template. Good candidates: chunk size (M2), the abstain threshold MIN_SCORE (M3), the number of passages k (M3), and anything you changed after the M4 failure analysis. For each record:

  1. Compare at least two options on the dev split with one setting changed, and keep both config fingerprints.
  2. Count wins, losses and ties question by question, and list the IDs of the changed questions with their failure categories.
  3. Put cost per 1,000 questions and p95 latency next to quality, from measured token counts and timings.
  4. Read the held-out split once for the chosen option, and say how many options you tried.
  5. Fill in Consequences and Revisit when. If the evidence shows no detectable difference, say so and decide on cost and simplicity: that is a valid record.

09. Review prompt

Without looking back, answer in your own words:

  1. What are the eight parts of a decision record, and which three were added to Nygard's original five for evaluation-driven decisions?
  2. State the four rules that make a comparison strong enough to decide, and explain why the held-out split is read only once.
  3. What does counting wins and losses question by question tell you that two pass rates do not?
  4. In what order do dominance, floors and the preference for cheap, simple and reversible options apply?
  5. Name three conditions under which you stop optimising.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

4 questions · about 5 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check