Encoder-Free Multimodal Small Models: Architecture and Inference Acceleration in Practice

    This article explains how to build encoder-free multimodal small models and speed up their inference. It covers why small models need to go multimodal, how projection layers replace external vision/audio encoders, how Thinking Mode turns the reasoning budget into an adjustable parameter, and how to choose among multi-token prediction, speculative decoding, and quantization-aware training. It also gives a deployment checklist spanning inference images, elastic scaling, SLOs, canary releases, observability, and security, plus an FAQ on architecture choices, chunk granularity, and when to enable reasoning. Readers will learn the core trade-off of shifting cost from model parameters to data, training, and context length, and how to balance the latency, cost, and accuracy constraints of real deployments.

    1. Why Small Models Need to Go Multimodal

    Over the past two years, the main theme of model deployment has shifted: the returns from simply stacking parameters to gain capability are declining, and what really determines business cost is inference pricing, on-device latency, data compliance, and offline availability. Meanwhile, business needs are expanding from pure text to “seeing images, hearing audio, and calling tools across multiple turns.” For a small model to satisfy both “small footprint” and “multimodal,” it has to make trade-offs at the architecture level.

    This article does not rely on unnamed reports. The relevant methods can be verified in the following public sources: Alibaba’s Qwen2.5 Technical Report (2024, https://arxiv.org/abs/2412.15115), Google DeepMind’s official Gemma 3 materials and report entry (2025, https://deepmind.google/models/gemma/), and the Hugging Face SmolVLM project page (2024, https://huggingface.co/blog/smolvlm). Together, these public sources point to one trend: covering more modalities with smaller parameters and more controllable compute.

    2. Encoder-Free Architecture: Replacing External Encoders with Projection Layers

    The traditional “modality encoder + LLM” approach typically uses a vision encoder and an audio encoder to process images and audio separately, then projects them into the language space. The engineering burden of this approach includes: large parameter and VRAM overhead; complex training and alignment pipelines; and the need to maintain multiple sets of weights, operators, and runtimes at deployment time. For on-device or low-cost environments, these costs are often hard to accept.

    The core idea of the encoder-free architecture is to remove the dedicated vision/audio encoders and keep only a tiny projection layer that maps raw signals directly into the language model’s unified embedding space. Images can be split into patches and then projected; audio can be split by fixed frame length and then projected. What ultimately enters the Transformer backbone is the same kind of token vectors. This adds almost no backbone parameters, but training data and compute costs rise accordingly.

    It must be made especially clear: removing the encoder saves on parameter count, but in exchange it creates a dependence on large-scale image-text/audio paired pre-training data. Perception quality is also constrained by input resolution, sampling rate, and chunk granularity. In other words, encoder-free is not “zero-cost multimodal”—it shifts cost from model parameters to data, training, and context length.

    The sample code below emphasizes structure rather than production detail:

    1. import torch
    2. import torch.nn as nn
    3. class UnifiedProjector(nn.Module):
    4. """Projects image patches, audio frames, and text embeddings into the same hidden space.
    5. In production, add norm, dropout, positional encoding, and padding masks as required by the actual model.
    6. """
    7. def __init__(self, hidden_dim: int, patch_dim: int, audio_dim: int):
    8. super().__init__()
    9. self.img_proj = nn.Linear(patch_dim, hidden_dim)
    10. self.audio_proj = nn.Linear(audio_dim, hidden_dim)
    11. self.modality_embed = nn.Embedding(3, hidden_dim) # 0=text, 1=image, 2=audio
    12. def forward(
    13. self,
    14. text_embeds: torch.Tensor,
    15. img_patches: torch.Tensor,
    16. audio_frames: torch.Tensor,
    17. img_lens: torch.Tensor,
    18. audio_lens: torch.Tensor,
    19. ):
    20. # text_embeds: [B, N_text, H]
    21. # img_patches: [B, N_img, patch_dim]
    22. # audio_frames: [B, N_audio, audio_dim]
    23. text_tokens = text_embeds
    24. img_tokens = self.img_proj(img_patches)
    25. audio_tokens = self.audio_proj(audio_frames)
    26. b = text_embeds.size(0)
    27. text_tokens = text_tokens + self.modality_embed(torch.full((b, text_embeds.size(1)), 0, device=text_embeds.device))
    28. img_tokens = img_tokens + self.modality_embed(torch.full((b, img_patches.size(1)), 1, device=text_embeds.device))
    29. audio_tokens = audio_tokens + self.modality_embed(torch.full((b, audio_frames.size(1)), 2, device=text_embeds.device))
    30. # In actual training, use an attention mask; this is only a structural illustration here
    31. tokens = torch.cat([text_tokens, img_tokens, audio_tokens], dim=1)
    32. return tokens

    There are three engineering points. First, the projection layer must be restrained—it is only a translation layer and should not take on heavy perception. Second, the projection layer needs to be trained jointly with the backbone so that image patches and audio frames naturally align to the text semantic space. Third, it is best to keep the modality identifiers, because although the backbone does not explicitly distinguish modalities, the model needs to know whether the current token is text, image, or audio.

    3. Thinking Mode: Turning the Inference Budget into an Adjustable Parameter

    Being multimodal only means “able to see and hear”; what really determines the experience is “how deeply it thinks.” Controllable inference modes (mechanisms like Thinking Mode) control tokens or system prompts to let the model perform more thorough and more structured intermediate reasoning before producing an answer. Its engineering value lies in turning the inference budget into an adjustable parameter. For simple tasks, turn reasoning off or minimize it; for complex tasks, turn it on and trade more intermediate tokens for accuracy.

    But note: reasoning modes significantly increase the number of generated tokens and latency, so they must be paired with speculative decoding, quantization, batching, and other techniques. Otherwise, “thinking deeply” degrades into “waiting long.”

    The code below is more complete than the original sketch—it adds model loading, the chat template, stop conditions, and a length budget. Before running it, you must adjust it according to the target model’s tokenizer, chat template, and control tokens:

    1. from transformers import AutoTokenizer, AutoModelForCausalLM
    2. model_id = "Qwen/Qwen2.5-3B-Instruct"
    3. tokenizer = AutoTokenizer.from_pretrained(model_id)
    4. model = AutoModelForCausalLM.from_pretrained(
    5. model_id,
    6. torch_dtype="auto",
    7. device_map="auto"
    8. )
    9. def generate(prompt: str, think: bool, answer_budget: int = 256, think_budget: int = 512):
    10. # Depends on the actual model; different models may use a system message, control tokens, or special tokens to control thinking mode
    11. system_prompt = "<think>" if think else "<no_think>"
    12. messages = [
    13. {"role": "system", "content": system_prompt},
    14. {"role": "user", "content": prompt},
    15. ]
    16. text = tokenizer.apply_chat_template(
    17. messages,
    18. tokenize=False,
    19. add_generation_prompt=True
    20. )
    21. inputs = tokenizer(text, return_tensors="pt").to(model.device)
    22. # Stop conditions: eos / stop tokens differ across tokenizers, so filter according to the actual vocabulary
    23. candidate_stops = ["<|end|>", "</s>", "<|eot_id|>"]
    24. stop_ids = []
    25. for s in candidate_stops:
    26. tid = tokenizer.convert_tokens_to_ids(s)
    27. if tid is not None and tid != tokenizer.unk_token_id:
    28. stop_ids.append(tid)
    29. eos_ids = [tokenizer.eos_token_id] if tokenizer.eos_token_id is not None else []
    30. all_eos = list(set(eos_ids + stop_ids))
    31. # Constrain both total length and answer budget: when think=True, total budget = think_budget + answer_budget
    32. total_budget = think_budget + answer_budget if think else answer_budget
    33. output_ids = model.generate(
    34. **inputs,
    35. max_new_tokens=total_budget,
    36. do_sample=False,
    37. eos_token_id=all_eos or None,
    38. pad_token_id=tokenizer.pad_token_id or tokenizer.eos_token_id,
    39. )
    40. generated = output_ids[0, inputs.input_ids.shape[-1]:]
    41. return tokenizer.decode(generated, skip_special_tokens=True)

    The key to deployment is defining “when to think.” This can be decided by business rules, such as task type, confidence thresholds, or explicit user requests; alternatively, the model can judge whether to enter reasoning based on input difficulty. For low-latency scenarios like customer service, extraction, and classification, long reasoning should be turned off first; for code, math, and multi-step agent scenarios, fuller reasoning can be enabled.

    4. How to Choose Inference Acceleration? Comparing Three Approaches

    Even with deep reasoning enabled, small models must control the cost per token. The three approaches below each have their applicable conditions and cannot be stacked blindly.

    Approach Main Benefit Prerequisites Risks and Fallbacks
    Multi-Token Prediction (MTP) Increases training signal density and improves representation quality; if a draft head is trained for MTP, it can be used to speed up inference A training-time technique; inference speed-up usually requires additionally training a draft head or module If only multiple tokens are predicted during training, the extra prediction head is usually discarded at inference; verify draft head hit rate before launch
    Draft model + speculative decoding Reduces latency while keeping the output distribution approximately consistent The draft model shares the same tokenizer as the main model and has a close training distribution; draft overhead must be lower than the verification passes saved When hit rate is low, it slows things down; for small models, first use n-gram, self-drafting, or simple heuristics to validate the benefit
    Quantization-Aware Training (QAT) Reduces accuracy loss for low-bit inference, cuts VRAM usage, and improves throughput Requires additional training or calibration cost and a representative validation set; must specify whether the quantization target is weights, activations, or KV Cache If accuracy drops noticeably, fall back to post-training quantization (PTQ) or mixed precision

    1. Multi-Token Prediction Is Not the Same as Inference Acceleration

    Multi-Token Prediction is a training-time technique. It lets the model predict several future tokens in a single forward pass, increasing training signal density. To get inference-stage benefits, you usually need to additionally train or use an MTP draft head. Merely predicting multiple tokens during training does not automatically bring inference speed-up; in many implementations, the extra prediction head is discarded at inference.

    2. Speculative Decoding Hinges on Balancing Hit Rate and Overhead

    The draft model first quickly generates several candidate tokens, and the main model then verifies them all at once. If the draft hits, multiple tokens can be confirmed in a single main-model forward pass, yielding a speed-up. But this is not unconditional acceleration. The draft model must share the same tokenizer as the main model and have a close training distribution; the draft-generation overhead must be lower than the number of main-model verification passes it saves. If the draft hit rate is low, speculative decoding actually slows down the service.

    For small models, it is recommended to first validate the benefit with simple methods, such as n-gram drafts, self-drafting, or rule templates, before evaluating whether to introduce an independent draft model.

    3. QAT Should Be Used Conditionally

    Quantization-Aware Training simulates quantization error during training so the model adapts to low-bit inference. It can reduce VRAM usage and improve throughput, but it requires additional training or calibration cost, and you should prepare a representative validation set. There is also more than one quantization target: you can quantize only weights, or use combinations like W8A8 and INT8 KV Cache. If noticeable accuracy loss appears after quantization, fall back to PTQ, mixed precision, or keeping some layers at high precision.

    5. From Model to Service: A Deployment Checklist

    Turning these capabilities into an operable service is not just a matter of listing cloud product categories—it requires concrete deployment steps.

    1. Prepare the inference image and weight artifacts
      The image should contain the inference runtime, quantized weights, tokenizer, chat template, stop conditions, and startup parameters. Weights, datasets, and inference artifacts can be stored in object storage and managed by version.

    2. Configure elastic scaling
      Run the inference service on a general-purpose container platform. Scaling metrics should not look only at CPU; it is recommended to watch queue length, concurrent request count, GPU utilization, and p95 latency. Thresholds need to be determined through load testing.

    3. Set SLOs
      Common targets include p95 latency, p99 latency, maximum tokens per request, and cost per thousand tokens. For multimodal inputs, you should also cap the number of image patches, audio frame length, and maximum context length to avoid long-tail requests overwhelming the service.

    4. Canary release and rollback
      New models, new quantization versions, and new speculative decoding configurations should all be canary-released with small traffic first. Metrics to watch include latency, throughput, token consumption, speculative decoding hit rate, and task-set performance before and after quantization. Roll back to the last stable version when anomalies occur.

    5. Build an observability loop
      Logging and monitoring/alerting should collect: per-request latency, p95/p99 latency, cost per thousand tokens, speculative decoding hit rate, draft overhead, post-quantization accuracy loss, modality distribution, and context truncation rate. Example thresholds: keep p95 latency below the business commitment; if the draft hit rate stays below expectation over time, disable speculative decoding; if the quantization task set drops beyond a threshold, fall back to PTQ or mixed precision.

    6. Security and compliance
      Multimodal inputs may contain not only illegal or harmful content but also prompt-injection risks—for example, instructions embedded in OCR text from an image, or inducements smuggled into audio. Before launch, apply content moderation, encrypt sensitive data, enforce access control, and limit input length, file size, and modality ratio.

    6. FAQ

    How do I choose between encoder-free and encoder + LLM?

    If the task has high requirements on image detail and audio/video perception, and the team has enough multimodal data and compute to train perception capabilities, the encoder approach is usually more stable. If the goal is on-device, low-cost, fast, unified modality access, and higher data and training costs are acceptable, the encoder-free approach is lighter.

    How do I set projection chunk granularity and audio frame length?

    The principle is to balance context length against compute. If image patches are too large, detail is insufficient; if too small, the context balloons. If audio frames are too short, token count increases; if too long, time resolution drops. It is recommended to start from resolution, sampling rate, and task accuracy to run ablation experiments, and to load-test latency at the same time.

    When should Thinking Mode be enabled?

    For simple Q&A, extraction, classification, and casual chat, it is recommended to keep it off. For math derivations, code generation, multi-step agents, and complex instruction-following, it can be turned on with a total length and answer budget. In the early launch stage, it is recommended to route by task rather than enabling it by default for all requests.

    Why is speculative decoding sometimes slower?

    Common causes are a draft hit rate that is too low, a large distribution gap between the draft model and the main model, draft-generation overhead that is too high, or an inability to amortize the cost under batching. In these cases, you can first turn off speculative decoding and switch to a smaller draft, rule-based drafts, or caching strategies.

    7. Conclusion

    The essence of encoder-free multimodal small models is to reallocate costs under limited compute: replace external encoders with lightweight projections, adjust reasoning depth with controllable inference, and optimize throughput with techniques like speculative decoding and quantization. It has no default configuration that is universally optimal. The truly reliable approach is to first clarify the business’s latency, cost, and accuracy triangle constraints, then choose projection granularity, reasoning switches, and an acceleration combination, and continuously calibrate through canary releases and observability metrics.