How the settings fit together
A reinforcement run repeats one loop: sample answers, score them, compare, update. Each setting acts at one point of that loop, so most problems in a run can be traced to one of them.
- 01Samplethe model writes N answers to each prompt⚙ answers per prompt · max answer length
- 02Scorethe grader gives every answer 0–1⚙ grader · judge model
- 03Compareeach score vs its group's average⚙ nothing to set: the group is the baseline
- 04Updatea small step toward the above-average answers⚙ learning rate · KL β
The settings
What turns each answer into a 0–1 score: a judge model, similarity to your reply, a numbers check, exact-match checks, or a blend. It is the definition of “better” for the whole run, so pick it for what you actually want and check it on a few answers by hand. Graders explains each option.
Which LLM does the scoring when the grader includes a judge. A stronger judge ranks answers more reliably, which matters more than usual here because GRPO turns even small score differences into full-size updates. It also costs more per call. Prefer a model from a different family than the one being trained, and keep yet another judge for the final evaluation.
The group size: how many answers the model writes to each prompt per step. More answers give a clearer picture of which kind of answer scores better, and make it more likely that at least one differs from the rest. They also multiply generation time and the judge's input tokens; the judge still makes one call per prompt. With N = 2, any difference at all becomes a full +1 / −1 signal.
The longest answer, in tokens, the model may write per attempt. An answer that hits the limit is cut off mid-sentence and usually scores badly, which wastes the step or teaches the model to be terse for the wrong reason. Set it a little above a good answer's length: a token is about ¾ of a word, so a 150-word reply is about 200 tokens. Thinking models write long reasoning before answering; Scalata turns thinking off for them during RL so the budget goes to the answer.
The size of each update. RL steps are much smaller than supervised ones: the signal is noisier (scores of the model's own tries rather than a correct answer), and the data changes as the model does, so a big step can take it somewhere its next answers can't recover from. With LoRA a rate around 1e-5 is a common start; full-weight RL typically uses about 1e-6, as DeepSeekMath did.
How strongly the model is held near its starting point. Each step, β × the KL divergence between the trained model and a frozen copy of the start is subtracted from the objective. 0 means no penalty; it is the current default in TRL and also skips loading the frozen copy. DeepSeekMath used 0.04. Raise it from 0 if answers start to drift in ways the grader doesn't punish: odd phrasing, broken formatting, switching language, or losing general skills.
Worked examples
- Take a pass/fail grader and a model that gets a prompt right 10% of the time. A group only teaches something if its answers differ.
- N = 2: all fail with probability 0.9² = 0.81 and all pass with 0.01, so only about 18% of prompts give a signal.
- N = 4: all fail with probability 0.9⁴ ≈ 0.66, so about 34% give a signal.
- N = 8: 0.9⁸ ≈ 0.43, so about 57% give a signal, at twice the generation time of N = 4.
- If the model is right half the time, N = 4 already gives a signal on about 88% of prompts (only 1 group in 8 is all-pass or all-fail). Bigger groups help most when good answers are rare.
- Take one decision where the starting model says “Yes” or “No” with 50% each.
- After training it says “Yes” 80% of the time. KL from the start = 0.8 × ln(0.8 ÷ 0.5) + 0.2 × ln(0.2 ÷ 0.5) ≈ 0.19.
- If it becomes 99% sure: 0.99 × ln(0.99 ÷ 0.5) + 0.01 × ln(0.01 ÷ 0.5) ≈ 0.64. The cost climbs quickly as the model grows certain where its start was undecided.
- With β = 0.04 those cost about 0.008 and 0.025 per token, added up over every token of an answer: small for one token, noticeable when a whole answer's style moves.
- Your reference replies average about 120 words; the longest are about 250.
- 120 words ≈ 160 tokens; 250 words ≈ 330 tokens.
- A limit of 384–512 tokens leaves room for a full answer. Watch the clipped ratio in the first steps: if more than a few percent of answers hit the limit, raise it or ask for shorter answers in the system prompt.
A sensible first run
- Start from a supervised run, not the plain base model, unless the base already answers your questions reasonably well.
- Grader: a judge model (or judge + numbers for calculations), with a strong, affordable judge.
- N = 4, max answer length a little above your typical reply, learning rate around 1e-5 with LoRA, KL β = 0.
- Small first: a few dozen prompts and one epoch, then read the groups and the reward chart before scaling up.
Common mistakes
- Raising N to fix a flat reward. If the model never produces a good answer, more tries of the same quality don't help; start from a better model.
- A max answer length below your typical reply. Complete answers are cut off and the model learns from truncated text.
- Using a supervised-training learning rate. Large RL steps can wreck the model's output within a few steps.
- Starting with a large KL β. The model then barely moves; begin at 0 and raise it only if answers degrade.
- Grading with the same judge you will evaluate with.
References and further reading
External sources open in a new tab.
- 01GRPO TrainerHugging Face TRL docs · huggingface.coDefaults and meaning of the group size, completion length, β and the loss variants.
- 02DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language ModelsShao et al., 2024 · arXiv · arxiv.orgThe original GRPO settings: learning rate 1e-6, KL coefficient 0.04, 64 answers per question.
- 03Training language models to follow instructions with human feedbackOuyang et al., 2022 · arXiv · arxiv.orgHow a KL penalty keeps an RL-tuned model close to its supervised starting point.
- 04Kullback–Leibler divergenceWikipedia · en.wikipedia.orgThe definition, and why KL is not symmetric.