Error analysis: look at your data

In one sentence

Read ~100 real traces, write a free-form note on each failure, group the notes into failure modes, count them, and fix the biggest bucket first. Automate evals only for modes you actually found.

Analogy: A restaurant owner reads every complaint card for a month before touching the menu. Three causes explain most of the cards, and none of them is the one she had guessed.

Open coding describes each failure in plain words, axial coding names the modes, and counting tells you where to spend the week.

How it works

  • Generic metrics like "helpfulness" rarely match how your product fails; real traces show what to measure.
  • Open coding: an expert notes pass/fail and the first upstream error per trace; later errors are often consequences.
  • Axial coding groups the notes into a handful of failure modes; an LLM can propose clusters, a human decides.
  • Grade pass/fail, not 1–5: binary forces a decision, raters agree more, and the note explains why.
  • Stop at saturation, when new traces reveal no new modes, and repeat after every big change.

Check yourself

Answer to mark it learned; your answers aren't scored.

Reviewing a trace: the agent parsed "last quarter" as the wrong dates, so retrieval returned irrelevant reports, so the final answer was off-topic. How do you label it?

Go deeper

Full explanation

Error analysis is reading real outputs before deciding what to measure. Generic metrics ("helpfulness", "coherence") rarely match how your product fails; the traces tell you.

The process comes from qualitative research (grounded theory) and was popularized for LLMs by Hamel Husain and Shreya Shankar:

  1. Sample ~100 traces: full conversations with tool calls and retrieved context, mixing random picks with thumbs-down and edge cases.
  2. Open coding: a domain expert writes a short free-form note per trace, pass/fail plus what went wrong. Note the first upstream error; later ones are often its consequences.
  3. Axial coding: group the notes into a handful of failure modes ("misreads date ranges", "answers out-of-policy questions"). An LLM can propose clusters; a human decides.
  4. Count: the distribution is usually skewed, so fix the biggest bucket first.
  5. Automate: only now write evals, one per mode that matters, with code checks where possible and a judge where not.

Judge each trace pass/fail, not 1–5. Binary forces a decision, agrees better across raters, and makes the note (why it failed) the useful output. Keep reading until new traces stop revealing new modes (saturation), and repeat after every big change.

Code From annotated traces to a ranked list of failure modes
pythonFrom annotated traces to a ranked list of failure modes
import pandas as pd

# One row per reviewed trace, filled by a domain expert in a sheet or annotation UI.
# Columns: trace_id, passed (bool), note (open code), failure_mode (axial code), channel
df = pd.read_csv("annotations.csv")
fails = df[~df["passed"]]
print(f"pass rate: {df['passed'].mean():.0%} over {len(df)} traces")

# Share of ALL traces per mode, so buckets compare directly with the pass rate
print((fails["failure_mode"].value_counts() / len(df)).round(3))

# Where does each mode concentrate? Slices often point at the root cause
print(pd.crosstab(fails["failure_mode"], fails["channel"]))

# Saturation: did the last 20 traces reveal a mode never seen before?
earlier = set(df.iloc[:-20].query("not passed")["failure_mode"])
latest = set(df.iloc[-20:].query("not passed")["failure_mode"])
new_modes = latest - earlier
print("keep reading:" if new_modes else "saturated, go fix", new_modes or "")
Real example

A tax-prep assistant has a 4.1/5 average from an LLM judge, and nobody knows what to fix. A domain expert reads 120 traces in an afternoon, marking pass/fail with a one-line note: 41 fail. Axial coding groups them: 17 cite last year's limits, 11 ignore the user's filing status, 8 hand off to a human too late, 5 miscellaneous. Two modes are two-thirds of all failures. Last year's limits trace back to a stale index, a retrieval fix rather than a prompt fix; filing status gets a code assertion and a prompt rule. A fresh sample a week later passes 85%, up from 66%.

Trade-offs +3 · −3

+ You gain

  • Finds the failures that matter for your product, not generic ones.
  • Cheap: a few hours of expert reading and a spreadsheet, no infrastructure.
  • Tells you which evals to build, and which ones to skip.

− You pay

  • Needs a domain expert's time; engineers alone misjudge domain failures.
  • Manual and periodic: it must be redone after big changes or traffic shifts.
  • Small samples miss rare but severe failures; add targeted sampling for those.

Use it when

Before building any automated eval, after every significant change (model, prompt, retriever), and whenever metrics look fine but users complain. Budget a few hours a week once in production.

Avoid it when

Never skip it entirely, but don't hand-read what a deterministic check already catches: sample the residual. And don't start before you have real or realistic traces to read.

Numbers to know 3
  • Rule of thumb: review ~100 traces per round, and keep going until new traces stop revealing new failure modes.
  • Typical shape (rule of thumb): a handful of modes, often 3–6, covers most failures: Pareto, not uniform.
  • Effort (rule of thumb): with a good trace viewer, 100 traces is a few hours of reading, not days.
Common pitfalls 4
  • Starting from off-the-shelf metrics (helpfulness, toxicity) instead of reading traces.
  • Letting an LLM do the open coding unsupervised: it misses domain errors and invents tidy categories.
  • Rating 1–5: raters disagree on a 3 versus a 4, and the score explains nothing.
  • Labeling every error in a trace instead of the first: one root cause gets counted several times.
Interview questions 3

Answer out loud first, then reveal.

You inherit an LLM product with a dashboard of generic scores and unhappy users. What's your first week?Show answer

I'd stop staring at the dashboard and read traces. I sample about 100, mixing random traffic with thumbs-down conversations, and sit with a domain expert to mark each pass or fail with a one-line note on the first thing that went wrong. Then we group the notes into failure modes and count them. Usually two or three modes explain most failures, and at least one isn't a prompt problem: stale data, a broken tool, a late handoff. Only then do I build evals, one per mode, so the dashboard measures what actually hurts users.

Why binary pass/fail instead of a 1–5 score?Show answer

Because the score has to drive a decision. With 1–5, two raters argue whether something is a 3 or a 4, the average moves for reasons nobody can explain, and you need more samples to see a real change. Pass/fail forces the reviewer to decide whether this output is acceptable for the product, and the critique, why it failed, carries the detail. If I need gradations, I split the criterion into several binary checks, like "cites a source" and "the source supports the claim", instead of one fuzzy scale.

Can't an LLM do the error analysis for you?Show answer

It can help, not lead. I use a model to cluster notes into candidate failure modes and to pre-filter obviously fine traces, which saves hours. But open coding needs domain judgment: a model will happily pass a confident, wrong tax answer. And Shreya Shankar's work on criteria drift shows people refine what "good" means while grading outputs, so the reading itself is how you discover the criteria. A human makes the final call on every label.