Abstract
Large Language Models (LLMs) such as Claude and ChatGPT demonstrate a surprising ability to interpret document layouts when OCR text is formatted with strategic whitespace. This paper introduces LATIN-Prompt (Layout and Task Aware Instruction Prompt), a method that reconstructs visual structure through spaces and line breaks. This approach enables zero-shot performance on Document Visual Question Answering (DocVQA) tasks that rivals specialized, heavily pre-trained state-of-the-art models without requiring additional layout-aware neural modules.
Introduction
Document Visual Question Answering (DocVQA) is a complex task because documents are inherently two-dimensional structures. Meaning is derived not just from text, but from the spatial proximity of words, table columns, and headers.
Traditional "layout-aware" models, such as LayoutLM, address this by incorporating additional neural network layers to process 2D coordinates. However, these models require extensive pre-training on millions of document images and are difficult to integrate with powerful, closed-source LLMs like GPT-4 or Claude. This research explores whether LLMs can understand document layout using only text-based prompts.
Methodology
LATIN-Prompt
The core contribution is the Layout and Task Aware Instruction Prompt (LATIN-Prompt). Instead of providing a model with a flat string of OCR text, LATIN-Prompt reconstructs the document's visual appearance using two primary components:
- Layout-Aware Content: The system utilizes OCR bounding boxes to calculate a "character width" for the document. It then inserts a specific number of spaces between text segments and line breaks between rows to mimic the original physical layout.
- Task-Aware Instructions: The formatted text is wrapped in a template that explicitly defines the task constraints, such as requiring answers to be short text spans taken verbatim from the document.
LATIN-Tuning
While large-scale models handle whitespace layout intuitively, smaller open-source models (e.g., Alpaca 7B) often struggle. To address this, the authors developed a synthetic training pipeline called LATIN-Tuning. This involves converting CSV tables into layout-aware strings and using Claude to generate question-answer pairs. Fine-tuning smaller models on this synthetic data teaches them to "read" whitespace-based layouts effectively.
Experimental Results
The authors evaluated LATIN-Prompt on three major benchmarks: DocVQA, InfographicVQA, and MP-DocVQA. The performance gains over standard "plain" text prompts were significant:
- Claude: Improved DocVQA performance by 263%, with the ANLS score jumping from 0.2298 to 0.8336.
- ChatGPT-3.5: Observed a 20% improvement.
- Alpaca 7B: After LATIN-Tuning, performance on DocVQA improved by 87.7%.
- SOTA Comparison: Claude combined with LATIN-Prompt achieved zero-shot results comparable to the fine-tuned performance of specialized models like LayoutLMv3, despite never being explicitly trained on document images.
Discussion and Key Insights
- Whitespace as a Universal Language: The study suggests that LLMs can treat a prompt as a "text-based image," bypassing the need for complex 2D coordinate embeddings.
- Synthetic Data for Small Models: Small models are not inherently incapable of layout understanding; they simply lack exposure to structured whitespace during initial training. A small amount of targeted synthetic data (5,000 samples) can bridge this gap.
- Precision via Instructions: Explicit task instructions are crucial for preventing hallucinations in document tasks where verbatim extraction is required.
Limitations and Future Work
The method relies heavily on the quality of the underlying OCR engine; poor OCR grouping can lead to garbled whitespace reconstruction. Furthermore, while the method captures spatial layout, it currently ignores visual cues like font color, bolding, or icons. Future research may explore "multimodal" prompts that combine whitespace layout with actual visual features for more robust understanding.
Summary updated