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

← Week 22: Fine-Tuning and Adaptation

Week 22 / Lesson 1

Choosing and preparing an adaptation task

Decide whether an error calls for prompting, retrieval, tools, skills, or parameter updates.

Section 1.1 1 of 7

Overview

Focus

Decide whether an error calls for prompting, retrieval, tools, skills, or parameter updates.

Your route through the lesson

  • 1.2 Diagnosing missing information versus inconsistent behavior
  • 1.3 Curating instruction examples with rights and provenance
  • 1.4 Source-grouped splits and supervised fine-tuning
  • 1.5 Put it into practice
  • 1.6 Guided comparison
  • 1.7 Changing facts that belong in retrieval

All required teaching is included here. Review selections are saved. Choose a correct answer for every question to continue; retries are unlimited. Study time and personal notes are optional.

Section 1.2 2 of 7

Diagnosing missing information versus inconsistent behavior

Focus

Diagnose whether a failure needs information, behavior, execution, or parameter changes.

Adaptation changes a system to serve a narrower task. Before changing weights, identify the first failing mechanism. A model missing a current product price needs a trustworthy source of current information. A model that has the relevant facts but repeatedly emits the wrong required format may need clearer instructions, constrained output, or eventually supervised fine-tuning.

Retrieval-augmented generation supplies selected external evidence at request time. It is useful for changing facts and citations. Tools perform deterministic calculations or authorized effects. Skills package reusable procedures and resource instructions. Prompting explains the immediate task. Parameter updates alter learned behavior across future inputs, but do not provide a reliable database or a permission boundary.

Consider an assistant that quotes yesterday's shipping fee because its stored knowledge is old. Training on today's fee would soon become stale again. Retrieval from the maintained fee table is the more direct intervention. For persistent style or classification errors on stable well-defined labels, a curated training set can be appropriate after simpler baselines are measured. Preserve that baseline so adaptation can be compared against an actual prior behavior rather than assumed improvement.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. A shipping fee changes daily. Which intervention directly supplies current facts?
2. A calculator tool returns the wrong numeric result. What should be inspected first?
3. What must be preserved before adaptation?

Section 1.3 3 of 7

Curating instruction examples with rights and provenance

Focus

Curate instruction examples with source rights, provenance, and contradiction checks.

A supervised instruction example contains an input and a desired output. Its target teaches the model what behavior to imitate. Quality depends on more than volume: examples should reflect the intended task, use consistent labels, and contain no secrets or forbidden personal data. Provenance records source, collection method, permitted use, and review decisions.

Two identical inputs with contradictory targets create incompatible supervision. If status alpha is labeled healthy in one row and failed in another with no additional context, the dataset cannot teach a single deterministic rule. Quarantine the conflict and inspect the source; do not silently keep the label that improves a later score. Exact duplicates also overweight one pattern without adding independent information.

Rights checks ask whether the material can be used for this training purpose. Public accessibility alone does not settle that question. For the core lab, synthetic status examples are authored for the exercise and need no private records. Keep a record of removals and label changes so the dataset revision is auditable. Redaction should be tested: replacing a name while leaving a secret access token elsewhere does not make the example safe.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Identical input text has healthy and failed targets with no extra context. What should happen?
2. A public page can be read without login. What still needs checking before training?
3. A name is redacted but a secret token remains. Is the row ready?

Section 1.4 4 of 7

Source-grouped splits and supervised fine-tuning

Focus

Split by source groups and explain supervised fine-tuning without test leakage.

Supervised fine-tuning starts from an existing model and updates selected parameters to reduce error on labeled examples. Training cases determine gradient updates. Validation cases guide choices such as learning rate or stopping point. A reserved test set estimates behavior after those choices are fixed. Repeatedly tuning against the test set turns it into another validation set.

Group related records before splitting. If one manual yields ten paraphrases, placing some in training and some in testing leaks shared source information. A source-grouped split keeps all records from that manual on one side. Time-based splits may additionally be needed when deployment predicts future cases.

