FAQ

Fine-tuning

TRL dataset formats: the five types, and which trainer wants which

Unsloth builds directly on TRL's trainers, and Axolotl and LLaMA-Factory use TRL for preference training such as DPO, so for those methods TRL's dataset types are the real spec.

If you only read one format specification, read TRL's. Unsloth trains with TRL's trainers directly, and the other popular wrappers hand their preference training to TRL, so for DPO and its relatives, whatever shape your data starts in, this is the contract it ends up satisfying.

Format versus type

TRL draws a distinction worth adopting. Format is whether your data is standard — plain strings — or conversational, a list of role-tagged messages. Type is what the fields mean: language modelling, prompt-completion, preference, unpaired preference, or prompt-only.

Both axes are independent. Preference data can be standard or conversational. The trainer cares about the type; the chat template cares about the format. Keeping the two ideas separate makes the documentation much easier to follow.

the five types, as TRL documents them
# language modeling
{"text": "The sky is blue."}

# prompt-completion
{"prompt": "The sky is", "completion": " blue."}

# preference, explicit prompt  (recommended)
{"prompt": "The sky is", "chosen": " blue.", "rejected": " green."}

# preference, implicit prompt
{"chosen": "The sky is blue.", "rejected": "The sky is green."}

# unpaired preference  (KTO)
{"prompt": "The sky is", "completion": " blue.", "label": True}

# prompt-only  (GRPO, RLOO, online DPO) - no target at all
{"prompt": "The sky is"}
Each stage consumes a different shape of data, usually less of it than the stage before, so the stage your goal belongs to decides what you collect and how much of it.

Which trainer wants which type

This table is the reason to read TRL's docs before picking a method. The data you can realistically collect often determines the method rather than the other way round.

TrainerDataset typeWhat you must collect
SFTTrainerlanguage modeling or prompt-completionone good answer per prompt
DPOTrainerpreference, explicit prompt preferredtwo answers plus an ordering
RewardTrainerpreference, implicit prompt preferredtwo answers plus an ordering
KTOTrainerunpaired preference, or preferenceone answer plus a thumbs up or down
GRPOTrainerprompt-onlyprompts plus a reward function
RLOOTrainer; online DPO (experimental)prompt-onlyprompts plus a reward signal
ORPO, CPO (experimental)preferencetwo answers plus an ordering
A diagram: a model goes through supervised fine-tuning to a reference model, then to an aligned model. Below, a circle labelled hard-to-get shows paired preferences (B over A, C over B) feeding RLHF and DPO, marked prior work; a circle labelled abundant shows single outputs with thumbs up or down feeding KTO, marked this work.
Where each alignment method's data comes from: RLHF and DPO need paired preferences (output B preferred to A), which are hard to collect, while KTO needs only a thumbs-up or thumbs-down on single outputs, which are far more plentiful. In TRL these are different dataset types: preference pairs for DPO, unpaired labelled completions for KTO. Image: Figure 1 of the paper · CC BY-SA 4.0 · from Ethayarajh et al. 2024, “KTO: Model Alignment as Prospect Theoretic Optimization”, arXiv:2402.01306

KTO is the cheap one, and that is the point

Paired preference data is expensive. For every prompt an annotator must read two answers and decide which is better — and on answers of similar quality that judgement is slow and inconsistent between people.

KTO needs only a binary judgement on a single answer. That is a fundamentally cheaper annotation task, and it is also the shape feedback naturally arrives in from real users, who will click a thumbs-down on a bad answer but will not sit through a comparison.

If you have production traffic with any feedback mechanism, you may already have KTO data and no preference pairs at all. That is a reason to consider the method, not a reason to manufacture pairs from it.

A preference pair is not good-versus-bad writing. If the two completions differ in length, format and content at once, the model learns the cheapest difference to detect, which is usually length.

GRPO needs no answers whatsoever

The prompt-only types are worth understanding even if you do not use them, because they change what counts as a dataset.

For GRPO you supply prompts and a reward function. The model generates several candidate answers per prompt, the function scores them, and the relative scores drive the update. No human ever writes a target output.

This only works where correctness is programmatically checkable: does the code pass the tests, does the arithmetic come out right, does the output parse as valid JSON against a schema, does the extracted value match the record. Where that holds it is extremely attractive, because prompts are cheap and the reward function is written once. Where it does not — anything requiring taste, tone or open-ended judgement — you are back to collecting answers.

Flow diagram. A prompt s_t enters a blue "Policy Model" (trained), which produces outputs a_1 to a_G. These go to a pink "Reference Model" (frozen, with "KL in loss" fed back to the policy) and a pink "Reward Model (or verifier)" (frozen), which gives rewards r_1 to r_G. A box computes A_i = (r_i − μ)/σ, with "μ, σ from group", giving advantages A_1 to A_G, and a dashed arrow returns them to the policy.
GRPO in one diagram: the policy samples a group of G answers to a prompt, a reward model or verifier scores each, and each answer's advantage is its reward relative to the group's mean and spread. No step needs a target answer written by a person; the dataset is the prompts, and the scoring does the rest. Image: natolambert/rlhf-book · MIT repository (diagrams folder) · from “Reinforcement Learning from Human Feedback (Nathan Lambert)”, arXiv:2504.12501

Conversational data in any of these types

Every type above has a conversational variant where the string fields become message lists. A conversational preference example has a prompt that is a list of messages, and chosen and rejected that are each a list containing the assistant's reply.

TRL applies the model's chat template for you when it detects the conversational format, which is the behaviour you want — it means the same dataset trains correctly against different model families without you rendering template tokens into your files.

A preference annotation card. A blue header box holds the prompt, a question about the benefits of reinforcement learning from human feedback. Beneath it sit two candidate answers side by side: the left one is highlighted in green as the selected response, the right one is left plain as the rejected response.
One prompt, two completions, one marked chosen. That record is what every DPO-style trainer in the TRL family reads, and nothing else in the file matters to it. Image: HumanSignal/label-studio · Apache-2.0 repository

Questions people ask

Does TRL publish how many preference pairs I need?

No. TRL documents the formats and not the volumes. Unsloth publishes row counts for SFT (at least 100, over 1,000 preferable) and for GRPO (at least 500), but none for preference pairs. For preference tuning, look at the scale of the established public preference datasets for orientation and treat any specific recommendation as a rule of thumb.

Can I convert SFT data into preference data?

Partly. Your existing good answer becomes chosen; you still need a plausible rejected. Generating it from a weaker model or an earlier checkpoint is a common approach, but be careful — if the rejected answers are bad in an obvious, uniform way, the model learns to avoid that artefact rather than to prefer quality.

What is beta in the DPO config?

It controls how far the tuned model is allowed to move from the reference model. Lower values permit bigger changes, higher values keep it close to where it started. Unsloth's DPO example uses 0.1. It interacts with the learning rate, and preference tuning generally wants a much lower rate than SFT — around 5e-6 rather than 2e-4.

Do I need a reference model for DPO?

The implementation needs one, but you can pass ref_model=None when training a PEFT adapter: disabling the adapter recovers the base model, so it serves as its own reference. That is what Unsloth's DPO notebook does, and it avoids loading a second copy of the model.

Stop hunting. Start searching.

Tens of thousands of curated datasets, searchable in plain language — with the licence and size checked before you download anything.

Search Dataset Finder →