آخر تحديث:
Supervised fine-tuning (SFT) is the step that turns a base language model into something that follows instructions. Before RLHF, DPO, or Constitutional AI can align preferences, the model usually needs SFT to learn the basic shape of assistant behavior. This guide explains what SFT is, how it works, and where it sits in the LLM training stack.
Supervised fine-tuning (SFT) is a training phase where a pre-trained language model learns from curated input-output examples. Each example pairs a prompt with an ideal response written or verified by humans. Unlike pre-training, which predicts the next token across billions of web pages, SFT teaches task-specific behavior: answer questions clearly, follow formatting instructions, refuse unsafe requests, and adopt a consistent assistant persona. SFT is the foundation of modern instruction-tuned models.
Typical LLM development order: 1. Pre-training: Learn language and world knowledge from massive text corpora. 2. SFT: Learn to follow instructions from demonstration data. 3. Preference alignment: RLHF, DPO, or Constitutional AI to refine behavior. 4. Deployment: Serve through APIs and products. Without SFT, a base model may continue raw text completion instead of answering as an assistant. Alignment methods assume SFT has already established instruction-following basics.
SFT datasets contain high-quality demonstrations across diverse tasks: Question answering with accurate, sourced responses. Summarization with appropriate length and focus. Code generation with working, commented examples. Multi-turn conversations with coherent context handling. Refusals for harmful or out-of-scope requests. Data quality matters more than quantity. A few thousand excellent examples often outperform millions of noisy ones. Teams invest in writer guidelines, expert review, and deduplication to keep SFT data clean.
Training treats each demonstration as a supervised learning target. The model sees the prompt tokens and learns to predict the response tokens with standard cross-entropy loss. Only response tokens typically contribute to the loss; prompt tokens are masked so the model learns to answer, not to repeat the question. Hyperparameters (learning rate, epochs, batch size) are tuned carefully. Too much SFT can cause overfitting to demonstration style or catastrophic forgetting of pre-trained knowledge. Too little leaves the model undertrained for instruction following.
General SFT teaches broad assistant behavior. Domain SFT teaches professional work: legal drafting patterns, financial analysis formats, clinical note structures, or tax research workflows. For enterprise deployment, domain SFT on proprietary or licensed data is often the highest-leverage customization step before preference alignment. It grounds the model in how your organization actually works, not how the open internet writes.