AI Space

Remember SFT

Full name: Supervised Fine-Tuning

Memory aid: Supervised examples Fine-Tune behavior.

Fine-tuning does not automatically keep knowledge current.

Study area: AI & machine learning · Batch 5

Relevant study for: Azure AI Fundamentals AI-901 · Azure AI Apps and Agents Developer AI-103 · Azure AI Fundamentals (retired) AI-900 · Azure AI Engineer (retired) AI-102

Practice with exam flashcards →

AI Models & Assistants / Knowledge library

SFT (Supervised Fine-Tuning)

Supervised fine tuning on examples of desired responses

Model adaptation method

Why learn SFT (Supervised Fine-Tuning)?

Teaches a model a task format, response style, or demonstrated behavior. Dataset quality and held-out evaluation are essential because imitating examples does not guarantee factual correctness or broad generalization.

The problem it solves

Adapts pretrained capabilities to a demonstrated task or response pattern using explicit target examples.

Where it came from

Supervised fine-tuning adapts a pretrained model using examples of desired outputs. In instruction tuning, those examples often pair prompts or conversations with target assistant responses. It can be a standalone adaptation step or precede preference optimization, and may update all weights or a smaller set of adapter parameters.

Build your understanding

Work through these exercises in order. Try the task before opening a reference.

  1. Write five prompt-response examples that demonstrate a consistent output format.
  2. Separate training examples from held-out prompts before any fine-tuning.
  3. Inspect a chat template and identify which tokens contribute to the training loss.
  4. Compare full-parameter fine-tuning with an adapter-based setup conceptually.
  5. Define an evaluation for format adherence and factual accuracy on unseen prompts.

Documentation and sources

Connect the ideas

Explore next

Supervised LearningRLHF (Reinforcement Learning from Human Feedback)DPO (Direct Preference Optimization)LoRA AdaptersIn-Context Learning (ICL)LLM (Large Language Model)PEFT (Parameter-Efficient Fine-Tuning)Transfer Learning

Real World Example

Illustrative business scenario · AI-generated from linked documentation · Not a measured customer case study

Legal Document Summarization Fine-Tuning

Legal tech firms providing automated contract analysis for corporate law departments.

The business problem

Generic base models frequently hallucinate legal terminology or fail to adhere to the specific, dense formatting requirements of corporate contract summaries, leading to costly manual review cycles.

How this topic solves it

Supervised Fine-Tuning (SFT) allows the firm to train a base model on a curated dataset of high-quality, human-verified contract summaries, forcing the model to learn the precise structure and professional tone required for legal documentation.

  1. Prepare a conversational dataset containing pairs of raw legal contracts as user inputs and expert-verified summaries as assistant outputs.
  2. Define a chat template to ensure the model correctly distinguishes between the contract text and the required summary structure.
  3. Configure the SFTTrainer with assistant_only_loss=True to ensure the model focuses its learning exclusively on the quality of the generated summary rather than the input contract text.
  4. Execute the training process using a PEFT configuration to efficiently adapt the model while minimizing hardware resource consumption.
  5. Validate the model on a held-out set of contracts to ensure adherence to the desired summary format.
SFT Training Pipeline for Legal Summaries · Process flow

The flow shows how raw legal data is transformed into a specialized model.

Raw Contracts

Input text corpus

Dataset Formatting

Applying chat templates

SFTTrainer

Supervised learning engine

Fine-Tuned Model

Specialized summarizer

  • Raw Contracts → preprocess → Dataset Formatting
  • Dataset Formatting → train → SFTTrainer
  • SFTTrainer → output → Fine-Tuned Model

Implementation example

This code initializes the SFTTrainer with a configuration that ensures the model learns specifically from the assistant's summaries, ignoring the input contract text during loss calculation.

python · Illustrative code; not executed or production-validated.

from trl import SFTTrainer, SFTConfig
# Configure trainer to focus loss only on assistant responses
training_args = SFTConfig(assistant_only_loss=True)
trainer = SFTTrainer(
    model="Qwen/Qwen3-0.6B",
    train_dataset=legal_dataset,
    args=training_args
)
trainer.train()

Expected business outcome

The model consistently produces summaries that mirror the structure and professional precision of human-written legal documents, significantly reducing the time required for attorney oversight.

Limitations and checks

Over-fitting to the training examples can lead to a loss of general reasoning capabilities; this is checked by monitoring the validation loss and evaluating the model on diverse, unseen contract types.

Sources

Generated 2026-10-18 with gemini-3.1-flash-lite. Your assessment includes two questions about this example.

Catalog source: technology-maxxing. This page reproduces the existing catalog’s learning material and source links.