SFTTrainer
SFTTrainer is a trainer component in the TRL library for configuring and running supervised fine-tuning of language models.
LLM Customization and Fine-Tuning
A trainer component in the TRL library for supervised fine-tuning of transformer language models.
- How it is used
- Provides the training loop for LoRA adapters and full-parameter supervised fine-tuning of an IT support assistant.
- How deep it goes
- Walks through configuration, training and loss monitoring, with separate adapter and full-parameter workflows.
- Examples
- Uses IT support message datasets and Qwen3-4B-Instruct-2507 for a 20-step adapter run and a full-parameter run.
- What you can do after
- Apply it via TRL to configure and run adapter or full-parameter training and inspect training signals.
Read how LLM Customization and Fine-Tuning explains SFTTrainer →
Building Specialized AI Systems
A training component in the TRL library that automates supervised fine-tuning of language models.
- How it is used
- Automates supervised fine-tuning after examples have been converted into trainer-ready prompt strings.
- How deep it goes
- Explains configuration and delegated training mechanics, but stops short of low-level gradient or optimizer internals.
- Examples
- Uses formatted credit-risk prompts, applicant profiles, LoRA settings, trainer arguments, generated output, and saved model artifacts.
- What you can do after
- Operate TRL-based supervised fine-tuning by preparing formatted data, configuring training arguments, training, testing, and saving artifacts.
Read how Building Specialized AI Systems explains SFTTrainer →
Rearchitecting LLMs
SFTTrainer is a training component that performs supervised fine-tuning of language models using a configured dataset and training procedure.
- How it is used
- Trains a LoRA-adapted language model on formatted clinical examples for supervised fine-tuning.
- How deep it goes
- Configures dataset field, epochs, batch size, learning rate schedule, warmup, precision, and sequence length; leaves trainer internals unspecified.
- Examples
- Uses formatted medical notes and structured labels for extraction, then evaluates schema compliance with an “Extract:” prompt.
- What you can do after
- Apply via TRL's SFTTrainer to fine-tune an adapted model on formatted examples, then evaluate schema compliance.
Also covered in
What to know first
- language modelA language model is a computational model that represents patterns in linguistic sequences to assign probabilities, predict, generate, or evaluate language.
- low-rank adaptationLow-rank adaptation (LoRA) is a parameter-efficient fine-tuning technique that adapts a model by learning low-rank updates to its weights, typically while keeping most original weights fixed.
Related concepts
- low-rank adaptationuses · Low-rank adaptation (LoRA) is a parameter-efficient fine-tuning technique that adapts a model by learning low-rank updates to its weights, typically while keeping most original weights fixed.
- JSONLuses · JSON Lines (JSONL) is a line-oriented text format in which each line contains one complete, independently parseable JSON value.
- MLflowused by · MLflow is an open-source platform for managing the machine-learning lifecycle, including experiment tracking, model and artifact management, and model deployment.
- QLoRAuses · QLoRA is a parameter-efficient fine-tuning method that combines a quantized pretrained model with trainable low-rank adapters.
- supervised fine-tuninguses · Supervised fine-tuning is further training a pretrained model on labeled input-output examples to adapt its behavior to desired outputs.
Questions about SFTTrainer
What is SFTTrainer?
SFTTrainer is a trainer component in the TRL library for configuring and running supervised fine-tuning of language models.
Which Manning books explain SFTTrainer?
LLM Customization and Fine-Tuning, Building Specialized AI Systems and Rearchitecting LLMs.
What should I know before learning SFTTrainer?
Manning books that teach SFTTrainer usually introduce language model and low-rank adaptation first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


