Architecture Design and Vision-Text Compression Practices for High-Resolution Document Recognition Models

    This article explores the architecture and engineering practices behind high-resolution document recognition models, focusing on the innovative "vision-text compression" approach. It covers how an encoder-sparse decoder architecture, dynamic token rearrangement, and multi-level resolution configurations optimize OCR accuracy and reduce inference costs. Additionally, it reviews benchmark performance, deployment strategies for high-throughput processing, and the broader implications for LLM long-context memory mechanisms.

    1. Background: Why “Vision-Text Compression” is Needed

    In the training and application of Large Language Models (LLMs), massive historical documents (PDFs, scanned files, whiteboard notes, charts) have long existed in image formats, making it difficult for them to participate efficiently in model training and context memory. While the traditional pipeline of page-by-page OCR conversion to text is feasible, it suffers from two bottlenecks: a long parsing pipeline where errors accumulate progressively, and the loss of layout, table structures, and relative image-text positions in pure text.

    Recently, the industry has proposed a new approach: since visual tokens can carry semantics, can long texts be rendered into images first, and then their information “compressed” using a minimal number of visual tokens, allowing the model to read the text back directly from the image? This is the core problem addressed by “vision-text compression boundary” research—how much text content can be losslessly restored using as few visual tokens as possible. Empirical results show that when the compression ratio is controlled at around 10x, the OCR accuracy reaches 97%; even when compressed to 20x, it retains about 60% restoration accuracy. This phenomenon indicates that the visual modality has a considerably high density for carrying text information, providing a new direction for long-text compression and model memory mechanism research.

    2. Core Architecture: Encoder-Sparse Decoder Collaborative Design

    Such high-compression-ratio document recognition models typically adopt a two-stage structure: a “strong encoder + sparse activated decoder,” with a total parameter scale controlled around 3B to balance accuracy and inference cost.

    2.1 Vision Encoder: Hierarchical Processing for Heavy Workloads

    Document images differ significantly from natural images: text strokes are fine and dense, and layout elements are tightly packed. Relying solely on general vision backbones tends to lose focus on fine text. Therefore, the encoder design has two key points:

    • Dual-stage feature extraction: First, convolutional vision modules are used for high-resolution local feature extraction (bearing most of the computational load), followed by window attention or a lightweight language model for global semantic aggregation, preventing the Transformer’s self-attention from quadratically expanding with resolution.
    • Layout information retention: The encoder must not only extract text content but also preserve the original image’s layout structure. Some upgraded solutions abandon general visual contrastive learning models in favor of a lightweight language model (around 0.5B) as the vision encoder, allowing “reading text” and “understanding layout” to be accomplished in the same semantic space.

    2.2 Dynamic Token Rearrangement: Causal Flow Query Mechanism

    The sequential order of document image patches often does not match their reading order (e.g., double columns, tables, interspersed captions). Upgraded solutions introduce learnable “query vectors” to dynamically rearrange image patches, making the visual token sequence closer to the causal reading order of the text. This reduces cross-patch information jumps during the decoder’s autoregressive generation. This mechanism also supports variable visual token inputs ranging from 256 to 1120, achieving “on-demand allocation” of compression granularity.

    2.3 Sparse Decoder: MoE Structure to Control Inference Cost

    The decoder utilizes a Mixture of Experts (MoE) structure. With total parameters around 3B, less than 0.6B are activated during each inference, drastically reducing the single forward computation while ensuring model capacity. This is particularly crucial for document processing tasks handling millions of pages daily.

    3. Multi-level Resolution Configurations: Balancing Accuracy and Cost

    Targeting different document types, models typically offer multiple configuration tiers. Below is an illustrative parameter structure:

    1. CONFIGS = {
    2. "tiny": {"base_size": 512, "image_token": 64},
    3. "small": {"base_size": 640, "image_token": 100},
    4. "base": {"base_size": 1024, "image_token": 256},
    5. "large": {"base_size": 1280, "image_token": 512},
    6. "gundam": {"base_size": 1024, "sub_size": 640, "mode": "hybrid"},
    7. }

    Selection recommendations:

    • Pure text pages, notes: Choose a smaller resolution tier for fewer tokens and higher throughput.
    • Complex layout pages: Choose a hybrid size tier (e.g., 1024x640 dynamic combination), combined with built-in bounding box detection and dynamic cropping strategies to locate layout regions before block-level recognition.
    • Academic papers dense with tables and formulas: Choose a larger resolution tier, trading more visual tokens for structural restoration accuracy.

    4. Performance Benchmarking and Engineering Deployment

    4.1 Benchmark Performance

    On public document parsing benchmarks (such as OmniDocBench-like evaluations), these models exhibit a clear “token-accuracy” gradient: using only 100 visual tokens can surpass dedicated OCR models, and 800 tokens outperform multi-module pipeline solutions. Upgraded versions achieve over 91% on the latest benchmarks, a roughly 3.7 percentage point improvement over the first generation. This indicates that end-to-end vision solutions have the potential to replace multi-stage pipelines in full-page parsing.

    4.2 Throughput Capacity

    Thanks to sparse activation and visual token compression, a single high-end inference card can process over 200,000 pages per day. Key engineering deployment points:

    1. Rasterize PDFs into images first, scheduling by page queue for easy horizontal scaling.
    2. Group batch inference by resolution tier to reduce memory fragmentation.
    3. Standardize output to Markdown, preserving heading hierarchies, tables, and paragraph structures for easy downstream RAG ingestion.
    1. # Pseudocode: Batch document recognition task
    2. for pdf in pdf_queue:
    3. images = pdf_to_images(pdf)
    4. results = model.batch_infer(
    5. images, config="small", output_format="markdown"
    6. )
    7. store.save(pdf.id, results)

    5. Application Value and Research Insights

    For engineering teams, these models can be directly used as foundational components for PDF-to-Markdown conversion, scanned document structuring, and batch document ingestion. For researchers, the concept of “rendering long texts into high-compression images carried by a few visual tokens” provides a novel perspective on LLM long-context memory mechanisms. Historical conversations or knowledge can be “image-compressed” and stored in memory banks, then read back via the visual channel when needed, with an information density far exceeding the bloat rate of traditional KV caches. As compression algorithms and decoding strategies continue to evolve, vision-text compression is poised to become a critical infrastructure for long-context management and multimodal memory.