Back to the curriculum

L2-M04 · Level 2 · ~14 h

LLM-as-a-Judge

What you build: Judge evaluator with calibration checks

lessons
5
lesson hours (estimate)
≈ 9.5 h
0/5 lessons marked done · Progress is saved in this browser only. No account, nothing is sent to a server.
In review. The curriculum, module overviews and Levels 1–3 lessons are drafts written with AI assistance and reviewed by AI. Human review is still pending. English translation: AI-assisted, not human-reviewed.

Levels 1–3 lessons, exercises and quizzes are published as drafts, in Vietnamese with an AI-assisted English translation. They may change after human review.

Module path

  1. Lesson 1 · L2-M04-L01≈ 1.5 h

    How LLM-as-a-Judge works, and when not to use it

    What you build: Decision checklist

    Needs: L2-M03-L05

    Key terms (6)
    • Judge (LLM-as-a-Judge)Judge: LLM chấm đầu ra của model khác
    • Decision checklistBảng quyết định
    • Raw output / parseĐầu ra thô của judge / đọc phán quyết từ nó
    • False accept / false rejectLọt / oan
    • Simulated judgeJudge mô phỏng (hàm có seed)
    • TutorGia sư
  2. Lesson 2 · L2-M04-L02≈ 2 h

    Judge prompt design: pointwise, pairwise, reference-based

    What you build: Three judge variants

    Needs: L2-M04-L01

    Key terms (7)
    • Pointwise (single answer grading)Chấm từng câu: một điểm cho một câu trả lời
    • Pairwise comparisonSo sánh cặp: chọn câu tốt hơn hoặc hòa
    • Reference-based (reference-guided)Chấm theo đáp án tham chiếu
    • SlotKhe điền trong prompt
    • Abstention (`[[?]]`)Đường lui: judge từ chối chấm khi thiếu thông tin
    • Fail closedĐóng: không đọc được thì báo lỗi, không đoán
    • Prompt injectionChèn lệnh vào nội dung được chấm
  3. Lesson 3 · L2-M04-L03≈ 2 h

    Known judge biases (sources to be verified at authoring)

    What you build: Bias probes such as order swaps and length changes

    Needs: L2-M04-L02

    Key terms (5)
    • Bias / noiseThiên lệch (có hướng) / nhiễu (ngẫu nhiên)
    • Position / verbosity biasThiên lệch vị trí / độ dài
    • Self-preference, leniencyTự ưu ái, dễ dãi
    • ProbePhép thử có chủ đích để đo một thiên lệch
    • Both-orders ruleQuy tắc cả hai thứ tự
  4. Lesson 4 · L2-M04-L04≈ 2 h

    Calibrating a judge against human labels

    What you build: Agreement report and threshold choice

    Needs: L2-M04-L03

    Key terms (6)
    • Calibration (of a judge)Hiệu chuẩn judge bằng nhãn người
    • Cohen's kappaHệ số kappa của Cohen (đồng thuận đã trừ phần ngẫu nhiên)
    • Chance agreement (p_e)Độ đồng thuận ngẫu nhiên
    • False-accept rate / false-reject rateTỷ lệ lọt / tỷ lệ oan
    • Dev set / test setTập dev (để chỉnh) / tập test (để báo cáo)
    • Release gateCổng phát hành (quy tắc n, lọt, kappa)
  5. Lesson 5 · L2-M04-L05≈ 2 h

    Judge versioning, cost and monitoring

    What you build: Judge configuration recorded per run

    Needs: L2-M04-L04

    Key terms (6)
    • Pinned model ID / aliasID model ghim phiên bản / alias (con trỏ có thể đổi)
    • Judge configurationCấu hình judge ghi theo từng lần chạy
    • Canary setTập canary: mục có nhãn người, cố định, để bắt trôi
    • DriftTrôi: cùng judge cho kết quả đổi theo thời gian
    • Repeat consistencyĐộ ổn định khi chấm lặp
    • Comparable runsHai lần chạy so được với nhau

A. Module overview

