The Cost Challenge of Multimodal Models: How Visual Capabilities Serve AI Agents
Language models are widely validated, but visual capabilities often launch later—mainly because of inference cost. This article examines the engineering of visual capabilities from four angles: cost, technical approaches, data engineering, and agent applications, and offers guidance on selecting the right strategy.
1. Background
The capabilities of language models have been widely validated, yet visual capabilities often go live later. The main reason is the inference cost of visual input. Text is billed per token, but images must first be converted into visual tokens before entering the model. If this conversion is handled crudely, the compute and memory footprint of a single request can multiply. For services whose core value proposition is low pricing and high throughput, this cost must be carefully calculated before deciding what form visual capabilities should take.
This article discusses the engineering of visual capabilities from four angles—cost, technical approaches, data engineering, and agent applications—and provides guidance for choosing the right strategy.
2. Why Visual Tokens Are Expensive
2.1 Token Count Grows with Resolution
Most vision encoders split an image into fixed-size patches, with each patch mapped to one visual token. Taking a common 16-pixel patch size as an example, an image with resolution H×W produces roughly (H/16)×(W/16) tokens. Doubling the resolution quadruples the token count.
Illustrative code (pseudocode, for estimation only):
function estimate_visual_tokens(height, width, patch_size):rows = ceil(height / patch_size)cols = ceil(width / patch_size)return rows * cols# Example: a 1024 x 768 image with a patch size of 16tokens = estimate_visual_tokens(1024, 768, 16) # 64 * 48 = 3072
A single high-resolution screenshot can correspond to thousands of tokens—already longer than many ordinary text requests.
2.2 Attention Computation and Cache Overhead
Standard attention scales quadratically with sequence length. During inference, the key-value cache (KV cache) for each token consumes GPU memory linearly with sequence length. Once visual tokens dominate the sequence, per-request latency and memory pressure rise accordingly. Under high concurrency, service throughput drops noticeably.
2.3 Cost Comparison of Common Processing Approaches
| Approach | Effect on Sequence Length | Main Trade-off |
|---|---|---|
| Direct encoding of high-resolution originals | Many tokens, highest cost | Best detail retention, but high latency and cost |
| Fixed low-resolution encoding | Few tokens | Small text and small objects are easily lost |
| Content-adaptive dynamic resolution | Determined by image complexity | Requires additional scheduling logic |
| Token compression or merging | Significantly fewer tokens | Excessive compression loses information |
| Region-coordinate representation | Keeps only key regions | Depends on localization accuracy and training data |
3. Main Approaches to Reducing Visual Cost
3.1 Downsampling and Token Merging
After the encoder output, several adjacent tokens can be merged into one, or pooling can reduce the token count. This approach is simple to implement and requires little modification to existing models. The merging ratio must be determined experimentally: if too large, text and fine lines become blurred; if too small, the cost savings are limited.
3.2 Sparse Attention and Cache Compression
Sparse attention lets each token attend to only a subset of relevant positions, reducing computation. Cache compression reduces the number of key-value pairs that must be retained for each visual position. Used together, they can significantly cut the memory footprint of the visual portion. Poorly designed sparsity patterns can lose cross-region relational information, so they need to be paired with targeted training.
3.3 Replacing Pixels with Regions
Many tasks do not require understanding every pixel of an image—only knowing where an object is located. In such cases, coordinate information such as points, boxes, and regions can be treated as a class of tokens in the reasoning process. The model references these regions during inference instead of repeatedly processing the entire image. This approach has high information density but relies on reliable localization capability.
4. Data Engineering: The Hidden Threshold of Visual Reasoning
Integrating visual capabilities into the reasoning process requires training data that differs clearly from ordinary image-text pairs. General image-text data mainly teaches a model to describe image content. Region reasoning data must additionally contain the image, region annotations, and reasoning steps that reference those regions.
A typical data construction pipeline includes the following stages:
- Data collection: organize object detection datasets and unify annotation formats.
- Deduplication and cleaning: remove duplicate samples, corrupted images, and incorrectly annotated samples.
- Quality filtering: select samples based on annotation density, object size distribution, and class balance.
- Reasoning sample generation: organize region information into reasoning chains, such as “first locate a region, then determine its attributes.”
- Manual spot checks and regression testing: confirm
