Architecture Design and Practical Implementation of Edge-Side Small-Parameter Multimodal Models

    This article explores the architecture design and practical implementation of small-parameter multimodal models optimized for edge devices. It covers parameter scale selection, unified processing strategies for text, image, video, and audio inputs, long-context attention design using interleaved layers and rotary position embeddings (RoPE), hierarchical conditional embeddings for efficient token information injection, and evaluation methodologies for edge-side AI agent tasks.

    1. Background and Problem Definition

    Edge devices (such as smartphones, embedded development boards, and home workstations) have three conflicting requirements for multimodal models: controllable memory footprint, inference latency that ensures a smooth interactive experience, and the capability to process text, images, video, and audio. Historically, the common approach was to chain multiple independent modules—like speech recognition, vision encoders, and language models. This long pipeline increased memory overhead at every stage and led to error accumulation.

    Consequently, recent design trends for small-parameter multimodal models have shifted toward two directions: utilizing a single model to process multiple input types and improving expression efficiency within limited parameters. Before evaluating any edge-side model, it is crucial to understand this trend and determine whether its design trade-offs fit your specific use case.

    2. Parameter Scale and Architecture Selection

    Architecture selection begins with the deployment target. The memory footprint of model weights can be estimated using the following formula:

    Weight Memory ≈ Parameter Count × Bytes per Parameter

    For instance, FP16 uses 2 bytes per parameter, INT8 uses 1 byte, and INT4 uses approximately 0.5 bytes. Taking a 3-billion-parameter model as an example, weights quantized to INT4 occupy about 1.5 GB, while FP16 occupies about 6 GB. Actual memory usage must also account for the KV cache, runtime, and system overhead, meaning the reserved space typically needs to be significantly larger than the weight estimate.

    Dense models activate all parameters during every inference step. Mixture of Experts (MoE) architectures, on the other hand, route each token through only a subset of expert networks, resulting in significantly lower per-step computation compared to a dense model with the same total parameter count. However, all MoE parameters must still be loaded into memory or high-speed storage, making it more suitable for scenarios with sufficient compute and memory. Dense models have a simpler structure, making latency easier to predict on resource-constrained devices.

    Common parameter tiers and their constraints are as follows:

    Tier Typical Scale Applicable Scenarios Main Constraints
    Large Dense ~30B Local workstations, complex reasoning VRAM capacity
    Mixture of Experts (MoE) Large total params, small active params Balancing quality and throughput Loading space for total parameters
    Small Edge-Side ~2B to 4B Smartphones, embedded devices Power consumption and first-token latency

    3. Unified Processing of Multimodal Inputs

    Text: Utilizes the standard tokenization process and shares the same context window as other modalities.

    Image: Variable resolution input is a key design factor. Uniformly scaling to a fixed square size loses aspect ratio information or wastes compute on irrelevant regions. Splitting the image according to its original aspect ratio and generating visual tokens allows the token count to scale with resolution. In practice, an upper limit must be set to control the peak memory usage.

    1. MAX_VISUAL_TOKENS = 512 # Upper limit of visual tokens per image, set based on memory budget
    2. def plan_image_size(width, height, patch, max_tokens=MAX_VISUAL_TOKENS):
    3. # patch is the patch size of the vision encoder, determined by the specific model
    4. tokens = (width // patch) * (height // patch)
    5. if tokens <= max_tokens:
    6. return width, height
    7. scale = (max_tokens / tokens) ** 0.5 # Square root of the area ratio to get the edge scaling factor
    8. new_w = int(width * scale) // patch * patch
    9. new_h = int(height * scale) // patch * patch
    10. return new_w, new_h

    Video: Typically involves frame extraction at fixed intervals, encoding them via the image pipeline, and appending temporal position information. The frame extraction frequency directly determines the token count, requiring a trade-off based on the task’s demand for temporal detail.

    Audio: Edge-side models can directly accept audio tokens, eliminating the need for an independent speech recognition module. The benefits include a shorter pipeline, lower latency, and keeping audio data on-device. The trade-off is that audio length is constrained by the context window and memory; excessively long recordings require chunked processing.

    1. def chunk_audio(samples, sample_rate, max_seconds):
    2. # max_seconds is set based on the maximum supported length per segment for the model
    3. step = sample_rate * max_seconds
    4. return [samples[i:i + step] for i in range(0, len(samples), step)]

    4. Attention Design for Long Contexts

    Long contexts present two challenges. First, the computational complexity of global attention grows quadratically with sequence length. Second, position encoding must remain effective in scenarios that exceed the training length.

    A common practice is to interleave two types of attention layers. Sliding window layers only attend to neighboring tokens, keeping computational cost proportional to the window size and bounding the KV cache. Global attention layers can access the complete context and are responsible for aggregating cross-segment information.

    Position information is typically injected via Rotary Position Embedding (RoPE). The two layer types can employ different position encoding configurations: local layers use standard settings, while global layers can use scaled variants to extend the effective position range. The scaling method must be validated through long-context evaluations, such as key information retrieval tests in long documents, and by observing perplexity changes as length increases. Long-text capability cannot be judged solely based on configuration parameters.

    5. Hierarchical Conditional Embeddings: Injecting Token Information on Demand

    A standard Transformer assigns only a single input embedding vector to each token, requiring all potential information to be packed in at that moment. Hierarchical conditional embeddings offer an alternative approach: adding a parallel low-dimensional pathway alongside the main backbone to generate a specific, small vector for each decoding layer.

    This vector consists of two parts: a token identity signal derived from a lookup table, and a context-aware signal derived from the projection of the current hidden state. After combining these two signals, each layer reads only its corresponding slice when needed. This way, token-specific information does not have to be entirely compressed into the initial embedding, allowing deeper network layers to access localized clues at any time.

    1. def build_layer_conditions(token_ids, hidden_states, num_layers):
    2. identity = low_dim_table[token_ids] # Token identity signal, obtained via lookup
    3. context = project(hidden_states) # Context-aware signal, projected from hidden states
    4. cond = identity + context # Combine the two signals
    5. return split_into_layers(cond, num_layers) # Each layer receives a low-dimensional vector

    The additional cost of this design includes the storage of lookup table parameters and a single projection computation. Lookup table parameters are accessed by index, so they can be placed in an appropriate storage tier at runtime. The specific combination method and dimensions vary by implementation; evaluations should rely on measured latency and memory data.

    6. Evaluating Edge-Side Agent Tasks

    Evaluation should revolve around real task types, which commonly include intent parsing, tool call format generation, multi-step planning, and short text summarization. A single successful case cannot prove model reliability; it is necessary to build a test set covering target scenarios and record failure samples.

    It is recommended to track the following metrics:

    • Task success rate, categorized by task type
    • Structural legality of tool calls, meaning whether the output can be parsed and pass parameter validation
    • First-token latency and tokens generated per second