Vocabulary Freezing for Small Language Models: Reducing Inference Memory and Deployment Overhead
Small language models are often constrained not only by backbone parameters but also by vocabulary-related modules such as input embeddings, output projections, tokenizer metadata, runtime caches, and framework overhead. This article explains why vocabulary costs can dominate a small model’s memory footprint, what it means to freeze token mappings and embeddings, and how weight sharing, low-precision storage, low-rank factorization, layered vocabularies, and on-demand loading can reduce training and deployment overhead. It also covers the limits of vocabulary freezing, an implementation workflow, and metrics for deciding whether the approach is worthwhile.
In large-model discussions, attention usually focuses on parameter counts: hundreds of millions of parameters, billions of parameters, or even larger models. For on-device applications, embedded devices, low-cost inference services, and high-concurrency endpoints, however, the deployment experience is often shaped not only by the main network but also by the vocabulary, embedding layer, output layer, runtime cache, and overhead from the framework itself.
One easily overlooked fact is that the main network of a small model may already be compact, while vocabulary-related modules can become a major part of the model’s size. When the vocabulary contains tens of thousands of tokens or more, and each token requires a relatively long vector, the input embedding matrix and output layer matrix can grow quickly. For models with a small total parameter count, this share is especially noticeable; in extreme cases, it can approach more than half of total storage overhead.
A useful approach, therefore, is to treat the vocabulary and its related parameters as relatively stable infrastructure: compress, share, or freeze them, and concentrate limited training resources on the main network that actually handles semantic modeling. “Freezing” here does not mean simply deleting the vocabulary. It means keeping token mappings and embedding parameters unchanged during later training stages, reducing update overhead, and combining this with low-precision storage, weight sharing, or tiered loading to lower overall cost.
1. Why the Vocabulary Consumes So Much Memory
A language model typically splits text into tokens and then converts each token into a continuous vector. If the vocabulary size is (V) and the hidden dimension is (D), the input embedding matrix contains roughly:
[
V \times D
]
parameters.
If the model uses a separate output projection matrix to map hidden states back into vocabulary space, there may be another matrix of approximately (D \times V). If the two are not shared, vocabulary-related parameters can reach:
[
2VD
]
parameters.
For example, when the vocabulary contains more than 80,000 tokens and the hidden dimension is around 1,000, a single embedding matrix already has tens of millions of parameters. If stored at higher precision, its footprint is not small; if the input embedding and output projection are stored separately, storage pressure increases further.
This overhead is not directly tied to the number of layers in the main network. Even if the model has only a few attention layers, the embedding module still carries a large fixed cost as long as the vocabulary is large and the hidden dimension is high. In small models, the relative share of the vocabulary is therefore often more prominent than in large models.
2. Why Vocabularies Grow
A larger vocabulary is not always worse. A larger vocabulary can reduce tokenization length, lower the number of sequence-processing passes, and improve representation efficiency for some common words, proper nouns, or multilingual text. But it also brings clear costs.
First, multilingual coverage increases the number of tokens. Different languages differ significantly in writing systems, spacing rules, morphology, and encoding. A unified vocabulary usually needs to accommodate many language-specific fragments.
Second, code, numbers, paths, punctuation, and special symbols expand the vocabulary. Developer-oriented models often need to handle variable names, function fragments, configuration content, and structured text, and these can appear in many combinations.
Third, vocabulary construction usually balances compression ratio and generalization ability. If the vocabulary is too small, a common word may be split into multiple fragments, making input sequences longer. If the vocabulary is too large, embedding parameters increase, and low-frequency tokens may receive insufficient training quality.
Vocabulary design is therefore essentially a trade-off between sequence length and parameter scale. For small models, it is not enough to pursue shorter input sequences; the fixed cost of the embedding layer must also be included in the overall budget.
3. What Freezing the Vocabulary Actually Means
Freezing the vocabulary usually has three levels.
3.1 Fix the Token-to-ID Mapping
Tokenization rules, special markers, ID assignment, and normalization methods remain unchanged during training. This ensures consistent input semantics across training data, inference data, and historical checkpoints.
3.2 Fix the Input Embedding Parameters
During continual pretraining, domain adaptation, or task fine-tuning, the token embedding matrix is no longer updated. Backpropagation can skip gradient computation for these parameters, reducing memory and optimizer state usage.
3.3 Reuse Input and Output Representations Where Possible
If the model architecture allows it, the input embedding matrix and output projection can share weights. This can significantly reduce parameter count while maintaining consistency in token space. Weight sharing is not suitable for every architecture, but for resource-constrained small models it is a common and effective engineering choice.
It is important to emphasize that freezing does not mean the vocabulary is inherently reasonable. If the initial vocabulary has insufficient coverage, produces overly long tokenization results, or splits many domain tokens, those problems remain after freezing. Vocabulary evaluation should therefore be completed before freezing.
4. What Freezing Strategies Can Deliver
Lower Resource Consumption During Training
If embedding-layer parameters participate in training, the optimizer often needs to maintain additional state. In common adaptive optimization methods, for example, each parameter may have first- and second-order statistics. For a large vocabulary, these states can significantly increase memory usage.
After freezing, the embedding layer no longer produces gradients, and full optimizer state does not need to be maintained for it. This leaves more resources for the main network and is especially useful for incremental training in limited-memory environments.
Smaller Model Checkpoints
If vocabulary parameters remain unchanged for a long time, they can be saved as an independent base file and reused across different task models. Task checkpoints then only need to store changes to the main network, reducing transfer, version management, and storage costs.
Better Deployment Stability
Keeping the vocabulary and tokenization rules consistent between training and inference can reduce compatibility problems caused by changes in token IDs. For online services, a stable vocabulary version also makes rollback and canary release easier.
More Modular Management
The model can be split into a vocabulary module, a main network module, and a task adaptation module. Different businesses can share the same vocabulary and base embeddings while replacing only the main parameters or lightweight adaptation parameters, enabling more flexible model asset management.
5. Freezing Does Not Solve Every Problem
Vocabulary freezing has clear benefits, but it also has boundaries.
First, after freezing, the model cannot correct token representations through training. If the target domain differs greatly from the base training corpus—for example, if it contains many technical terms, special encodings, or industry abbreviations—fixed embeddings may limit adaptability.
Second, the output computation cost of a large vocabulary remains. When generating the next token, a language model usually needs to map the hidden state to the entire vocabulary space. Even if the embedding matrix is not updated, output-layer computation can still be high. When necessary, this should be combined with methods such as candidate filtering, layered vocabularies, low-rank projections, or efficient sampling.
Third, freezing the vocabulary cannot replace quantization. It mainly reduces training updates and parameter management costs. If the model is still stored at high precision, the reduction in deployment size may be limited. In practice, freezing is usually combined with low-bit quantization, weight sharing, sparse storage, and similar techniques.
6. Combined Optimization Options for Small Models
Share Vocabulary and Output-Layer Weights
This is the most direct way to reduce parameters. The token vectors used at the input are the same set used at the output, avoiding two similar matrices. After sharing, model parameter count and checkpoint size can both decrease, but the network architecture and training objective must be confirmed to support this design.
Layered Vocabulary
Process high-frequency tokens and low-frequency tokens separately. The high-frequency part uses fast, direct representations, while the low-frequency part is generated through finer-grained combinations. This can control the fixed parameter scale without completely sacrificing coverage.
Low-Rank Factorization
Approximate a large embedding matrix as two smaller matrices:
[
E \approx AB
]
where the intermediate dimension of (A) and (B) is smaller than the original hidden dimension. This method can reduce parameter count, but it introduces approximation error. Validation sets should be used to check whether semantic representations and generation quality degrade.
Low-Precision Storage
After parameters are frozen, the embedding matrix usually no longer needs frequent updates, making it more suitable for storage at lower precision. During inference, it can be converted into a computation format suited to the hardware. Quantization should be evaluated with calibration data to avoid noticeable precision loss for low-frequency or multilingual tokens.
On-Demand Loading
For devices with extremely limited resources, part of the embedding data can be loaded according to the token range involved in the input text. This method requires runtime support for efficient indexing and must handle latency from random access. It is better suited to scenarios where vocabulary access has clear locality.
7. Engineering Implementation Workflow
A relatively reliable implementation workflow is as follows.
Step 1: Profile the vocabulary structure. Record vocabulary size, the proportion of tokens for different languages or domains, the number of special markers, and average tokenization length.
Step 2: Measure memory composition. Separately measure the input embedding, output projection, main network, optimizer state, and runtime cache. Avoid looking only at total model parameters.
Step 3: Evaluate vocabulary quality. Use real business text to calculate the rate of unseen fragments, average sequence length, long-tail token coverage, and tokenization stability.
Step 4: Determine the freezing scope. Usually, prioritize freezing token mappings and base embeddings, then decide whether to freeze the output projection based on task requirements. If the task is sensitive to domain vocabulary, retain a small number of trainable domain adaptation parameters.
Step 5: Choose compression methods. Try weight sharing, low-precision storage, low-rank factorization, and modular checkpoints in sequence, and compare them on a unified validation set.
Step 6: Run end-to-end tests. In addition to accuracy and generation quality, measure first-token latency, throughput, peak memory, model loading time, and upgrade/rollback cost.
Step 7: Establish version constraints. The vocabulary, tokenization rules, and main model must be explicitly bound to versions. Any vocabulary change should be treated as a compatibility change and must not be deployed simply by replacing files.
8. How to Decide Whether the Approach Is Worthwhile
Evaluating vocabulary freezing should not focus only on whether the model file becomes smaller. Four categories of metrics should be considered.
First, quality metrics, including task accuracy, generation coherence, domain term recognition, and multilingual performance.
Second, resource metrics, including resident memory, peak GPU memory, model loading time, and optimizer state size.
Third, efficiency metrics, including input processing speed, output projection time, concurrency capacity, and on-device energy consumption.
Fourth, maintenance metrics, including vocabulary reuse rate, checkpoint size, version compatibility, and rollback difficulty.
If freezing saves only a small amount of disk space but causes clear degradation on domain tasks, the approach is not worthwhile. Conversely, if the model mainly handles stable general-purpose tasks and vocabulary quality has been thoroughly validated, freezing can usually deliver good returns.
Conclusion
Whether a small model is suitable for deployment cannot be determined by parameter count alone. Vocabulary-related modules have characteristics such as fixed scale, strong reusability, and low update frequency, and they should be examined separately in resource-constrained scenarios. By freezing token mappings and base embeddings, and combining this with weight sharing, low-precision storage, low-rank factorization, and modular loading, redundant overhead in training and deployment can be reduced.
More importantly, this approach changes the focus of model optimization: instead of only compressing the main network, it identifies components that matter for quality but do not need frequent updates, and turns them into stable, reusable, independently managed base components. For sub-billion-parameter small models, this may be an important path to improving deployment efficiency, controlling costs, and expanding application scope.
