On-Device Large Models: Effective Parameter Evaluation and Deployment Practices
On-device large models are constrained by memory, compute, bandwidth, thermal limits, power budgets, and model loading time, so total parameter count alone is not a reliable evaluation metric. This article explains the concept of effective parameters, introduces per-layer embedding mechanisms, proposes a multi-dimensional evaluation system covering storage, latency, power, and task quality, and outlines practical selection criteria, deployment pipelines, optimization directions, and quality assurance practices for mobile, edge, automotive, and smart-home scenarios.
1. Why Total Parameters Are Not Enough for On-Device Model Evaluation
Large models are moving from cloud services to local execution across mobile devices, edge gateways, automotive systems, and smart-home products. Unlike cloud environments, on-device environments are constrained by memory capacity, compute capability, memory bandwidth, thermal conditions, power budgets, and model loading time. Because of these constraints, evaluating a lightweight on-device model only by its total parameter count often leads to inaccurate conclusions.
Traditionally, parameter count is treated as a basic indicator of model capability. However, in on-device deployment, a more important concept is effective parameters. Total parameters refer to the sum of all storable parameters in the model, including model weights, embedding tables, and output layers. Effective parameters refer more closely to the portion that actively participates in dense computation during a single inference pass and significantly affects compute consumption. These two concepts are not equivalent.
For a language model, parameters are generally composed of several parts:
- Attention layer parameters;
- Feed-forward network parameters;
- Input embedding parameters;
- Output projection parameters;
- Per-layer embedding parameters or other auxiliary lookup parameters.
Embedding parameters may occupy a large portion of storage, but during runtime they often behave as sparse lookups rather than participating in dense matrix multiplication on every element. If evaluation focuses only on total parameters, it may overestimate the actual compute pressure. If evaluation focuses only on theoretical compute cost, it may underestimate memory and memory-access pressure. A complete on-device evaluation must consider compute, storage, bandwidth, and latency together.
2. The Engineering Meaning of Effective Parameters
Effective parameters can be understood as the core parameter scale that stably participates in computation during each forward pass under a given input length, sampling strategy, and hardware environment. This usually excludes large lookup structures that are accessed sparsely.
A simplified example is:
Total parameters = dense compute parameters + lookup-table parametersPer-step compute cost ≈ number of tokens × active dense parameters + lookup overhead
From an engineering perspective, effective parameters affect three key metrics:
- Compute demand: The larger the dense matrix multiplication scale, the longer each inference pass takes.
- Memory-access pressure: The larger the parameter set, the higher the cost of moving weights during execution.
- Cache efficiency: Whether the model can remain resident in on-chip cache or low-latency memory affects first-token latency and sustained throughput.
Therefore, on-device models should not simply pursue “more parameters is better.” Instead, the key question is whether the effective parameters match the device’s capabilities. A model with a smaller effective parameter count and a well-designed structure is often more suitable for local deployment than a model with a large total parameter count and similarly large effective parameters.
3. How Per-Layer Embedding Improves On-Device Efficiency
The idea that “each layer has a small embedding table” can be summarized in engineering terms as per-layer embedding or layered embedding. The core idea is to avoid relying on only one global input embedding. Instead, each model layer maintains a lightweight embedding table that can perform a secondary mapping over input tokens or intermediate states.
The basic process can be abstracted as:
Original token↓Base embedding↓Layer 1 embedding lookup and fusion↓Layer 1 attention and feed-forward computation↓Layer 2 embedding lookup and fusion↓Layer 2 attention and feed-forward computation↓……↓Output logits
In pseudocode, it can be represented as:
function infer(model, token):hidden = model.base_embedding(token)for layer in model.layers:layer_embedding = layer.embedding_table(token)hidden = fuse(hidden, layer_embedding)hidden, kv_cache = layer.attention(hidden, kv_cache)hidden = layer.feed_forward(hidden)logits = model.output_projection(hidden)return logits
The value of this mechanism is that it can shift part of the model’s parameters from dense computation to sparse lookup. If designed well, the model can maintain a certain level of representational capability while reducing the parameter scale that is actively used during each inference pass.
However, per-layer embedding also introduces additional complexity:
- More complex storage structures: Multiple embedding tables need to be managed, quantized, and loaded separately.
- Longer memory-access paths: Each layer may require a lookup, which places higher demands on the memory subsystem.
- Higher implementation difficulty: Runtime systems need cache and prefetch optimizations for layered lookups.
- Quality depends on the fusion method: How embeddings are fused with hidden states can affect model stability.
Therefore, per-layer embedding is not simply about increasing model size. It changes how parameters are organized so that on-device hardware can achieve a better efficiency balance under limited resources.
4. Building a Multi-Dimensional Evaluation System for On-Device Models
In real-world model selection and evaluation, it is recommended to build a complete metric system across several dimensions.
1. Storage and Memory Metrics
On-device models are first constrained by storage and memory. The following aspects should be evaluated:
- Model file size;
- Runtime resident memory;
- Peak memory usage;
- Cache growth under long-context inputs;
- Model loading and cold-start time;
- Memory usage under different quantization precisions.
For per-layer embedding models, it is especially important to evaluate embedding-table storage separately. Embedding tables may not directly determine inference speed, but they can significantly affect installation package size and runtime memory pressure.
2. Inference Performance Metrics
Inference performance should not be measured only by average speed. The following aspects should be considered:
- First-token latency: Time from completed input to the first generated token;
- Generation throughput: Number of tokens generated per second;
- Long-text stability: Whether noticeable slowdown occurs as context grows;
- Batch processing capability: Whether multiple requests or sessions can run in parallel;
- Tail latency: Whether P95 and P99 latency remain acceptable;
- Streaming output experience: Whether users can see continuous output with low perceived delay.
In on-device interaction scenarios, first-token latency is often more important than peak throughput. Users usually perceive “speed” based on how quickly the first token appears and whether subsequent generation remains stable.
3. Power and Thermal Constraint Metrics
Mobile devices and edge devices often have strict power limits. Model evaluation should include:
- Average power consumption;
- Peak power consumption;
- Temperature changes during sustained inference;
- Throttling risk under high load;
- Effective output per unit of energy consumed.
A simple reference formula is:
Energy efficiency = effective output tokens / consumed energy
If a model produces high-quality output for a single response but consumes too much power and generates excessive heat, it is not suitable for long-term resident operation on the device.
4. Task Quality Metrics
On-device models should not pursue lightweight design at the expense of real business requirements. It is recommended to evaluate the following aspects:
- Instruction-following capability;
- Summarization and information extraction capability;
- Coherence in multi-turn conversations;
- Long-context understanding;
- Domain terminology handling;
- Safety and compliance behavior;
- Robustness under abnormal inputs.
For on-device scenarios, two evaluation sets can be used: a lightweight task set and a difficult task set. The lightweight task set can determine whether everyday user experience meets requirements, while the difficult task set can help decide whether cloud-device collaboration is needed.
5. Key Decision Criteria for On-Device Model Selection
When facing on-device models with different scales and structures, developers can follow the selection process below.
Step 1: Define the Device Capability Boundary
The first step is to confirm whether the device has:
- Available memory;
- Allocatable memory for the model to remain resident;
- Operator support on the processor or accelerator;
- Support for low-precision inference;
- Capability for sustained execution;
- Sufficient storage space for model files.
If device memory is limited, priority should be given to models with smaller effective parameters, quantizable embedding structures, and predictable runtime memory usage.
Step 2: Distinguish Total Parameters from Effective Parameters
During model selection, it is helpful to establish a comparison table:
| Metric | Meaning | On-Device Impact |
|---|---|---|
| Total parameters | Sum of all weights and lookup parameters | Affects installation size and static memory |
| Effective parameters | Core parameters that actively participate in one inference pass | Affects compute and latency |
| Embedding table size | Scale of lookup parameters | Affects storage and memory access |
| KV cache size | Cached historical states | Affects long-context memory usage |
| Quantized size | Actual footprint after compression | Affects deployment feasibility |
A large total parameter count alone should not be used to reject a model. Likewise, a small effective parameter count should not cause the storage pressure from embedding tables to be ignored.
Step 3: Evaluate Runtime Implementation Capability
Models with the same structure may perform very differently under different runtime environments. For on-device deployment, the following capabilities should be confirmed:
- Support for dynamic-shape inputs;
- Support for streaming inference;
- Support for incremental decoding;
- Support for KV cache management;
- Support for loading quantized models;
- Support for exception recovery and resource release.
If the runtime has insufficient support for per-layer embeddings, sparse lookups, or dynamic cache management, even a theoretically efficient model may be difficult to deploy successfully.
6. A Typical On-Device Deployment Pipeline
A complete on-device model service pipeline usually includes the following stages:
User input↓Tokenization and preprocessing↓Model loading↓Embedding and per-layer computation↓Attention cache maintenance↓Sampling and decoding↓Post-processing and output↓Logging, metrics, and security auditing
During deployment, several issues should be considered carefully.
1. Model Loading and Warm-Up
On-device applications should not wait until the user’s first request to load the model. The following tasks can be completed during idle periods:
- Reading model files;
- Dequantizing and unpacking weights;
- Preprocessing embedding tables;
- Initializing cache pools;
- Warming up inference threads.
This can reduce first-token latency and improve user experience.
2. Memory Pools and Cache Management
On-device memory is limited, so it is better to use preallocated memory pools rather than frequently allocating and releasing memory. For the KV cache, it is useful to set:
- Maximum context length;
- Minimum retention window;
- Expired cache recycling policy;
- Compression policy for long conversations;
- Memory alert thresholds.
When a conversation becomes too long, sliding windows, summarization-based compression, or hierarchical caching can reduce memory pressure.
3. Quantization and Precision Selection
Quantization is a core technique for on-device deployment, but it should not be applied uniformly across all modules. It is better to distinguish between:
- Dense compute layers: lower precision may be used;
- Attention weights: medium precision may be used;
- Embedding tables: lookup precision and index precision should be evaluated;
- Output layers: higher precision may be used to preserve output stability.
Using different precision levels for different layers often achieves a better balance among quality, speed, and model size.
7. Common Optimization Directions
1. Sparse Lookup Optimization
For per-layer embedding structures, random memory access should be reduced as much as possible. Possible techniques include:
- Preloading hot tokens;
- Caching embedding tables in blocks;
- Keeping high-frequency tokens resident;
- Asynchronous prefetching;
- Merging lookup results.
2. Operator Fusion
Fusing adjacent operators such as normalization, activation functions, and matrix multiplication can reduce intermediate tensor reads and writes, thereby lowering memory-bandwidth pressure.
3. KV Cache Compression
In long-context scenarios, KV cache growth is often a memory bottleneck. Possible approaches include:
- Cache quantization;
- Low-rank compression;
- Evicting historical tokens;
- Hierarchical caching;
- Replacing part of the history with session-level summaries.
4. Cloud-Device Collaboration
The on-device model does not necessarily need to handle all tasks. A more reasonable architecture is:
Low-latency, lightweight tasks: handled by the on-device modelHigh-complexity, non-real-time tasks: handled by cloud modelsSensitive or offline scenarios: prioritize local processingTasks requiring continuous improvement: cloud updates and evaluation
For example, the local model can handle fast intent recognition, simple summarization, offline question answering, and basic instruction execution. Complex reasoning, long-document analysis, and cross-domain knowledge integration can be delegated to the cloud.
5. General Cloud Capability Support
In a cloud-device collaboration architecture, the cloud side often needs to support model distribution, canary releases, monitoring and alerting, log analysis, data reflow, and evaluation management. Developers can build a complete pipeline using general cloud capabilities such as container platforms, object storage, message queues, logging, and monitoring, for example through Baidu AI Cloud where applicable, instead of relying on one fixed component.
8. Quality Assurance and Continuous Operation
After an on-device model is deployed, a continuous operation mechanism should be established.
1. Offline Evaluation
A fixed evaluation set should be maintained and should cover:
- Daily question answering;
- Summarization;
- Instruction following;
- Multi-turn dialogue;
- Long-text understanding;
- Safety and compliance cases;
- Robustness against abnormal inputs.
Every model update or quantization version change should be evaluated with regression tests.
2. Online Canary Release
On-device model updates have special characteristics because client versions, device performance, and network conditions vary widely. A canary strategy is recommended:
- Release to a small percentage of users first;
- Monitor crash rate, memory usage, latency, and user feedback;
- Perform grouped analysis of abnormal devices;
- Keep a rollback version;
- Switch high-quality tasks to cloud enhancement when needed.
3. Observability
The following metrics should be collected:
- Model loading success rate;
- Inference latency;
- First-token latency;
- Generation throughput;
- Peak memory usage;
- Crashes and timeouts;
- Spot-check results of output quality;
- User satisfaction feedback.
It is important to follow privacy protection principles when collecting logs. Sensitive text should be desensitized or minimized in collection.
9. Common Misconceptions
Misconception 1: A larger total parameter count always means better on-device performance
This is not true. On-device experience depends not only on model size, but also on structural efficiency, quantization quality, runtime optimization, and task fit.
Misconception 2: A larger effective parameter count always means a stronger model
A larger effective parameter count may improve representational capability, but it may also exceed the device’s compute and memory budget. On-device model selection always requires engineering trade-offs.
Misconception 3: Embedding tables only create storage overhead and do not affect performance
Embedding tables are mostly accessed sparsely, but they still affect memory usage, cache hit rate, loading time, and runtime stability.
Misconception 4: Average latency is enough
Real user experience is often more affected by tail latency. If some requests frequently stall or time out, users may still have a poor experience even if the average metrics look acceptable.
Misconception 5: Quantization solves everything
Quantization still requires validation of precision, stability, and compatibility. This is especially true for per-layer embeddings, attention caches, and long-context scenarios, which should be tested separately.
10. Conclusion
Evaluating on-device lightweight large models should not stop at parameter count, benchmark scores, or a single latency metric. It should return to the real resource constraints of the device and the actual business scenario. Developers need to understand the difference between total parameters and effective parameters, master the efficiency benefits and engineering costs introduced by parameter organization methods such as per-layer embeddings, and build a complete evaluation system covering memory, compute, power, throughput, quality, and stability.
In practice, a more reasonable path is to first define the device’s resource boundaries, then select models with controllable effective parameters, quantizable structures, and mature runtime support. After that, overall experience can be improved through memory pools, cache compression, operator optimization, streaming inference, and cloud-device collaboration. For complex tasks, cloud capabilities can provide supplementation and enhancement, allowing the system to preserve privacy, low latency, and offline availability while delivering a more stable intelligent experience.
