What is FTPO (Final-Token Preference Optimisation)?
mainFTPO is a preference optimization training algorithm that focuses gradient updates exclusively on the continuation token (the choice between a rejected and a chosen token) rather than the entire preceding context.
Goal: To push probability mass away from the first token of a banned phrase (the rejected token) and toward viable alternatives (the chosen tokens) while keeping the rest of the model's distribution stable.
Training Example Structure:
- Prompt: The shared context up to the point of the ban.
- Rejected Token: The specific token that triggered the ban.
- Chosen Tokens: A set of coherent alternatives sampled using a min-p filter.
Loss Mechanism:
- Preference Term: Encourages the model to rank all
chosentokens higher than therejectedtoken. Once a chosen token's logit beats the rejected one by a specific margin (ftpo_clip_epsilon_logits), the loss for that pair stops contributing. - MSE Regularizer: A two-part Mean Squared Error loss in logit space (rather than KL loss) to minimize unnecessary weight movement:
mse_target: Applies targeted pressure to thechosenandrejectedtokens. Users should typically enable eithermse_target_tokenwiseormse_target_aggregate.mse_non_target: Applies loss to the rest of the vocabulary to maintain stability.