Adaptive Markup Language Generation for Contextually-Grounded Visual Document Understanding

Han Xiao, Yina Xie, Guanxin Tan, Yinghao Chen, Rui Hu, Ke Wang, Aojun Zhou, Hao Li, Hao Shao, Xudong Lu, Peng Gao, Yafei Wen, Xiaoxin Chen, Shuai Ren, Hongsheng Li

Introduction

Multimodal Large Language Models (MLLMs) have made significant strides in general image understanding, yet they frequently falter when faced with "text-rich" documents such as dense PDFs, complex tables, and scientific charts. The primary hurdle is the structural gap between raw visual perception and the logical layout of a document. DocMark introduces a novel framework that teaches models to bridge this gap by using markup languages as an intermediate reasoning step.

The Hallucination Problem

Current fine-tuning paradigms often train models on simple Question-Answer pairs. This encourages models to map pixels directly to answers, bypassing a deep structural understanding of the document. Consequently, models often "hallucinate"—generating plausible-sounding but factually incorrect answers based on visual patterns rather than precise data extraction. This is particularly evident in charts and tables where spatial relationships are critical.

The DocMark Framework

DocMark addresses this by introducing an Adaptive Markup Language Generation pipeline. Instead of jumping straight to an answer, the model performs a two-step "Chain-of-Thought" (CoT) process:

  1. Context Extraction: The model identifies the most relevant part of the document and converts it into a structured markup language (e.g., Markdown for tables or JSON for charts).
  2. Grounded Reasoning: The model uses this intermediate "rationale" alongside the original image to derive the final answer.
DocMark's two-step reasoning process compared to standard MLLM direct answering.

Adaptive Structural Representation

A key innovation of DocMark is its adaptivity. The model is not hard-coded to a single format; rather, it learns to select the most appropriate markup language based on the document's content. This includes Markdown for tabular data, JSON for statistical charts, LaTeX for mathematical formulas, HTML for web layouts, and TikZ for geometric diagrams. By forcing the model to output the relevant context first, the task of "finding the data" is effectively disentangled from "calculating the answer."

The diverse set of markup languages used by DocMark to represent different document structures.

Data and Training

To support this capability, the researchers developed two large-scale datasets:

  • DocMark-Pile (3.8M pairs): A pretraining dataset designed to teach models how to parse diverse document types into six distinct markup formats.
  • DocMark-Instruct (624k annotations): A fine-tuning dataset containing annotations that follow the two-round CoT format, using teacher models (like GPT-3.5) to generate intermediate rationales based on ground-truth text.

Performance and Insights

Evaluations across benchmarks like DocVQA, ChartQA, and MathVision demonstrate that DocMark significantly outperforms baseline models. For instance, DocMark-8B (built on InternVL2) achieved a score of 84.2 on ChartQA, surpassing the standard InternVL2-8B. The inclusion of TikZ and LaTeX data also led to a significant jump in MathVision scores, proving that structural understanding directly aids complex scientific reasoning.

Conclusion

By using markup languages as a bridge between vision and text, DocMark provides a scalable path toward more reliable document understanding. While the intermediate generation step increases inference tokens, the gains in accuracy and the reduction in hallucinations represent a significant step forward for MLLMs in professional, academic, and scientific domains.

Summary updated

BibTeX
@inproceedings{xiao2025adaptive,
  author = {Han Xiao and Yina Xie and Guanxin Tan and Yinghao Chen and Rui Hu and Ke Wang and Aojun Zhou and Hao Li and Hao Shao and Xudong Lu and Peng Gao and Yafei Wen and Xiaoxin Chen and Shuai Ren and Hongsheng Li},
  title = {{Adaptive Markup Language Generation for Contextually-Grounded Visual Document Understanding}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.02752},
}
Figure