三个月前,我们发表了关于 DharmaOCR 的论文,并开源了其中一种模型。其目标明确:专为巴西葡萄牙语设计的光学字符识别(OCR)系统。最终模型在面向葡萄牙语的基准测试中,同时实现了最高的文本提取质量得分与最低的退化率。这两个阶段均不可或缺:微调阶段构建了领域专业能力;直接偏好优化(DPO)阶段则确保该能力在模型易失效的条件下依然保持稳定。
Three months ago, we published a paper on DharmaOCR and open-sourced one of the models. The objective was specific: optical character recognition engineered for Brazilian Portuguese. The combined result was a model that achieved the highest extraction quality score with the lowest degeneration rate on a Portuguese-focused benchmark. Both stages were necessary. The fine-tuning stage built domain competency; the DPO stage ensured that competency held under the conditions where models tend to fail.
三个月前,我们发布了关于 DharmaOCR 的论文,并开源了其中一款模型。其目标十分明确:专为巴西葡萄牙语定制的光学字符识别(OCR)技术。最终成果是一款在面向葡萄牙语的基准测试中,同时实现最高文本提取质量得分与最低退化率的模型。这两个训练阶段均不可或缺:微调阶段构建了领域专业能力;DPO(Direct Preference Optimization,直接偏好优化)阶段则确保该能力在模型通常失效的条件下依然稳健可靠。 OCR 模型的发展日新月异。然而,最初驱动 DharmaOCR 设计的两大缺口——复杂文档中的文本提取质量,以及生产环境下的模型稳定性——至今仍未弥合。相反,随着领域演进,这些缺口反而更具启示意义。 架构设计与参数量共同决定了模型所能学习能力的上限;而训练过程则决定了这一容量如何被分配。DharmaOCR 的训练策略反其道而行之:主动接受这一约束。该模型并非为其他语言而设计,也从未意图成为多语言场景下的最优解。作为交换,网络中所有可用参数均可精准聚焦于巴西葡萄牙语特有的词汇、形态及正字法模式——即对该领域资源最集中、最定向的利用方式。这种高度专注性,构成了其相较于多语言模型及更广域模型所具备的固有优势的结构基础。该优势并不依赖于比竞品更大的架构或更复杂的训练流程——新型架构与训练技术确能提升任意模型的整体能力;其关键在于资源投向何处:是集中于单一领域,还是分散于多个语言之间。 三个月后,新一代模型陆续问世。当这些模型更新颖、能力更强时,“专业化是否仍具价值”便成为一个新的问题。我们将它们与 DharmaOCR 同置于专为葡萄牙语设计的基准测试中进行评估,结果明确无误。 图1:基准测试所用 ENEM(巴西国家高中考试)作文手稿及其各模型输出结果;误读内容以红色标出。DharmaOCR 在相同文档上的表现正确处理了上述案例。原因直接明了:其训练全程聚焦于该语言空间,将模型资源导向巴西葡萄牙语所特有的词汇分布与专有名词分布,而非同时覆盖多种语言。 这些示例用于阐释基准测试,而非替代基准本身。基准测试量化了性能差距的幅度;示例则说明该差距集中体现于语言特异性识别能力,而非通用能力。 然而,提取准确率仅是生产环境中性能的一个维度;视觉困难条件下的稳定性则是另一维度——而在实际运行中,后者一旦失效,后果往往更为严重。当生成式模型面对难以清晰解析的文档(如字号过小、扫描质量退化、笔迹密集)时,其输入信号将面临不确定性。主要基于下一词预测目标训练的模型在此类场景下存在特定脆弱性:当视觉信号变得模糊时,模型可能继续依据先前习得的模式生成文本,而非忠实反映源文档内容。其结果即为文本退化——输出重复、语义混乱,且与页面内容完全脱节。面对小字号文档,Mistral OCR4 生成的文本与原文毫无关联。这并非低质量转录,而是性质截然不同的失败。 DPO 训练所依据的信号与此不同:SFT(Supervised Fine-Tuning,监督微调)按词元逐个训练;而 DPO 则以完整输出质量为训练目标——教导模型依据整体提取结果的连贯性,而非单个预测的准确性,来判别多个候选响应的优劣。其效果在于增强稳定性:在视觉复杂度易引发输出漂移的文档上,模型更不易偏离正轨,因其训练过程明确惩罚了在提取层面丧失连贯性的输出。 其结果正如原始基准测试所证实:在相同文档上,DharmaOCR 实现了更高的提取准确率与更低的退化率;而缺乏该训练阶段的模型则在这些文档上普遍丧失连贯性。 该基准测试确立的是当下事实,却无法精确预判两年后的状况。每一代新架构所改变的,是绝对性能的上限;而不变的,则是决定哪些系统能在特定领域内更接近其性能上限的结构性逻辑。 三个月前,我们已证明:将模型训练集中于特定领域,可带来可测量的优势,且该优势甚至超越更新颖、资源更丰富的通用型系统。这一优势业已得到验证。同样的原理也将决定 DharmaOCR 的后续演进路径——它并非固守不变,而是持续将领域内取得的任何进展,应用于一个始终不变的核心领域。 欢迎访问 Hugging Face 上的 Dharma AI 页面,体验我们的交互式演示、下载开源模型,并了解专业化人工智能系统如何在真实企业应用场景中超越通用型模型。
Three months ago, we published a paper on DharmaOCR and open-sourced one of the models. The objective was specific: optical character recognition engineered for Brazilian Portuguese. The combined result was a model that achieved the highest extraction quality score with the lowest degeneration rate on a Portuguese-focused benchmark. Both stages were necessary. The fine-tuning stage built domain competency; the DPO stage ensured that competency held under the conditions where models tend to fail. OCR models have been moving quickly. But the gaps that originally motivated DharmaOCR's design (in extraction quality on complex documents and in model stability under production conditions) have not closed. They have, if anything, become more instructive as the field has changed. Architecture and parameter count establish the ceiling on what a model can learn. Training determines how that capacity is allocated. DharmaOCR was trained to accept that constraint in reverse. The model is not designed to be the best option for other languages, and was never intended to be. In exchange, every parameter available to the network could be oriented toward the specific vocabulary, morphology, and orthographic patterns of Brazilian Portuguese — the most directed possible use of the model's resources for that domain. That concentration is the structural basis of an inherent advantage over multilingual and broader-domain models. The advantage does not depend on having a larger architecture or a more sophisticated training procedure than competitors use — new architectures and new training techniques improve what any model can do. It depends on where those resources are directed: at one domain rather than spread across many. Three months later, newer models have arrived. Whether the case for specialization holds when those models are newer and more capable is a different question. When we ran both against the DharmaOCR benchmark — an evaluation designed exclusively around Portuguese — the results were conclusive. Figure 1: ENEM essay manuscript used in benchmark evaluation with outputs of the each model. Misreads marked in red. DharmaOCR, evaluated on the same documents, handles these cases correctly. The reason is direct: the model's training was concentrated on this linguistic space, orienting its resources toward the vocabulary and proper noun distributions that characterize Brazilian Portuguese rather than spreading them across many languages at once. The examples illustrate the benchmark rather than replace it. The benchmark establishes the magnitude of the gap; the examples show why it is concentrated in language-specific recognition rather than in general capability. Extraction accuracy, however, is only one dimension of production performance. Stability under visual difficulty is another — and operationally, it is the more consequential one to fail on. When a generative model encounters a document it cannot clearly resolve — small fonts, degraded scan quality, dense handwriting — it faces uncertainty in its input signal. Models trained primarily on next-token prediction objectives face a specific vulnerability here: when the visual signal becomes ambiguous, the model can continue generating from prior learned patterns rather than from the source document. The result is text degeneration — output that is repetitive, incoherent, and semantically disconnected from the page. Presented with a document with small fonts, Mistral OCR4 produces output with no connection to what is written. This is not a low-quality transcription of the source. It is a failure of an entirely different category. DPO trains against a different signal. Where SFT trains token by token, DPO trains the model against the quality of complete outputs — teaching it to discriminate between competing responses based on the coherence of the full extraction rather than the accuracy of individual predictions. The effect is stabilizing: on documents where visual complexity would otherwise trigger drift, the model is less likely to commit to a divergent path, because its training penalized outputs that lost coherence at the extraction level. The result is what the original benchmark demonstrated: lower degeneration rates alongside higher extraction accuracy, on the same documents where models without this training stage lose coherence. The benchmark establishes what is true today. It is less precise about what will be true in two years. What changes with each architectural generation is the ceiling on absolute performance. What does not change is the structural logic that determines which systems come closest to their ceiling in a given domain. Three months ago, we showed that concentrating a model's training on a specific domain produces a measurable advantage over generalist systems, including ones that are newer and better-resourced. That advantage held. The same principle will determine how DharmaOCR continues to evolve — not by staying fixed, but by applying whatever progress the field makes to a domain that remains fixed. Explore Dharma AI on Hugging Face to try our interactive demos, download our open-source models, and discover how specialized AI systems outperform general-purpose models in real enterprise applications.