Visually-Native Multimodal Agents: Architecture, Training, and Practical Implementation
This article explores the development of visually-native multimodal agents, emphasizing why visual perception must be integrated with reasoning rather than functioning as an add-on. It covers unified architectural design, continuous perception enhancement throughout the training lifecycle, and building a closed loop for perception, reasoning, and execution. The article further delves into constructing corrective datasets, a layered framework for agent training, engineering implementation challenges, and a practical checklist for successful deployment.
1. Background: Why Vision Cannot Just Be an Add-On
A significant amount of real-world work information exists in visual formats, such as web interfaces, mobile screenshots, design drafts, scanned documents, and surveillance videos. Many systems use a separate vision module to convert images into vectors or text descriptions before handing them over to a language model for reasoning. This approach creates an information gap between perception and reasoning. Details missed by the vision module cannot be recovered by the language model, and incorrect descriptions outputted by the vision module will be treated as facts, ultimately leading to hallucinations.
For example, when a model views a screenshot of a form, if the vision module only outputs “the page has three input boxes and one button,” the model cannot determine which input box the button is located below, nor can it distinguish which input box is mandatory. Once information like layout, hierarchy, and relative position is lost, subsequent operation planning will suffer from systematic deviations.
Therefore, the core goal of native multimodality is to enable visual signals to participate in representation learning from the model’s foundational layer, rather than acting as an external patch to the language model.
2. Three Levels of Native Multimodality
2.1 Architecture Level: Unified Representation Space
The architecture level addresses how images, videos, and text can enter the same sequence modeling framework. Common practices include:
- Splitting images into patches and mapping them via a vision encoder into a vector sequence with dimensions consistent with text tokens;
- Applying temporal sampling and compression to videos to control sequence length;
- Using unified positional encoding so the model can distinguish between text positions and two-dimensional image coordinates;
- Allowing visual tokens and text tokens to interact thoroughly across multiple attention layers, rather than fusing them only once at a specific layer.
Resolution determines the upper limit of details the model can perceive. Higher resolution means more visual tokens and higher inference costs. In engineering, dynamic resolution or patching strategies are often used to balance detail retention and computational overhead. For instance, text-dense document screenshots can retain higher resolution, while scenarios that only require identifying the page type can use lower resolution to save resources.
2.2 Training Level: Perception Throughout the Entire Lifecycle
Many teams treat visual understanding as a single pre-training stage and stop paying attention once completed. Practice shows that this limits the model’s capability ceiling. Perception capabilities need continuous enhancement across three stages: pre-training, instruction fine-tuning, and reinforcement learning.
A typical example is structured code generation data. Pairing interface screenshots with their corresponding structured code (such as markup languages or vector graphics formats) seemingly trains the model for frontend generation, but essentially forces the model to understand element hierarchy, alignment, and spatial positioning. These capabilities can be transferred to tasks like chart understanding and geometric reasoning, as they all rely on a precise grasp of spatial relationships.
Another example is the grounding task in the reinforcement learning stage. In agent scenarios, “where to click” is the most fundamental capability. Using grounding accuracy as an independent reward signal in reinforcement learning can directly improve operation accuracy and reduce cascading errors caused by mis-clicks.
2.3 Toolchain Level: The Closed Loop of Perception, Reasoning, and Execution
Understanding an interface does not equate to completing a task. The toolchain must convert model outputs into executable actions and feed the execution results back to the model via screenshots or state updates, forming a closed loop. The key to this loop is that every step is observable, replayable, and correctable. Without these capabilities, a single mis-click could be amplified by subsequent steps, making the problem difficult to trace.
3. Corrective Data in Instruction Fine-Tuning
Types of perception errors are relatively fixed, mainly including misreading interface elements, clicking the wrong button, ignoring pop-ups, and confusing similar controls. To address these error types, specifically designed evaluation data can be constructed. The specific approach is to let the model judge whether candidate operations are correct or incorrect and provide reasons. The training data includes both positive and negative samples.
Effective evaluation data must meet three requirements:
- Negative samples should come from actual model failure cases, not artificially fabricated ones;
- Each error type must have clear judgment criteria, such as “a button’s text not matching the instruction’s target constitutes an error”;
- The ratio of positive to negative samples should be balanced to prevent the model from learning to reject everything indiscriminately.
After incorporating such data, hallucination-type errors typically decrease significantly. This indicates that perception capabilities require long-term maintenance and cannot be solved once and for all in the early stages.
4. Layered Training for Agents
End-to-end training of agents is intuitive but highly difficult to implement. Environment setup costs are high, trajectory data is hard to annotate at scale, task success verification relies on complex rules, and the reinforcement learning process can easily become unstable.
Layered training breaks complex tasks into multiple independently evaluable layers:
| Layer | Task Definition | Primary Data | Evaluation Metrics |
|---|---|---|---|
| Element Perception | Identify control types and text in the interface | Screenshots with bounding boxes | Detection precision, text recognition accuracy |
| Interface Grounding | Locate the target element based on instructions | Instruction and coordinate pairs | Grounding hit rate |
| Single-Step Action | Predict the next action given a screenshot and goal | Single-step operation samples | Action type and parameter accuracy |
| Trajectory-Level | Complete sequence for multi-step tasks | Full operation trajectories | Task completion rate |
There are two main benefits to layering. First, each layer has independent evaluation metrics, allowing issues to be pinpointed to specific stages. Second, lower-layer capabilities can serve multiple upper-layer tasks simultaneously, reducing the cost of redundant data construction.
In terms of training strategy, supervised fine-tuning is suitable for learning basic mapping relationships, while reinforcement learning is suited for optimizing long-sequence decisions. The two can be conducted in stages or alternately during training.
Below is a simplified example of a layered evaluation framework used to monitor the performance of each layer during training:
from dataclasses import dataclass@dataclassclass LayerResult:layer: strscore: floatnum_samples: intdef evaluate_layers(model, datasets):results = []for layer_name, dataset in datasets.items():correct = 0for sample in dataset:pred = model.predict(sample.input)if sample.check(pred):correct += 1score = correct / max(len(dataset), 1)results.append(LayerResult(layer_name, score, len(dataset)))return results# Example: Output report by layer# datasets = {"element": ..., "grounding": ..., "action": ..., "trajectory": ...}# for r in evaluate_layers(model, datasets):# print(f"{r.layer}: {r.score:.2%} ({r.num_samples} samples)")
When the score of a certain layer drops, you should first check the data quality and distribution of that layer before deciding whether to retrain the entire model. This prevents blindly tuning parameters when the problem is unclear.
5. Main Challenges in Engineering Implementation
5.1 Environment Costs
Use reproducible sandbox environments and record operation trajectories for replay. The recorded interface states can be used for offline training, thereby reducing the number of calls to the online environment.
5.2 Data Annotation
Adopt semi-automatic annotation. First use rules or existing models to generate candidate annotations, followed by manual spot-checking and correction. For grounding data, the interface’s structured information (such as the control tree) can be leveraged to verify coordinate accuracy.
5.3 Verification Difficulties
A single task success rate cannot explain the cause of failures. You should simultaneously record the action correctness, grounding errors, and state deviations for each step to form a diagnosable metric system.
5.4 Optimization Instability
Common issues in reinforcement learning include sparse rewards, reward exploitation, and sudden policy degradation. Three general countermeasures are: designing phased rewards, limiting the deviation amplitude between the policy and the reference model, and periodically conducting regression checks on a fixed evaluation set.
6. Implementation Checklist
When initiating a project or making technology selections, you can cross-check against the following questions:
- Does the task input contain a large amount of image information, and would a pure text approach lose critical details?
- Have the types of perception errors been cataloged, and is there corresponding corrective data?
- Have the agent tasks been split into independently evaluable layers?
