Skip to main content
Combine supervised fine-tuning and reinforcement learning in a single recipe. Train on demonstrations first to bootstrap output format, then continue with RL to improve quality.

Why two stages?

SFT teaches the model to imitate a curated set of demonstrations — picking up format, structure, and style from labeled examples. It generalizes from them, but remains anchored to their distribution: the model learns how good responses look, not necessarily how to reason toward them. RL builds on this foundation, optimizing behavior through feedback signals rather than imitation. Guided by a reward function, it can surface behaviors and strategies that no demonstration explicitly encoded — though the quality of what it discovers is ultimately bounded by the quality of the signal it’s optimizing for. Without SFT, RL must spend samples learning format basics — JSON structure, required fields, response conventions — rather than optimizing for quality. These constraints are far cheaper to teach through direct imitation than through reward signals, which are poorly suited to enforce rigid structural rules. SFT bootstraps format compliance efficiently, giving RL a well-initialized starting point. From there, RL can focus its signal on what matters: refining quality beyond what the demonstrations captured.

The two-stage recipe

This is a complete @recipe_main that orchestrates both SFT and RL in sequence. This example uses GSPO for the RL stage, but other algorithms (GRPO, ENVGRPO, ENVGSPO) work the same way:

SFT vs. RL: Complementary objectives

SFT (Supervised Fine-Tuning)
  • Learns to imitate labeled demonstrations — anchored to the distribution of examples
  • Uses supervised loss (typically cross-entropy)
  • Converges quickly: few epochs on a small demonstration set (early stopping avoids overfitting)
  • Best for: bootstrapping output format, structure, or style
RL (e.g., GSPO, GRPO, PPO)
  • Learns from feedback signals — grader scores, preference pairs, or other reward signals depending on the algorithm
  • Can discover behaviors beyond the demonstrations
  • Step-based; runs for many steps driven by online rollout generation, not dataset size
  • Best for: optimizing quality, refining output, and improving beyond what demonstrations capture
Together, they form a complete pipeline: imitate first, then improve.

When to skip SFT

  • Base model already formats correctly: If the vast majority of generations produce valid output, skip SFT and start with RL directly.
  • No demonstration data available: SFT requires labeled examples. If you only have unlabeled prompts, start with RL directly.
  • Output is simple: Plain text, single categories, or yes/no don’t need SFT. Complex, multi-field structured output benefits most.
  • Graders are lenient on format: If graders score semantically rather than penalizing parsing errors, malformed output is less costly.

Key takeaways

  1. SFT imitates, RL improves — SFT is anchored to its demonstrations; RL optimizes beyond them through reward signals
  2. SFT is efficient — A small demonstration set and few epochs converge quickly; stop early to avoid overfitting
  3. Dataset format depends on the algorithm — SFT needs full conversations with expected outputs; GSPO and GRPO use prompt-only datasets; DPO uses preference pairs
  4. Consider skipping SFT — If the base model already formats correctly, has no available demonstrations, or produces simple outputs, start directly with RL