Why Embedding Vocabularies Become the New Size Bottleneck in Compressed Small Models

    As small models become standard on phones, laptops, and edge devices, an underappreciated problem is surfacing: shrinking a model's parameter count does not automatically shrink its file size or its runtime cost. Many developers fixate on "how many billion parameters" while overlooking the internal structure of small models. For large models, the embedding vocabulary may be a rounding error; for small models, it often becomes a heavyweight that cannot be ignored. This article explains what embedding tables are and why they eat into small-model budgets, why vocabulary becomes more prominent after the backbone is compressed, what "freezing the vocabulary" really means across training, release, and inference, and the practical optimization paths, evaluation practices, and risks that teams should weigh when deploying small models at the edge.

    In the era of on-device small models becoming standard on phones, laptops, and edge devices, an often-underestimated problem is coming into focus: fewer parameters does not mean a smaller file size or lower running cost. Many developers watch only the “how many billions of parameters” number and overlook the structural differences inside small models. For large-parameter models, the embedding vocabulary may be a negligible fraction. For small-parameter models, the vocabulary often turns into a “weight” that is impossible to ignore.

    1. What an embedding vocabulary is, and why it consumes small-model size

    When a language model processes text, the first step is usually not “thinking” but “looking things up.” The model has to turn discrete text units into continuous vectors, and this relies on an embedding table—the embedding matrix. You can picture it as a large lookup table: every token or subword maps to a row of vectors, and the model converts text into numeric representations through indexing.

    The parameter count of an embedding table follows a simple formula:

    1. embedding parameters ≈ vocabulary size × hidden dimension

    Suppose the vocabulary size is 100,000 and the hidden dimension is 512. The embedding table alone then holds about 51.2 million parameters. If the hidden dimension is only 256 but the vocabulary grows to 200,000, the count can still exceed 50 million. For a small model whose backbone network might hold only tens of millions to one or two hundred million parameters, the embedding table can easily account for 30%, 50%, or even more.

    More importantly, many models share parameters between the input embedding layer and the output projection layer. The intent is to save parameters and improve representational consistency, but the effect is that vocabulary-related parameters reappear throughout the model structure. If the input and output layers do not share parameters, the overhead introduced by the vocabulary can grow further.

    So the “size problem” in small models is not merely a mathematical one—it is structural. Many of these parameters do not take part in complex inference computation, yet they carry a heavy load of storage, loading, and memory access.

    2. After the backbone is compressed, the vocabulary stands out even more

    Over the past few years, small-model compression techniques have advanced steadily. Low-bit quantization, mixed precision, ternarization, sparsification, and other approaches all work on the model weights, aiming to make models as small and fast as possible on resource-constrained devices.

    The problem is that these compression techniques tend to focus on the backbone computation layers rather than the embedding table. The reasons are not hard to understand.

    First, the embedding table is not an ordinary linear layer. It is a lookup structure: the input is a discrete index and the output is the corresponding vector. Quantization tools are usually good at compressing the continuous weights in matrix multiplications, but they are more cautious about the “index-to-vector” mapping. If low-bit compression wrongly merges the vectors of different tokens, the model’s language understanding is directly affected.

    Second, the output layer is very sensitive to the distribution. At the final step, generative models must map hidden vectors to a probability distribution over the vocabulary. If the output layer is over-compressed, the boundary between high-frequency and low-frequency tokens can be distorted, hurting generation stability.

    Third, long-tail tokens are hard to calibrate. Quantization typically relies on calibration samples, but low-frequency words, proper nouns, and rare expressions in real corpora may not be adequately covered. The model backbone can be compressed with general-purpose corpora, whereas the vocabulary often has to cope with a more complex long-tail distribution.

    Fourth, engineering pipelines often bypass the embedding layer. Many quantization workflows skip it by default because the risk is high, the payoff is unstable, and debugging is costly. The result is an awkward situation: the backbone is squeezed down to extremely low bits, while the embedding table stays at relatively high precision.

    A simplified model illustrates the point:

    1. If backbone parameters are 100M, compressed to 2bit, size is about 25MB
    2. If embedding parameters are 100M, kept at 16bit, size is about 200MB

    In this situation, even if the backbone is already very slim, the vocabulary can still take up most of the file size. If the vocabulary is larger and the backbone is smaller, the embedding table can even become the main component of the entire model file.

    This is not only a storage problem but a runtime one. The embedding table usually involves a great deal of random access—especially during generation, where a lookup happens at every step. Compressed low-bit weights need to be decompressed, and if the embedding table stays at high bit width, it adds memory-bandwidth pressure. Cold start, first-token latency, and peak memory usage on edge devices are all affected as a result.

    3. “Freezing the vocabulary” is not simply not training—it is layered solidification

    Once the vocabulary becomes a size bottleneck, the industry begins to revisit a question: should the vocabulary be brought into the compression system just like the model backbone? So-called “freezing the vocabulary” does not simply mean setting parameters to non-trainable. It means turning the vocabulary from a “dynamically learned object” into a “solidifiable resource.”

    This can be understood on three levels.

    1. Freeze during training

    At initialization, the embedding table usually comes from large-scale pretraining. For a downstream small task, if the domain does not change much, continuing to update the entire vocabulary often yields limited benefit while increasing training cost and the risk of overfitting. In this case, you can keep the embedding table stable and train only the upper-layer adapters, classification heads, or a small set of structural parameters.

    The benefit of this approach is lower training instability, avoiding the situation where a small model drags its vocabulary representations off course on limited data.

    2. Freeze at release

    When training is complete and the model is ready for deployment, the vocabulary can be treated as a static resource. At this point you can perform offline compression, codebook representation, sparsification, or task-specific pruning. Because inference no longer needs to update the vocabulary, you can pursue more aggressive optimization for on-device storage and loading paths.

    3. Freeze at inference

    At inference time, the vocabulary usually only needs to be read, not written back. Once frozen, it lends itself better to optimizations such as memory mapping, on-demand loading, low-bit decoding, and operator fusion. The more stable the vocabulary, the easier it is to cache and prefetch.

    So the core of “freezing the vocabulary” is not giving up quality, but turning the vocabulary from an uncontrollable block of large parameters into an independent resource that can be managed, compressed, evaluated, and monitored.

    4. Practical paths for small-model vocabulary optimization

    1. Input-output sharing and output-layer dimension reduction

    If the input embedding and the output layer share parameters, repeated storage is reduced. But sharing also ties compression strategies together. In engineering practice, you can consider the following:

    • Use a low-rank projection on the output layer, mapping hidden vectors to a smaller dimension first, then expanding to the vocabulary;
    • Prune generation candidates, computing the full output only over a subset of candidate tokens;
    • For scenarios with clear task boundaries, use a smaller output subset to reduce wasted vocabulary computation.

    2. Low-bit embeddings and codebook compression

    The embedding table is not impossible to compress—it just needs a more careful approach. Common ideas include:

    • Group quantization: divide each row vector into multiple small groups, computing a scale factor per group;
    • Product quantization or vector quantization: represent sub-vectors with a codebook to reduce the original floating-point parameters;
    • Mixed precision: keep high-frequency tokens at higher precision and use lower bits for low-frequency ones;
    • Error compensation: introduce a small residual or correction term after compression to reduce quality loss.

    This is more robust than bluntly converting the entire embedding table to low bits.

    3. Dynamic vocabulary and task specialization

    On-device small models often do not need to carry the full language coverage of a general-purpose large model. If the task is concentrated in scenarios such as customer-service Q&A, device control, text classification, or simple summarization, you can consider:

    • Pruning low-frequency tokens;
    • Merging similar subwords;
    • Falling back to byte- or character-level handling for rare tokens;
    • Retaining high-frequency domain terms and entities for vertical domains;
    • Splitting language packs in multilingual scenarios.

    The core of a dynamic vocabulary is not full language coverage, but improving the quality of task-relevant expression under limited resources.

    4. Layered loading and on-demand caching

    If the vocabulary is large, you can split it into hot, warm, and cold zones. High-frequency tokens stay resident in memory, while low-frequency ones load on demand. Edge devices can also combine this with memory mapping to avoid reading all parameters in at once.

    Pseudo-code illustration:

    1. if token_frequency >= hot_threshold:
    2. load_from_local_cache()
    3. elif token_frequency >= warm_threshold:
    4. load_from_prefetch_buffer()
    5. else:
    6. fallback_to_byte_encoding()

    This strategy can significantly reduce cold-start memory pressure.

    5. Operator optimization in the inference engine

    The embedding table is not only a storage problem but a computation one. The inference engine can optimize the lookup process:

    • Fuse embedding lookup with the subsequent matrix multiplication;
    • Use dedicated decode instructions for low-bit embedding tables;
    • Compute the output layer in chunks to avoid constructing one huge tensor at a time;
    • Preallocate for high-frequency paths to reduce runtime memory allocation;
    • Prune candidate tokens early during generation.

    6. Coordinating cloud training with on-device deployment

    Small-model compression is usually not a one-time action but an iterative process. The cloud can handle model analysis, quantization calibration, evaluation, packaging, and distribution. When it comes to model-file delivery, task scheduling, and quality monitoring, you can draw on general capabilities such as object storage, message queues, container platforms, logging services, and monitoring/alerting offered by Baidu AI Cloud to build a closed loop from training to on-device feedback.

    5. Evaluation should look at resource structure, not just parameter count

    Many teams still evaluate small models by “total parameters” or “theoretical compute” alone. But on-device deployment actually cares about another set of metrics:

    • Model file size;
    • Peak memory usage;
    • Cold-start time;
    • First-token latency;
    • Tokens generated per second;
    • Embedding-table loading time;
    • Long-tail token recognition quality;
    • Task accuracy change after compression;
    • Cross-device compatibility;
    • Power consumption and thermal behavior.

    For vocabulary optimization in particular, you cannot test only average metrics. You also need to observe separately:

    • Whether high-frequency tokens are distorted;
    • Whether low-frequency tokens are over-merged;
    • Whether entity names, numbers, and proper nouns degrade;
    • Whether multi-turn generation shows repetition or drift off topic;
    • Whether loading differences across devices are noticeable.

    A reasonably complete evaluation table can be designed like this:

    1. Category Question to watch
    2. Size Does the file carry most of the vocabulary overhead?
    3. Memory Is the embedding table resident? Does it trigger frequent paging?
    4. Latency Do lookup, decoding, and the output layer become bottlenecks?
    5. Quality Do long-tail tokens, entities, and rare expressions degrade?
    6. Stability Does compressed output drift or produce format errors?

    6. Boundaries and risks to watch

    Freezing and compressing the vocabulary are not without cost. Handled poorly, they can cause several problems.

    First, language-coverage capability drops. Over-pruning low-frequency tokens makes the model perform worse in open-domain conversation.

    Second, entity recognition suffers. If long-tail tokens such as personal names, place names, product names, and code identifiers are merged bluntly, professional scenarios can be affected.

    Third, the vocabulary falls out of sync with the model version. A frozen vocabulary must stay strictly consistent with the model backbone, the output layer, and the tokenization strategy; otherwise index misalignment occurs.

    Fourth, compression error gets amplified. Small models have limited capacity to begin with, and if the embedding table is compressed too aggressively, later layers may be unable to repair the errors.

    For these reasons, vocabulary optimization should follow a “diagnose, then compress, then evaluate” workflow rather than simply chasing the smallest possible size.

    7. Moving from parameter optimization to structural optimization

    Small-model development is shifting from “piling on parameters” to “refining structure.” Early on, people cared whether a model could run at all; later, whether it could be compressed; now the further question is whether every remaining megabyte after compression is spent where it truly matters.

    The embedding vocabulary is a typical example. It is not necessarily the core of a model’s “thinking,” yet it heavily influences whether the model can be deployed, loaded, and run stably. For on-device small models, the vocabulary is not an accessory but a core resource that needs to be governed on its own.

    The future of small-model optimization may no longer compare “how many billions of parameters” but rather:

    • Whether the vocabulary’s share is controllable;
    • Whether the embedding table can be compressed;
    • Whether the backbone and the vocabulary can be loaded in tiers;
    • Whether on-device memory is configured sensibly;
    • Whether long-tail capability remains acceptable;
    • Whether the model size genuinely serves the business scenario.

    When the model backbone has already been compressed to extremely low bits, whether the vocabulary still deserves to stay at high precision, large size, and full loading is itself a question that needs reevaluation. Treating the vocabulary as an independent engineering object to design, freeze, compress, and monitor is becoming an important step in bringing small models to the edge.