How a 0.9B Small Model Solves Irregular Polygon Detection for Document Parsing

    This article explains why location, not recognition, is the bottleneck in real-world document parsing, and how a compact 0.9B vision-language model handles irregular polygon detection. It covers the five common physical distortions, the benefits of polygon-based geometry over axis-aligned boxes, evaluation practices for distorted-document benchmarks, a capability checklist, a reusable integration pipeline with sample code, and tuning advice for deployment.

    1. Why Real-World Document Parsing Breaks at Localization

    Digitizing invoices, archives, contracts, and forms usually splits document parsing into two subproblems: first find where something is, then recognize what it is. Most traditional pipelines simplify localization into horizontal rectangle detection. That works reasonably well for clean scans and front-facing photos, but it falls apart quickly in the physical world.

    Physical distortion typically falls into five categories: scanning artifacts, page skew, paper warping, screen rephotography, and uneven lighting. The direct consequences are text lines that are no longer horizontal, table lines that are no longer orthogonal, and seal contours stretched into irregular shapes. If you still regress rectangles under these conditions, each box mixes in content from neighboring columns and background noise, and downstream recognition and structural reconstruction collapse. Irregular-shape localization is therefore not a nice-to-have feature; it is the dividing line between usable and unusable parsing for complex documents.

    2. Technical Approach: Why a Small Model Can Do Precise Polygon Detection

    A new generation of 0.9B-class vision-language models treats document parsing as a multi-task generation problem: the model outputs text content together with the corresponding sequence of geometric positions, expressed as polygon vertices rather than a fixed four-point axis-aligned box. This change brings three benefits.

    First, the geometry fits physical deformation better. A polygon can follow the actual path of a curved text line, avoiding the “noise outside the box” problem on warped pages. Second, the tasks are more tightly coupled. Localization and recognition share the same visual semantic representation, reducing the error amplification that plagues two-stage pipelines. Third, parameter efficiency is higher. The compact 0.9B scale keeps memory usage and inference latency manageable, making batch deployment on edge devices or in private environments practical, while extending capability boundaries through tasks such as text detection and seal recognition instead of piling on parameters.

    One engineering caveat: the number of polygon vertices, the coordinate normalization convention, and the output sequence length directly affect post-processing logic. In production, make “vertex parsing → mask cropping → perspective correction” an independent, replaceable module so it can be tuned per distortion type.

    3. Evaluation Strategy: From a Single Leaderboard to a Real Distortion Benchmark

    Looking only at accuracy on clean datasets tends to overestimate production performance. A more rigorous approach is to build an augmented evaluation set covering the five physical distortion categories, measure performance separately on text recognition, table structure reconstruction, formula recognition, and chart-to-table conversion, and report seal and text-line localization metrics on their own.

    Three points matter when designing the evaluation. First, distortion parameters must be reproducible, for example skew angle ranges and lighting intensity gradients. Second, metrics must distinguish “recognition correct but localization offset” from “localization correct but recognition wrong”; otherwise you cannot find the bottleneck. Third, include document-level metrics for long, multi-page documents so single-page evaluation does not hide content fragmentation. Public industry results show this class of 0.9B model reaching roughly 94.5% accuracy on complex document benchmarks, improving on the previous best result, which indicates the lightweight route is practically viable in document intelligence.

    4. Capability Checklist

    • Irregular-shape localization: polygon detection that adapts to skewed and warped pages.
    • Tables and formulas: simultaneous improvements in structure reconstruction and math expression recognition.
    • Chart-to-table: recovering numeric relationships in visualizations as computable structures.
    • Text spotting: unified output of localization and recognition.
    • Seal recognition: extraction of key elements for credential-type documents.
    • Multilingual and specialized text: broader language coverage and better handling of hard samples such as rare characters, ancient texts, underlines, and checkboxes.
    • Cross-page merging: automatically stitching cross-page tables and linking cross-page paragraphs and headings to mitigate fragmentation in long documents.

    5. Engineering: A Reusable Integration Pipeline

    A typical integration wraps the model as a local inference engine that loads weights and the multimodal projection file through a quantized format, so the business side depends only on the engine interface. Sample code:

    1. var engine = new DocumentVlmEngine();
    2. engine.LoadModel(modelPath, mmprojPath);
    3. var result = engine.Parse(imagePath, new ParseOptions {
    4. EnableTable = true,
    5. EnableFormula = true,
    6. EnableSeal = true,
    7. PolygonOutput = true
    8. });
    9. foreach (var block in result.Blocks) {
    10. // block.Polygon holds irregular quadrilateral/polygon vertices
    11. // block.Text holds the recognition result
    12. }

    Deployment recommendations: keep model files in a separately mounted directory to avoid coupling them to the image; use dynamic batching for batch requests to amortize per-inference overhead; split very long documents by page, process pages in parallel, then perform cross-page merging at the business layer; route low-confidence polygon results to a human review queue.

    For cloud hosting, you can compose general-purpose capabilities: object storage for raw and result files, a container platform for stateless inference services, a message queue for peak shaving and asynchronous processing, and logging plus monitoring and alerting to track latency and failure rate. Baidu AI Cloud typically builds solutions for document intelligence scenarios along these same general capability layers.

    6. Common Pitfalls and Tuning Advice

    Pitfall one: assuming a small parameter count necessarily means insufficient accuracy. The real bottleneck is often pre-processing and post-processing, not model size. Pitfall two: treating rectangle metrics as the final metrics. Introduce polygon IoU and structure reconstruction accuracy. Pitfall three: ignoring long documents; cross-page consistency needs separate design. For tuning, filling in distortion samples, unifying the coordinate normalization convention, and setting independent thresholds for tables and seals usually pay off more than blindly switching to a larger model.