Vocabulary Embeddings in Small Models: Why They Dominate Size and the Freezing vs. Quantization Trade-off
This article explains why vocabulary embeddings and output projection matrices can dominate the storage footprint of small language models, and why freezing the vocabulary during training is not the same as compressing it for deployment. It compares three practical directions—low-bit quantization, vocabulary pruning/merging/remapping, and sharing, low-rank decomposition, or distillation—and summarizes deployment practices such as partitioned storage, on-demand loading, and an evaluation checklist for balancing size, accuracy, and compatibility.
1. The Core Problem: Why the Vocabulary Becomes the Size Bottleneck
In small-parameter models, the vocabulary embedding matrix is often underestimated. Let the vocabulary size be V and the hidden dimension be H. The embedding matrix then has roughly V × H parameters. If the output layer shares weights with the embedding layer, this same block also carries the storage burden of the output projection. With a vocabulary of more than 200,000 tokens and a hidden dimension of several hundred, the embedding matrix can reach hundreds of millions of parameters. Stored at 16 bits, the vocabulary alone can exceed 300 MB.
A typical estimate illustrates the issue: for a small model with around 270 million parameters, if the main weights are ternarized, the main file can be compressed to about 20 MB. But if the vocabulary is still kept at 16 bits, it can be about 335 MB, and the overall file is instead dominated by the vocabulary. Two concepts need to be distinguished here: tokenizer rule files are usually not large. What actually consumes space is the embedding matrix and output projection matrix corresponding to the vocabulary. In other words, “the vocabulary eats the small model’s weight budget” does not mean the tokenizer itself is bloated. It means high-precision embedding parameters stand out sharply next to a low-bit main body.
Therefore, the optimization target cannot be limited to the quantization factor of the main weights. It must consider total file size, peak memory, and the inference path. Even if the main body is quantized to extremely low bits, as long as the vocabulary remains high precision, download size, resident memory, and initial load time for edge deployment may still fail to meet requirements.
2. Freezing the Vocabulary: A Training Optimization, Not Storage Compression
“Freezing the vocabulary” is a common training strategy: the embedding layer is excluded from gradient updates, reducing optimizer state, gradient communication, and backpropagation overhead. For resource-constrained training jobs, this can significantly lower GPU memory usage and also prevent the vocabulary from being over-updated when data is limited.
But it is important to be clear: freezing the vocabulary does not automatically reduce the inference file. Parameters still need to be stored at some precision and still occupy memory when loaded. Freezing changes “whether to train,” not “how to store.” If the full vocabulary is still saved at 16 bits after freezing, the file size will not decrease because requires_grad=False.
Freezing the vocabulary is applicable to scenarios such as main-body fine-tuning, early domain adaptation, tight training resources, and cases where the vocabulary already covers the target language. The risk is that new domain terminology, rare symbols, code identifiers, and multilingual long-tail cases may not be effectively adapted. A safer approach is layered unfreezing: freeze most low-frequency tokens first, and unfreeze only high-frequency tokens or newly added tokens; or use lightweight adaptation modules to compensate for the representational loss caused by a frozen vocabulary. From an engineering perspective, “training freezing” and “storage quantization” should be designed separately to avoid mistaking training benefits for deployment benefits.
3. Route One: Low-Precision Vocabulary Quantization
The most direct compression method is to reduce vocabulary precision, such as 8-bit, 4-bit, or even mixed precision for selected channels. Embedding lookup is essentially retrieving a vector by index. After quantization, the vector can be dequantized before participating in computation. The output layer affects the logits distribution and is more sensitive to precision.
In practice, grouped quantization can be used: group by row or by column, and save a scale factor and zero point independently for each group to reduce the impact of outliers. Higher precision can be retained for high-frequency words, special symbols, numbers, and code-related tokens; lower bits can be used for long-tail words. Calibration data should cover the target scenario rather than relying only on general text.
Pseudocode illustration:
for block in embedding_matrix:scale, zero = calibrate(block)q_block = quantize(block, bits=4, scale, zero)save(q_block, scale, zero)load:block = dequantize(q_block, scale, zero)
The risk is that low-precision embeddings can amplify confusion among similar tokens, and output-layer quantization may change tail probabilities. Evaluation should not rely only on average perplexity; it should also examine rare-word recall, multilingual tasks, code completion, and recognition of numbers and units. The inference kernel needs to support on-demand dequantization of quantized embeddings; otherwise, frequent conversions may increase latency.
4. Route Two: Vocabulary Pruning, Merging, and Remapping
Vocabulary pruning starts from reducing V, and the benefit is direct. Common methods include removing extremely low-frequency tokens, merging semantically similar subwords, using byte fallback to cover unknown characters, and rebuilding a smaller vocabulary for the target language. For edge scenarios, pruning is often more effective than quantization alone because the parameter count decreases linearly with V × H.
However, pruning changes the token ID mapping and breaks compatibility with the original model’s output layer, tokenizer, and downstream post-processing. The tokenization rules, embedding matrix, output layer, and special tokens must be updated together, with version validation. Long-tail capabilities such as multilingual handling, code, and mathematical symbols should be evaluated separately. If low-frequency tokens are deleted directly, a segment originally expressed by one token may be split into multiple bytes or subwords, which can instead increase sequence length and inference cost.
A safer strategy is “analyze coverage first, then prune”: count token frequency, byte fallback rate, and sequence-length changes in the target corpus; remap mergeable items; and retain tokens required for special symbols and structured text. At release time, the vocabulary version, mapping table, and checksums should be recorded in model metadata to avoid index misalignment caused by loading an old vocabulary.
5. Route Three: Sharing, Low-Rank Decomposition, and Distillation
Weight tying is a common practice: the input embedding and output projection share the same matrix, reducing the storage of one large matrix. If the model was not originally tied, tying can be attempted after training followed by fine-tuning, but changes in the output distribution need to be evaluated.
Low-rank decomposition approximates a large embedding matrix as the product of two smaller matrices, reducing the parameter count. Distillation uses a larger model to guide a smaller model. It does not necessarily prune the vocabulary, but it can help the smaller model maintain capability with a smaller vocabulary. Both require training or calibration, and the engineering complexity is higher than direct quantization. For an already trained small model, the usual priority order is: quantize the vocabulary first, then evaluate pruning, and finally consider retraining-based approaches.
6. Deployment: Partitioned Storage, On-Demand Loading, and an Evaluation Checklist
During deployment, the model should be partitioned into main weights, vocabulary embeddings, output layer, tokenizer metadata, and quantization parameters. Edge devices can use on-demand mapped loading: load only high-frequency token blocks at startup and page in low-frequency tokens as needed. Evaluation metrics should include at least file size, resident memory, first-token latency, throughput, perplexity, downstream task metrics, rare-token performance, and compatibility.
A release checklist should include the vocabulary precision and grouping strategy, whether training was frozen, the pruning mapping version, the special token list, the calibration data scope, and a rollback plan. Only by managing “training-time freezing” and “deployment-time compression” separately can a controllable balance be achieved among size, accuracy, and compatibility.
