Unit 2 of 7 · about 4 hours · implement

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.

You'll be able to

  • 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 schemaExact match, normalized match and structured verifiersGeneration metrics and their counterexamplesRaw-output retention and evaluator versioning
1

Read

In this order, only the parts listed

0 of 5 done

  1. Modern LLM Notebook 25-evaluation: metric system and pitfallsModern 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 contractLanguage 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 guideLanguage 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 metricsLanguage 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 gameStanford 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

2

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.
Common mistakes · 3
  • 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.
3

Try it yourself

Closed-book, before checking anything

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.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

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

    Strict fails because there is no #### (number) match, while flexible extracts the last number-like token 42 and passes. Report both pipeline names with the score.

  2. 2.When should you report acc_norm instead of acc?Answer

    acc compares raw choice loglikelihoods, acc_norm normalizes by length or bytes. Use the normalized form when choices differ in length or tokenization, and state which one the table uses.

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

    Use temperature 0 with do_sample false for exact and structured metrics. Use non-zero temperature only for pass@k, self-consistency or robustness runs, and then fix the seed.

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

    Task YAML plus commit hash, prompt text, few-shot count and split, filter regexes, generation kwargs, model version and evaluator version, plus raw outputs saved with log_samples and output_path.

You're done when

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

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 3 more in the section
  • Stanford CS336 - resource accounting, inference and evaluationStanford University · primary

    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 accountingWalking Labs · required

    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 HarnessEleutherAI · optional

    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 analysisSebastian Raschka · required

    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 sliceRoadmap-Final · support

    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 scalingStanford University · optional

    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.