7 routes42 sections324 units

Unit 4.2 · about 4 h

312 / 324

Task contracts and automatic metrics

Most evaluation gains come from parsing, prompts or versions, not from the model. A contract plus raw outputs turns a score into evidence that survives review.

  • implement

You can now

  • Define a task contract with prompt version, few-shot count, output schema and parsing rules before running any model.
  • Implement exact and normalized match plus a structured verifier, and show a counterexample for each automatic metric.
  • Retain raw outputs and version the task, prompt, parsing and model so another run reproduces the score.

Covers

  • Task contract, prompt version and output schema
  • Exact match, normalized match and structured verifiers
  • Generation metrics and their counterexamples
  • Raw-output retention and evaluator versioning

Study, in this order

5 steps

  1. Modern LLM Notebook 25-evaluation: metric system and pitfalls
    Modern LLM Notebook - evaluation and FLOP accounting

    Section 9.1 (loglikelihood acc and acc_norm for MCQ, generate_until exact_match, pass@k and F1 for generation, strict_acc for IFEval) and Sections 10.1 to 10.2 (prompt sensitivity 5 to 15 percent with OLMES prompts, few-shot 0, 5 and 8, seed, temperature 0, Chat versus Completions API confusion)

  2. lm-eval-harness: GSM8K task contract
    Language Model Evaluation Harness

    doc_to_text and doc_to_target, metric exact_match with strict-match regex #### (number) versus flexible-extract last-number regex, generation_kwargs until Question with do_sample false and temperature 0.0, num_fewshot 5, metadata version 3.0

  3. lm-eval-harness: task configuration guide
    Language Model Evaluation Harness

    Task naming, doc_to_text, doc_to_target, doc_to_choice, num_fewshot, output_type generate_until, loglikelihood and multiple_choice, filter_list pipelines, metadata version

  4. lm-eval-harness: exact match and accuracy metrics
    Language Model Evaluation Harness

    exact_match_hf_evaluate with regexes_to_ignore, ignore_case and ignore_punctuation plus mean aggregation; acc and acc_norm entries for loglikelihood and multiple_choice

  5. CS336 Lecture 12: exam benchmarks and rules of the game
    Stanford CS336 - resource accounting, inference and evaluation

    Function exam_benchmarks() with MMLU 57 subjects and few-shot prompting, MMLU-Pro 4 to 10 choices with 16 to 33 percent drops, IFEval synthetic constraints that check format not semantics; plus how_to_think_about_evaluation() with methods versus models and the nanogpt speedrun and DataComp-LM rules of the game

Focus on

  • The task is the prompt plus few-shot plus parsing plus version, not just the dataset name. Change any part and the score means something new.
  • Strict match needs the #### marker, flexible extract takes the last number. The same outputs can pass one and fail the other.
  • acc picks the highest-prob choice, acc_norm corrects for length. IFEval strict_acc checks format and keywords, not whether the answer is right.
  • Keep raw generations and the config hash. Reruns compare filtered outputs, not just the mean.

Reproduce closed-book

From one GSM8K output without a #### marker that states the right number, show strict-match failing while flexible-extract passes, then write the version string that would catch the parser change.

Traps

  • Comparing scores across papers with different prompts, few-shot counts or parsers. The notebook calls such comparisons invalid without aligned configs.
  • Treating flexible-extract as strict. Lenient parsing inflates the score without changing the model.
  • Reading IFEval strict accuracy as semantic quality. It verifies constraints such as word count and keywords, not the meaning of the response.

Practice

The section mini-project covers this: a versioned task contract with prompt, parser and exact or structured metric, raw outputs kept beside the scores, and one parser failure exposed and fixed.

Self-test

  1. An output says The answer is 42 with no #### marker. How do strict-match and flexible-extract score it?

  2. When should you report acc_norm instead of acc?

  3. Which temperature and sampling settings suit deterministic task metrics?

  4. What must be versioned for a task result to be reproducible?

Completion criterion

Stop when

Your harness records prompt, few-shot, parser and versions with raw outputs, and you can show one output where strict and flexible disagree.

Mark passed, then open 4.3 Only mark this when you can do it without notes.

Leads to

Comes after

Resources for this unit

  • Stanford CS336 - resource accounting, inference and evaluation
    Stanford Universityprimarycourse
    Use Spring 2026 Lectures 2, 10 and 12 for FLOPs, memory, arithmetic intensity, inference and evaluation. Reproduce the small calculations locally. Assignment 3 IsoFLOPs analysis is optional; do not require its hosted training API or costly experiments.
  • Modern LLM Notebook - evaluation and FLOP accounting
    Walking Labsrequiredimplementation
    Use English notebook 25-evaluation and Appendix B FLOP and memory accounting. Build a 20-example evaluator with two slices, raw outputs and bootstrap intervals, and deliberately create one parser, prompt or judge failure.
  • Language Model Evaluation Harness
    EleutherAIoptionalreference
    After the small evaluator passes, inspect task versioning, request construction and result schemas to understand production evaluation plumbing. Do not use the harness as a substitute for owning the task and metric contract.

Also in this section

  • LLMs from Scratch companion - GPT FLOP analysis
    Sebastian Raschkarequiredimplementation
    Use ch04/02_performance-analysis/flops-analysis.ipynb as a concrete calculator, then rebuild the formulas from the model configuration and reconcile parameters and at least one memory or operation estimate with runtime state.
  • LLM Foundations Checkpoint - evaluation and arithmetic slice
    Roadmap-Finalsupportassessment
    Use the contamination, evaluator-bias, parameter, FLOP, activation, state and KV requirements as the assessment contract. Keep raw outputs and distinguish a verified task result from a broad model capability claim.
  • Stanford CS336 Assignment 3 - IsoFLOPs scaling
    Stanford Universityoptionalpractice
    Use Section 2.1 and Problem chinchilla_isoflops with data/isoflops_curves.json for the bounded curve-fitting exercise only. Do not use the hosted training API or costly experiments.

Quick find

Search Michi

Type to search every route, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels