---
title: "Direct Preference Optimization Beyond Chatbots"
description: "Adding a DPO stage after supervised fine-tuning reduced text degeneration (repetition loops) in every one of five vision-language model families tested on Brazilian Portuguese structured OCR."
url: "https://swe.quest/articles/direct-preference-optimization-beyond-chatbots-b552e31e2b3fa017"
canonical: "https://huggingface.co/blog/Dharma-AI/direct-preference-optimization-beyond-chatbots"
source: "Hugging Face"
published: "2026-06-03"
difficulty: "hard"
kind: "Research"
reading_minutes: 13
tags: ["model-training","llms","computer-vision","evals"]
---

# Direct Preference Optimization Beyond Chatbots

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2026-06-03, 13 min read, Research. Original: [https://huggingface.co/blog/Dharma-AI/direct-preference-optimization-beyond-chatbots](https://huggingface.co/blog/Dharma-AI/direct-preference-optimization-beyond-chatbots)

## Summary

Adding a DPO stage after supervised fine-tuning reduced text degeneration (repetition loops) in every one of five vision-language model families tested on Brazilian Portuguese structured OCR. The average reduction was 59.4% and the best was 87.6%, with Nanonets-OCR2-3B falling from 1.61% to 0.20%. The key design choice was to keep the SFT model's own degenerate outputs as the rejected examples in preference pairs, rather than filtering them out. An LLM judge scored multiple candidate responses per document across 23,726 documents to pick chosen and rejected outputs. The authors argue that token-level SFT loss cannot penalize completion-level failures like loops, while DPO can, and they outline when the approach should transfer to other structured generation tasks: the failure mode must be a distinct, recognizable class of output.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Computer vision](https://swe.quest/tags/computer-vision.md) (AI & ML)
- [Evaluation](https://swe.quest/tags/evals.md) (AI & ML)

## Prerequisites

- supervised fine-tuning ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))
- Direct Preference Optimization ([easy posts on Performance engineering](https://swe.quest/tags/performance.md?difficulty=easy))
- autoregressive decoding
- vision-language models ([easy posts on Computer vision](https://swe.quest/tags/computer-vision.md?difficulty=easy))

## Keywords

DharmaOCR, Direct Preference Optimization, text degeneration, Qwen2.5-VL-3B, gemma-3-4b-it, Nanonets-OCR2-3B, LLM-as-judge

## Related posts

- [Newer Models, Same Advantage](https://swe.quest/articles/newer-models-same-advantage-43649f104bf0ba91.md): Hugging Face · 2026-07-16 · Easy · 11 min read · Computer vision, Model training, Evaluation, LLMs
  DharmaOCR, a Brazilian Portuguese OCR model trained with supervised fine-tuning followed by Direct Preference Optimization, scored 0.925 on a Portuguese-only benchmark, ahead of the newer Mistral OCR4 (0.798) and Unlimited-OCR (0.7587).
- [Preference Optimization for Vision Language Models](https://swe.quest/articles/preference-optimization-for-vision-language-models-a84799e96613bf21.md): Hugging Face · 2024-07-10 · Hard · 11 min read · Model training, Computer vision, LLMs, Python
  TRL now supports direct preference optimization (DPO) for vision language models, trained on chosen/rejected answer pairs rather than fixed labels.
- [Generating Human-level Text with Contrastive Search in Transformers 🤗](https://swe.quest/articles/generating-human-level-text-with-contrastive-search-in-transformers-e7358d1977f145fe.md): Hugging Face · 2022-11-08 · Medium · 18 min read · LLMs, Inference & serving, Python
  Contrastive search is a decoding method for neural text generation that picks each token from the model's top-k candidates by balancing model confidence against a degeneration penalty: the maximum cosine similarity between the candidate's hidden representation and those of prior context tokens.
- [Training Design for Text-to-Image Models: Lessons from Ablations](https://swe.quest/articles/training-design-for-text-to-image-models-lessons-from-ablations-0bc11bc8d1a3210c.md): Hugging Face · 2026-02-03 · Hard · 31 min read · Model training, Computer vision, Machine learning, Evaluation
  Photoroom's ablations on its PRX-1.2B text-to-image model compare recent training-efficiency techniques against a plain Flow Matching baseline: 100k steps at 256×256 on 1M MidJourney images, scored with FID, CMMD, DINO-MMD and throughput.
- [Open Preference Dataset for Text-to-Image Generation by the 🤗 Community](https://swe.quest/articles/open-preference-dataset-for-text-to-image-generation-by-the-community-51063f2eca79d4de.md): Hugging Face · 2024-12-09 · Easy · 7 min read · Model training, Computer vision, Evaluation, Open source
  Data is Better Together released an Apache 2.0 text-to-image preference dataset of 10K pairs, with over 30K annotations from more than 250 community members collected in under two weeks.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
