Unit 1 of 10 · about 4 hours · explain, implement

Construct validity and likelihood, multiple-choice and generation evaluation contracts

The LLM Foundations unit on likelihood and perplexity taught the arithmetic. Here you make that arithmetic an instrument whose score supports a specific decision, rather than a general claim about intelligence.

You'll be able to

  • Turn an intended research decision into a task contract with a target population, observable behavior and explicit exclusions.
  • Implement response-only likelihood, multiple-choice likelihood and generation scoring without changing the question being measured.
  • Explain why capability, truthfulness, robustness, privacy and harmlessness need separate evidence.

Covers

Task definition, construct validity and intended decisionLikelihood, multiple-choice and generation evaluation contracts
1

Read

In this order, only the parts listed

0 of 3 done

  1. CS336 Spring 2026 Lecture 12: evaluationCS336 2026 - Evaluation

    Trace functions what_is_good, perplexity, exam_benchmarks, realism and how_to_think_about_evaluation

    Skip leaderboard browsing. Correct two slips in perplexity: conditional perplexity is the reciprocal geometric mean probability, and minimum population perplexity is exponentiated entropy, not entropy.

  2. HELM: scenarios, adaptation and metric dimensionsHolistic Evaluation of Language Models

    Sections 2 to 4: Preliminaries, Core scenarios and General metrics; Section 7, Adaptation

    Read the taxonomy and metric definitions; skim individual dataset descriptions. Do not run another evaluation framework.

  3. Harness task contractsLanguage Model Evaluation Harness

    Using Local Datasets; Writing a Prompt Template, including Multiple choice format; inspect output_type in the linked Task Configuration guide

    Use local JSON with lm-eval 0.4.13, not a custom dataset loading script. Build one tiny task, not a benchmark sweep.

2

Focus on

  • Write down the population, item unit, allowed inputs, answer space, scoring rule and intended decision before selecting a benchmark. A multiple-choice knowledge test is not a privacy or safety test.
  • For a nonempty response, conditional perplexity is , where counts response tokens. Corpus aggregation weights tokens, not sequences. Compare only under the same tokenizer and context policy.
  • Summed continuation log likelihood and length-normalized scores define different choice rules. Generating a letter is a third protocol; do not silently substitute it for scoring continuations.
  • TensorTonic supplies aligned logits. A causal model pipeline must align next-token predictions separately and exclude prompt and padding targets. Its empty-mask return is a programming convention, not evidence of perfect prediction.
Common mistakes · 3
  • Averaging per-item perplexities. Exponentiate the token-weighted aggregate NLL instead.
  • Allowing an empty continuation to compete with nonempty choices. Its summed log likelihood is zero; reject empty choices in the task contract even though the component drill defines them.
  • Calling a higher preference score a correctness gain without a correctness measure.
3

Try it yourself

Closed-book, before checking anything

Closed-book, implement the two TensorTonic functions, then attach the same three scoring interfaces to a local JSON task in lmlab. For the uniform two-token public perplexity case, selected count is 2, NLL is and perplexity is 2. Add an empty-mask status so an undefined evaluation cannot enter an aggregate as perplexity 1. Use fixed logits for CPU checks; model scores are not targets.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.Why is conditional perplexity useful but insufficient for a generation task?Answer

    It scores reference response tokens given the prompt. It does not test the sampled answer, stopping behavior or semantic correctness of alternative valid answers.

  2. 2.With natural-log entropy, what is minimum population perplexity?Answer

    . Cross-entropy equals entropy plus KL divergence when defined; its minimum occurs when the model matches the target distribution on its support. This population result is not a finite-sample guarantee.

  3. 3.Does identical text make token perplexity comparable across tokenizers?Answer

    No. Token counts and probability factorizations differ. Fix the tokenizer or define and justify a common scoring unit and boundary policy.

5

Practice

  • TensorTonic: Compute Conditional Perplexity

    Implement conditional_perplexity(logits, target_ids, response_mask); public cases Uniform selected tokens, One confident selected token and Empty response mask

    Use PyTorch 2.14.1 on CPU. These cases exercise selected-token reduction and the stated empty convention, not causal alignment or gradients.

  • TensorTonic: Score Multiple-Choice Continuations

    Implement multiple_choice_likelihood(logits, token_ids, continuation_mask); public cases One-token choice ranking, Variable continuation lengths and Empty continuations tie

    Keep summed likelihood and lowest-index tie breaking. The section mini-project extends these components into likelihood and generation contracts with raw item records.

You're done when

Both component drills pass their public cases, your local task exposes all three scoring contracts, and each metric has a written decision it can and cannot support.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 15 more in the section
  • CS336 2026 - EvaluationStanford University · primary

    Step through the Lecture 12 trace (perplexity, knowledge, instruction, agent, reasoning and safety benchmarks, validity). Rebuild conditional perplexity, multiple-choice scoring and one generation evaluator, then fix prompt, decoding, item and inference-compute versions before any comparison.

  • Language Model Evaluation HarnessEleutherAI · required

    Follow docs/new_task_guide.md to write one local JSON task (dataset_path: json) with explicit output_type, prompt, choices, filters and metrics, and run it with --log_samples to keep per-sample outputs. Pin the harness version (0.4.13 was checked). should_decontaminate only marks a query; it does not search any training corpus.

  • Holistic Evaluation of Language ModelsStanford CRFM · required

    Read Sections 2 to 4 (scenarios and the seven metrics) and Section 7 (adaptation via prompting) to define capability, robustness, fairness, toxicity and efficiency as separate evidence. HELM entered maintenance mode on 2026-06-01, so treat the framework as methodology and do not run a second full evaluation stack.

Also in this section