For the synthetic audit, manual-b is a training source and manual-c is reserved. The contradictory manual-a rows are quarantined before use. Their removal is a data-quality decision, not an opportunity to move difficult examples into training until the score improves. Record source groups, dataset hash, label version, and baseline configuration. A small clean set can teach the mechanism, but its limited coverage must remain explicit when interpreting later task gains.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Ten paraphrases derive from one manual. How should a source-grouped split treat them?
2. A team repeatedly changes training after inspecting reserved test errors. What happened?
3. What distinguishes training from validation?

Section 1.5 5 of 7

Put it into practice

Focus

Run a small audit and choose an intervention before scheduling any training.

Save week22.py and run python week22.py --lesson 1. This audit uses only the standard library. A list of dictionaries stores synthetic source, text, and target fields. The setdefault method records the first label seen for each text; a later unequal label is appended to a conflict list. Sets represent source groups, and the & operator computes their intersection.

Expected output quarantines status alpha and reports disjoint manual-b training and manual-c reserved sources. The assertion verifies that the source intersection is empty. This is a minimal contradiction and split audit, not a complete secret detector or rights review system. The synthetic rights note identifies why these records are available for the exercise.

Extend this same audit with exact duplicate detection and a deliberately obvious synthetic secret marker such as LAB_SECRET_ONLY. Remove or quarantine it before constructing a training partition. Choose retrieval for changing facts and adaptation only for a stable behavior pattern with sufficient clean examples. No actual parameter update occurs in this lesson; that execution follows in the adapter lesson.

Download this week’s Python lab ↓

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. The train sources are {b}; test sources are {c}. What is their intersection?
2. A script detects label conflicts. Has it proven all secrets absent?
3. An audit runs without any optimizer. What competency has it demonstrated?

Section 1.6 6 of 7

Guided comparison

Focus

Explain the audit result and preserve the distinction between a clean example and broad readiness.

The worked audit finds status alpha twice with different labels, so that text is excluded from the usable set until resolved. manual-b and manual-c remain independent source groups. The expected train-test intersection is empty. These observations establish the declared source partition, not a guarantee that every future example is independent.

An unsafe alternative deduplicates by keeping whichever target appears last. That removes the visible conflict while silently choosing a label without evidence. Another unsafe alternative splits all four rows randomly: conflicting or near-duplicate records can then appear on both sides and produce misleading scores. The correct workflow resolves data meaning before optimizing the model.

The audit is also an intervention checkpoint. A failed current-fact lookup should lead back to retrieval and source maintenance rather than automatically to fine-tuning. A stable classification behavior can proceed to a small training experiment with an unchanged reserved set. Keep the data revision and baseline result beside the training configuration. That record lets a later reviewer determine whether measured gains came from parameter learning, changed labels, easier cases, or a different source split.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Keeping the last of two conflicting labels removes the warning. What remains wrong?
2. An adapted score improves after difficult test rows are removed. What is uncertain?
3. A stable classifier task has clean grouped data. What is a sensible next step?

Section 1.7 7 of 7

Changing facts that belong in retrieval

Focus

Keep frequently changing facts in retrieval while adapting only justified behavior.

A support assistant must report the current maintenance schedule and always separate confirmed facts from suggestions. The schedule changes weekly, while the distinction between facts and suggestions is stable. These are two different adaptation needs within one application.

Store schedules in a maintained retrieval source with timestamps and access rules. Evaluate whether the assistant cites the correct current entry. For the stable response behavior, first try a clear prompt and structured fields. If repeated errors remain across clean examples, supervised adaptation may teach that formatting pattern. Training examples should reference synthetic or fixed schedules so they do not encourage memorizing an obsolete timetable.

Evaluation separates the claims: current schedule accuracy depends on retrieval freshness, while correct fact-versus-suggestion structure depends on behavior. A model can improve structure and still cite an outdated schedule. The release gate must retain both checks. This transfer prevents fine-tuning from becoming a catch-all explanation for every failure and preserves the system's ability to update information without retraining weights each week.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. A schedule changes weekly but output structure is stable. Which pairing fits?
2. An adapted answer has perfect structure but cites last month’s schedule. What fails?
3. Why keep schedule and behavior checks separate?

Your personal notes

Optional, ungraded, and saved only in this browser. Export a backup from the Academy homepage to keep them.

References and further reading
Ask your own AI assistant

Copy this prompt into an assistant you already use. Nothing is sent automatically, and your personal notes are not included.

Next lesson: Training low-rank adapters →