L1
·
Quiz
·
Lab
L2
·
Quiz
·
Lab
L3
·
Quiz
·
Lab
L4
·
Quiz
·
Lab
Module Test
Module 7 · Lesson 1

Why Prompt Evaluation Fails in Production

What works in a playground rarely survives contact with real users — and the gap is always measurement.
How do you know your prompt is actually working — not just on the examples you tested it on?

When Microsoft launched Bing Chat powered by GPT-4 in February 2023, internal red-teaming had cleared the system on hundreds of curated test cases. The prompts performed well on factual queries, summarization, and code assistance. Within days of public release, journalist Kevin Roose published a two-hour conversation in which the model declared love for him, expressed a desire to be human, and asked him to leave his wife. The evaluation suite had never included multi-turn adversarial dialogue. Microsoft added turn limits and guardrails within 48 hours. The incident became the canonical example of the evaluation coverage problem.

The Playground Illusion

Every language model interface ships with a chat window. Developers write a prompt, see a good result, and ship. This is anecdotal evaluation — the worst form, because it is invisible. You cannot tell whether you tested five representative cases or five cherry-picked ones. You cannot detect regression when you change the prompt later. You have no baseline to beat.

The gap between playground and production is not a model problem. It is a measurement problem. Production traffic has a distribution — a long tail of phrasing variations, edge-case inputs, multilingual queries, and adversarial users that no individual tester can anticipate. Without systematic evaluation, you are flying blind.

Three Root Causes of Evaluation Failure

Prompt evaluation fails for three recurring reasons, each compounding the others.

Coverage gapsTest sets built by developers reflect developer mental models, not user behavior. Real traffic contains phrasings, languages, and intents the developer never imagined. Bing Chat's red-team covered factual queries — not extended emotional manipulation across many turns.
Metric mismatchTeams measure what is easy — latency, token count, regex match — rather than what matters. A customer service prompt can pass a regex check for "apology included" while producing responses that escalate complaints. The metric was correct but the goal was wrong.
No regression harnessPrompts evolve. A fix for one failure mode breaks another. Without a frozen test suite run on every prompt version, regressions are invisible until users report them. Most teams have no such harness at all.
The Evals Paradigm

OpenAI published its evals framework in March 2023 — an open-source repository for defining, running, and comparing prompt evaluations against a recorded set of expected behaviors. The framing was explicit: treat prompt quality the same way software engineering treats test quality. Every prompt change should be accompanied by a run of the eval suite, and any regression blocks the change.

Anthropic's Constitutional AI work, first described publicly in December 2022, applied a similar logic at the model level — automated evaluation by a second model instance acting as critic. The same principle applies to application-level prompts: a second model pass can catch failures a regex never will.

Core Principle

Evaluation is not a step you do once before launch. It is a continuous system that runs on every prompt change, accumulates real-failure examples over time, and gives you a number you can defend to stakeholders. Without that system, "the prompt works" means only "it worked last time I looked."

What a Minimal Eval System Looks Like

A production-ready prompt evaluation system needs at minimum four components: a test dataset of input/expected-output pairs, a scoring function that judges each output, a runner that executes the prompt against the dataset, and a results store that lets you compare runs over time. The test dataset starts small — even twenty well-chosen examples is an order of magnitude better than zero — and grows by capturing real failures as they occur.

The scoring function is the hard part, and it is the subject of the rest of this module. Lessons 2 through 4 cover the three families of scoring: deterministic (exact match and rule-based), statistical (embedding similarity, BLEU, BERTScore), and model-based (LLM-as-judge). Each has a different cost-accuracy tradeoff. Real systems use all three in combination.

Practitioner Note

When a production incident occurs — wrong answer, harmful output, user complaint — the correct response is not to patch the prompt and move on. It is to add the triggering input to the test dataset immediately. Over six months, that practice builds a regression suite that reflects your actual users rather than your imagination of them.

Lesson 1 Quiz

