SynfraCore
Synfracore
Start Learning
Navigation

Academies

Platform

RoadmapsLabsCertificationsInterviewPYQsAI AssistantCareer
Start Learning Free Learning Roadmaps

AI Evals — Intermediate

Real-world patterns, best practices, and deeper topics

📄
Last updated Dec 2026
Expert Content

AI Evals — Intermediate

Designing an LLM-as-judge prompt that doesn't fool itself

A judge model given a vague instruction ("rate this response 1-5") produces inconsistent, hard-to-interpret scores — different runs on the identical output can land on different numbers. A judge given a specific rubric, with concrete criteria and example outputs for each score level, produces far more consistent and far more useful results.

text
Weak judge prompt:
  "Rate the response from 1-5."

Stronger judge prompt:
  "Score the response on these specific criteria:
   - Does it directly answer what was asked? (yes/no)
   - Does it avoid unsupported claims? (yes/no)
   - Is the tone appropriate for a support context? (yes/no)
   Score 5 if all three are yes, 3 if two are yes, 1 if zero or one is yes."

Specificity doesn't eliminate judge error, but it narrows what the judge is actually deciding, which makes disagreements between the judge and a human reviewer easier to diagnose — "the judge missed the unsupported-claim criterion" is a fixable, specific problem; "the judge's overall vibe disagreed with mine" is not.

Calibrating a judge against human judgment

Before trusting an LLM-as-judge score at scale, it's worth measuring how often the judge agrees with a human reviewer on a held-out sample — not assuming agreement because the judge's reasoning sounds plausible when read. A judge that disagrees with human raters on a meaningful fraction of cases needs either a clearer rubric, a stronger judge model, or an acknowledgment that this particular task isn't well-suited to automated judging at all.

💡 In simple words

One-line idea: Calibration means measuring judge-vs-human agreement on a sample small enough to label by hand but large enough to trust the result.

python
def judge_agreement_rate(judge_scores: list[int], human_scores: list[int]) -> float:
    """What fraction of cases did the judge and a human reviewer agree on?"""
    agreements = sum(1 for j, h in zip(judge_scores, human_scores) if j == h)
    return agreements / len(judge_scores) if judge_scores else 0.0

Try it in 2 minutes: A judge agrees with human raters on 60 out of 100 held-out cases. Is this judge ready to score production traffic unsupervised?

Answer: No — 60% agreement is low enough that the judge is making a meaningfully different call from a human reviewer on 4 in 10 cases. Fix the rubric (make the criteria more specific) or the judge model before trusting it at scale, and re-measure agreement after the fix.

Common mistake + fix: Calibrating once and assuming it holds forever. Fix: re-check agreement whenever the task, the judge model, or the rubric changes — a judge calibrated for one task version isn't guaranteed to still agree with humans on a changed one.

Memory line: An uncalibrated judge is a guess wearing a number. Calibration is what turns that number into evidence.

Why an aggregate score can hide a real regression

A golden set's overall pass rate staying flat, or even improving, can conceal one specific category getting meaningfully worse while enough other categories improve to cancel it out in the average. Breaking scores down by category — intent type, difficulty tier, input length — before declaring a change safe is what catches this; reading only the headline number is how a real regression ships unnoticed.

Aggregate score: 91% -> 92%
Looks like an improvement
Category breakdown
One category actually dropped from 85% to 60%
The real finding
A localized regression the aggregate number hid

Evaluating a RAG system's retrieval, not just its final answer

One-line idea: A RAG system can fail at retrieval, at generation, or at both — scoring only the final answer can't tell you which, so RAG evaluation checks retrieval and generation separately.

Everyday comparison: If a research assistant hands you a wrong answer, you'd want to know whether they read the wrong sources (a retrieval problem) or read the right sources and still got it wrong (a generation problem) — fixing the wrong one wastes time.

python
def context_precision(retrieved_ids: list[str], relevant_ids: set[str]) -> float:
    """Of what was retrieved, how much was actually relevant?"""
    if not retrieved_ids:
        return 0.0
    return len(set(retrieved_ids) & relevant_ids) / len(retrieved_ids)

def context_recall(retrieved_ids: list[str], relevant_ids: set[str]) -> float:
    """Of what was truly relevant, how much did retrieval actually find?"""
    if not relevant_ids:
        return 1.0
    return len(set(retrieved_ids) & relevant_ids) / len(relevant_ids)

def faithfulness(answer_claims: list[str], context_text: str, judge_fn) -> float:
    """Is each claim in the answer actually supported by the retrieved
    context — not just plausible-sounding? Delegates the "is this claim
    supported" check to an LLM judge, one claim at a time."""
    supported = sum(1 for claim in answer_claims if judge_fn(claim, context_text))
    return supported / len(answer_claims) if answer_claims else 1.0

Common mistake + fix: Reporting one combined "RAG quality" score. Fix: a low context recall with high faithfulness means retrieval is missing relevant material (the model is being honest about what little it got); high recall with low faithfulness means the model is making claims the retrieved context doesn't support (hallucinating despite having the right material) — these point at completely different fixes, and a single blended number hides which one you have.

Memory line: Context precision/recall score the search step. Faithfulness scores whether the answer stayed honest about what it found. Answer relevance (does the final answer actually address the question, independent of grounding) is a third, separate check — a perfectly grounded answer can still miss the point of what was asked.

Evaluating multi-step agent behavior, not just a single response

One-line idea: A single-turn eval scores one input-output pair; an agent working through several steps needs checking at the level of the whole trajectory, not just where it ended up.

A single-turn eval scores one input-output pair. An agent that works through a task in several steps — invoking tools, reasoning across more than one turn — needs checking at more than one level: was the overall sequence of actions sensible, did each individual tool call carry reasonable arguments, and did the task actually get solved by the end. A final answer can be correct by accident despite a genuinely bad intermediate step (an unnecessary tool call, a wrong argument that happened not to matter this time), which end-to-end scoring alone won't surface.

python
def evaluate_trajectory(trajectory: list[dict], expected_tools: set[str]) -> dict:
    """trajectory = [{"tool": "...", "args": {...}, "result": "..."}]"""
    tools_used = {step["tool"] for step in trajectory}

    return {
        "task_completed": trajectory[-1].get("result") == "success" if trajectory else False,
        "unnecessary_tool_calls": len(tools_used - expected_tools),
        "missing_expected_tools": len(expected_tools - tools_used),
        "step_count": len(trajectory),
    }

Try it in 2 minutes: An agent correctly books a meeting, but its trajectory shows it called check_calendar three times with the same arguments before succeeding. Does task_completed=True alone tell you this agent is working well?

Answer: No — the task succeeded, but three redundant identical calls is a real inefficiency (cost, latency, and a sign something in the retry logic isn't working as intended) that trajectory review catches and end-to-end scoring completely misses.

Keeping an eval set honest over time

A golden set that never changes eventually stops testing anything relevant to current usage — the system and its users both evolve, but the set measuring them doesn't. A set that changes too often loses the ability to compare today's score against last month's, since the comparison is no longer apples to apples. A practical middle ground versions the golden set explicitly (like code), so a specific score is always tied to a specific, known version of what it was measured against, and older versions stay available for historical comparison rather than being silently overwritten.

Share:
Join our Community
Daily tips, job alerts, interview help — join engineers learning together
→
Up Next
🚀
AI Evals — Advanced
Production patterns, performance, security hardening
Also Worth Exploring
← Back to all AI Evals modules
← FundamentalsAdvanced →