The New Bottleneck in Small Model Compression: Reducing the Cost of Vocabulary Embeddings
As language models shrink to hundreds of millions of parameters or fewer, vocabulary embeddings can become a major share of total storage and memory usage. This article explains why embedding layers are harder to compress than the main network and examines vocabulary redesign, low-bit quantization, low-rank factorization, parameter sharing, freezing, tiered storage, and evaluation methods for more efficient edge deployment.
For large language models, model size usually comes from two major components. The first is the network responsible for language understanding and reasoning. The second is the vocabulary embedding parameters used at the input and output ends.
Historically, optimization efforts have focused on the “main” architecture, including attention layers, feed-forward layers, and normalization layers, because these components contain a large number of parameters. However, when a model is reduced to hundreds of millions of parameters or fewer, the vocabulary embedding layer can account for an increasingly large proportion of the total size. In some cases, it becomes one of the most difficult components to ignore in the deployment package.
This creates an easily overlooked problem: the main network has been compressed aggressively, while the vocabulary retains its original size and numerical precision. As a result, further optimizing the network produces diminishing returns. The vocabulary, despite appearing to be an ordinary lookup table, may become the factor that determines model size, memory consumption, and loading speed.
1. What Does the Vocabulary Embedding Layer Store?
Language models typically do not process complete text directly. A tokenizer first converts text into a sequence of integer IDs. Each ID corresponds to a token in the vocabulary, and the model retrieves a vector associated with that token for use as the input to subsequent layers.
Assume that the vocabulary contains (V) tokens, each vector has a dimension of (D), and every parameter uses (b) bits. The theoretical storage requirement of the embedding table is approximately:
[
S=V\times D\times b
]
For example, a vocabulary containing tens or even hundreds of thousands of tokens, combined with a hidden dimension of several hundred and relatively high-precision embedding parameters, can require hundreds of megabytes for the table alone. This estimate does not include the main network, runtime caches, indexing structures, or any separate output-layer parameters.
Many language models share parameters between the input embedding layer and the output projection layer. This avoids storing the same data twice and helps keep the input and output semantic spaces aligned. However, sharing does not make the embedding parameters themselves smaller. It only prevents duplication. For small models, the embedding table can still represent a substantial percentage of the total parameter count.
2. Why Small Models Are More Easily Weighed Down by the Vocabulary
In a large model, the main network may contain billions or more parameters, so the vocabulary represents a relatively small fraction of the total. Even an embedding layer with hundreds of millions of parameters may not appear particularly significant in the overall model.
The situation is different for small models. Suppose the main network has been pruned down to tens or hundreds of millions of parameters, while the vocabulary size, hidden dimension, and storage precision remain unchanged. The more aggressively the main network is compressed, the larger the vocabulary becomes as a relative share of the model.
This is a form of fixed-cost effect. Vocabulary size is usually determined by language coverage, tokenization strategy, and input-output requirements. It does not automatically shrink when the main network becomes smaller. If a model still needs to process multilingual text, code, numbers, symbols, and many rare tokens, it may need to retain a large vocabulary.
For edge deployment, model size should therefore not be evaluated solely by parameter count. A more complete assessment should include:
- The number of parameters in the embedding table and output layer;
- The numerical precision used by each layer;
- Whether input and output weights are shared;
- Peak memory usage during model loading;
- The random-access overhead caused by vocabulary lookup;
- Whether high-precision copies must also be kept at runtime.
3. Why Conventional Quantization Does Not Fully Solve the Problem
Quantization represents weights with fewer bits. For example, parameters stored as relatively high-precision floating-point values can be converted to 8-bit, 4-bit, or even lower-bit integers or discrete values. This can significantly reduce storage requirements and memory-bandwidth pressure.
However, embedding layers are often more difficult to quantize than the main network for three primary reasons.
First, every row in an embedding table corresponds to a token, and the distribution of each token vector can vary significantly. Frequent words, rare words, numbers, punctuation, and code symbols do not share the same statistical characteristics. If the entire table uses a uniform quantization range, useful information in some vectors may be lost.
Second, embedding vectors directly affect all subsequent layers. A local error in one part of the main network may be partially corrected by later computation. But if the input embedding is already distorted at the beginning, the error can propagate through the entire network. The output projection is similarly sensitive because it directly contributes to token probability calculations.
Third, many quantization pipelines prioritize the main layers that are dominated by matrix multiplication. Embedding lookup is not exactly the same as ordinary matrix multiplication. Its engineering implementation, hardware support, and accuracy evaluation methods are also different. As a result, real-world systems often end up in a hybrid state: the main network uses low-bit weights, while the vocabulary remains at relatively high precision.
This approach is relatively safe for accuracy, but it creates a new imbalance. As the main network becomes smaller, the vocabulary gradually becomes the primary source of model size.
4. The First Step: Redesign the Vocabulary
A larger vocabulary is not always better. A large vocabulary allows common words or complete phrases to be represented by a single token, potentially shortening the input sequence. The trade-off is a larger embedding table and higher training and deployment costs.
Vocabulary design should balance three objectives:
- Coverage: Minimize characters or fragments that cannot be represented directly;
- Sequence efficiency: Avoid splitting common text into unnecessarily long sequences;
- Parameter cost: Prevent the number of tokens from growing without limit.
A common strategy is to analyze token frequency using representative business or application data. High-frequency tokens can retain dedicated representations, while extremely rare tokens that almost never occur can be merged or removed. For multilingual models, vocabulary budgets can also be assigned according to target languages and application scenarios, preventing one language or a large collection of special symbols from consuming too much space.
Vocabulary pruning should not rely solely on general-purpose corpora. If the model is mainly used for customer service, code completion, document retrieval, or device control, domain-specific terms, abbreviations, command formats, and numerical patterns may be critical.
A better process is to evaluate coverage using data from the target scenario and observe changes in sequence length, the proportion of unknown fragments, and downstream task accuracy after pruning.
5. Low-Bit Embeddings: Significant Benefits with Layered Handling
Reducing the embedding table from high precision to a lower bit width is usually the most direct way to reduce storage. However, applying one quantization parameter to the entire table is not recommended.
More robust approaches include the following.
1. Group-Wise Quantization
Divide the vocabulary by rows or columns into multiple smaller groups, with each group using its own scale and zero point. This reduces the quantization error caused by distribution differences between token vectors.
2. Importance-Based Precision
Classify tokens into multiple levels according to frequency, gradient magnitude, or sensitivity in downstream tasks. High-frequency and high-importance tokens can use higher precision, while low-frequency tokens use fewer bits. This reduces average storage costs while protecting the tokens most relevant to the primary workload.
3. Separate Outliers
Some embedding vectors may contain dimensions with unusually large magnitudes. If these outliers are quantized together with the rest of the data, they can force the entire group to use a wider numerical range. One option is to extract and store the outliers separately while encoding the remaining values in a more compact format.
4. Post-Training Calibration
After quantization, representative text should be used for calibration. Compare vector distances, output-probability changes, and task metrics before and after quantization. Looking only at overall loss is not sufficient, because some low-frequency but important tokens may suffer from localized degradation.
6. Low-Rank Factorization and Parameter Sharing
If the embedding matrix contains substantial redundancy, it can be approximated as the product of two smaller matrices:
[
E\approx AB
]
The original embedding matrix (E) has dimensions (V\times D). After factorization, it can be represented approximately by (A) and (B). If the intermediate rank (R) is sufficiently small, storage can be reduced from (V\times D) to:
[
V\times R+R\times D
]
The main advantage is that the compressed structure is regular and can be executed efficiently by hardware or inference engines. The drawback is that factorization error may affect fine-grained differences between token representations. In practice, distillation or continued training is often needed so that the model can adapt to the approximate embedding space.
Another approach is to share more structure among the input embedding, output projection, and selected intermediate representations. Parameter sharing can eliminate duplicated storage, but it should not be applied blindly. Input representations emphasize semantic encoding, while output projections emphasize class discrimination. Although the two are related, they are not necessarily identical.
Before increasing the degree of sharing, ablation experiments should verify that accuracy and generation quality do not decline significantly.
7. Freezing the Vocabulary Does Not Mean “Never Train It”
The term “freezing” usually has two meanings.
The first is freezing embedding parameters during training. During fine-tuning, the vocabulary is no longer updated, and only the main network or a small set of adaptation parameters is trained. This can reduce GPU memory usage and training costs, while also preventing small datasets from damaging the general-purpose semantic space.
The second is freezing the vocabulary during deployment. The vocabulary is quantized, partitioned, or placed in read-only storage in advance and is not modified while the model is running. This reduces memory copying, supports on-demand loading, and makes it easier to use memory-mapped files provided by the operating system.
Freezing does not mean that vocabulary quality can be ignored. If the initial vocabulary differs substantially from the target domain, a frozen table may prevent the model from adapting effectively to new terms and specialized expressions.
A more practical workflow is to train or calibrate the vocabulary on a sufficiently large dataset, freeze it afterward, and then use lightweight adaptation layers to address domain differences.
8. Tiered Storage and On-Demand Loading
For edge devices, it may not be necessary to load the entire vocabulary into high-speed memory at startup. Multi-level storage can be designed according to token frequency:
- Keep high-frequency tokens in fast memory;
- Store low-frequency tokens in slower but larger-capacity storage;
- Load long-tail tokens only when they are accessed;
- Cache repeated requests to reduce random reads.
This approach does not reduce the logical number of vocabulary parameters, but it can lower startup memory requirements and resident memory pressure. It is particularly suitable for scenarios with relatively stable input distributions, such as domain-specific question answering, device commands, and structured text processing.
However, tiered storage must also be evaluated under worst-case conditions. If an input suddenly contains many long-tail tokens, frequent page faults or random reads may eliminate the speed gains achieved by compressing the main network.
Cache hit rate, read latency, and concurrent access behavior should therefore be included in testing. Measuring only model computation time is not enough.
9. Establish a Complete Compression Evaluation Framework
Vocabulary compression should not be judged by file size alone. At a minimum, the following metrics should be monitored together:
- Total model size and the embedding layer’s share of that size;
- Startup time and first-inference latency;
- Steady-state inference speed and memory-bandwidth usage;
- Representation error for common, frequent, and long-tail tokens;
- Language-model loss and generation quality;
- Accuracy, recall, and format-following ability on domain tasks;
- Worst-case behavior under different input lengths;
- Stability during power interruptions, memory pressure, or concurrent execution.
If a method only makes the file smaller but slows token lookup, degrades long-context performance, or reduces recognition accuracy for specialized terms, it may not be suitable for real-world deployment.
Conclusion
Small-model compression is entering a new stage. In the past, developers mainly focused on quantizing, pruning, and distilling the main network. Today, the vocabulary embedding layer has become an optimization target that cannot be ignored. Once the main network has been compressed to very low precision, the vocabulary may shift from a peripheral component to the largest storage burden.
There is no single solution. Vocabulary pruning reduces parameters at the source. Group-wise quantization lowers the storage cost per parameter. Low-rank factorization removes structural redundancy. Parameter sharing avoids duplicate storage. Freezing and tiered loading focus more on runtime optimization.
In practice, these methods usually need to be combined and evaluated against language coverage, application data, hardware capabilities, and accuracy requirements.
A truly efficient small model is not defined only by a low parameter count. Its parameter structure must be合理, its storage format must match the target hardware, its loading path must be clear, and its error distribution must remain controllable. By treating the vocabulary as a core module that can be designed, compressed, and evaluated—not merely as a fixed component that is retained by default—developers can further reduce the deployment barrier for edge AI applications.
