Skip to main content

Overview

RLOO (REINFORCE Leave-One-Out) is described in the paper Back to Basics: Revisiting REINFORCE Style Optimization for Learning from Human Feedback in LLMs. It is an online RL method that uses a leave-one-out baseline to reduce gradient variance, avoiding the need for a separate value model as required by PPO. RLOO generates multiple completions per prompt and uses the average reward of all other completions as a baseline for each completion, reducing variance while remaining computationally efficient.

Quick start

How RLOO works

1

Generate completions

At each step, sample a batch of prompts and generate num_generations (G, default 2) completions per prompt.
2

Compute rewards

For each completion, compute a reward using the reward function(s). Add a KL penalty to discourage deviation from a reference policy:
3

Compute leave-one-out advantages

For each completion, compute a baseline as the average reward of all other completions in the same group:
This leave-one-out estimate eliminates the need for a value model while still reducing gradient variance.
4

Update the policy

Minimize the REINFORCE loss weighted by advantages. In the single-step setting (default), this is equivalent to standard REINFORCE. With num_iterations > 1, a clipped surrogate objective is used.

Dataset format

The dataset must include a "prompt" column. Additional columns are passed to reward functions.
For VLM training, include an image or images column alongside prompt.

Custom reward functions

Reward functions follow the same interface as in GRPOTrainer. They must accept prompts, completions, completion_ids, and any dataset columns as keyword arguments, and return a list of floats.
Pass reward functions to the trainer:
Reward functions can be async def coroutines. Multiple async functions are executed concurrently, so their latency overlaps.

Multi-task reward functions

Return None for samples that a reward function does not apply to. The trainer ignores None values:

Key configuration parameters

int
default:"2"
Number of completions to generate per prompt (the group size G). Must be at least 2 for the leave-one-out baseline. The effective batch size must be divisible by this value.
int | None
default:"256"
Maximum number of tokens to generate per completion.
float
default:"1.0"
Sampling temperature. Higher values produce more diverse completions.
float
default:"0.05"
KL coefficient controlling deviation from the reference model. When 0.0, the reference model is not loaded.
float
default:"0.2"
Clipping range for the importance sampling ratio in the surrogate objective.
int
default:"1"
Number of gradient update passes per generated batch (μ in the algorithm). When greater than 1, uses a clipped surrogate objective.
bool
default:"false"
Normalize advantages across the generation batch to have mean 0 and standard deviation 1.
list[float] | None
Per-function weights when using multiple reward functions. Defaults to equal weighting.
tuple[float, float] | None
Clip rewards to (min, max) before computing advantages. If None, no clipping is applied.
bool
default:"false"
Exclude truncated completions from the loss. Recommended for training stability.
bool
default:"false"
Use vLLM for faster generation. Requires pip install trl[vllm].
str
default:"colocate"
How to run vLLM: "colocate" (shares training GPUs) or "server" (separate process on dedicated GPUs).
float
default:"0.3"
Fraction of GPU memory reserved for vLLM in colocate mode.
RLOOConfig overrides some TrainingArguments defaults: logging_steps=10, gradient_checkpointing=True, bf16=True, and learning_rate=1e-6.

Accelerating generation with vLLM

vLLM runs inside the trainer process and shares GPU memory:
In server mode, ensure the vLLM server uses different GPUs than the trainer. Use CUDA_VISIBLE_DEVICES to separate them, or you may encounter NCCL errors.

Training at scale (70B+ models)

For large models, combine DeepSpeed ZeRO-3 with vLLM server mode:

GRPO vs RLOO

Logged metrics