Multimodal LLM Practice: Long Video and Document Parsing

    This article presents a practical, model-agnostic approach to building multimodal LLM workflows. Instead of coupling business logic to a specific model, it abstracts requirements into four independently testable capabilities: visual grounding with structured output, cross-document reasoning, long-video temporal understanding, and front-end code generation with multi-turn revision. For each capability, it shares reusable prompt structures, task breakdowns, and acceptance criteria, followed by engineering recommendations covering interface abstraction, output contracts, cost routing, observability, and data security.

    1. Background: From Quota Anxiety to Capability Abstraction

    Many developers evaluating a cloud vendor’s model service on a free tier eventually run into tightened quotas: advanced models are no longer available to free users, and lightweight models are capped at a very low number of daily calls. When a batch workflow that depended on a lightweight model breaks, the real problem is not that one model disappeared. The problem is that the workflow tightly coupled business logic to a specific model.

    A more practical approach is to abstract capabilities first, breaking requirements into four categories that can be evaluated independently:

    • Visual grounding and structured output (grounding plus JSON/HTML constraints);
    • Long-document and multi-document cross-reasoning;
    • Long-video temporal understanding;
    • Code generation and multi-turn interactive revision.

    As long as each of these capabilities has a replaceable implementation, model selection becomes a configuration item rather than a reason to refactor. The sections below provide reusable practices for each capability, using generic technical terms without binding to any specific product.

    2. Capability 1: UI Replication and Front-End Code Generation

    2.1 Task Breakdown

    UI replication is not “look at an image and write a page.” It is a three-layer task: layout structure recognition, style restoration, and asset/interaction completion. In practice, it is best to proceed in three rounds, avoiding a vague one-shot request that leads the model to pile up meaningless container tags.

    Round one asks only for the structural skeleton and styles. Image areas must use placeholders, and using the screenshot as a background image or embedding the original image directly is prohibited. This keeps the page runnable even when assets are missing.

    Round two introduces asset retrieval: the model searches for available images based on the semantic meaning of each card’s topic and fills them into the corresponding positions. The key constraint here is that semantic match takes priority over visual similarity; otherwise, text and images may not correspond.

    Round three adds interactions: provide the detail-page screenshots as well, and require state transitions such as clicking through, expanding comments, and dragging the playback progress bar.

    2.2 Sample Prompt and Constraints

    1. Role: Senior front-end engineer
    2. Input: 1 screenshot (list page) + 2 screenshots (detail page)
    3. Requirements:
    4. 1) Output a single self-contained page; prefer semantic tags; no meaningless nesting;
    5. 2) Use placeholders for images, with dimensions matching the container aspect ratio;
    6. 3) Interactions must cover: card click to open detail, comment expand/collapse, progress bar dragging;
    7. 4) Manage state with a minimal set; avoid unnecessary dependencies;
    8. 5) List the 3 assumptions you made at the end.

    2.3 Acceptance Criteria

    • Structural soundness: whether semantic tags are used and whether the hierarchy is manageable;
    • Style fidelity: whether spacing, border radius, and font-size hierarchy match;
    • Runnability: whether it still renders without external assets;
    • Maintainability: after multiple rounds of added requirements, whether it produces clean incremental changes instead of rewriting the full code.

    Stacking requirements across multiple rounds best exposes differences in model capability: weaker models tend to rewrite entire sections, while stronger models provide patch-style changes with minimal edits.

    3. Capability 2: Extraction and Structured Output from Mixed Materials

    3.1 Why It Is Hard

    Handing the model a collage containing a handwritten table, a receipt, and a handwritten resume essentially tests three things: reading the content, locating positions, and clarifying relationships between fields. Traditional optical character recognition can only “read the text”; it cannot answer “which field does this text belong to, and which entity does that field belong to.” As a result, downstream still requires extensive rule-based patching.

    3.2 Composite Instruction Design

    Giving multiple non-overlapping output requirements in a single conversation tests whether the model can maintain multiple output contracts at the same time:

    1. 1) Recognize the table in the image and output an HTML <table>, preserving merged-cell semantics;
    2. 2) Recognize the stamp in the image, split it into fields such as "organization/name/tax ID," and output JSON key-value pairs;
    3. 3) Recognize the body text in the image and output Markdown, preserving heading levels and lists.

    3.3 Interpreting Results

    Ideal output has three characteristics: text inside the stamp is not mixed with the body text; fields are split into independent key-value pairs rather than one long string; and the three formats do not contaminate each other. Once structured output is stable, this step can be integrated into an automated pipeline—for example, delivering tasks through a message queue, consuming them with a containerized service, writing results to object storage, and tracking failure rates with logging and monitoring alerts—without manual re-entry.

    4. Capability 3: Cross-Document Academic Analysis and Long-Form Writing

    4.1 Task Setup

    Provide two papers and ask for a comparison of figure differences, a comparison of the similarities and differences between two sequence-modeling architectures, and further improvement ideas. The dividing line for this kind of task is whether it cites details from the original text. Analysis that gives only conclusions cannot be verified; analysis with figure locations and textual evidence can be reviewed.

    4.2 Prompt Structure

    1. 1) First summarize the core contributions and experimental setup of each paper separately;
    2. 2) Align the figure metrics of both and list differences and possible causes;
    3. 3) Compare the two architectures in terms of gating mechanisms, parallelism, and long-range dependency modeling;
    4. 4) Provide 2-3 verifiable improvement ideas and note the validation metrics.

    4.3 Quality Control

    Require the model to mark evidence locations, so humans only need to spot-check key conclusions; inferences that cannot be supported by the original text should be explicitly marked as “speculation.” Long-form writing follows the same principle: define the outline first, expand section by section, then unify terminology and conventions, which significantly reduces contradictions.

    5. Capability 4: Long Video and Long-Context Understanding

    Long-video understanding must handle both time and semantics: shot changes, subtitles, progress-bar position, and key actions. In practice, it is recommended to sample frames at fixed time intervals with timestamps attached, have the model output a structured event table with time ranges, and then generate summaries and answer questions based on the event table. This controls context length and makes conclusions traceable to specific timestamps.

    6. Engineering Recommendations

    • Abstract the interface layer: uniformly wrap “image/document/video to structured result,” with pluggable models;
    • Contracts first: constrain output with a JSON Schema, automatically retry on validation failure, and degrade gracefully;
    • Cost control: route by task difficulty to models of different parameter sizes; simple extraction goes through a lightweight channel;
    • Observability: record latency, failure reasons, and retry counts, and configure monitoring alerts;
    • Data security: desensitize sensitive materials first, and use encrypted channels for both transmission and storage.

    7. Conclusion

    Quota changes are only a reminder: the stability of a multimodal workflow comes from task decomposition, output contracts, and replaceable model abstractions, not from a particular model’s free quota. Once you have accumulated evaluation sets and prompt templates for the four capabilities above, any newly released model can be compared and switched to within half a day.