본문으로 건너뛰기

Level 6 project

Train and Ship a Tiny LLM

Start from the canonical project files, validate the result, and keep the evidence you need to explain what you built.

There is no upload or grading service. Run the documented validator or checks where applicable, keep the results, and score your own evidence against the rubric below. A passing check by itself does not mean the project is complete. Suggested strong-evidence target: 16/20. Critical-criterion rule: A 16/20 total is not sufficient if any criterion the rubric marks as critical scores zero.

Launch lesson: Tiny LLM Integration Workshop

Prerequisite project: Build a Mini Transformer

Prerequisites

Python help for this project:

Complete Level 6 through L6.14 — Tiny LLM Integration Workshop. The canonical cumulative project dependency is the Level 5 project Build a Mini Transformer.

You should be able to:

  • create next-token input/target windows without leakage;
  • reason about (B, T, C) hidden states and (B, T, V) logits;
  • train the validated tiny decoder-only model and read train/validation loss;
  • save configuration/checkpoint identity and seed information;
  • sample with controlled decoding settings;
  • recognize repetition/collapse/incoherence and debug with evidence.

Goal

Train or reuse the validated Level 6 tiny decoder-only language-model path, evaluate it on fixed evidence, diagnose one failure, and ship a reproducible run package that another learner can inspect.

Task

Complete the TODOs in run_package.py and produce a run.json from your training/evaluation evidence.

Your implementation must provide:

  1. perplexity(loss) for positive finite average natural-log loss;
  2. repeated_bigram_rate(text) as a simple generation-failure indicator;
  3. choose_best(records) selecting the lowest validation-loss record;
  4. validate_run(data) rejecting missing or inconsistent reproducibility evidence.

Your run.json must include:

  • run_id and integer seed;
  • model config including vocabulary/context/model dimensions;
  • tokenizer_fingerprint;
  • checkpoint_fingerprint and matching checkpoint_tokenizer_fingerprint;
  • train/validation loss history or selected validation loss evidence;
  • at least two fixed evaluation samples with their prompt/decoding settings;
  • environment with Python/runtime information;
  • debug_record containing failure, evidence, hypothesis, focused fix, and result;
  • a limitations statement.

Stuck on a TODO?

Choose one function at a time. Hint 1 offers direction, hint 2 offers pseudocode, and hint 3 reveals only that function's reference implementation after confirmation.

run_package.py: perplexity()

Try the starter function and run its validator before revealing the reference.

Hints for this TODO

run_package.py: repeated_bigram_rate()

Try the starter function and run its validator before revealing the reference.

Hints for this TODO

run_package.py: choose_best()

Try the starter function and run its validator before revealing the reference.

Hints for this TODO

run_package.py: validate_run()

Try the starter function and run its validator before revealing the reference.

Hints for this TODO

Validation

Run these commands from the downloaded Project folder or the public materials repository root.

python projects/tests/l06/validate_submission.py \
projects/starters/l06/run_package.py \
path/to/your/run.json
uv run python projects/tests/l06/validate_submission.py \
projects/starters/l06/run_package.py \
path/to/your/run.json

Compare with a reference

First complete your own TODOs and run the submission validator above. Then open the published reference solution. Reference acceptance tests check the completed reference, not your submission:

python projects/tests/l06/test_reference.py

Rubric

Score each criterion from 0–4. A submission should score at least 16/20 overall and must not score 0 on reproducibility or debugging.

Criterion4 — Strong evidence3 — Meets2 — Partial1 — Weak0 — Missing
End-to-end language-model workflowCorrect next-token/data/model/training story; training evidence is finite and tied to a decoder-only configuration; selected checkpoint is justifiedComplete workflow with minor gapsSome stages evidenced but important connection missingMostly description without run evidenceNo credible training workflow
Evaluation and controllable samplingHeld-out loss plus fixed prompt samples; decoding settings recorded; controlled comparison changes one factor; limitations statedUses held-out metric and fixed samples with settingsEvaluation present but comparison/provenance weakOne cherry-picked sample or train loss onlyNo evaluation
Failure analysis and debuggingReproduces a concrete failure, separates evidence/hypothesis, makes one focused fix/check, records result and next implicationComplete failure/debug traceFailure shown but cause/evidence reasoning incompleteVague “fixed it” noteNo failure/debug path
Reproducibility and packagingSeed, config, tokenizer/checkpoint fingerprints, environment, commands, artifact provenance, metrics, samples, and reduced validation path all align; no secretsPackage can be restored/reviewed with small omissionsImportant metadata missing or ambiguousMostly an unlabeled artifactMissing package or secrets committed
Communication and engineering judgmentExplains tensor/data contracts, resource expectations, what evidence proves, what it does not prove, and next testClear report with sensible tradeoffsUnderstandable but shallow tradeoff reasoningMostly output dumpNo explanation

Exit-skill mapping

  • Train a tiny decoder-only LM end to end: End-to-end workflow.
  • Diagnose loss/generation failures: Failure analysis and debugging; evaluation.
  • Sample controllably: Evaluation and controllable sampling.
  • Package a reproducible run: Reproducibility and packaging.

Objective checks

The repository validator verifies the reduced-path functions, required run metadata, compatible tokenizer/checkpoint fingerprints, fixed sample records, valid configuration shapes, and intentional failure rejection. Your own scoring decides whether the training/evaluation claims and explanations are convincing: each one should trace to a recorded run or artifact, so add any missing command, metric, or sample before scoring.

Assessment guardrail

Generated text does not need to match the reference sample. Tiny model quality is intentionally limited. The rubric rewards controlled evidence, correct contracts, debugging, and reproducibility rather than fluent prose alone.

Self-check before you call it done

  • Can you show the validator result, tokenizer/checkpoint fingerprints, decoder configuration, seed, environment, and replay commands?
  • Can you point to finite training and held-out-loss evidence plus fixed-prompt samples with decoding settings?
  • Can you show a one-factor sampling comparison and a failure → hypothesis → focused check → result trace?
  • Can you explain what the small model and packaged evidence establish, and what they do not establish?

Want the from-scratch version?

This project trains and packages a working tiny LLM. Want to build every part from scratch against tests and debug planted failures? Tiny LLM Builder

← Back to all projects