Why Vocabulary Tables Burden Small Models: Trinarization and Freezing Strategies
Small language models often face an imbalanced parameter distribution where embedding tables dominate the overall file size. While techniques like trinarizing the transformer body can significantly reduce computational parameters, the vocabulary table remains a major bottleneck. This article explores why embedding layers are often bypassed in quantization, the distinct impacts of freezing vocabulary tables during training versus inference, and optimization strategies such as dimensionality reduction and low-rank decomposition. It also provides a practical evaluation sequence for edge deployment and highlights common pitfalls to avoid when optimizing small models.
Why the Vocabulary Table Becomes the Size Bottleneck
Lightweight models typically exhibit uneven parameter distributions. Take a small model from a lightweight family with 268 million parameters as an example: the embedding table (the lookup table mapping tokens to vectors) accounts for 168 million parameters, or about 63%. The remaining 100 million parameters belong to the Transformer body, of which the feed-forward network (FFN) layers account for roughly 71 million.
The size of the embedding table is determined by two factors: the vocabulary size (V) and the vector dimension (d), resulting in V×d parameters. In large models, the main body parameters easily reach billions, making the embedding table proportionally small. However, since the body of a small model is inherently small, the relative weight of the embedding table is significantly amplified.
Weight sharing complicates matters further. When the input embedding and output projection use the same matrix, the total parameter count does not increase, but this table must serve both the input and output ends. Consequently, operations like quantization or freezing will simultaneously affect both sides.
Why Quantization Often Bypasses the Embedding Layer
Many low-bit schemes are more conservative with embedding layers, commonly keeping them at higher bit-widths, such as 8-bit or 16-bit, or only quantizing the computational layers. The reason is that embedding vectors lack the statistical regularity found in convolutional kernels; compressing them too aggressively can make vectors of different tokens indistinguishable. This does not mean the embedding layer cannot be quantized, but it requires separate evaluation.
Trinarization restricts weights to -1, 0, and +1. The theoretical information content is approximately log2(3)≈1.58 bits. Under specific models and calibration conditions, its performance can approach full precision, though it usually incurs some accuracy loss and requires storing additional information like scaling factors.
Let’s do a rough calculation with these numbers. Non-embedding parameters are about 100 million, multiplied by 1.58 bits, resulting in about 20MB. The embedding table has 168 million parameters, which at 16-bit storage is about 335MB. The vocabulary table accounts for about 335÷(335+20)≈94% of the total size. The actual file size will be slightly larger due to scaling factors, metadata, and alignment overhead, but the conclusion remains the same: if you only compress the main body, the bulk of the file is still the vocabulary table.
Freezing the Vocabulary Table: Training vs. Inference Savings
Freezing the vocabulary table means not updating embedding parameters during training or fine-tuning. This primarily saves training resources. Frozen parameters do not require gradients, and the optimizer does not need to maintain states for them. Taking the commonly used Adam optimizer as an example, each trainable parameter requires two additional states to be saved. Once the embedding table is frozen, this overhead disappears.
However, freezing only affects training. During inference, the model still needs to store these parameters unless additional compression is applied. Therefore, freezing the vocabulary table cannot replace quantization or dimensionality reduction.
It is also crucial to verify whether the input and output share weights beforehand. If they are shared, freezing the input embedding will simultaneously freeze the output projection, making it impossible to separate the two. If you only want to update the output layer, you must unbind them first.
Reducing Embedding Dimension: Clear Benefits, Measurable Costs
Embedding parameters are directly proportional to the dimension d. Reducing the dimension from 4096 to 1024 decreases embedding parameters by 75%. This step is straightforward, but the vector representation capability will degrade. The extent of this degradation must be measured on the target task rather than just looking at the theoretical compression ratio.
Shared Weights and Low-Rank Decomposition: Do Not Mix the Two Routes
Low-rank decomposition splits a V×d matrix into two matrices: V×r and r×d, changing the parameter count to V×r + r×d. When r is much smaller than d, the savings are significant. A choice must be made here beforehand:
Route 1: Unbind input and output. Apply low-rank decomposition to the output layer, while keeping the input embedding as is or quantizing it separately. The scope of impact for this route is clear.
Route 2: Keep sharing. Apply low-rank decomposition to the shared matrix, which affects both the input and output ends simultaneously. Freezing and quantization strategies must also be designed together.
Mixing these two routes can easily lead to misjudgments. For example, you might think you only compressed the output layer, when in reality the input end has also been altered.
Reconstructing Embeddings: Theoretically Feasible, High Barrier to Entry
Reconstructing embeddings represents each token as a linear combination of K basis vectors. The coefficient matrix is V×K, and the basis vector matrix is K×d, bringing the total parameter count to V×K + K×d. When the vocabulary is much larger than the dimension, K needs to be smaller than d to save space. The coefficients must also be stored in a reasonable manner, otherwise the benefits will be offset.
This method is sensitive to initialization and training strategies. Early in training, representation collapse is prone to occur, making it difficult for the model to converge. Unless the team has abundant resources for hyperparameter tuning, it is not recommended as the first choice.
Evaluation Sequence for Edge Deployment
The following sequence is suitable for step-by-step progression on a real device:
- Establish a baseline first. Record model file size, runtime memory, first token latency, and memory bandwidth usage.
- Change the embedding table to 8-bit or half-precision, and measure changes in task metrics. The acceptable margin of decline depends on the task; for instance, if it drops beyond a preset threshold on your validation set, roll it back.
- When metrics are acceptable, try 4-bit, clustering, or dimensionality reduction.
- Re-measure memory, bandwidth, and latency at each step. If the size shrinks but latency does not decrease, the bottleneck might be elsewhere.
- Set rollback conditions. Stop if any condition is met: metrics exceed the threshold, latency shows no improvement, or the target inference framework does not support the used format.
Common Mistakes
- Freezing only the output layer or only the input embedding under shared weights without realizing they are the same matrix.
- Only compressing the computational layers while ignoring the vocabulary table, and later finding the file is still large.
- Looking only at file size without measuring runtime memory and memory bandwidth.
- Treating the VRAM saved during training as storage saved during inference.
- Ignoring additional overhead like scaling factors, leading to an underestimation of size.
- Directly applying monolingual compression parameters to multilingual models, ignoring the coverage risks after vocabulary expansion.
Conclusion
The vocabulary table is a key variable in the size of small models. Trinarization makes the computational layers very lightweight, which in turn makes the proportion of the embedding layer more prominent. It is a relatively safe approach to first calculate the parameter distribution, then follow the sequence of “8-bit testing, dimensionality reduction or low-rank decomposition, and embedding reconstruction” to experiment step by step, while recording metrics, memory, and latency at each stage. Freezing the vocabulary table primarily serves training; to solve inference size issues, it still needs to be paired with quantization or dimensionality reduction.