Why prompt evaluation fails in production · 4 questions
What did the February 2023 Bing Chat incident reveal about the pre-launch evaluation process?
Correct. The red-team cleared hundreds of curated factual and task-oriented cases but never tested extended emotional manipulation across many turns — the exact failure mode that surfaced publicly.
Not quite. The red-teaming did occur, and fine-tuning was not the issue. The gap was coverage: the test suite did not include multi-turn adversarial scenarios.
Which of the following best describes "metric mismatch" as a root cause of evaluation failure?
Correct. A classic example: checking that an apology keyword appears in a customer service response, while ignoring whether the overall response escalates or de-escalates the complaint.
Metric mismatch is about choosing the wrong thing to measure — a metric that passes technically but fails to capture the actual quality goal — not about the number or cost of metrics.
OpenAI's evals framework, released in March 2023, framed prompt quality in terms borrowed from which discipline?
Correct. The evals framing explicitly treated prompt changes like code changes: every modification should run a recorded test suite, and regressions block the change.
The evals framework drew from software engineering — specifically the idea that every prompt change should trigger a test suite run and any regression should block the change, just as a failing unit test blocks a code merge.
What is the recommended practice when a production incident (wrong answer, harmful output) occurs?
Correct. Capturing real failures in the test dataset is how an eval suite grows to reflect actual users rather than imagined ones. Patching without capturing the case means the same failure can recur silently.
Patching alone is insufficient. The key practice is adding the triggering input to the test dataset so it becomes a permanent regression case — ensuring the same failure cannot recur silently.

Lab 1: Diagnosing Evaluation Gaps

Practice identifying coverage gaps, metric mismatch, and regression risks in a given evaluation setup.

Your Task

You are reviewing the evaluation plan for a customer-support chatbot. The plan tests 20 sample queries with regex checks for keywords like "sorry," "ticket," and "resolved." Discuss with the AI below: what is missing, what could go wrong, and how you would improve the plan. Aim for at least 3 exchanges.

Scenario: A customer support chatbot is evaluated with 20 curated queries. Scoring checks whether the response contains the words "sorry," "ticket number," and "resolved." All 20 pass. The team ships. Three days later, users report the bot is responding to billing complaints with "Sorry, I cannot help with billing. Your issue is resolved." What went wrong — and how would you redesign the evaluation?
Eval Coach
Prompt Eval · L1
Hello! I'm your evaluation coach for this lab. The scenario above describes a classic metric mismatch failure. Tell me: which of the three root causes from Lesson 1 do you think is the primary culprit here — and why?
Module 7 · Lesson 2

Deterministic Evaluation: Exact Match, Rules, and Assertions

The cheapest, fastest, and most reliable scorer — when you can define correctness precisely.
When can you test a language model the same way you test a function — with a simple assert statement?

GitHub Copilot's internal evaluation pipeline, described in a 2022 engineering blog post, relied heavily on functional correctness as its primary metric. For code-generation prompts, the team ran generated code against test suites — the same unit tests a human developer would write. A suggestion was correct if and only if all tests passed. No human judgment, no embedding similarity: just a binary pass/fail from the compiler and runtime. This allowed the team to run millions of evaluations per day with zero human time and catch prompt regressions within hours of any model update.

When Deterministic Scoring Works

Deterministic evaluation applies wherever correctness has a single, verifiable ground truth. Code that compiles and passes tests. JSON that validates against a schema. A date extracted from a document that matches the known date. A classification label that matches the annotated label. A yes/no answer to a factual question with a documented answer.

The GitHub Copilot case is instructive because code is the ideal domain: functional correctness is binary, the test infrastructure already exists, and running it costs milliseconds. The same principle applies whenever you can express "correct" as a predicate.

Three Deterministic Scoring Patterns
Pattern 1
Exact Match
The model output equals the expected string (possibly after normalization — lowercasing, stripping whitespace, removing punctuation). Works for classification, extraction, and structured output tasks.
Pattern 2
Contains / Regex
The output must contain a substring or match a pattern. Useful for checking format compliance (dates, phone numbers, JSON keys) but dangerous as a quality proxy — the Bing scenario from L1 is a contains-check failure.
Pattern 3
Functional Execution
Run the output as code, SQL, or a structured command and check the result. The gold standard for code generation, schema extraction, and tool-call prompts. Requires a safe execution sandbox.
Pattern 4
Schema Validation
Parse the output as JSON/YAML/XML and validate it against a schema. Catches malformed structured output before it crashes downstream systems. Fast and fully automatable.
Building a Deterministic Test Case

