↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

What KTO is

DPO (the DPO tab) learns from preference pairs: two answers to the same prompt and a judgement of which is better. Pairs are expensive to collect. A thumbs up or a thumbs down on a single answer is much cheaper, and products gather it anyway. Kahneman–Tversky optimisation (KTO) trains on exactly that: each example is a prompt , one answer and a label saying whether is desirable or undesirable. Nothing tells KTO which answers belong together.

This page runs ten real updates of TRL's KTOTrainer on SmolLM2-135M-Instruct, with , and a learning rate of , on 16 rows of trl-lib/kto-mix-14k's test split: the first eight single-turn prompts of at most 40 tokens whose two answers have at most 70 tokens each. kto-mix-14k is argilla's dpo-mix-7k with every pair split into a desirable row and an undesirable row, so here each prompt contributes one of each; the Thumbs up or down panel shows the two, but KTO reads them as independent rows. All 16 go into every step, and a frozen copy of the starting model is the reference .

Prospect theory

Kahneman and Tversky's prospect theory describes how people value an uncertain outcome. They judge it relative to a reference point, not in absolute terms; the value of a gain grows ever more slowly (concave), as does the pain of a loss (convex); and losses weigh more than gains of the same size (loss aversion). Ethayarajh et al. observe that the alignment losses that work well, DPO and PPO's clipped objective among them, already have this shape when written as a function of an implied reward, and call such losses human-aware losses (HALOs). KTO is a HALO built on purpose: it plugs the language model's implied reward into a value function of prospect theory's shape and maximises the value of the labelled answers directly, instead of the likelihood of preferences.

Implied reward and reference point

As in DPO, an answer's reward is implicit: how much more likely the policy makes it than the reference,

with each log-probability the sum of the answer's tokens' log-probabilities given the prompt; the Reward → value → loss table shows the four numbers for the prompt's two rows. A desirable row should earn a reward above the reference point and an undesirable one a reward below it. KTO's reference point is the KL divergence of the policy from the reference, : a policy that drifts far from the reference must raise a good answer by more than its general drift before the answer counts as a gain.

The KL cannot be computed exactly, so it is estimated from the batch with answers paired to the wrong prompt. TRL rotates the batch by one: prompt is scored with answer , never its own. The Reference point z_ref panel lists the 16 mismatched pairs and their log-ratios; their mean, clamped at 0 and carrying no gradient, is . In this run the mean is negative from step 1 on, falling to by step 10: off their prompts, the desirable answers mostly became more likely (one by 15.9 nats) and the undesirable ones much less likely (one by 32.2 nats). So the clamp holds at 0 throughout, and every reward is measured from 0.

Value function and loss

The value of a row is a sigmoid of its reward measured from the reference point, rising for a desirable row and falling for an undesirable one:

The Value function chart draws both curves with all 16 rows on them. At step 0 every reward is 0, every value and every row's loss ½. The loss is bounded between 0 and , and its slope, which sets how hard a row pushes, is largest at the reference point and fades on both sides: a row already far past stops pushing, and so does one hopelessly short of it. DPO's keeps pushing a pair that is far behind.

and weigh the two kinds of row, the counterpart of loss aversion. The paper recommends between 1 and 4/3, where and count desirable and undesirable rows, and TRL warns outside that range; with eight of each and both weights 1 this run sits at 1.

Ten updates, beside DPO

The strip follows the run. The batch loss falls from 0.5 to 0.245, and after ten steps all eight desirable answers are more likely than under the reference and all eight undesirable ones less likely. As TRL logged it, the desirable answers' summed log-probability rose from −47.6 to −38.7 on average and the undesirable ones' fell from −72.7 to −90.8: as with DPO, pushing the bad answers down moves the most.

For comparison the same 16 token sequences were trained with TRL's DPOTrainer as eight pairs, at the same learning rate and number of steps. The Against DPO panel sets the two runs side by side. Here they behave alike: DPO also raises all eight desirable answers and lowers all eight undesirable ones, by a mean of 8.8 and −20.3 nats against KTO's 9.8 and −19.8, and both change every prompt's greedy answer. DPO's loss falls from 0.693 to 0.114, but the two losses are on different scales. The difference is in what each needs: DPO could not have trained on a thumbs-down without a matching thumbs-up for the same prompt, while KTO could. Recomputed one sequence at a time, the page's loss matches TRL's log to and its KL estimate exactly.

Where KTO came from

Prospect theory comes from Kahneman and Tversky (1979); the cumulative version of 1992 gave the value function the form KTO borrows. Ethayarajh et al. (2024) introduced HALOs and KTO, and found that KTO on unpaired labels matched or beat DPO on paired data from 1 B to 30 B parameters, even when most desirable examples were thrown away. TRL ships it as KTOTrainer, with the kto-mix datasets used here. Binary classifier optimisation (Jung et al., 2024) also learns from thumbs up or down, as a logistic classifier on the implied reward with its own reward shift. Other tabs vary DPO in different directions: SimPO (the SimPO tab) drops the reference model and ORPO (the ORPO tab) folds preferences into SFT.

Papers

  1. KTO: Model Alignment as Prospect Theoretic Optimization Kawin Ethayarajh et al. · ICML 2024 Introduces human-aware losses and KTO: a prospect-theory value function on the implied reward, trained from single answers labelled desirable or undesirable.
  2. Prospect Theory: An Analysis of Decision under Risk Daniel Kahneman, Amos Tversky · Econometrica 1979 Outcomes valued relative to a reference point, concave for gains, convex for losses, with losses weighing more: the shape KTO's value function copies.
  3. Advances in prospect theory: Cumulative representation of uncertainty Amos Tversky, Daniel Kahneman · Journal of Risk and Uncertainty 1992 Cumulative prospect theory and its parametric value function with a loss-aversion coefficient, the λ that KTO's λ_D and λ_U play.
  4. Direct Preference Optimization: Your Language Model is Secretly a Reward Model Rafael Rafailov et al. · NeurIPS 2023 The implied reward β log π/π_ref that KTO reuses, and the paired loss it is compared with on this page (see the DPO tab).
  5. SmolLM2: When Smol Goes Big -- Data-Centric Training of a Small Language Model Loubna Ben Allal et al. · arXiv 2025 SmolLM2-135M-Instruct, the policy and reference on this page.
  6. Binary Classifier Optimization for Large Language Model Alignment Seungjae Jung et al. · arXiv 2024 Another way to align from thumbs up or down: a binary classifier on the implied reward, with a reward shift instead of KTO's KL reference point.

See also