AI Engineering
/
Model Adaptation
/

Decide whether to fine-tune

Model Adaptation · 90 minutes

Decide whether to fine-tune

Decide whether a feedback assistant's failures call for prompting, retrieval, or fine-tuning, and explain the reviewed data, grouped split, and baseline comparison that fine-tuning would need.

Easy
Conceptual

Conceptual scenario

1.5 h

Used in interview rounds:

Technical Screen (Easy)

Overview

Learn when changing a model is justified, what training examples teach, and how to judge whether adaptation improves a real application. You practice by classifying the failures of a fictional feedback assistant and deciding what evidence fine-tuning would need before you trust it.

Study time: 90 minutes

Interview format: Conceptual screen with a failure-classification exercise

By the end you can

  • Distinguish prompting, retrieval, supervised fine-tuning, and preference learning by what each one changes
  • Match an observed failure to the first intervention worth investigating, and say why
  • Describe a trustworthy training dataset: reviewed targets, provenance, coverage, and privacy
  • Split related examples so that evaluation measures generalization rather than recognition
  • Explain why a lower training loss is insufficient evidence of product improvement, and what to measure instead

Prerequisites

Helpful background: Basic familiarity with JSON and with how a chat model receives system and user messages helps.

This topic covers choosing between prompting, retrieval, and fine-tuning, validating training data, and proving that specialization helped. Training infrastructure and distributed training are out of scope.

What adaptation changes

Model adaptation changes learned behavior using additional training. Full fine-tuning updates the model's weights broadly. Parameter-efficient methods train a smaller set of parameters, such as adapters. Prompting supplies instructions at inference time without updating weights. Retrieval supplies external evidence at inference time.

These techniques can be combined. Suppose a coding-practice platform retrieves the current grading rubric, uses a fine-tuned model to deliver consistent feedback, and validates the model's JSON with application code. No single technique replaces the others' responsibilities.

Choose the intervention from the failure

Observed failureFirst intervention to investigateWhy
Missing instructionsImprove prompt and examplesClarifies expected behavior cheaply
Missing or changing factsImprove retrieval and source accessSupplies evidence without retraining for each update
Unstable output structureSchema constraints and validationEnforces the machine-readable contract
Repeated style or task errors despite a strong baselineCurated supervised fine-tuningTeaches repeated input/output patterns
Two acceptable outputs differ in usefulnessPreference data and optimizationEncodes comparative judgments
Incorrect permission enforcementBackend authorizationAccess control requires deterministic enforcement

Fine-tuning may teach information, but it is usually a poor sole mechanism for frequently changing facts, exact citations, or tenant-specific access rules. Diagnose retrieval failures before training the generator to compensate for missing evidence.

Supervised fine-tuning

Supervised fine-tuning, or SFT, uses examples of desired outputs conditioned on inputs. During training, a language model is encouraged to assign higher probability to the target response tokens.

An example is a demonstration, not merely a topic label. If all feedback examples praise incorrect code, training can reinforce that behavior. If targets always include the full solution, the model may reveal answers even when a learner requests a hint.

For a coding-practice feedback assistant, a useful example contains the exercise, the learner's submission, the rubric or other relevant evidence, the requested help level, and an expert-reviewed response. Include only context available at inference. A target relying on hidden reviewer notes cannot be reproduced reliably when those notes disappear.

Training examples and formatting

This is an illustrative record, not a universal provider upload schema:

{
  "id": "feedback-001",
  "group_id": "exercise-family-17",
  "messages": [
    {"role": "system", "content": "Give one useful hint without the final solution."},
    {"role": "user", "content": "My loop misses the last array element. What should I inspect?"},
    {"role": "assistant", "content": "Compare your loop's stopping condition with the index of the final element."}
  ]
}

Roles, special tokens, and chat templates affect the token sequence the model actually sees. Training and inference must use compatible formatting. Inspect several rendered examples before training. Do not assume that a valid JSON record creates a correct training sequence.

Dataset quality

Prefer reviewed, representative demonstrations over indiscriminate volume. Cover common inputs, ambiguous cases, mistakes, legitimate refusals, and edge cases. Include difficult examples only when their targets are reliable.

Track provenance, permitted use, reviewer decisions, dataset version, and the intended skill. Remove credentials and unnecessary personal information. A private dataset does not guarantee that a trained model cannot reproduce sensitive text.

Synthetic examples can expand coverage, but repeated model mistakes can become training targets. Review samples and keep evaluation independent of the generation process. Many paraphrases of the same exercise do not provide many independent tests of generalization.

Train, validation, and test sets

Training examples update parameters. Validation examples guide model selection and training decisions. A held-out test set estimates performance after those choices are complete.

Split related examples together. Put variants of one exercise, source document, or conversation into the same partition. Otherwise a model can appear to generalize while recognizing a lightly edited training example. For time-sensitive behavior, a temporal holdout may better represent future traffic.

