Cheat sheet · Module 10

Cheat sheet: Evaluation and model adaptation

Generative AI · Cheat sheet · Evaluation and model adaptation

Open the moduleModule quiz

Prompting vs RAG vs fine-tuning (match the lever to the problem; cheapest and most reversible first):

  1. Prompting changes the instructions. Fastest to iterate; try first.
  2. RAG changes the information in the prompt. Use it when the model must know something: facts, current or private data, citations, per-user access.
  3. Fine-tuning changes the weights. Use it for consistent style, format or behaviour at scale, with labelled data and a strong baseline to beat. It is not a way to inject changing facts, and it does not cure hallucination by itself (training on correct refusals can help abstention).

The levers combine: a tuned model for format plus RAG for facts is common.

Fine-tuning methods

  • Pretraining: knowledge. SFT: prompt and ideal response (behaviour). RLHF or DPO: preferred and rejected response (judgement). Distillation: small model learns from a large one.
  • LoRA: frozen W plus a low-rank B x A; a d x d layer gets 2 x d x r trainable weights (4096, r = 8: 65,536, about 0.39%). Swappable and mergeable.
  • QLoRA: 4-bit frozen base plus higher-precision adapters. Least memory, slower steps.
  • Data quality over volume. Train on the exact production prompt format. Hold out a test set.
  • Must beat the best prompt plus RAG baseline. Watch forgetting and safety regressions. Version adapters and keep a rollback.

Evaluation

  • Pyramid: deterministic checks, reference metrics, LLM judge, human review, online signals. Push checks down.
  • Error analysis first. Dev set to iterate, held-out set to gate. Slice results.
  • Judges: position, verbosity and self-enhancement bias. Validate with kappa against humans, swap pairwise order, use a rubric.
  • Small sets are noisy: compare paired, with an interval.
  • Benchmarks shortlist. The product eval decides.

Interview traps: “fine-tune it on our data” when the need is RAG · claiming fine-tuning solves hallucination · trusting an unvalidated judge · reporting percent agreement without kappa · tuning on the held-out set.

Quick answers

  • Fine-tune for: behaviour, format and distillation. Not for changing facts.
  • Fine-tuning ladder: SFT (behaviour), then RLHF or DPO (preference). LoRA: frozen W plus low-rank B x A. QLoRA: 4-bit base.
  • Evals: deterministic, reference, judge (validate against humans), human, online. Error analysis first; dev vs held-out; slice; intervals for small sets.

Traps

Optimising without measuring · tuning on the held-out set · percent agreement without kappa · judge bias · training and serving prompt formats that differ.