Interview's MateAI Engineering
Interview's Mate

AI Engineering

LLMs, RAG, agents & evals

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
AI Engineering topics
Lesson 62/ 160
04. Evals

Error Analysis

Taxonomize failures to find the highest-leverage prompt, retrieval, or tool fixes.

BeginnerFailure Taxonomy · Pareto3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidHands-onQuiz (3)Practice

In plain words

Read many wrong answers, sort them into piles by what went wrong, and fix the biggest pile first.

Think of it like…

A doctor reviewing patient files before prescribing: sort the cases by diagnosis, see that 60% share the same cause, and treat that first. Prescribing a general tonic for everyone wastes effort.

Where you’ve seen it

A RAG assistant answers correctly 74% of the time on 300 sampled conversations. The team reads the 78 failures and tags them: retrieval missed the right document (31, 40%), the answer used an outdated policy version (14, 18%), the model ignored the "answer in two sentences" instruction (11, 14%), wrong tool arguments (9, 12%), unclear question not clarified (8, 10%), other (5, 6%). The Pareto shows two causes (retrieval and stale documents) explain 58% of failures. Fixing chunking, adding hybrid search and versioning policy documents lifts accuracy from 74% to 86% in two weeks, far more than prompt wording experiments had.

Words you’ll hear

Open coding
Writing a free-form note about what went wrong in each failure before choosing categories.
Failure taxonomy
A named set of failure categories derived from real examples.
Pareto analysis
Ranking categories by frequency to find the few causes behind most failures.
Root cause
The upstream component whose fix removes the failure (retrieval, data, prompt, tool, model).

Visual diagram

Loading interactive diagram

Theory & deep dive

How to do it

Collect failures from evals, production logs with negative feedback, escalations and manual review; sample 50 to 100 and read each end to end: user input, system prompt, retrieved context, tool calls, intermediate steps and final answer. For each, write one sentence on the first thing that went wrong (the earliest root cause usually matters most: if retrieval returned the wrong document, the wrong answer is a symptom). Start without predefined categories so surprises surface, then cluster similar notes and name the groups specifically ("retrieval missed policy PDF" rather than "bad answer").

Count each category (a spreadsheet is enough) and sort descending. Weigh frequency with severity (a rare but harmful failure such as leaking private data outranks a frequent formatting slip) and effort. Then choose fixes at the right layer: retrieval and data problems need chunking, indexing, filters or fresher documents; instruction-following problems need prompt changes, examples or structured output; tool errors need schema and description fixes; knowledge gaps may need more context or a better model; ambiguity needs clarifying questions.

A coded failure

"Trace 0481: user asks about the 2026 return window; retrieved chunks are from the 2023 policy; model answers 14 days (should be 30). First failure: stale document retrieved. Category: outdated policy. Secondary: no date metadata filter."

Key takeaway: Read traces, label the first failure, cluster, count, then fix the biggest category at its root.

Making it a habit

Do error analysis at the start of a project (before building elaborate evals), after every major change and on a regular cadence for production. Use the taxonomy to design targeted evals: each frequent category becomes a tagged slice or a dedicated test (does retrieval return the right document? are tool arguments valid?) that you can track. Involve domain experts for judgement calls, and keep notes concise so the exercise stays cheap; 100 traces take a few hours.

Pitfalls: judging only the final answer without inspecting the context and steps; making categories too vague to act on; sampling only the easiest failures; stopping once an LLM judge says "incorrect" without understanding why; and treating the taxonomy as fixed. LLMs can help (summarising traces, proposing clusters), but a human should read the raw data, at least until the categories stabilise. Track the share of each category over time: successful fixes shrink a category, and new ones appear as the product changes.

Tracking categories across releases

Release 12: retrieval misses 40% of failures. After hybrid search and reranking in release 13, they fall to 14%, and "ignored instruction" becomes the largest bucket at 28%, telling the team where to look next.

Key takeaway: Repeat regularly, turn categories into evals, and keep humans reading raw traces.

How it works, step by step

Step 1 of 4
Analyst

1. Gather and sample failures

Collect failing cases from evals, feedback and escalations, and sample 50–100 spanning intents.

78 failing of 300
Key numbers at this step
Stratify
by intent

When to use it & trade-offs

What it is

Error analysis is the practice of systematically reading failing examples, grouping them into a failure taxonomy, counting each category and fixing the biggest ones first. Instead of guessing ("let's try a bigger model"), you sample 50 to 100 failed traces, write a short note on what went wrong in each (open coding), cluster the notes into named categories (wrong retrieval, bad tool arguments, ignored instruction, outdated policy, formatting, hallucinated detail), and build a Pareto chart showing which categories account for most failures. It's the highest-leverage activity in improving an AI product.

Why it matters: Aggregate metrics tell you that quality is 78%, not why. Teams without error analysis spend weeks on improvements that touch 2% of failures. Looking at real traces makes the true causes visible (often retrieval or data problems rather than the model), tells you which evals to build, and turns vague "the AI is bad at X" feedback into a prioritised, measurable backlog.

When to reach for it

  • Starting or restarting an AI product's quality work
  • After a metric drop or major model change
  • Deciding between retrieval, prompt, tool and model fixes

When to avoid or be careful

  • Judging only final answers without reading the context and steps
  • Predefining categories before looking
  • Fixing the most interesting failure instead of the most frequent

Ways to decide what to fix

Error analysis on real traces
Best for: Finding true root causes and priorities

Strengths: Grounded in evidence; cheap; reveals non-model causes.

Watch out: Manual effort; needs domain judgement.

Aggregate metrics only
Best for: Monitoring overall trends

Strengths: Fast and automated.

Watch out: Doesn't explain why; hides distinct causes.

Trying fixes by intuition
Best for: Nothing reliable

Strengths: Feels productive.

Watch out: Often targets rare failures; wastes time.

Interview signals & numbers to know

When this topic comes up

  • “Accuracy is 78% but we don't know why”
  • “What should we improve first?”
  • “Failure taxonomy”
  • Pareto of failure causes
  • Retrieval vs prompt vs model errors

Benchmarks & rules of thumb

50 – 100 -
traces to read in a first pass
58% -
failures explained by two causes in the example
74% → 86% -
accuracy gain from targeted fixes

Common mistakes & follow-ups

Common interview mistakes

  • Blaming the model for failures caused by stale or missing documents.
  • Writing categories like "bad answer" that point to no fix.
  • Doing error analysis once and never repeating it as the product changes.

Likely interviewer follow-ups

  • How would you decide what to fix first in an AI assistant?
  • Why look at the first failure in a trace?
  • How do you turn error categories into evals?
Interview tip: Quote a Pareto (two causes explained 58% of failures). A concrete distribution makes the case for reading traces better than any argument.
Loading hands-on exercise

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Error Analysis with generative AI interview Q&A and hands-on practice.

Open Generative AI Q&A →Tech Learn Q&A
Previous topic
Golden Datasets
Next topic
LLM as a Judge