Field Value
Module ID L2-M04
Level 2 - AI Quality Engineer (Evaluation)
Description Use an LLM as a judge for the criteria that a metric function cannot score, and know when not to: a decision table across code, humans and a judge; three prompt variants (pointwise, pairwise, reference-based) with a closed parser and a structure lint; the published biases (position, verbosity, self-preference, leniency) and probes to measure them; calibrating the judge against human labels with a confusion matrix, Cohen's kappa, a threshold chosen on dev and reported on test; recording the judge configuration, cost, stability and a canary set that tracks drift. The lab continues the fictional HocVui Tutor product from L2-M01 to L2-M03 and runs offline with a seeded simulated judge (no model calls, no API key). What real models can do is quoted from sources that were read, with access dates.
Why this module matters A figure such as "92% of answers are friendly", scored by a judge, is only as trustworthy as the judge. A judge can be fooled by a confident-sounding wrong answer, prefer the answer that comes first or the longer one, be lenient, and change behaviour when its version changes. This module teaches measuring the judge itself and recording enough configuration for others to re-check it.
Target professional competency Level 2: "Implement and calibrate judges (LLM-as-a-Judge) against human labels, and know their biases and limits".
Estimated duration 1 lesson × 90 minutes + 4 lessons × 120 minutes = 9.5 hours + module assignment ~4 hours + quiz 0.5 hours ≈ 14 hours for someone who has completed L2-M03. An estimate, not yet measured with real learners.
Prerequisites L2-M03 (deterministic metrics, rubrics, per-slice reports); the judge is introduced in L1-M01-L05 and used in L2-M01-L03 (this module goes further, without repeating). High-school math. No API key needed.
Module output A judge evaluator with a calibration check: a decision table, three prompt variants and a parser, a set of bias probes, a calibration report (kappa, threshold), a configuration record for each run
Cost 0 VND

What learners build. Step by step, in code-labs/l2-m04: (L01) a decision table that picks code, humans, a judge or a judge plus humans for each criterion, and a comparison of a code grader with a simulated judge; (L02) three prompt templates, a closed parser (output that cannot be read is an error, counted separately) and a structure lint; (L03) probes for position, length and model family on a log of verdicts, the both-orders rule and what it does not fix; (L04) a dev and test split, raw and chance-level agreement, kappa computed exactly with Fraction, a threshold chosen under a ceiling on the false-accept rate, a per-group report and a release gate; (L05) a lint and a hash of the judge configuration, a comparison of two runs, a cost estimate, a measure of repeat-scoring stability and a canary set that tracks drift. The lab is independent of the earlier labs and needs only pytest.

What the module does not do. It does not call a real model: the lab's numbers describe the simulation, not the properties of any model. The lab does not teach which wording makes a real judge score better; that takes running a real model on your own label set. Cohen's kappa is taught and computed for pass or fail labels; the §9 exercise of L04 extends it to multiple levels as an advanced exercise; L2-M05-L02 goes deeper (weighted kappa).

B. Learning objectives

ID Objective
MO1 Decide when to use a judge, code, humans or a judge plus humans for a criterion, using a decision table with reasons.
MO2 Design a judge prompt in three variants, write a closed parser and lint the prompt structure.
MO3 Measure position, verbosity, self-preference and leniency bias with probes, apply mitigations and state what the mitigations do not fix.
MO4 Calibrate a judge against human labels: compute kappa, choose a threshold on dev, report per group on test and make a decision.
MO5 Record the judge configuration for every run, estimate cost and stability, and detect drift with a canary set.

C. Lessons

ID Lesson Duration Prerequisite Concepts Practical output
L2-M04-L01 How LLM-as-a-Judge works, and when not to use it 90' L2-M03-L05 judge, raw output and parse, decision table, false accept and false reject, cost per call A decision table
L2-M04-L02 Designing prompts for a judge: pointwise, pairwise and reference-based 120' L01 three variants, prompt anatomy, closed parser, lint, a frame against fake delimiters Three judge variants
L2-M04-L03 The known biases of judges: position, verbosity, self-preference and leniency 120' L02 bias and noise, probe, both-orders rule, model family, threshold A swap-order and length probe
L2-M04-L04 Calibrating a judge against human labels: agreement, kappa and choosing a threshold 120' L03 dev and test, kappa, false-accept and false-reject rates, choosing a threshold, release gate, a baseline that always passes An agreement report and a threshold choice
L2-M04-L05 Versions, cost and monitoring of a judge: recording the configuration for every run 120' L04 configuration and hash, pinning a version, comparable runs, cost, stability, canary A judge configuration recorded for every run

D. Hands-on assignment (module assignment)

The module assignment (one judge for one criterion of an AI feature, with a decision table, a bias report, a calibration report and a configuration record) is in exercises.md. The five standalone exercises for the individual lessons are in code-labs/l2-m04/exercises/ and in §9 of each lesson.

E. Module assessment

The module quiz quiz.md, the module assignment rubric in exercises.md, and the practice-0N.md practice for each lesson. The solutions and the instructor guide are for instructors only and are not published.

F. References

The shared list references.md; each lesson also has its own references table in §12 with the access date and how much of each source was read.

Objectives ↔ assessment matrix

Objective Lesson Standalone exercise (§9) Module quiz
MO1 L01 exercises/test_l01_checklist.py (to be added with the quiz)
MO2 L02 exercises/test_l02_prompts.py (to be added with the quiz)
MO3 L03 exercises/test_l03_bias.py (to be added with the quiz)
MO4 L04 exercises/test_l04_calibration.py (to be added with the quiz)
MO5 L05 exercises/test_l05_ops.py (to be added with the quiz)