In April, Dharma AI released DharmaOCR, a specialized structured OCR model, along with a paper detailing its methodology and benchmark results. The model, available on Hugging Face, demonstrated superior quality and cost efficiency on Brazilian Portuguese text extraction. Among the reported metrics was text degeneration rate—the frequency at which a model produces a repetition loop instead of a transcription.
Across tested open-source vision-language model families, vanilla degeneration rates ranged from below 1% to over 33%. Supervised fine-tuning (SFT) reduced these rates for most models but rarely to production-acceptable levels. This points to a structural limitation: SFT optimizes for correct outputs but does not explicitly penalize degeneration. There seems to be a ceiling on how much task-focused fine-tuning alone can reduce this failure mode.
A second training stage, applied after SFT on the same documents using the same model, reduced text degeneration in every family tested. The average reduction was 59.4%, with a best case of 87.6%. This second stage was Direct Preference Optimization (DPO).
Almost all published DPO applications target chat alignment—models trained on human judgments about helpfulness or harmlessness. OCR carries none of that subjectivity; the task is objective, and there is no conversational context. However, there is a clear preference signal: a correct transcription is chosen; a degeneration loop is rejected. DharmaOCR used this binary to construct a DPO training set, testing the technique not for alignment but as a direct mitigation tool for a specific failure mode.
The training signal came from the model itself—specifically from the outputs it produced when it failed. How a failure mode becomes a training signal is a structural question about the failure, not the model.
The Loop Survives Fine-Tuning
Why SFT has a ceiling on degeneration is still an open question, but the leading conjecture points to loss granularity. SFT trains token by token: each prediction is evaluated in isolation, and a repetition loop is never penalized as a completion-level failure. DPO inverts that logic. The training signal is the full output—chosen or rejected—which means a degenerated completion can be explicitly labeled as the wrong outcome, not just a sequence of locally probable tokens.
When a training objective maximizes the likelihood of observed sequences, it concentrates probability mass in the regions of distribution space those sequences occupy. A model that enters one of these high-probability attractor regions during inference assigns elevated probability to the same token at the next step—which increases the probability further, sustaining the loop until the sequence hits the maximum token limit. Text degeneration is the output of this geometry: a self-reinforcing repetition loop that an autoregressive model cannot exit without external intervention. It is not purely a decoding artifact. The attractor involves the training objective, the learned distribution, and how probability mass concentrates during inference—a systems-level failure rather than a failure localized to any single component.
Inference-layer interventions—repetition penalties, temperature adjustments, early-abort logic—operate on the sampling step. They contain the symptom without touching the distribution that produces it. The attractor persists.
Supervised fine-tuning moves the distribution closer to the task domain. For a structured generation pipeline, this means training on domain-specific documents, in the target language, with the required output format. The model gains fluency with longer sequences, constrained syntax, and domain vocabulary. What SFT does not do is attack degeneration directly. Its objective—maximizing the likelihood of observed sequences—has no term that penalizes repetition loops. The failure mode is simply outside the scope of what the training signal optimizes for.
One model family in the DharmaOCR benchmark showed an unexpected pattern: a vanilla degeneration rate of 0.60%, rising to 3.23% after SFT, before a subsequent DPO stage brought it to 1.41%. This single data point is an exception, not a rule, but it illustrates that SFT does not reliably reduce degeneration. Capability and degeneration resistance can move independently.
This distinction matters structurally. SFT and DPO are not interchangeable training stages performing the same operation at different intensities. SFT closes the distance between the model's prior distribution and the task domain. What it does not do is target degeneration as an objective—its effect on the failure mode is incidental, and the benchmark results show it is not consistent. The attractor that produces degeneration is not a problem with the model's proximity to the task—it is a problem with the shape of the distribution space the model now occupies.
Addressing that geometry requires a training signal built specifically to point the model away from its own failure modes. For a structured, non-conversational task with no human preference labels and no conventional "helpful versus harmful" distinction, constructing such a signal is a challenge that DPO can meet.
The Design Decision: Degenerate Outputs as Rejection Pairs
For a model that has undergone SFT on correct examples, the remaining degeneration cases follow a pattern: the model starts generating a correct transcription but then enters a repetition loop mid-sequence. These degenerate outputs are not random—they are systematic failures tied to the model's own learned distribution. By treating these failure cases as rejection pairs (chosen = correct transcription; rejected = degenerate output), the team created a DPO training set directly from the model's own mistakes.
This approach has two key advantages. First, it does not require human preference labels, which are expensive and subjective. Second, it targets the exact failure mode that SFT cannot fix, creating a complementary training signal that explicitly penalizes the behavior.
Consistent Across Five Model Families
The results were striking. Across five model families of varying sizes and architectures, DPO consistently reduced degeneration rates after SFT. The average reduction was 59.4%, with the best case showing an 87.6% drop. Importantly, the improvement was not limited to small or simple models—even large models with low baseline degeneration benefited from the additional DPO stage.
The Pattern Beyond OCR
While the experiments focused on OCR, the pattern suggests broader applicability. Any task where a clear correct/incorrect signal exists could benefit from this two-stage approach: first, SFT to bring the model into the task domain, then DPO using the model's own failure modes as rejection pairs. This could apply to data extraction, document parsing, code generation, or any structured generation task where degeneration is a production concern.
The key insight is that DPO, originally designed for chat alignment, can be repurposed as a targeted fix for specific failure modes in non-conversational tasks. The technique transcends its original context.