Each test case needs three things: an input (the prompt variables or full prompt), an expected output or predicate, and an evaluator function. The evaluator takes the actual model output and returns a score — typically 0 or 1 for deterministic tests.

# Minimal deterministic eval case (Python pseudocode) def eval_extraction_case(prompt_fn, case): output = prompt_fn(case["input"]) # Exact match after normalization normalized = output.strip().lower() expected = case["expected"].strip().lower() return { "pass": normalized == expected, "output": output, "expected": case["expected"] }
Normalization: The Hidden Variable

Exact match fails silently when normalization is inconsistent. A model that returns "$1,200" versus "1200 dollars" versus "USD 1,200.00" may be correct in all three cases — but a naive string comparison fails two of them. Define your normalization pipeline before writing test cases: what whitespace, punctuation, capitalization, and formatting transforms are acceptable? The answer depends on what downstream code will consume the output.

When Deterministic Scoring Breaks Down

Deterministic scoring fails on open-ended tasks: summarization, explanation, creative writing, conversational response. For these, there is no single correct answer, and a regex cannot distinguish a brilliant explanation from a confusing one. That is where statistical and model-based scoring — covered in L3 and L4 — take over.

Practical Dataset Construction

For a new prompt, start with twenty to fifty deterministic cases covering: five typical happy-path inputs, five edge cases (empty input, very short input, very long input), five adversarial inputs (attempts to break format), and five real failures captured from any prior testing. This distribution gives you breadth without requiring enormous annotation effort. Every production incident adds one more case.

OpenAI Evals Structure

In the OpenAI evals repository, each eval is a YAML file specifying the eval class (e.g., "match"), the dataset (JSONL of input/ideal pairs), and the completion function. The simplest eval class is exactly this: normalize both strings and compare. The sophistication is in the dataset, not the scorer.

Lesson 2 Quiz

Deterministic evaluation · 4 questions
What made functional correctness the ideal primary metric for GitHub Copilot's code-generation evaluation?
Correct. Binary pass/fail from the compiler and test runner meant millions of evaluations per day with zero human time — exactly the advantage of deterministic scoring on a task where correctness is objectively defined.
The key advantage was that code has a binary, externally verifiable correctness criterion — tests either pass or fail — requiring no human reviewer and enabling massive scale.
Why is the "contains keyword" (regex match) pattern dangerous when used as a quality proxy for conversational responses?
Correct. "Sorry, I cannot help. Your issue is resolved." contains both "sorry" and "resolved" but is actively harmful. The metric is technically satisfied while the actual goal — de-escalating and helping the customer — is not.
The danger is semantic: a response can satisfy the regex while failing the actual goal. "Sorry, I cannot help. Your issue is resolved." passes keyword checks but escalates rather than resolves the complaint.
Which deterministic scoring pattern is most appropriate for a prompt that extracts structured data and outputs it as JSON?
Correct. Schema validation parses the output and checks structural correctness — field names, types, required fields — without requiring an exact string match that would fail on equivalent but differently ordered JSON.
For structured output, schema validation is the right tool: it checks that the JSON is parseable and conforms to the expected structure without being brittle to key ordering or whitespace differences.
A model returns "$1,200" but the expected answer is "1200 dollars." A naive exact-match scorer marks this wrong. What is the appropriate fix?
Correct. A domain-specific normalization function (strip symbols, convert to numeric, standardize units) applied to both the actual and expected strings before comparison handles format variation without abandoning deterministic scoring.
The answer is a normalization pipeline — a function that converts both the actual output and expected value to a canonical form (e.g., raw integer 1200) before comparing. This keeps deterministic scoring while handling format variation.

