Practices for Visual Reasoning and Efficient Compression in Multimodal Large Models

    Multimodal capabilities are essential for modern large models to directly process images, charts, and UIs, bypassing error-prone OCR pipelines. This article explores the technical evolution of vision-language models, including alignment, Mixture of Experts (MoE), and the shift from basic understanding to complex reasoning. It details key technical points such as visual token compression, intermediate representations for visual reasoning, and inference cost estimation. Additionally, it covers practical implementations of image understanding in AI agent scenarios, emphasizing action validation and state management.

    I. Why Multimodal Capabilities are Essential for Large Models

    Large Language Models (LLMs) primarily process text, yet a massive amount of information in real-world business scenarios exists in the form of screenshots, tables, charts, scanned documents, and files. Models restricted to text reading require Optical Character Recognition (OCR) or manual data preparation. This creates a long processing pipeline where errors at any step propagate to subsequent stages. Models equipped with native visual understanding can directly extract layout structures, spatial relationships, and numerical trends from images, effectively eliminating intermediate steps.

    For developers, the value of multimodal capabilities is primarily reflected in three types of scenarios. First is document and chart understanding, such as parsing line charts in financial reports or reading stamps and handwritten annotations in scanned contracts. Second is interface understanding, such as determining control positions based on UI screenshots or identifying text content in error pop-ups. Third is AI agent tasks, where the model must observe the environmental state and decide the next action; visual input is almost indispensable in these tasks.

    II. Main Paths of Technological Evolution

    1. Vision-Language Alignment Stage

    Early solutions typically consist of three components. A visual encoder slices images into patches and encodes them into vectors. A projection module maps these visual vectors into the embedding space of the language model, which is responsible for text generation. Training generally involves three steps: first, alignment using image-text pairs to correspond visual features with language semantics; second, pre-training with large-scale multimodal corpora; and finally, supervised fine-tuning (SFT) with instruction data so the model can answer questions according to user intent.

    In this approach, the decoder-only architecture is quite common. Image tokens and text tokens are placed in the same sequence for autoregressive generation, providing a unified structure that scales easily to multi-turn conversations.

    2. Introduction of Mixture of Experts (MoE)

    Mixture of Experts (MoE) splits the feedforward network into multiple expert sub-networks, routing each input token to only a few experts. The total parameter count of the model can be very large, but the actual parameters activated during a single inference are relatively small, balancing capability with inference costs. In multimodal scenarios, the distribution variance between visual and text tokens is significant; the routing mechanism must account for the characteristics of both token types, requiring focused engineering validation.

    3. From Understanding to Reasoning

    Simple visual question answering only requires converting image information into an answer. Complex tasks require intermediate reasoning steps, such as locating a key inflection point in a chart, reading the corresponding value, and finally calculating the year-over-year change. A recent research direction involves incorporating visual indicator signals, such as bounding boxes and coordinate points, directly into the Chain of Thought (CoT). This allows the model to explicitly reference positions within the image during reasoning, rather than relying solely on text descriptions. This approach reduces reasoning deviations caused by “looking at the wrong position” and makes the results easier for manual review.

    III. Key Technical Points

    1. Visual Token Compression

    The higher the image resolution, the more visual tokens are generated after patch slicing. The computational overhead of attention mechanisms scales quadratically with the sequence length, meaning high-resolution images can rapidly inflate inference costs. Common compression strategies include dynamically allocating resolution based on content, merging or pooling adjacent visual patches, downsampling background areas, and retaining details in high information-density regions such as text and edges.

    The core of compression is retaining task-relevant information. For tables and documents, text regions require higher resolution; for natural landscape photos, lower resolution is usually sufficient to answer general questions.

    Below is a schematic function for estimating the number of visual tokens, which can be used to assess costs before sending a request:

    1. def estimate_visual_tokens(height, width, patch=14, merge=2):
    2. # Number of tokens obtained after patch slicing
    3. rows = height // patch
    4. cols = width // patch
    5. raw_tokens = rows * cols
    6. # Merge every merge x merge adjacent tokens into one
    7. return raw_tokens // (merge * merge)

    This function is only a rough estimate. The actual token count depends on the specific model’s slicing rules and should be verified against the model’s official documentation and empirical test results.

    2. Intermediate Representations for Visual Reasoning

    Incorporating visual indicator signals into the reasoning chain requires training data that includes reasoning samples with coordinate or region annotations. After training, the model’s output can contain structured steps like “reading values in Region A.” Engineering-wise, the model can be prompted to output coordinates in a structured format, allowing downstream systems to validate whether the coordinates fall within the image boundaries.

    3. Activated Parameters and Inference Costs

    When evaluating models, one cannot solely look at the total parameter scale. Two models with the same total parameters but different activated parameters will exhibit noticeable differences in computational load and latency during a single inference. During model selection, one should record total parameters, activated parameters, context length, token count per image, and average output length simultaneously to estimate the true costs accurately.

    IV. Image Understanding Practices in Agent Scenarios

    Agents typically operate in an “observe, plan, execute” loop. Images serve as the observation input in this loop. When designing such systems, the following points should be noted:

    • Screenshot frequency: It is unnecessary to capture a full screen at every step. Screenshots can be taken after the page changes, or only relevant regions can be captured.
    • State recording: Save the key information from each screenshot as a text summary to prevent infinite context growth.
    • Action validation: The click coordinates provided by the model should be validated to ensure they fall within the range of interactive elements before execution.
    • Timeout and fallback: If recognition fails consecutively multiple times, the system should switch to manual confirmation or halt execution directly.

    The schematic code is as follows:

    1. def run_visual_agent(task, max_steps=20):
    2. history = []
    3. for step in range(max_steps):
    4. screenshot = capture_screen()
    5. observation = vision_model.describe(screenshot, task, history[-5:])
    6. action = planner.next_action(task, observation)
    7. if action.type == "done":
    8. return action.result
    9. if not is_valid_action(action, screenshot):
    10. history.append({"step": step, "error": "invalid action"})
    11. continue
    12. execute(action)
    13. history.append({"step": step, "summary": observation.summary})
    14. raise TimeoutError("Task not completed within the maximum steps")

    Here, the screenshot capture, model invocation, and execution functions are abstract interfaces that need to be implemented according to specific use cases.