Evolution Path of Multimodal Large Models and Key Practices for Agent Implementation
Multimodal large models are evolving from text-only processing to understanding images, documents, and user interfaces. Understanding this technical trajectory helps determine when multimodal capabilities are necessary and when text-only models suffice. This article outlines three technical stages, two key technologies, and practical methods for implementing multimodal capabilities in Agent tasks.
Multimodal large models are shifting from processing only text to simultaneously understanding images, documents, and interfaces. Grasping this technological path helps in deciding when multimodal capabilities are required versus when a text-only model suffices. This article explores the subject purely from a technical perspective, detailing three evolutionary stages, two key technologies, and practical implementation methods for Agent tasks.
1. Three Technical Stages of Multimodal Large Models
1.1 Early Stage: Vision-Language Alignment
Early efforts focused on enabling models to understand images and align image content with text semantics. The common approach involved encoding images into a set of visual features, which were then mapped into the input space of the language model. Training typically involved three steps: vision-language alignment, large-scale pre-training, and supervised fine-tuning. While this established basic image-text comprehension, visual information was generally encoded holistically before input, making it difficult for the model to revisit specific local parts of the image during inference.
1.2 Mid Stage: Mixture of Experts (MoE) Architecture
As model scales increased, dense models activated all parameters during every inference, causing compute and latency costs to surge. The Mixture of Experts (MoE) architecture splits the feedforward network into multiple experts, with a router selecting only a few experts for each input token. This allows for a large total parameter count while keeping the activated parameters per forward pass relatively low.
MoE is not universally superior. It suits scenarios with concurrent multi-tasking, high request volumes, and sensitivity to single inference costs. However, it introduces new engineering challenges:
- When routing is unbalanced, some experts become overloaded while others sit idle. Load balancing losses or capacity constraints are typically needed to mitigate this.
- When experts are distributed across multiple GPUs, the communication overhead of transmitting tokens between cards can offset computational gains.
- Routing during training can be unstable; learning rates, initialization methods, and auxiliary loss weights require careful tuning.
Therefore, MoE is a trade-off tool between cost and capability and cannot single-handedly solve all model problems.
1.3 Current Stage: Native Multimodal and Visual Primitive Chain of Thought
Recent directions shift from external fusion to native multimodal support. Models are exposed to both text and images during the pre-training phase. During inference, visual operations can be inserted into the chain of thought (CoT), such as highlighting a region, zooming into a detail, or comparing two elements. These operations can be termed “visual primitives.” Compared to the “look at the whole image first, then reason” approach, this method makes visual perception a part of the reasoning steps, making it better suited for tasks requiring step-by-step detail verification.
2. Two Key Technologies
2.1 Integrating Visual Primitives into Chain of Thought
Traditional workflows are serial: the visual encoder first outputs features, and the language model reasons based on them, with almost no feedback between the two. The visual primitive method allows the model to actively request a specific region of the image during intermediate reasoning steps. For example, in solving a geometry problem, the model can first locate the angle points, then read the line segment lengths, and finally apply the formula. This mirrors the human process of repeatedly looking at a diagram.
The applicability of this method needs to be clearly defined.
Suitable tasks:
- Q&A requiring detail verification in images, such as reading small text or comparing values
- Step-by-step interpretation of charts and flowcharts
- Interface element localization and state determination
Unsuitable tasks:
- Image description requiring only an overall impression
- Scenarios with extremely strict latency requirements that only accept a few hundred milliseconds, as multi-step visual operations increase inference rounds
- Situations with poor image quality, extremely small targets, and insufficient resolution. The information is already lost, and visual primitives cannot recover it
Common failure modes include bounding box offsets, repeatedly looking at the wrong region, and confusing similar elements. To address these, first check the image resolution, then prompt the model to explain the region it focuses on in each step.
2.2 Visual Token Compression
High-resolution images, long documents, and videos generate a massive number of visual tokens. As token counts grow, inference latency and memory usage increase. Some models reduce the number of visual tokens passed to the language model by improving the encoder and feature aggregation methods. For tables, charts, and scanned documents, the compressed representation usually retains the main semantics, though the compression ratio needs validation based on specific tasks.
During evaluation, it is recommended to fix a set of samples and record accuracy, time-to-first-token latency, and peak memory before and after compression. Looking at a single metric can lead to misleading conclusions. The effects of compression vary significantly across models and resolutions, so no universal compression ratio is provided here.
3. Multimodal Implementation for Agent Tasks
The primary value of multimodal capabilities lies in enabling Agents to perceive interfaces and documents. The following two scenarios are most common.
3.1 Browser Operation and Screenshot Reading
When automating web operations, the Agent needs to know what elements are on the page, where they are, and whether they are clickable. Multimodal models can read page screenshots to identify button text, disabled states, pop-ups, and overlay layers. Compared to reading only DOM text, the screenshot method is closer to what the user actually sees. Localization accuracy depends on the screenshot resolution and page zoom level.
3.2 Chart and PDF Document Processing
Enterprise materials contain a large number of scanned documents, reports, and flowcharts. Multimodal models can extract table content, explain the branching conditions of flowcharts, and output structured data. After outputting the results, the business system should re-verify critical numbers, especially amounts and dates.
4. Pre-Deployment Checklist
Before calling the API, it is recommended to confirm the following items one by one:
- Input Format: Common image formats like PNG and JPEG can be used directly. An excessively large screenshot size will increase latency and cost, while too small a size will lose details. Refer to the official documentation of your service for specific size limits.
- Output Format: Require the model to return a fixed JSON structure, such as
{"x": integer, "y": integer}. Providing field names and examples in the prompt can significantly reduce format errors. - Failure Retry: Use exponential backoff for network timeouts and rate limiting errors, with a maximum of 3 retries recommended. If JSON parsing fails, feed the error message back into the prompt and make another request.
- Permissions and Privacy: Screenshots may contain sensitive information like account names, phone numbers, and ID numbers. Desensitize them before uploading, such as by covering sensitive areas with solid color blocks. Set a clear retention period for screenshot files and delete them after the task ends.
- Result Verification: For coordinate-based results, draw the coordinates back onto the screenshot locally for validation. For numeric results, compare them with the original data.
5. Example Code
The following code demonstrates the calling process. The URL and model name are placeholders, not official interfaces of any real service. When using it, please replace them with the addresses and parameters from your platform’s official documentation. The API key is read through environment variables and not hardcoded. The runtime requires Python 3.9 or above and the requests library.
import base64import jsonimport osimport timeimport requests# Placeholder configuration: Replace with the address, API key, and model name of your actual platform via environment variablesAPI_URL = os.environ.get("MM_API_URL", "https://api.example.com/v1/multimodal/chat")API_KEY = os.environ.get("MM_API_KEY", "")MODEL_NAME = os.environ.get("MM_MODEL_NAME", "your-multimodal-model")TIMEOUT_SECONDS = 30MAX_RETRIES = 3def encode_image(image_path: str) -> str:with open(image_path, "rb") as f:return base64.b64encode(f.read()).decode("utf-8")def analyze_screenshot(image_path: str, prompt: str) -> dict:if not API_KEY:raise RuntimeError("Please set the MM_API_KEY environment variable first.")image_b64 = encode_image(image_path)headers = {"Authorization": f"Bearer {API_KEY}","Content-Type": "application/json",}payload = {"model": MODEL_NAME,"messages": [{"role": "user","content": [{"type": "text", "text": prompt},{"type": "image_url","image_url": {"url": f"data:image/png;base64,{image_b64}"},},],}],"response_format": {"type": "json_object"},}last_error = Nonefor attempt in range(1, MAX_RETRIES + 1):try:resp = requests.post(API_URL, headers=headers, json=payload, timeout=TIMEOUT_SECONDS)if resp.status_code == 429 or resp.status_code >= 500:raise requests.HTTPError(f"Service temporarily unavailable, status code {resp.status_code}")resp.raise_for_status()content = resp.json()["choices"][0]["message"]["content"]return json.loads(content)except (requests.RequestException, KeyError, IndexError, json.JSONDecodeError) as exc:last_error = excif attempt < MAX_RETRIES:time.sleep(2 ** attempt)raise RuntimeError(f"API call failed after {MAX_RETRIES} retries: {last_error}")if __name__ == "__main__":result = analyze_screenshot("browser_screenshot.png",'Find the center coordinates of the "Submit" button in the image. Return only JSON in the format {"x": integer, "y": integer}.',)print(result)
The return fields in the code are defined as x and y, representing the pixel coordinates of the button’s center in the screenshot. If the return structure of your service is different, you need to adjust the value extraction path accordingly.
6. Three Deployment Recommendations
- First, determine whether the task truly requires visual information. If the problem can be solved with text alone, do not introduce multimodal API calls.
- Use a fixed sample set to evaluate the changes brought by compression, MoE, and visual primitives, while simultaneously recording accuracy, latency, and cost.
- Before launching the automated workflow, establish desensitization and retention rules for screenshots and documents.
