TextHawk2: A Large Vision-Language Model Excels in Bilingual OCR and Grounding with 16x Fewer Tokens

Ya-Qi Yu, Minghui Liao, Jiwen Zhang, Jihao WuarXiv 2024 · DOI

Abstract

TextHawk2 is a bilingual Large Vision-Language Model (LVLM) designed to address the computational bottleneck of high-resolution visual processing. By employing a novel two-stage compression architecture, TextHawk2 achieves a 16x reduction in visual token count compared to its predecessors while maintaining state-of-the-art performance in Optical Character Recognition (OCR) and object grounding. Through multi-level feature extraction and a unified backbone, the model demonstrates that fine-grained perception can be achieved without the massive computational overhead typically associated with high-resolution document understanding.

Introduction

As Large Vision-Language Models (LVLMs) move toward "document intelligence" and GUI automation, they face a fundamental conflict: resolution versus cost. To read dense text or locate small objects, models require high-resolution input. However, standard architectures convert these images into thousands of visual tokens, leading to massive memory usage and slow inference. Furthermore, most models struggle to balance general VQA with specialized tasks like grounding or OCR, often requiring multiple specialized encoders.

TextHawk2 aims to bridge this gap, creating a single, efficient model that excels at general VQA, bilingual (Chinese/English) OCR, and precise object grounding simultaneously, all while drastically shrinking the visual token footprint.

Architectural Innovations

To achieve high efficiency without sacrificing detail, TextHawk2 introduces several key structural components:

  1. 16x Token Compression: The model uses a two-step process to shrink visual representations. First, a Query Proposal Network (QPN) utilizes 2×2 max pooling during resampling. Second, a rearrangement strategy combines four adjacent tokens into a single window. This results in a total compression ratio of 16, significantly reducing the sequence length passed to the LLM.
  2. Multi-Level Cross-Attention (MLCA): Instead of relying solely on the final layer of the visual encoder, TextHawk2 extracts features from four different stages (layers 14, 18, 22, and 26). This allows the model to capture both low-level structural details (crucial for OCR) and high-level semantic information.
  3. Scalable Positional Embeddings (SPEs): To handle images of any aspect ratio, the model uses Spherical Linear Interpolation (Slerp) to adapt positional embeddings dynamically, ensuring spatial awareness regardless of image shape.
  4. Efficient Grounding Head: Rather than representing coordinates as long text strings, TextHawk2 uses specialized coordinate tokens, reducing a bounding box representation to just 7 tokens.
Overview of the TextHawk2 architecture, featuring the Visual Encoder, Resampler, and LLM with a specialized Detection Head.

The "Gulliver Tunnel" Effect

A central concept in the paper is the "Gulliver Tunnel" (referencing the shrinking gadget from Doraemon). This metaphor describes how the model can squeeze 183 words from a high-resolution image into just 32 tokens while remaining perfectly recoverable by the LLM. Simply pooling tokens often destroys the reading order of text; TextHawk2’s rearrangement strategy interleaves tokens from sub-images to align with natural line-by-line scanning, which is vital for document understanding.

The 'Gulliver Tunnel' concept: compressing high-resolution text into a compact 32-token representation.

Training and Datasets

The model was pre-trained on a massive mixture of 100 million samples, categorized into three primary pillars:

  • General Knowledge: Data from CapsFusion (re-captioned web data) and Wanjuan1.0.
  • Grounding: GrIT-20M (synthetic captions with location labels) and UMG-41M.
  • OCR & Document Understanding: Wukong (Chinese OCR), IIT-CDIP (English), LaTeX/Markdown documents, and PubTables-1M.

By co-training on these diverse tasks, the authors demonstrate that a language-supervised encoder (SigLIP), which is typically less effective at fine-grained spatial tasks, can be "reinforced" to excel at both Chinese OCR and grounding without needing a second, specialized encoder.

Experimental Results

TextHawk2 consistently outperforms both closed-source and open-source models of similar or larger scales across several benchmarks:

  • OCR Performance: The model achieved 78.4% on OCRBench and 89.6% ANLS on DocVQA, rivaling or beating models like Gemini-1.5-Flash and InternVL2-8B.
  • Chart & Table Mastery: It scored 81.4% on ChartQA, showing a significant lead over many generalist LVLMs.
  • Grounding: On RefCOCOg-test, it reached 88.1% [email protected], proving that massive token compression does not sacrifice the ability to precisely locate objects.

Conclusion and Future Work

TextHawk2 proves that fine-grained perception does not require massive computational overhead. While the model currently faces some challenges with rare Chinese characters and high-level logic tasks, it sets a new standard for efficient, high-resolution visual understanding. Future work will focus on refining OCR data quality, exploring native resolution ViT training, and implementing Reinforcement Learning from Human Feedback (RLHF) to further reduce hallucinations.

Summary updated

BibTeX
@misc{yu2024texthawk,
  author = {Ya-Qi Yu and Minghui Liao and Jiwen Zhang and Jihao Wu},
  title = {{TextHawk2: A Large Vision-Language Model Excels in Bilingual OCR and Grounding with 16x Fewer Tokens}},
  year = {2024},
  eprint = {2410.05261},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.05261},
}
Figure