High-Compression Vision-Text Encoding Models: A Technical Architecture Overview for Document Recognition

    This article explores the technical architecture of high-compression vision-text encoding models designed for document recognition. It covers the background of visual-text compression, the division of labor between visual encoders and Mixture of Experts (MoE) decoders, and key technical evolutions such as multi-size configurations and causal flow queries. Additionally, it outlines engineering best practices for deployment and discusses the implications of this technology for LLM memory mechanisms.

    I. Background: The Need for Visual-Text Compression

    The context window of Large Language Models (LLMs) is a limited and expensive resource. Traditional OCR pipelines typically recognize documents as plain text before passing them to language models. This approach presents two prominent issues: first, it loses the original layout information, making it impossible to restore structures like tables, multi-column layouts, and mixed text-image arrangements; second, long documents consume a massive amount of text tokens, causing inference costs to increase linearly with document length.

    The approach of “rendering text as images and expressing it with a small number of visual tokens” offers a new direction for solving this problem. Research indicates that language models possess a compression potential for text information in image form that far exceeds pixel density. When a long text document is rendered into a highly compressed image, the model can express thousands of words using tens to hundreds of visual tokens, with almost no information loss at moderate compression rates. The core research question thus becomes: Where exactly does the compression boundary lie between the number of visual tokens and the fidelity of text information?

    II. Typical Model Architecture: Encoder and MoE Decoder Division of Labor

    Taking recent representative technical solutions in the industry as an example, such models typically adopt a hierarchical architecture of “heavy encoder + light decoder.” The total parameter size can be controlled at around 3B while maintaining extremely high throughput.

    2.1 Visual Encoder (DeepEncoder-like Structure)

    The encoder generally consists of three cascaded modules:

    • Image Segmentation Module: Responsible for local feature extraction under high-resolution input, dividing the entire image into several semantically complete regions, balancing the big picture with details.
    • Visual Understanding Module: Performs semantic-level compression and abstraction of local features, acting as the “information bottleneck” and serving as the primary source of the compression ratio.
    • Projection Module: Maps visual features to the token space of the language model. A common implementation is a two-layer MLP with an activation function.
    1. # Illustrative projector structure
    2. class MlpProjector(nn.Module):
    3. def __init__(self, dim_in, dim_out):
    4. super().__init__()
    5. self.proj = nn.Sequential(
    6. nn.Linear(dim_in, dim_out),
    7. nn.GELU(),
    8. nn.Linear(dim_out, dim_out),
    9. )
    10. def forward(self, x):
    11. return self.proj(x)

    In upgraded versions, a notable change is abandoning traditional pre-trained vision models in favor of lightweight language models as visual encoders. The motivation is that the pre-training objectives of general vision models lean towards image classification or image-text alignment, lacking sufficient sensitivity to text details (such as similar glyphs, punctuation, super/subscripts). Using a small language model as an encoder allows for extracting text content while better preserving the layout information of the original image, achieving a unity of “recognizing text” and “recognizing layout.”

    2.2 MoE Decoder

    The decoder side adopts a Mixture of Experts (MoE) structure, with a typical configuration of about 3B total parameters and roughly 570M activated parameters per token. This design brings two main benefits:

    1. High Inference Efficiency: Only a small fraction of parameters is activated per token, allowing a single high-end accelerator card to achieve a throughput of processing over 200,000 pages per day.
    2. Sufficient Capacity Redundancy: Sparse activation allows the model to share knowledge across multiple tasks—such as character recognition, table restoration, and formula parsing—without mutual interference.

    III. Key Technical Evolution: From Static Cropping to Causal Flow Query

    3.1 Multi-Size Configuration Strategy

    The first-generation solutions typically offer multiple input configurations (such as Tiny/Small/Base/Large, and a mixed-size version for complex documents). The compression ratio and accuracy vary with the visual token budget:

    Configuration Level Typical Visual Tokens Applicable Scenarios
    Tiny 64 Fast rough extraction, throughput priority
    Small 100 General document recognition
    Base 512 Balance of accuracy and cost
    Large 1024 High-fidelity parsing
    Gundam (Mixed Size) 1024×640 crop combination Large format, multi-column complex documents

    Among these, the mixed-size version introduces dynamic cropping modes and bounding box detection: the model first assesses the document layout, then decides whether and how to partition it, avoiding the information aliasing caused by global downsampling of multi-column documents.

    3.2 Causal Flow Query (Core of the Upgraded Version)

    The second-generation solution introduces a learnable “causal flow query” mechanism: instead of arranging image fragments in a fixed raster order, the model learns a dynamic reordering strategy to prioritize fragments with high information density into the decoder’s causal attention flow. This change allows a wide range of inputs from 256 to 1,120 visual tokens to be utilized efficiently, achieving significantly higher accuracy than the previous generation on public document parsing benchmarks.

    Meanwhile, after the visual understanding module on the encoding side was replaced with a lightweight language model, the new version performed better in layout preservation. Public evaluations show that using only 100 visual tokens can surpass previous mainstream document understanding solutions, and accuracy further improves to exceed traditional parsing pipelines when using 800 tokens. Under 10x compression, the text recognition accuracy can reach 97%, and under 20x compression, it still maintains about 60% accuracy. This curve itself is a direct answer to the research question regarding the “compression boundary.”

    IV. Engineering Practice Essentials

    When deploying such high-compression document models in practice, it is recommended to focus on the following points:

    1. Choose Token Budget Based on Scenarios. Pure text extraction can be reduced to under 100 tokens; for professional documents containing tables, formulas, and multi-column layouts, it is advisable to increase the budget and enable dynamic cropping; for mixed-layout documents, prioritize mixed-size input.

    2. Preprocessing Determines the Upper Limit. PDFs must first be converted to rendered images. The rendering DPI, page margin padding, and image clarity directly affect recognition results. It is recommended to denoise and perform skew correction on scanned documents before feeding them into the model.

    3. Output Structuring. Mainstream implementations support Markdown format output, facilitating secondary editing and importing into office or knowledge base systems. For table scenarios, post-processing rules can be used to convert Markdown tables into structured JSON.

    4. Batching and Elastic Scaling. Using cloud object storage to manage document assets, scaling inference replicas based on load levels through a container platform, and using monitoring alerts to track token consumption and page-level throughput can significantly reduce unit processing costs.

    1. Typical Pipeline:
    2. PDF/Image → Preprocessing (Correction/Denoising) → Tiered Rendering → Visual Encoding
    3. → Dynamic Cropping (Complex Documents) → Projection → MoE Decoding → Markdown Output

    V. Implications for LLM Memory Mechanisms

    The value of this technology extends beyond OCR itself. When a model can losslessly express thousands of words of content using tens of visual tokens, “using images as a compressed carrier for long contexts“ becomes a new paradigm for LLM memory mechanisms: historical conversations and long document summaries can be rendered into images and re-injected into the context at extremely low token costs. This provides a feasible technical path for breaking through the cost bottleneck of long contexts and building sustainably updating agent memory systems, making it a direction worth continuous attention in current cross-disciplinary research between multimodality and LLMs.