Skip to content
AyoKoding

Overview

Prerequisites

  • Prior topics: creating-ai-powered-apps (prompting, structured output, and RAG -- the alternatives this course requires you to exhaust first) -- [Unverified] this course is not yet present in the AyoKoding course library on disk, so no link is given here; evaluating-ai-systems-in-depth (hard prerequisite: a fine-tune with no eval is unfalsifiable, and every decision in this course is an eval comparison) -- [Unverified] not yet present in the AyoKoding course library on disk; Statistics for Evaluation (the base-versus-adapted comparison is a paired significance test, not two printed numbers); Inference Serving & Model Deployment (where an adapter is actually served); data-engineering (the dataset pipeline) -- [Unverified] not yet present in the AyoKoding course library on disk; just enough python (4 · Just Enough Python) is assumed for reading and writing fully type-annotated Python.
  • Tools & environment: a macOS/Linux terminal; Python 3.13, the standard library only (json, math, dataclasses, pathlib, typing) -- no fine-tuning library, no network call, no real Hugging Face download, and no paid API key is required anywhere in this topic, deliberately. Every base model, tokenizer, and trainer this topic's examples reference is mocked exactly the way a real object's shape and failure modes behave.
  • Assumed knowledge: the model-application material and its eval discipline; what tokens and a context window are; loading and transforming a dataset in Python; the idea of gradient-based training at a conceptual level. No deep-learning course is assumed -- this course explains what it needs and does not teach model architecture or backpropagation theory.

Why this exists -- the big idea

The problem before the solution: fine-tuning is the intuitive response to "the model does not do what I want," and it is usually the wrong one. The one idea worth keeping if you forget everything else: fine-tuning teaches behaviour, not facts -- exhaust prompting, retrieval, and scoping first, and when you do adapt, the dataset is the whole job.

Cross-cutting big ideas: correctness-vs-pragmatism -- adaptation is a costly bet on a measured gap, not a default; abstraction-and-its-cost -- an adapter is a compact approximation of a full fine-tune, with the trade-offs approximations carry; taming-state -- adapted weights are a versioned artefact with a lifecycle, not a configuration change.

Confirm your toolchain

Every example in this topic is standard-library-only -- no fine-tuning library, no network call, no real GPU, and no paid API key required anywhere:

$ python3 --version
Python 3.13.12
$ python3 -c "import json, math, dataclasses, pathlib, typing; print('stdlib primitives OK')"
stdlib primitives OK
$ pyright --version
pyright 1.1.411
$ ruff --version
ruff 0.15.9

Captured 2026-07-26 -- these are point-in-time patch versions, not a durable claim; see this topic's Accuracy notes if you are reading this after a later patch has shipped.

Every worked example is a complete, self-contained, fully type-annotated (strict pyright) runnable Python file colocated under learning/code/, actually executed against Python 3.13 to capture its documented output -- every printed value on this topic's pages is a genuine, captured transcript, never a fabricated one. Every code-bearing worked example is independently runnable with no cross-example imports; the capstone's five files are the sole exception, each committing a JSON artefact the next step's file reads, so the five steps run as one small, ordered project.

How this topic's examples are organized

  • Band A -- The Decision, Not the Technique (Examples 1-16, 51-58) -- measuring a real gap, triaging behaviour-shaped versus knowledge-shaped complaints, exhausting prompting/retrieval/scoping in that order, the written decision gate, legitimate cases the gate should pass, and the costs nobody budgets.
  • Band B -- The Dataset and the Training Run (Examples 17-34, 59-67) -- assembling and auditing a supervised fine-tuning dataset, sourcing strategies and their biases, leak-free splits, full fine-tuning versus parameter-efficient adapters, rank as a capacity knob, and the hyperparameters that actually matter.
  • Band C -- Evaluation, Distillation, and Operation (Examples 35-50, 68-75) -- the paired comparison against the base, the forgetting-regression suite, overfitting invisible in training loss, distillation's ceiling, serving and hot-swapping adapters, version pinning, and retirement.
  • Capstone -- the complete adaptation arc for one real behaviour gap: a measured decision gate, a curated and audited dataset, a rank-justified adapter, a paired evaluation with a forgetting-regression suite, a served swappable artefact, and a written maintenance and retirement plan.

Read more

  • AI Engineering: Building Applications with Foundation Models -- Chip Huyen (O'Reilly, 2025). The corrected source for this course's "exhaust prompting/RAG/scoping before fine-tuning" framing -- see this topic's Accuracy notes for the correction detail.
  • LoRA: Low-Rank Adaptation of Large Language Models -- Hu, Shen, Wallis, Allen-Zhu, Li, S. Wang, L. Wang & Chen, arXiv:2106.09685 (2021). The originating paper for the low-rank-adaptation principle this course teaches as durable. https://arxiv.org/abs/2106.09685
  • Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks -- Patrick Lewis et al. (2020). The alternative this course requires you to rule out before adapting weights. https://arxiv.org/abs/2005.11401
  • Language Models are Few-Shot Learners -- Tom B. Brown et al. (2020). The result that made instruction-and-example steering a substitute for task-specific training. https://arxiv.org/abs/2005.14165

Examples by Level

Beginner (Examples 1–16, 51–58)

Intermediate (Examples 17–34, 59–67)

Advanced (Examples 35–50, 68–75)


← Previous: Overview · Next: Band A: The Decision, Not the Technique

Last updated July 25, 2026

Command Palette

Search for a command to run...