Skip to main content
Supervised fine-tuning (SFT) trains a model on labeled chat examples rather than through trial-and-error with rewards. It’s useful for distillation (training a smaller model on outputs from a larger teacher model), teaching a specific output style or format, and warming up a model before RL training so it starts from a stronger baseline. ART supports SFT on both LocalBackend and ServerlessBackend.

Data format

SFT training data is a JSONL file where each line is a JSON object with messages and optionally tools. Here’s a simple example:
To train on tool-call conversations, include a tools array and tool_calls in the assistant message:
Each line must follow these rules:
  • messages (required) β€” a non-empty list of chat messages. Each message has a role (system, user, assistant, or tool) and content. The last message must be from the assistant role.
  • tools (optional) β€” a list of tool/function definitions, following the OpenAI tool format.
Messages follow the OpenAI chat format, including support for tool_calls in assistant messages.
Only the assistant’s response tokens contribute to the training loss. Instruction and user tokens are automatically masked so the model learns to produce better responses without memorizing prompts.

Training from a JSONL file

For large datasets, use train_sft_from_file. It handles batching and applies a learning rate schedule automatically.

Distillation

Distillation trains a smaller model on completions from a larger teacher model. Generate responses from the teacher, wrap them as trajectories, and fine-tune:

SFT as warmup before RL

A common pattern is to run SFT first to give the model a head start, then switch to RL for further improvement. ART supports switching between SFT and RL training seamlessly within the same run:
This works because both SFT and RL train the same LoRA adapter. After SFT completes, RL continues from the updated weights.

Local vs Serverless

Both backends support SFT with the same API. The key differences are in how training executes: The ServerlessBackend requires a W&B API key. See the backend docs for setup instructions.