Freezing the Vocabulary: A Key Step in Lightweighting Small Models for Edge Deployment

    Once sub-billion-parameter models become practical, the vocabulary and embedding table emerge as structural costs. This article explains why embedding tables are disproportionately heavy in small models, what freezing the vocabulary actually freezes, the engineering patterns for implementing it, its benefits and limitations, and a step-by-step path from experiments to edge deployment. It clarifies that freezing is about decoupling training and update logic—not directly shrinking model size—and should be combined with quantization, pruning, and shared asset management.

    1. Restating the Problem: Once Small Models Are “Good Enough,” Costs Become Visible

    Models with fewer than one billion parameters are becoming genuinely useful: general Q&A, summarization, classification, information extraction, and lightweight code assistance can now run on edge devices or in resource-constrained environments. When a model moves from “it runs” to “it must be mass-produced, distributed, and frequently updated,” the evaluation criteria change. Accuracy is no longer the only metric; package size, peak memory, cold-start time, I/O bandwidth, update traffic, and training cost all matter.

    At this stage, the vocabulary and embedding table become structural costs that cannot be ignored. Language models typically maintain an embedding table that assigns a learnable vector to every token in the vocabulary. To reduce parameters, many models also share the same parameters between the input embedding layer and the output projection layer. As a result, the embedding table serves both as the “lookup dictionary on the input side” and potentially as the “scoring matrix on the output side.” For small models with few layers and small hidden dimensions, the larger the vocabulary, the higher the share of the embedding table in total parameters. In some configurations, the embedding table can account for a substantial portion of model parameters—close to 60% in extreme cases.

    “Freezing the vocabulary” does not mean deleting the vocabulary or eliminating the embedding table. It means stripping vocabulary-related parameters out of the trainable parameter set and managing them as fixed, read-only assets. What changes is the training and update logic: the vocabulary no longer drifts with task data, while the model body continues learning task capabilities. Understanding this is the prerequisite for judging whether the strategy applies.

    2. Why Embedding Tables Feel “Heavy” in Small Models

    Let the vocabulary size be (V) and the hidden dimension be (d). The embedding matrix then has roughly (V \times d) parameters. If input embeddings and the output layer share parameters, this is counted once; if not, the output side adds parameters of the same magnitude. A small model’s total parameter count can be approximated as embedding parameters plus backbone parameters. As layer count shrinks and feed-forward dimensions are compressed, backbone parameters drop—while vocabulary size, determined by tokenization strategy, language coverage, and general-purpose corpora, does not shrink proportionally. The embedding table’s share naturally rises.

    This creates three categories of cost:

    1. Storage cost: The embedding table is a major part of the model package, affecting edge installation packages, image sizes, and cache usage. Even with later quantization, the embedding table is typically a high-dimensional dense matrix whose compression difficulty differs from that of the backbone.
    2. Training cost: More trainable parameters mean larger gradients, optimizer states, communication, and checkpoints. After freezing the vocabulary, training only needs to maintain backbone parameters and their optimizer states, reducing both checkpoint size and distributed synchronization pressure.
    3. Update cost: If the vocabulary participates in every fine-tuning run, each iteration may produce new embedding weights, making incremental reuse of edge update packages difficult. Fixing the vocabulary as a read-only asset lets multiple model versions share a single vocabulary file, so upgrades only replace backbone weights or adapter modules.

    It must be emphasized: freezing the vocabulary does not directly halve the model size. The embedding table must still be loaded at inference time. Actually reducing size requires complementary measures such as vocabulary pruning, quantization, sparsification, shared vocabulary assets, or chunked loading. The core value of freezing lies in stabilizing the training target, reducing optimizer overhead, and simplifying release and incremental updates.

    3. What Freezing the Vocabulary Actually Freezes

    In a weight-tied structure, the input embedding matrix and the output projection matrix are the same weights. Freezing them means both the input-side lookup vectors and the output-side token scoring matrix stop updating. If you want “frozen input, trainable output,” you must untie the shared parameters, which adds a separate output matrix and increases the parameter count—so this trade-off must be weighed against your goals.

    There are three common freezing granularities:

    • Full freeze: The entire vocabulary matrix is frozen while the backbone trains normally. Suitable when the general vocabulary already covers the target domain and the task is mainly style adaptation or instruction following.
    • Partial freeze: High-frequency tokens are frozen while low-frequency or newly added domain tokens remain trainable; or a gradient mask is built based on token frequency, language, or domain labels. Suitable when there are many domain terms but you still want to control the scale of updates.
    • Delayed freeze: First briefly align the vocabulary on a small domain corpus, then freeze it and train the backbone. Suitable when the domain distribution differs significantly from general corpora and immediate freezing would hurt domain representations.

    The pseudocode below illustrates the idea—the focus is on parameter grouping and gradient switches, not framework-specific APIs:

    1. # Framework-agnostic pseudocode
    2. for name, param in model.named_parameters():
    3. if is_token_embedding(name) or is_tied_lm_head(name):
    4. param.requires_grad = False
    5. param.mark_as_readonly_asset()
    6. else:
    7. param.requires_grad = True
    8. # For partial freezing
    9. for token_id in vocabulary:
    10. if frequency[token_id] < threshold or is_domain_token(token_id):
    11. embedding.weight.grad_mask[token_id] = 1
    12. else:
    13. embedding.weight.grad_mask[token_id] = 0

    On the engineering side, the vocabulary file should also be packaged separately from backbone weights: the vocabulary as a versioned read-only asset, the backbone weights as updatable layers. At load time, use memory mapping or chunked reads to reduce peak memory. For multi-task, multi-version models, a single shared vocabulary asset reduces duplicated storage.

    4. Benefits and Boundaries: Freezing Is Not a Free Lunch

    The main benefits of freezing the vocabulary include: fewer optimizer states and smaller checkpoints on the training side, plus lighter distributed synchronization; a stable vocabulary on the release side, making incremental upgrades easier; shared vocabulary assets across multiple models on the edge, simplifying package size and cache management; and reduced risk of catastrophic drift, since vocabulary semantics are less likely to be skewed by small task datasets.

    But the boundaries are equally clear:

    1. Insufficient coverage of new words and new domains. After freezing, the model cannot learn dedicated vectors for new tokens. Faced with large amounts of domain terminology, specialized expressions, or mixed-language text, it may have to rely on subword composition, reducing representation efficiency.
    2. Constrained output side. With shared parameters, freezing the embedding equals freezing the output projection, limiting the model’s ability to adjust token distributions. If a task requires recalibrating token probabilities, evaluate untying the weights or using lightweight adapters.
    3. Vocabulary expansion requires re-alignment. Once the vocabulary is expanded, the mapping between old and new vocabularies must be rebuilt with a proper initialization strategy; you cannot simply concatenate and continue freezing.
    4. Evaluation must go beyond training loss. Look at downstream task metrics, perplexity, domain recall, long-tail token performance, peak memory, time-to-first-token, and update package size together.

    Therefore, freezing the vocabulary best fits scenarios where “the vocabulary already largely covers the target languages and domains, and task adaptation mainly happens at the semantic composition layer.” For tasks dense in domain terminology or with a clearly mismatched vocabulary, evaluate and expand the vocabulary first, then consider freezing.

    5. Implementation Path: From Experiments to Edge Release

    The recommended steps are:

    • Baseline measurement: Measure embedding table parameter count, its share of total parameters, model package size, peak memory, training checkpoint size, and update package size.
    • Vocabulary diagnosis: Analyze tokenization fragmentation rate, out-of-vocabulary ratio, long-tail token frequency, and multilingual coverage on the target corpus to judge whether the vocabulary is “good enough.”
    • Small-scale controlled experiments: Set up three groups—full freeze, partial freeze, and no freeze—with fixed data and training steps, comparing downstream metrics against cost metrics.
    • Complementary compression: Apply quantization, low-frequency token pruning, or asset sharing to the vocabulary. If you prune the vocabulary, you must simultaneously handle output-side mapping and tokenizer version compatibility.
    • Release governance: Assign independent version numbers to the vocabulary file and backbone weights; verify the vocabulary hash during upgrades to avoid tokenizer-weight mismatches.

    The evaluation table should include at least: task accuracy, domain recall, average token count, peak memory, cold-start time, model package size, checkpoint size, and incremental update size. Only when all these metrics are acceptable should vocabulary freezing move from an experimental strategy to a release strategy.

    6. Conclusion

    In the era of small models, the vocabulary is no longer “background infrastructure” but a key asset affecting parameter structure, training cost, and edge distribution efficiency. The essence of freezing the vocabulary is decoupling the frequently changing model body from the relatively stable vocabulary asset: the body continues learning task capabilities while the vocabulary is version-managed as a read-only foundation layer. It cannot replace quantization, pruning, and compression, nor does it suit every domain distribution. But in scenarios with adequate vocabulary coverage and high sensitivity to update costs, it is a lightweighting path worth systematic evaluation. Engineering teams should first use data to judge whether the vocabulary is “good enough,” then validate the boundaries of freezing through controlled experiments, and finally realize the benefits in the edge release pipeline through asset separation and version governance.