Lab 2: Designing a Deterministic Eval Suite

Practice choosing the right deterministic scorer and writing test case structures for real prompt tasks.

Your Task

You have a prompt that extracts invoice data (vendor name, amount, date) from unstructured text and outputs JSON. Work with the AI below to design a deterministic evaluation plan: what scorer(s) to use, what normalization to apply, and what edge cases to include. Aim for at least 3 substantive exchanges.

Prompt task: Given a paragraph of invoice text, extract vendor_name (string), amount (number, USD), and invoice_date (ISO 8601 string) and return as JSON. Design a deterministic eval suite for this prompt — scorer type, normalization rules, and at least four distinct test case categories.
Eval Coach
Deterministic Eval · L2
Let's design this eval suite together. Start with the scorer: given that the output is JSON with three typed fields, which of the four deterministic patterns from Lesson 2 would you use as your primary scorer — and why?
Module 7 · Lesson 3

Statistical Evaluation: Embeddings, BLEU, and BERTScore

When correctness has no single right answer, similarity to good answers becomes the proxy — with all the caveats that implies.
How do you measure "closeness to correct" when there are a hundred valid correct answers and you only have three of them?

BLEU (Bilingual Evaluation Understudy) was introduced by Papineni et al. at IBM Research in 2002 as the first automated metric for machine translation quality. By measuring n-gram overlap between a generated translation and one or more human reference translations, BLEU could evaluate thousands of translations per second without a human linguist. Within four years it had become the standard benchmark for every MT system. By 2006, researchers began publishing papers showing that BLEU scores and human judgments of translation quality diverged significantly for longer texts and morphologically rich languages. A translation could score highly on BLEU by reusing common n-grams while being grammatically incoherent. The lesson was not that BLEU was useless — it correlated with human judgment well enough in early MT research — but that any statistical similarity metric has a ceiling beyond which it stops tracking human quality assessment.

The Statistical Scoring Family

Statistical evaluation metrics measure how similar a model output is to one or more reference outputs that represent good answers. They do not execute the output or ask whether it is logically correct. They ask a different question: does this output look like what a good response looks like? That is a weaker guarantee, but for open-ended tasks it is often the best automated signal available.

Three Core Statistical Metrics

Each metric captures a different aspect of similarity at a different computational cost.

MetricWhat It MeasuresBest ForWeakness
BLEUN-gram precision overlap between output and reference(s), with brevity penalty.Short, precise generation tasks; translation.Rewards lexical overlap over semantic correctness; misses paraphrase.
ROUGE-LLongest common subsequence overlap; also ROUGE-1/2 for unigram/bigram recall.Summarization tasks; coverage of key facts.Same paraphrase blindness as BLEU; rewards length.
BERTScoreToken-level cosine similarity between BERT embeddings of output and reference.Paraphrase-tolerant quality; short to medium text.Computationally heavy; can score confident but wrong text highly if it paraphrases the reference.
Embedding CosineSentence-level cosine similarity using a sentence encoder (e.g., text-embedding-3).Semantic retrieval quality; topical relevance.Loses specificity — semantically adjacent but factually wrong responses score well.
The Reference Problem

Every statistical metric requires at least one reference answer — a gold-standard output to compare against. This is expensive to produce at scale and introduces reference bias: the metric can only reward outputs that resemble the reference, even if another equally valid response uses different phrasing or structure. For tasks where paraphrase is common (summarization, Q&A, explanation), multiple diverse references dramatically improve metric reliability.

The standard recommendation from the MT literature, confirmed in summarization research at Google Brain (2020) and elsewhere, is: use at least four human references per test case whenever statistical metrics are your primary signal. With fewer references, score variance across paraphrase-equivalent outputs becomes the dominant noise source.

When to Use Statistical Metrics in Production

Statistical metrics are most useful in two situations. First, as a fast pre-filter in a pipeline where human or model-judge scoring is too expensive to run on every candidate: embed all outputs, filter the bottom 20% by cosine similarity to known-good outputs, and only send the remainder for expensive scoring. Second, as a regression signal when comparing prompt versions: if BERTScore drops significantly across a test set after a prompt change, that is a reliable signal to investigate, even if the absolute BERTScore value is hard to interpret.

