Reinforcement Fine-Tuning (RFT) is a training technique that uses reward signals instead of labeled input-output pairs to improve a model’s reasoning and decision-making. Rather than teaching the model to reproduce a fixed “correct” answer, RFT teaches it to explore solution strategies, receive feedback from a grader, and reinforce the approaches that earn higher rewards. The result is a model that reasons more sharply in domains where correctness can be measured — making it well-suited for math, coding, scientific classification, and any task where you can define a clear grading function. This guide covers when to use RFT, how to design effective graders, and how to run and evaluate an RFT job end to end.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/openai/openai-cookbook/llms.txt
Use this file to discover all available pages before exploring further.
How RFT differs from SFT
Supervised fine-tuning (SFT) trains a model by minimizing the difference between predicted outputs and labeled targets. This works well when you have high-quality labeled data and the desired behavior can be expressed as an exact output. RFT takes a fundamentally different approach:| SFT | RFT | |
|---|---|---|
| Training signal | Labeled output pairs | Reward scores from a grader |
| What the model learns | To reproduce target outputs | To maximize reward through exploration |
| Data requirement | Correct answers for every example | Reward function; base model must have partial capability |
| Best for | Format, style, tone, distillation | Complex reasoning, verifiable correctness |
| Risk | Overfitting to examples | Reward hacking (optimizing the grader, not the task) |
RFT requires the base model to demonstrate at least partial capability on your task before training. If the model never produces a correct or near-correct output at baseline, there is no reward signal to learn from. Establish a baseline accuracy before committing to RFT.
When to use RFT
RFT is the right choice for tasks where:Outputs are verifiable
The correctness of a response can be checked programmatically — a math answer, a diagnosis code, a SQL query that executes correctly, or a classification label.
Reasoning depth matters
The task requires multi-step reasoning rather than simple pattern matching. RFT helps models learn strategies, not just outputs.
Labels are scarce but feedback is easy
You may not have thousands of labeled examples, but you can define a reward function. RFT can make meaningful improvements with as few as 100 training examples.
Partial capability already exists
The base model succeeds on some examples but is inconsistent. RFT hill-climbs from that starting point.
The grader: your reward function
The grader is the most important component of an RFT job. It defines what “good” means — and the model will optimize directly for whatever signal it receives. A poorly designed grader leads to reward hacking, where the model learns to score well according to the grader without actually improving on the real task. OpenAI’s RFT API supports several grader types:Python graders (custom logic)
Python graders (custom logic)
Python graders let you write arbitrary grading logic in a You can also use fuzzy matching for tasks where multiple valid phrasings exist:To submit a Python grader to the API, pass the source code as a string:
grade(sample, item) function. The function receives the model’s output and the training example, and returns a float between 0.0 and 1.0.Model graders (semantic scoring)
Model graders (semantic scoring)
Model graders use a second LLM (such as GPT-4.1) to evaluate the model’s output semantically. This is useful when the task requires domain expertise to score, or when multiple correct phrasings exist.Before using a model grader in training, validate that its scores agree with human or expert judgments on a calibration set.
Multi graders (combined signals)
Multi graders (combined signals)
A multi grader combines several graders with a weighted formula. This lets you balance exact-match precision against semantic flexibility.
Avoiding reward hacking
Reward hacking occurs when the model finds ways to score well according to the grader without actually solving the underlying task. Common signs include:- Training reward improves rapidly while qualitative output quality stays flat or degrades
- The model produces outputs that are superficially similar to references (high fuzzy score) but meaningless
- The model learns idiosyncrasies of your specific grader rather than the general task
- Evaluating on a held-out test set with a different (or stricter) grader
- Using human review on a sample of high-scoring model outputs
- Comparing model outputs before and after training qualitatively, not just by score
Example: math grader setup
Here is a worked example of an RFT grader for a math task, where the expected output is a numeric answer.messages list (the prompt) and a reference_answer field:
Training configuration
Prepare and upload your dataset
Format your data as JSONL with
messages and reference_answer fields. Upload it to the Files API:Create the RFT job
Pass your grader and the training file when creating the fine-tuning job. Specify
"reinforcement" as the method type:Monitor training progress
RFT jobs expose per-epoch reward metrics. Watch for a steadily increasing training reward alongside a stable or improving validation reward. If validation reward stagnates while training reward climbs, the model may be overfitting or reward hacking.
Interpreting results
A successful RFT run should show:- Rising training reward across epochs, indicating the model is learning the reward signal
- Stable or improving test reward, confirming that improvement generalizes
- Qualitative improvement on held-out examples reviewed manually
- Revising your system prompt to give the model clearer guidance
- Adjusting your grader to give more graduated (partial-credit) scores rather than hard binary signals
- Switching from a string-match grader to a model grader for richer semantic feedback
Common pitfalls
Base model has no initial skill
Base model has no initial skill
RFT cannot teach a model a task it has never encountered. If baseline accuracy is near zero, the reward signal is too sparse for the model to learn from. Try prompting the base model with few-shot examples, or consider supervised fine-tuning first.
Grader is too strict or too lenient
Grader is too strict or too lenient
A grader that returns only 0 or 1 for every example gives the model less to learn from than one that returns partial credit. Conversely, a grader that rewards almost everything provides no useful signal. Aim for a distribution of scores that correlates with actual quality.
Reward hacking
Reward hacking
If training reward rises sharply but test reward does not follow, the model has found a shortcut specific to your grader. Review high-scoring model outputs manually and update the grader to close the loophole.
Overfitting to training examples
Overfitting to training examples
Like SFT, RFT can overfit. Use a validation set and monitor validation reward at each epoch. Consider reducing the number of training epochs if overfitting is observed.
Next steps
Fine-tuning (SFT and DPO)
If your task involves format, style, or tone rather than verifiable correctness, supervised fine-tuning or DPO is likely a better fit than RFT.
Evaluation
Learn how to build evaluation pipelines that measure model quality, detect hallucinations, and compare model versions — skills that apply directly to grader design for RFT.