Training a Vision Encoder From Scratch: Technical Breakdown for Multimodal LLMs
This article explains the technical design behind training a vision encoder from scratch instead of loading pretrained visual weights. It covers a 27-layer bias-free vision Transformer, 2x2 pixel shuffle downsampling for visual token budgets, joint image-text pretraining with next-token prediction, shared parameters for images and video, high-resolution and long-context support, low-bit quantization, and practical guidance on capability boundaries. Readers will gain a vendor-neutral understanding of the architecture and training principles for long-context multimodal systems.
1. Introduction: Why Train a Vision Encoder From Scratch
In multimodal large language models, the vision encoder converts signals such as images and video into representations that the language model can process. The conventional approach loads mature pretrained visual weights first, then moves into multi-stage alignment and fine-tuning. This route is well established in engineering, but it splits the optimization objective across multiple stages. As a result, the visual representation and the language modeling objective may diverge, and training can become unstable when switching between stages.
An alternative design worth attention is to use no pretrained visual weights at all. Instead, the vision encoder is pretrained jointly with text from scratch, using only next-token prediction as the optimization signal. This article takes that type of approach as its technical background, abstracts its architecture and training principles, and discusses implementation considerations for long-context multimodal systems. It does not cover any specific vendor product and focuses only on general technical capabilities.
2. Overall Architecture: A 27-Layer Bias-Free Vision Transformer
The encoder uses a 27-layer vision Transformer with roughly 400 million parameters, placing it in the medium-scale vision backbone category. One of its defining features is that it is bias-free: attention projections, the feed-forward network, and normalization layers all omit bias terms.
The bias-free design reduces redundant parameters, lowers optimization difficulty, and keeps numerical distributions more stable. During joint training, fewer parameters and stronger constraints make overfitting and gradient spikes less likely. When paired with low-bit quantization, the bias-free structure also removes zero-point parameters that would otherwise need special handling, making quantization error in weights and activations easier to control.
A schematic structure is shown below (it expresses design principles only, not a specific interface):
Input image -> Patch splitting -> Linear projection (no bias)-> 2x2 pixel shuffle downsampling-> N x [bias-free attention + bias-free feed-forward]-> Visual token sequence -> Language model fusion layer
3. Pixel Shuffle Downsampling: Controlling the Visual Token Budget
High-resolution images produce a large number of visual tokens, which directly increases attention computation and memory overhead. 2x2 pixel shuffle rearranges spatially adjacent pixels into the channel dimension, reducing the token count to one quarter of the original without losing information.
Its engineering value shows up in three ways. First, it lowers computational complexity in long-context scenarios. Second, it makes high-resolution input compatible with million-token context windows. Third, it provides a unified compression method for temporal signals such as video. Note that a higher downsampling factor is not always better. Excessive compression loses detail and hurts dense small targets such as charts and formulas, so 2x2 is a common trade-off between accuracy and efficiency.
4. Training Paradigm: Fixed-Ratio Image-Text Mixing and Next-Token Prediction
This approach follows an early-fusion idea: vision and text are pretrained jointly in the same stage, with image-text data mixed at a fixed ratio and training scale reaching the order of trillions of tokens. The only optimization signal is predicting the next token, so the vision encoder’s representations serve the language modeling objective directly.
Fixed-ratio mixing brings two benefits. First, the training process stays stable and avoids the gradient spikes caused by switching between multiple stages. Second, vision and language evolve together under the same objective, reducing the extra cost of an alignment stage. Practical recommendations include keeping the data ratio stable, monitoring gradient norms and loss spikes, and applying the same normalization strategy to the vision branch as to the text branch.
5. Shared Parameters for Images and Video
Images and video share the same set of encoding parameters, avoiding the need to maintain two backbones. Video input is typically sampled by frame, encoded, and then pooled or compressed along the temporal dimension. Parameter sharing reduces total model size and deployment complexity, but it also requires training data to cover both static images and dynamic video so that neither modality is marginalized.
6. High Resolution and Long Context
Support for input resolution up to about 3584x3584 means the model can handle full-page documents, complex charts, and high-resolution screenshots. Combined with pixel shuffle and a long context window, the model can fit multiple high-definition images and long text in a single inference pass. For engineering, strategies such as chunked encoding, caching visual tokens, and on-demand downsampling help control cost.
7. Low-Bit Quantization and Deployment
The encoder uses a low-bit scheme that quantizes weights and activations separately (for example, 4-bit weights and 8-bit activations), with quantization-aware training to reduce accuracy loss. For deployment, general cloud capabilities such as container platforms, object storage, and monitoring alerts can be combined to build an elastic inference service. If you use general product categories from Baidu AI Cloud, you can build an observability pipeline around model hosting, logging, and monitoring.
8. Capability Boundaries and Practical Recommendations
A vision encoder trained from scratch can match pretraining-initialized baselines on chart understanding, mathematical visual tasks, and video tasks, but its effectiveness depends heavily on data scale and data ratio. Practical recommendations: prioritize image-text data quality and a stable data ratio; keep higher resolution for dense small targets; build a vision benchmark evaluation set; and run consistency checks before and after quantization. Overall, joint pretraining from scratch gives multimodal models a more unified optimization objective and a more stable training path, making it an important design option for long-context multimodal systems.