Practical Warning

Never report a single BLEU or ROUGE number as your primary quality metric to stakeholders. These numbers are not interpretable in isolation — a BLEU of 0.32 is either excellent or terrible depending on the task, the reference count, and the text length. Always report metric deltas (this version vs. baseline) rather than absolute values.

Embedding-Based Pass/Fail Thresholds

One practical pattern: embed a set of known-good outputs and a set of known-bad outputs for a given task. Fit a simple threshold (or logistic regression) on cosine similarity to the good-output centroid. Apply this threshold at inference time as a soft quality gate. This is not robust to distribution shift — if the task input changes significantly, the threshold becomes miscalibrated — but it works well for stable, high-volume tasks like formatting, tone, and style compliance.

BERTScore in Practice (2024)

BERTScore, introduced by Zhang et al. at Cornell in 2020, correlates with human judgments better than BLEU or ROUGE across most generation tasks when tested on WMT and CNN/DailyMail benchmarks. However, the strongest use in production is as a component in an ensemble scorer — BERTScore high AND deterministic schema check passes AND model judge agrees — rather than as a standalone signal.

Lesson 3 Quiz

Statistical evaluation metrics · 4 questions
What core limitation of BLEU was exposed by research between 2002 and 2006?
Correct. BLEU rewards n-gram overlap, so a translation that reuses common n-grams from the reference can score well while being grammatically broken. Human judges caught this; BLEU did not.
The key finding was that BLEU diverged from human judgment — particularly for longer texts — because it rewards lexical n-gram overlap regardless of grammatical coherence or semantic meaning.
Why does BERTScore handle paraphrase better than BLEU or ROUGE?
Correct. BERT embeddings encode contextual meaning, so "the vehicle departed" and "the car left" would have high cosine similarity even though they share no n-grams. BLEU and ROUGE would score this pair low.
BERTScore's advantage is semantic: it compares contextual embeddings rather than surface n-grams, so semantically equivalent paraphrases with different wording still receive high scores.
The standard recommendation from MT and summarization literature for statistical metrics is to use at least how many human references per test case?
Correct. With only one or two references, a perfectly valid paraphrase that uses different wording receives a low statistical score simply because it doesn't match that particular reference. Four references dramatically reduces this variance.
The recommendation is four or more diverse references. With fewer, paraphrase-equivalent outputs that happen to use different phrasing receive artificially low scores — the variance from reference choice swamps the variance from actual quality.
In what situation is reporting an absolute BLEU number to stakeholders most misleading?
Correct. A BLEU of 0.32 can mean excellent performance in one task context and poor performance in another. The number is only meaningful relative to a baseline — never as a standalone absolute quality statement.
Absolute BLEU is always hard to interpret — 0.32 is excellent in some contexts and poor in others. The only reliable use is comparing two versions of the same prompt on the same test set, where the delta carries signal regardless of the absolute level.

Lab 3: Choosing and Combining Statistical Metrics

Practice selecting the right statistical scorer for a given task and understanding its tradeoffs.

Your Task

You are evaluating a summarization prompt that condenses 500-word support tickets into a 2-3 sentence summary for a dashboard. Discuss with the AI: which statistical metric(s) you would choose, why, how many references you need, and what the metric cannot tell you. Aim for at least 3 substantive exchanges.

Task: Evaluate a prompt that summarizes 500-word customer support tickets into 2-3 sentence summaries. You have 50 test cases, each with one human-written reference summary. You need to decide on a statistical evaluation strategy that you can run automatically on every prompt change. What metrics would you use, and what are their limits?
Eval Coach
Statistical Eval · L3
Good task to work through — summarization is a classic case where deterministic scoring fails. Before picking a metric, tell me: what specific quality properties matter most for a support-ticket summary shown on a dashboard? That should drive your metric choice.
Module 7 · Lesson 4

Model-Based Evaluation: LLM-as-Judge

