Engineering Visual Inputs for Multimodal LLMs: A Practical Guide
This article breaks down the engineering work required to ship image input for multimodal large language models. It explains image detail levels (low, high, original), resolution normalization bounds, visual token budgets and cost estimation, observability, and failure handling, along with selection guidance for different use cases. Readers will learn how to make reproducible trade-offs between quality and cost.
1. Background: Once Multimodal Support Ships, the Real Engineering Problem Is Not “Can It See Images”
When a model team extends a text-only model into an experimental version that accepts image input, the discussion usually centers on benchmarks: whether agent capabilities, reasoning, and world knowledge regress, and whether the multimodal agent is close to the first tier. From a deployment perspective, however, the user experience is decided by more mundane questions: how an image is processed, how many tokens it consumes, how cost is estimated, and how failures are retried.
One notable pattern is that text-only performance should not regress noticeably after a multimodal version ships, and ideally it should improve slightly. The reason is that the vision encoder and the text backbone share the same alignment and training pipeline, and multimodal data often brings richer grounding signals. If text performance drops significantly, it usually indicates a problem with capacity allocation or training data mixing between the vision branch and the language backbone, rather than an inherent tradeoff where multimodality must sacrifice text.
Another practical constraint is the capability boundary: most experimental versions support static image input first, while video and audio remain out of scope. This means tasks involving temporal understanding or audio-visual synchronization still require frame extraction or alternative approaches at this stage, and cannot simply be handed to the model in one shot.
2. Image Detail Levels: Choosing Between low, high, and original
The common approach is to expose discrete detail levels, where a single parameter controls both input resolution and visual token consumption.
- low: The image is uniformly scaled to roughly 512x512. It suits scenarios that do not need fine texture, such as thumbnail moderation, layout judgment, coarse-grained classification, and coarse OCR localization, with the lowest token cost.
- high / original: Original information is preserved as much as possible. It suits detail-sensitive tasks such as receipt recognition, chart reading, debugging code screenshots, and UI walkthroughs.
The key point is that high does not mean the original pixels enter the model intact. A total-pixel-based normalization step is applied before the image reaches the model, so “preserving the original” is relative to low and is a semantic statement rather than a pixel-level guarantee.
3. Resolution Normalization: Both Bounds Exist
A more common engineering strategy is to set both a lower and an upper bound on total pixels while preserving the aspect ratio:
- Lower bound: If an image is too small (total pixels below roughly the 384x384 range), it is scaled up proportionally to avoid input resolution being so low that text blurs together. For example, 200x200 is enlarged to around 384x384.
- Upper bound: If an image is too large, it is scaled down proportionally so total pixels are compressed to around the 800x800 range. For example, 1600x1200 becomes roughly 924x693, and 1920x1080 becomes roughly 1067x600.
The upper bound is necessary because the visual tokens a single image can consume are capped (a common current cap is on the order of 384 tokens). Any portion beyond the budget brings no benefit and only increases latency and cost. The purpose of the lower bound is often overlooked: too small an input causes OCR and small-object detection accuracy to drop sharply, and although upscaling cannot restore information, it makes the model’s internal slicing and alignment more stable.
Illustrative implementation (pseudocode, showing processing order only):
def normalize(img, detail="high"):if detail == "low":return resize_keep_ratio(img, 512, 512)w, h = img.sizepixels = w * hlow_bound, high_bound = 384 * 384, 800 * 800if pixels < low_bound:scale = (low_bound / pixels) ** 0.5elif pixels > high_bound:scale = (high_bound / pixels) ** 0.5else:return imgreturn resize_keep_ratio(img, int(w * scale), int(h * scale))
4. Token Budget and Cost Accounting
For billing, an image is converted into visual tokens that are metered together with text tokens. Cost estimation therefore cannot rely on text length alone; it must account for “number of images x tokens per image + text tokens.” Practical recommendations:
- Build a budget table: Fix the detail level and maximum image count for each task type to produce a predictable cost range per call.
- Low first, then high: Run the pipeline with low by default, and escalate to high only when confidence is low or fields are missing, forming a cascading call strategy.
- Move preprocessing forward: Cropping, removing borders, grayscale conversion, and denoising on the business side are often more cost-effective than raising the detail level.
- Caching and deduplication: Cache stable images in the same batch by content hash to avoid repeated billing.
def estimate_cost(n_images, tokens_per_image, text_tokens):return n_images * tokens_per_image + text_tokens# Cascading strategy: start low-cost, then escalate on demanddef run_with_fallback(img, prompt):r = call_model(img, prompt, detail="low")if r.confidence < 0.8 or r.missing_fields:r = call_model(img, prompt, detail="high")return r
5. Observability and Failure Handling
Failure modes in a multimodal pipeline differ from those in a text-only one and require additional instrumentation: image decode failures, excessive compression ratios on very large images, single-image token hitting the cap, and extreme aspect ratios (such as very long screenshots) causing effective information to be cropped away. It is advisable to log dimensions before and after scaling, the actual detail level, and the deviation between estimated and actual single-image token usage, and to split extreme aspect ratios on the business side in advance.
6. Selection and Deployment Recommendations
- Agent scenarios that are primarily text with images as support: Prioritize keeping text performance from regressing, and treat multimodality as a supplementary perception channel.
- Detail-sensitive scenarios: Fix high, and return “insufficient resolution” as an explicit error rather than silently degrading.
- High-concurrency moderation scenarios: Fix low plus rule-based pre-filtering, reserving high-cost calls for difficult samples.
- If the business involves video or audio, design frame extraction or a separate processing pipeline at this stage, and do not assume a single interface can cover everything.
Overall, the value of an experimental multimodal version lies not in a leaderboard number but in turning “how visual input is normalized, billed, and rate-limited” into configurable engineering parameters. Understanding the coupling among the bounds, detail levels, and token budget is what makes it possible to make reproducible trade-offs between quality and cost.
