Skip to main content
Direct Preference Optimization (method="dpo") tunes a model on preference pairs: for the same prompt, one completion is chosen and one is rejected. The model learns to widen the gap between them, relative to a reference copy of the starting model. DPO is a simpler, more stable alternative to reward-model RLHF, and a common pass after SFT to align style and helpfulness. Veri runs DPO on TRL’s DPOTrainer. You provide a preference dataset; Veri provisions the GPU, runs the loop, streams metrics, and uploads the checkpoint. DPO takes no reward function — the preference pairs are the training signal.

Dataset format

Each row is a preference pair: a prompt, a chosen completion and a rejected completion. A row uses one of two shapes for all three fields, and every row of the dataset uses the same one. Standard: all three are strings. The trainer joins prompt + chosen and prompt + rejected as text.
Conversational: all three are message lists. Each field is a non-empty list of {"role", "content"} messages, and the trainer applies the model’s chat template.
A row that mixes the shapes (a string prompt with message-list completions, or the reverse) is rejected at upload with a 400 that names the row and the field:
The same check runs when you submit a dpo job, before a GPU starts, so a dataset uploaded before the check, or a stream whose appends mixed shapes, is rejected at submit with the same message. Tombstone or correct the row and submit again. You can also leave prompt out of every row (the implicit-prompt form, such as {"chosen": "The sky is blue.", "rejected": "The sky is green."}): the trainer takes the shared start of chosen and rejected as the prompt. The one-shape rule still applies to chosen and rejected. Every row needs a chosen and a rejected completion.

Submitting a job

This mirrors TRL’s DPO quickstart (a small Qwen model on the UltraFeedback preference dataset), run on Veri:

Hyperparameters

LoRA and QLoRA

DPO uses the same adapter path as GRPO and SFT. Set lora_rank to train low-rank adapters instead of the full model, and add load_in_4bit for QLoRA (a 4-bit NF4 base with adapters on top), which fits larger models on a single GPU.
See LoRA and QLoRA for the full rules (4-bit requires lora_rank; QLoRA is single-GPU; 16-bit LoRA is multi-GPU capable).
DPO compares the policy against a frozen reference copy of the starting model. With LoRA or QLoRA, that reference is the same base with the adapter disabled, so there is no extra copy. A full finetune (no lora_rank) instead holds a second reference model in memory, roughly doubling the VRAM needed versus SFT or GRPO on the same base. On tight VRAM, prefer LoRA or QLoRA for DPO.

Where to go next

Managed Training

Supervised finetune first, then align with DPO.

Datasets

Connect a preference dataset.

Submit a job

The full training_jobs.create schema.

Deploy your checkpoint

Serve the trained model with an OpenAI-compatible API.