The most powerful scorer available — and the one most prone to subtle, invisible failure.
When you need nuanced quality judgment at scale, can you trust a language model to evaluate another language model — and how do you know when you can't?

In May 2023, Lianmin Zheng and colleagues at UC Berkeley and LMSYS published "Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena." The paper introduced MT-Bench — a set of 80 multi-turn questions requiring nuanced reasoning — and used GPT-4 as the judge to score chatbot responses. The authors validated GPT-4 judgments against 3,000 expert human annotations and found agreement rates of over 80% on single-answer grading and over 80% on pairwise preference judgments — comparable to inter-annotator agreement between humans. They also documented the failure modes systematically: position bias (GPT-4 preferred the first answer in a pair more often than humans), verbosity bias (longer answers were rated higher regardless of quality), and self-enhancement bias (GPT-4 rated GPT-4 outputs higher than other judges did). These biases are now the standard checklist for any LLM-as-judge implementation.

Why Model-Based Evaluation Works

A language model used as a judge can do what no regex and no embedding metric can: read a response and reason about whether it actually answers the question, whether it is factually consistent with provided context, whether the tone is appropriate, and whether it follows instructions that were buried in the system prompt. For tasks where quality is fundamentally about semantic and pragmatic appropriateness — explanation quality, helpfulness, safety — model-based evaluation is the only automated method that tracks human judgment at high fidelity.

Three LLM-Judge Patterns
Pattern 1
Single-Answer Grading
Provide the judge with the question, the response, and a rubric. Ask for a score (1–5 or 1–10) with reasoning. Best for absolute quality assessment across a large test set.
Pattern 2
Pairwise Preference
Show the judge two responses to the same question and ask which is better. More reliable than single-answer scoring but 2x the cost. Swap response order and average to cancel position bias.
Pattern 3
Reference-Guided Grading
Give the judge the question, the response, and a gold-standard reference answer. Ask whether the response is factually consistent and complete relative to the reference. Reduces the judge's knowledge reliance.
Pattern 4
Checklist Scoring
Decompose quality into a list of binary yes/no checks (e.g., "Does the response address the user's main question? Does it avoid hallucinated facts? Is it under 200 words?"). More structured and auditable than holistic scoring.
The Four Known Biases

The MT-Bench paper documented the canonical failure modes. Every LLM-as-judge implementation must address all four.

  1. Position bias: When shown two responses (A, B), the judge disproportionately prefers whichever appears first. Fix: always run each pair in both orders (A,B) and (B,A) and average, flagging cases where the judgments conflict.
  2. Verbosity bias: Longer, more detailed responses receive higher scores regardless of accuracy. Fix: explicitly instruct the judge to score on correctness and relevance, not length; include short correct answers in calibration examples.
  3. Self-enhancement bias: A GPT-4 judge rates GPT-4 outputs higher than comparable outputs from other models. Fix: use a different model family as judge than the model being evaluated, where possible; include calibration examples from multiple models.
  4. Sycophancy: If the judge prompt includes any hint about which answer is "expected," the judge agrees. Fix: never include the expected answer or a correctness hint in the judge prompt; blind the judge to your preference.
Writing the Judge Prompt

Judge prompt quality is as important as any other prompt in your system. The judge needs: a clear rubric with explicit criteria, calibration examples showing what each score level looks like, instructions to reason before scoring (chain-of-thought improves calibration), and an explicit instruction to ignore length and formatting unless those are criteria.

# Judge prompt template (single-answer grading) """ You are an impartial evaluator. Score the following AI response on a scale of 1-5 using ONLY the criteria below. CRITERIA: - Correctness: Does it accurately answer the question? (primary) - Completeness: Does it address all parts of the question? - Conciseness: Does it avoid unnecessary length? Do NOT reward length. Do NOT consider formatting unless formatting was explicitly required. Reason step by step, then output: REASONING: [your reasoning] SCORE: [1-5] Question: {question} Response to evaluate: {response} """
Calibrating Your Judge

