How to Build a Multimodal Large Language Model: Architecture, Evaluation, and Cost-Based Model Selection
This guide explains how multimodal large language models unify text, code, images, video, and audio, covering their core architecture, modality alignment, missing-input handling, resolution and audio design, evaluation benchmarks, and cost-aware routing between full-size and lightweight models. It also provides a practical framework for comparing public benchmark results with real business data.
What Problems Do Multimodal Large Language Models Solve?
Multimodal large language models (MLLMs) understand and generate text, code, audio, images, and video within a shared set of parameters. Traditional models usually handle only one modality, such as a language model that reads text or a classifier that processes images. Multimodal models map different types of data into a shared semantic space, enabling cross-modal tasks such as visual question answering, speech transcription, and text-to-image generation.
For developers, a single API call can support multiple input types. However, multimodal systems are also more complex in terms of cost, latency, and evaluation than single-modality systems.
Models are often divided into two broad tiers by scale. Full-size models have more parameters and broader capabilities, making them suitable for quality-sensitive workloads. Lightweight models have fewer parameters, lower latency, and lower per-call costs, making them a better fit for high-concurrency and real-time scenarios. This choice directly affects the user experience and cost structure, so it should be made early in the product design process.
How Can Five Modalities Share One Model?
1. How Each Modality Enters a Unified Representation
Each modality first passes through its own encoder and is then projected into the same hidden dimension.
- Text and code: A tokenizer splits the input into tokens, which are mapped to embedding vectors through an embedding table.
- Images and video: A vision encoder divides images into patches. Video is sampled into frames, and each frame is processed in the same way.
- Audio: Audio is first converted into acoustic features such as mel spectrograms, and an audio encoder then produces a sequence representation.
The output dimensions of these encoders usually differ from the language model’s hidden size. Projection layers—often small MLPs or linear layers—are therefore used to map visual and audio features into the language model’s hidden dimension. These projection layers are typically added during training, and their quality directly affects cross-modal alignment.
Positional information also requires separate handling. Images need two-dimensional positional encoding, while video additionally requires temporal encoding. Otherwise, the model cannot distinguish the location of the same patch within an image or identify the frame in which it appears.
The following diagram is a simplified illustration. It omits projection layers, positional encoding, and modality masks:
Text/Code ──► Tokenizer + Embedding ───────┐Images/Video ──► Vision Encoder ─► Projection ──┼──► Unified Transformer Backbone ──► Decoded OutputAudio ──► Audio Encoder ─► Projection ──┘
2. How Are Modalities Aligned During Training?
Training usually includes two types of objectives.
The first is an alignment objective, such as image-text contrastive learning. The contrastive loss pulls matching image-text pairs closer together in the representation space and pushes mismatched pairs farther apart.
The second is a generation objective. The model performs next-token prediction on interleaved image-text or speech-text sequences.
The weighting of these objectives should reflect the downstream task. If retrieval is the priority, the contrastive loss should receive a greater weight. If dialogue and generation are more important, the autoregressive loss should have a greater weight.
3. How Should Missing Modalities and Resolution Be Handled?
Online requests often omit one or more modalities. For example, a user may send only text. If some modalities are randomly dropped during training, the model can learn to operate with the remaining inputs. During inference, modality masks should be passed explicitly to prevent blank placeholders from being interpreted as real inputs.
Image resolution directly determines the number of visual tokens. When resolution doubles, the number of patches increases by approximately four times, which raises both inference cost and latency. Common approaches include selecting a resolution based on the task or dividing large images into tiles, encoding them separately, and aggregating the results.
4. How Are Audio Capabilities Related to the Backbone?
Not every multimodal model includes text-to-speech (TTS) and automatic speech recognition (ASR). Some models connect an audio encoder directly to the backbone and can understand spoken content. Others rely on separate TTS or ASR services that are orchestrated at the application layer.
Before integration, confirm which design is described in the product documentation. The two approaches differ in latency, pricing, and error patterns.
How Should You Choose Evaluation Benchmarks?
Benchmark scores only show how a model performs on a particular dataset. They do not directly represent performance in a specific business scenario. The following table lists common public benchmarks and their typical use cases.
| Evaluation Dimension | Representative Benchmark | Core Metric | Applicable Modalities | Notes |
|---|---|---|---|---|
| Multidisciplinary knowledge and reasoning | MMLU | Accuracy | Text | Primarily multiple-choice questions; potential benchmark contamination should be considered |
| University-level multidisciplinary image and text understanding | MMMU | Accuracy | Image and text | Questions rely on specialized knowledge, and results are affected by prompting |
| Visual question answering | VQAv2 | Accuracy | Image and text | Focuses on relatively simple question answering and may not distinguish complex reasoning ability |
| Image captioning | COCO Caption | CIDEr, BLEU | Image and text | Results are related to human captioning style, and the metrics have limitations |
| Video understanding | Video-MME | Accuracy | Video and text | Evaluation is time-consuming, and the frame-sampling strategy must be controlled |
| Speech recognition | LibriSpeech | Word error rate (WER) | Audio | Primarily consists of English read-speech data; Chinese scenarios require separate testing |
A practical model-selection process can follow these steps:
- List the modality combinations that actually occur in the business, such as image-and-text customer support or voice-based work orders.
- Select only the benchmarks that correspond to these combinations and remove unrelated items.
- Evaluate samples from your own data. Use at least several hundred examples for each task category and record the types of errors.
- Compare public benchmark scores with results on your own data. When the gap is significant, prioritize the results from your own data.
How Can Engineering Teams Route Requests by Cost and Quality?
1. How Should Cost Be Calculated?
The cost of a single request can be estimated with the following formula:
Single-request cost = Input tokens × Input price + Output tokens × Output price
Token conversion rules for images and audio vary by provider. Unit prices and quotas should be based on the provider’s current official pricing and documentation, and prices may change over time. Estimates should use the distribution of real online requests rather than a single example.
2. Rules and Parameters for Hybrid Routing
A common hybrid-routing workflow is to have a lightweight model first identify the user’s intent and estimate request complexity. The full-size model is called only when the request matches a high-complexity rule.
The following parameter is only a starting point and should be calibrated with your own request data:
- Complexity score: A lightweight model or rule-based system outputs a score from 0 to 1. Requests with a score above 0.7 …