Do not repeatedly tune against the final test set. Once it influences decisions, it has effectively become a development set; establish a new independent evaluation when needed.

Basic training terms

TermMeaningPractical implication
EpochOne pass over the training datasetMore passes may increase memorization
Learning rateScale of parameter updatesToo large can destabilize learning
Batch sizeExamples or tokens contributing to an updateAffects memory and optimization
LossTraining objective valueUseful diagnostic, not a product score
CheckpointSaved training state or modelEnables comparison and recovery
OverfittingTraining-specific improvement without generalizationRequires held-out evaluation

A model can lower its loss by learning predictable formatting while remaining wrong on important reasoning cases. Evaluate the actual behavior you care about.

Full fine-tuning and adapters

Full fine-tuning changes many or all model parameters. Adapters add a smaller trainable component to a frozen base. LoRA represents selected weight updates with low-rank matrices. Its central benefit is reducing trainable parameter and optimizer-state requirements; the frozen model still needs memory and computation.

An adapter depends on a compatible base model and configuration. Treat the base revision, tokenizer, chat template, and adapter as one release bundle. An adapter file alone does not fully specify the deployed model.

Preference learning

Preference data compares responses to the same input. Reviewers choose which response better satisfies a defined rubric. The goal might be better correctness, more useful hints, or less unnecessary verbosity.

A preferred response is not automatically a flawless response. If both candidates are wrong, record that issue rather than silently turning the less wrong output into a gold demonstration. Keep criteria explicit so a preference for polished prose does not conceal incorrect code.

Evaluate the decision

Compare against the strongest practical prompting baseline using the same held-out inputs and comparable generation settings. Evaluate correctness, instruction adherence, structured-output validity, unsupported claims, and appropriate refusal behavior. Include regression cases from unrelated but important capabilities.

Measure cost and latency under the actual serving configuration. Training expense is only part of the lifecycle cost; deployment, maintenance, new data review, and regression testing also matter.

Worked comparison: better JSON, more leaks

Worked example

These numbers are illustrative, not benchmark results. A fine-tuned candidate and the prompt baseline answer the same 100 held-out cases with the same generation settings. Of those cases, 40 ask for a hint only.

CheckDenominatorBaselineCandidate
Valid JSON100 cases95 (95%)98 (98%)
Complete solution revealed40 hint-only cases2 (5%)12 (30%)

Format validity rose by 3 percentage points, while solution leaks on hint-only requests rose by 25 points, from 1 in 20 to 3 in 10. The candidate is not ready simply because its formatting improved.

Give each rate its own denominator. Reported against all 100 cases, the same 12 leaks would read as 12%, which hides how often hint-only requests are affected.

Classify five failures

Use the table in "Choose the intervention from the failure" and the advice in "Evaluate the decision".

Predict the outcome

Classify five failures

Suppose a coding-practice platform's feedback assistant shows the five failures below. For each one, propose the first intervention you would investigate and a measurable success criterion, then reveal the answers.

FailureObserved exampleFirst interventionSuccess criterion
Stale documentationA reply says learners may submit 20 times a day and cites Submission Policy 2025. The current Submission Policy 2026 allows 50.??
Inconsistent toneExplanation-level replies to similar questions range from a single sentence to a long review of the learner's whole file that never answers the question asked.??
Leaked authorization dataA learner on the free plan receives a hint that quotes the premium-only editorial for the exercise.??
Invalid JSONThe interface expects an object with hint, help_level, and citations fields, but some responses arrive wrapped in prose or cut off before the closing brace.??
Incorrect hintsFor an off-by-one error in a slice, the hint tells the learner to rewrite a loop condition that is already correct.??

Plan training-example categories

This continues the feedback assistant from the classification exercise.

Design exercise

Plan training-example categories

Suppose the coding-practice platform's team approves a small SFT pilot for hint-level feedback. Design ten distinct categories of training examples. For each category, say what the target reply must do, and whether an expert engineer must review the target or a trained general reviewer is enough.

Requirements

  • Ten categories that differ in the learner's situation, not only in wording
  • The target behavior at hint level for each category
  • The review level each category needs

Constraints

  • Targets use only context available at inference: exercise, code, test output, help level, and retrieved passages
  • No hint-level target includes a full solution

Deliverables

  • A table of ten categories with the target behavior and review level
  • One or two sentences on how the categories carry into the split and the evaluation

Completion checklist

  • I can match a failure to the first intervention to investigate and say why.
  • I can describe what one training example contains and which past responses to leave out.
  • I can split examples so that variants of one exercise stay in one partition.
  • I can name the baseline, the held-out measurements, and the regressions that decide whether adaptation helped.
  • I can list what stays outside the model after fine-tuning.

Sources

The platform, feedback samples, runtime guide versions, review counts, fixtures, and rubric are original synthetic teaching material about a fictional application. No training run or product benchmark is claimed. Study times and readiness thresholds are editorial estimates. Product and library details are as of November 2026.

Practice the interview question

Answer it in your own words before you look at the reference answer.