Free self-study · No account needed · Progress stays in this browser. Back it up before clearing site data or changing devices.

← All weeks

Understanding Modern AI / Week 04

Training, Alignment, and Inference

Build a miniature language model. Train the accumulated tiny decoder, compare checkpoints and sampling, and save a reproducible model.

Your lessons

  1. 01

    Training a miniature language model

    60 minutes planned · 7 sections
    Start →
  2. 02

    Instruction tuning, preferences, and distillation

    60 minutes planned · 8 sections
    Start →
  3. 03

    Inference, sampling, and computation

    60 minutes planned · 8 sections
    Start →

// Put it into practice

A miniature language model

  1. Download week04.py from a lesson's practice section. Follow its setup instructions before running it.
  2. Lesson 1: Train the Week 3 model from a supplied small starter and reload a saved checkpoint.
  3. Lesson 2: Classify complete training records and match each approach to what it changes.
  4. Lesson 3: Calculate sampling probabilities, compare saved checkpoints, and measure a tiny local model on short and long prompts.
  5. Run the supplied assertions and record actual results; a simulated contract check does not certify real model quality.
Download week 4 Python lab ↓

Read the script’s setup instructions and run it on your own computer. The website does not execute code or verify your results.

// Independent work

W04-LAB

Week 4: A miniature language model

Train the accumulated tiny decoder, compare checkpoints and sampling, and save a reproducible model.

Extend the guided artifact rather than start a second project. Reload the checkpoint; report held-out loss and explain attention with a complete small example.

What to produce

  • A miniature language model
  • Setup commands, data or generation procedure, versions, and recorded outputs
  • Acceptance results and a precise limitation

Check your work

  • Reload the checkpoint; report held-out loss and explain attention with a complete small example.
  • Each claimed execution is supported by actual saved output.
  • Fixture results and real model results are identified separately.
  • Setup and reproduction use the taught tools without private credentials.
Self-assessment rubric
Technical correctness · 35 points
Implementation or analysis follows the relevant technical mechanism and handles the stated case.
Evaluation and evidence · 30 points
Reproducible tests, appropriate baseline, and accurate interpretation.
Engineering quality · 20 points
Clear structure, safe boundaries, and usable reproduction instructions.
Explanation and reflection · 15 points
Explains tradeoffs, limitations, and next experiment with evidence.

// Phase milestone

M01

Miniature Language Model

Build and explain a miniature language model.

Must demonstrate a causal attention mechanism, held-out evaluation, and reproducible output.

What to produce

  • Runnable code with setup instructions
  • Training and held-out evaluation results
  • Attention explanation and checkpoint/sampling comparison

Check your work

  • Must demonstrate a causal attention mechanism, held-out evaluation, and reproducible output.
  • Setup and reproduction steps are complete.
  • Known limitations are explicit; no unsupported security or quality claims.
Self-assessment rubric
Functional integration · 30 points
Required components work together in a reproducible end-to-end workflow.
Security and reliability · 25 points
Boundaries, failure handling, and recovery are demonstrated with evidence.
Evaluation evidence · 25 points
Appropriate test set, clear measures, honest interpretation, and traceability.
Documentation and explanation · 20 points
Architecture, setup, tradeoffs, and limitations are understandable.

// Retrieve before you reread

Week 4 knowledge check

Try all 6 questions. Check your answers, review the explanations, and retry whenever you like. Answers are checked on this device.

1. A corpus contains overlapping windows from each source document. When should source partitions be made?
2. What does a compatible model reload need besides its learned weights?
3. A student learns from a frozen teacher’s probabilities [0.7,0.3]. What method does that illustrate?
4. Preferred and rejected responses are used to update a policy without fitting a separate explicit reward model. Which approach is being described?
5. Probabilities are [0.5,0.3,0.2] and nucleus threshold is 0.7. Which retained probabilities result after renormalization?
6. A request grows twice as long while model weights are unchanged. Which statement fits a linear key-value cache estimate?

Next: week 5 →