Multimodal Models in Practice: UI Replication, Structured Extraction, and Document Analysis

    This article explains how vision-language models can handle screenshots, scanned documents, handwritten materials, long PDFs, and videos in everyday work. It describes five dimensions for evaluating a model, walks through three implementation scenarios (UI replication, structured extraction from mixed documents, and comparison of academic papers), outlines a method for long video understanding, and covers engineering concerns such as cost control, stability, and data protection.

    1. Background: Why Multimodal Capabilities Are Entering Everyday Workflows

    Much of the information at work exists as screenshots, scanned documents, handwritten materials, long PDFs, and videos. Processing these materials used to require a combination of traditional OCR, layout analysis, rule-based scripts, and manual proofreading. These pipelines were long and expensive to maintain. As vision-language models improved, a single model became able to read images, interpret tables, understand layouts, and output structured results. This makes it possible to automate many steps that previously required people.

    However, whether a workflow runs reliably depends on more than model capability. Tighter free quotas, changes in per-call pricing, and API rate limits can all interrupt a workflow that once worked. When introducing multimodal capabilities, three questions need to be considered together: whether the model can complete the task reliably, whether its output can be used directly by downstream programs, and whether the call cost is sustainable over time.

    2. Five Dimensions for Evaluating Capabilities

    When you choose a model or evaluate a proposed system, check each of the following dimensions one by one. Do not rely only on demo results.

    1. Visual understanding: Can the model recognize layout, color, font hierarchy, and icon semantics?
    2. Spatial grounding: Can the model indicate where a piece of text or an element is located in the image, for example by giving bounding box coordinates, rather than only reading the characters?
    3. Structured output: Can the model produce output in a specified format (HTML, JSON, or Markdown) consistently, with consistent field names and hierarchy?
    4. Long-context handling: When facing hundreds of pages or a long video, can the model keep information consistent across the whole input?
    5. Reasoning depth: Can the model compare the similarities and differences between two materials and give judgments supported by evidence?

    Each dimension should have a measurable metric. For example, structured output can be measured by the share of valid JSON and the rate of missing required fields. Grounding can be measured by the coordinate deviation found in manual spot checks.

    3. Scenario 1: UI Replication

    UI replication is a typical task for testing a model’s visual understanding and code generation. A reliable approach usually has three steps.

    3.1 Layout Recognition and Structure Reconstruction

    The model should first identify the region divisions of the page, such as the top navigation bar, the waterfall card area, and the bottom action bar. Then it should choose a semantic tag for each region. Avoid wrapping every element in multiple nested div elements. Semantic markup makes later maintenance and accessibility support easier.

    1. <article class="note-card">
    2. <img class="cover" src="placeholder.jpg" alt="Cover image" />
    3. <h3 class="title">Sample title</h3>
    4. <footer class="meta">
    5. <button class="like" aria-label="Like">♡</button>
    6. <span class="count">128</span>
    7. </footer>
    8. </article>

    3.2 Image Placeholders and Asset Replacement

    Using the original screenshot directly as an asset often results in insufficient resolution and local blurriness. It can also raise copyright issues. A safer approach is to first use placeholder images to keep the layout correct, then search for replacement assets based on the card topics. When you search, record the source and license of each asset. Also keep replaceable data interfaces in the code.

    3.3 Interaction Logic and Verification

    Interactions include toggling the like state, submitting comments, and dragging the video progress bar. After generating the code, focus on three issues: whether state is managed in one place, whether event listeners are removed when components unmount, and whether the interface has a fallback when an asynchronous request fails. For verification, use a screenshot comparison tool to calculate pixel differences. Also check that the DOM structure has clear semantics.

    4. Scenario 2: Structured Extraction from Mixed Invoices and Handwritten Materials

    The difficulty in this scenario is that a single image may contain tables, seals, handwritten text, and printed text. Each type of content needs a different output format.

    4.1 Splitting Output Channels

    Splitting a large task into several sub-instructions, each with its own output format, can significantly reduce the chance that the model confuses content types.

    • Table content: Output as an HTML <table>, preserving merged cell relationships.
    • Seal content: Output as JSON, with key-value pairs for fields such as unit name, seal name, and taxpayer identification number.
    • Regular text: Output as Markdown, keeping the paragraph order.

    4.2 The Value of Grounding

    Traditional OCR can only answer “what is written here.” It cannot answer “where is this character, and how does it relate to other characters.” A model with grounding ability can output a bounding box for each field. These coordinates can highlight the original image position during manual review. They can also determine whether two fields belong to the same region.

    4.3 Structured Output Example

    1. {
    2. "seal": {
    3. "unit_name": "Sample Company Ltd.",
    4. "seal_name": "Finance seal",
    5. "taxpayer_id": "91000000000000000X",
    6. "bbox": [412, 306, 538, 432]
    7. }
    8. }

    4.4 Downstream Validation

    Model output should not be written directly into a database. Set up three layers of validation:

    1. Format validation: Use JSON Schema to check that fields are complete and types are correct.
    2. Rule validation: For example, a Unified Social Credit Code, the 18-character business identifier used in China, must have 18 characters. Its check digit can be verified with the algorithm defined in the national standard.
    3. Sampling review: Have a person confirm low-confidence fields, or the first appearance of a new document layout.
    1. import json
    2. REQUIRED_SEAL_FIELDS = {"unit_name", "seal_name", "taxpayer_id"}
    3. def validate_seal(raw_text: str) -> dict:
    4. data = json.loads(raw_text) # Raises an exception if the JSON is invalid
    5. seal = data.get("seal", {})
    6. missing = REQUIRED_SEAL_FIELDS - seal.keys()
    7. if missing:
    8. raise ValueError(f"Missing fields: {sorted(missing)}")
    9. if len(seal["taxpayer_id"]) != 18:
    10. raise ValueError("Taxpayer ID has an unexpected length")
    11. return seal

    5. Scenario 3: Academic Document Comparison and Architecture Analysis

    When the input is two or more papers, the task shifts from recognition to reasoning.

    5.1 Prompt Structure

    An effective prompt usually has four parts: the task goal, the comparison dimensions, citation requirements, and the output format. For example, asking the model to mark the source figure or table number for every conclusion can significantly reduce unsupported claims.

    5.2 Comparison Dimensions: Transformer and Improved LSTM

    Dimension Transformer with self-attention Improved LSTM variants
    Computation Tokens within a sequence interact pairwise and can be highly parallelized Computes recurrently over time steps, with limited parallelism during training
    Long-range dependencies Models relationships at any distance directly Relies on gates and memory cells to retain information
    Inference memory The key-value cache grows with context length, adding considerable overhead Fixed state size, with stable inference memory use
    Inductive bias Weak, relies on large-scale data Strong temporal assumptions

    These differences come from the architectures themselves. They should not be read as an overall advantage for either side. When choosing between them, consider sequence length, deployment resources, and data scale.

    5.3 Improvement Directions

    Research has commonly explored the following directions to address known weaknesses of LSTM:

    • Exponential gating: Replaces sigmoid gates with exponential forms to widen the dynamic range of information writing. Normalization is used to keep values numerically stable.
    • Matrix memory: Expands the vector memory cell into a matrix to store more information per step. Retrieval is implemented through covariance-style updates.
    • Parallelized training: Redesigns the recurrent structure so training can compute in batches, like attention. This eases the serial bottleneck of the original LSTM.
    • Hybrid architectures: Keeps recurrent modules in some layers and adds attention in others, balancing long-sequence efficiency and global modeling.