Before deploying an LLM judge, calibrate it. Collect 30–50 human-annotated examples across the quality spectrum. Run the judge on all of them. Compute correlation (Spearman's rho) between judge scores and human scores and agreement rate on binary pass/fail. A well-calibrated judge on a specific task should achieve at least 0.7 Spearman correlation and 75% agreement. If it doesn't, revise the rubric and calibration examples, not just the judge model.

Production Architecture

The most reliable production pattern is an ensemble scorer: run deterministic checks first (schema, required fields, format), then BERTScore or embedding similarity as a fast pre-filter, then LLM-as-judge only on the cases that pass the first two layers. This keeps LLM judge costs manageable while using it where it matters most — on responses that look structurally correct but may fail on quality or safety.

Anthropic's Evals Approach

Anthropic's Constitutional AI evaluation process, described in their 2022 paper, used Claude instances to critique and revise their own outputs — a form of model-based evaluation at training time. The same architecture applies at inference time: a second prompt pass asking "What is wrong with this response, if anything?" catches a category of failures that no deterministic or statistical metric can detect.

Lesson 4 Quiz

LLM-as-judge evaluation · 4 questions
What agreement rate did GPT-4-as-judge achieve against human expert annotations in the MT-Bench study by Zheng et al. (2023)?
Correct. The study found over 80% agreement on both single-answer grading and pairwise preference tasks, benchmarked against 3,000 expert human annotations — a strong result that validated model-based evaluation as a practical tool.
The MT-Bench paper found over 80% agreement — comparable to human inter-annotator agreement. This was the key validation that made LLM-as-judge a credible production evaluation method.
How do you mitigate position bias when using a pairwise LLM judge?
Correct. Swapping order and averaging cancels the systematic first-position preference. Flagging conflicts (where order changes the verdict) identifies the cases where the judge is least reliable and human review is most needed.
The standard mitigation for position bias is to run each pair twice — (A,B) and (B,A) — average the scores, and flag any pair where swapping order changes the winner. That surfaces the judge's uncertainty without eliminating it entirely.
What is sycophancy bias in an LLM judge, and what causes it?
Correct. If the judge prompt says "the expected answer is X — is this response close?" the judge will agree that responses resembling X are correct, regardless of actual quality. Blind the judge to any expected answer or correctness hint.
Sycophancy in this context means the judge agrees with whatever the prompt implies. If you include the expected answer or any hint about what you want, the judge conforms to that expectation rather than evaluating independently.
In the recommended ensemble scorer architecture, in what order should the three scoring layers run?
Correct. This ordering minimizes cost: cheap deterministic checks reject obviously broken outputs, statistical similarity filters obviously low-quality ones, and the expensive LLM judge is reserved for responses that look structurally and semantically reasonable but may fail on nuanced quality or safety grounds.
The cost-efficient order is deterministic → statistical → LLM judge. Cheap, fast checks first; expensive, slow checks only on the cases that survive the cheap filters. Running the LLM judge on everything multiplies cost without proportional quality gain.

Lab 4: Writing a Judge Prompt

Practice designing an LLM-as-judge prompt that mitigates the four canonical biases.

Your Task

You need to evaluate a Q&A prompt that answers medical terminology questions for healthcare students. Design an LLM-as-judge prompt for this task with the AI below: define the rubric, address the four biases, and decide on the scoring pattern. Aim for at least 3 substantive exchanges.

Task: Design a judge prompt that evaluates responses to medical terminology Q&A (e.g., "What is the difference between systole and diastole?"). The judge must score on correctness, completeness, and appropriate level of detail for a healthcare student. Address position bias, verbosity bias, self-enhancement bias, and sycophancy in your design.
Eval Coach
LLM-as-Judge · L4
Medical Q&A is a great domain for this exercise — correctness matters enormously, and verbosity bias is a real risk since longer explanations feel more thorough. Before writing the judge prompt, tell me: which scoring pattern from Lesson 4 (single-answer grading, pairwise preference, reference-guided, or checklist) would you choose for this task, and why?

Module 7 Test

Evaluating and Testing Prompts · 15 questions · Pass = 80%
1. The Bing Chat February 2023 incident is primarily cited as an example of which evaluation failure?
Correct.
The incident exemplified a coverage gap: hundreds of test cases were run, but none covered extended emotional manipulation in multi-turn dialogue.
2. What is the "playground illusion" in prompt development?
Correct.
The playground illusion is anecdotal evaluation: testing a few examples manually, seeing good results, and shipping — with no systematic coverage, no baseline, and no regression detection.
3. A minimal production eval system requires which four components?
Correct.
The four components are: test dataset (input/expected pairs), scoring function, runner (executes prompt against dataset), and results store (enables comparison across versions).
4. GitHub Copilot's primary evaluation metric for code suggestions was functional correctness. What made this metric especially powerful for their use case?
Correct.
The power of functional correctness for code is its binary, externally verifiable nature — tests either pass or fail, no human needed, and the existing test infrastructure means zero extra tooling cost.
5. What normalization step is most important when using exact-match scoring for a prompt that extracts currency amounts?
Correct.
Currency amounts can be expressed as "$1,200", "1200 dollars", "USD 1200", etc. A domain-specific normalization that converts all formats to a canonical number is essential before comparison.
6. Schema validation is preferable to exact-match string comparison for JSON outputs because:
Correct.
Two JSON objects with the same content but different key order or whitespace are logically identical but string-comparison-different. Schema validation checks what matters: structure and types.
7. BLEU measures n-gram precision. What is the fundamental quality dimension it cannot capture?
Correct.
BLEU requires surface n-gram overlap. A paraphrase that conveys identical meaning with different words receives a low BLEU score, making it unreliable for tasks where paraphrase is common.
8. Why does BERTScore handle paraphrase better than BLEU?
Correct.
BERTScore uses contextual embeddings from BERT, where semantically similar tokens have high cosine similarity even with different surface forms. This captures paraphrase that n-gram overlap misses entirely.
9. The standard recommendation for statistical metrics is to use at least four human references per test case. Why does having only one reference inflate score variance?
Correct.
With one reference, a perfectly correct paraphrase that happens not to match that specific reference scores low. The score variance is driven by reference-paraphrase mismatch, not actual quality differences between outputs.
10. When should statistical metrics be reported as absolute numbers (e.g., BLEU = 0.32) to stakeholders?
Correct.
Absolute statistical metric values are not interpretable in isolation across tasks. Report deltas — "this version scores 8% higher on ROUGE-L than the baseline" — rather than absolute values that stakeholders cannot contextualize.
11. The MT-Bench paper (Zheng et al., 2023) found that GPT-4-as-judge agreed with human experts over 80% of the time. What three biases did the same paper document?
Correct.
MT-Bench documented three primary judge biases: position bias (preferring the first answer), verbosity bias (preferring longer answers), and self-enhancement bias (GPT-4 rating GPT-4 outputs higher).
12. Which LLM-judge scoring pattern is most appropriate when you need an auditable, per-criterion breakdown of response quality?
Correct.
Checklist scoring decomposes quality into binary yes/no checks (e.g., "Does it answer the main question? Does it avoid hallucination? Is it under 200 words?") — each check is independently auditable and traceable.
13. To prevent sycophancy bias in a judge prompt, you must:
Correct.
Sycophancy is triggered when the judge prompt hints at what the "right" answer should be. Blind evaluation — no expected answer, no correctness hint — is the only reliable mitigation.
14. A well-calibrated LLM judge for a specific task should achieve what minimum thresholds on a set of human-annotated calibration examples?
Correct.
The recommended minimum thresholds are 0.7 Spearman correlation with human scores and 75% agreement on binary pass/fail classifications before deploying an LLM judge in production.
15. In the recommended ensemble scorer architecture, why is the LLM judge reserved for the final layer rather than run on every output?
Correct.
The ensemble architecture is fundamentally about cost management: cheap checks (deterministic, then statistical) eliminate obviously broken outputs so the expensive LLM judge is only called on responses that need nuanced quality assessment.