Embedding Tables Eat 60% of Small Model Parameters: How to Shrink Them for On-Device Deployment

    This article breaks down where small-model parameters actually live and shows that the embedding table can consume over 60% of the total. It explains why on-device deployment makes this vocabulary overhead especially costly, why common quantization schemes often skip the embedding layer, and why vocabularies are inherently hard to compress. It then lays out practical optimization paths—weight tying and freezing, grouped low-bit quantization, low-rank decomposition, and vocabulary pruning, hashing, and product quantization—along with engineering tradeoffs, deployment recommendations, and a checklist of metrics to validate after each compression step.

    1. Why the Vocabulary Swallows 60% of a Small Model’s Parameters

    When we discuss small models, we tend to judge their size by total parameter count, yet we often overlook how those parameters are distributed across layers. Take an example model aimed at on-device hardware such as phones and laptops—assume it is a 32-layer, Transformer-style small model with a hidden dimension of 640 and a vocabulary size of 128000. The numbers below illustrate parameter composition and are not official figures for any specific product; different implementations, vocabulary sizes, and layer configurations will all produce different results.

    In this example model, the total parameter count is roughly 268 million. Breaking it down layer by layer, the attention and feed-forward structures account for about 100 million parameters, of which the feed-forward portion is about 71 million, while the embedding table alone takes up about 168 million—a ratio of roughly 63%. In other words, more than 60% of the parameters do not come from attention or feed-forward computation, but from the lookup structure that maps a token ID to a vector.

    The embedding table is essentially a 2D matrix whose row count equals the vocabulary size and whose column count equals the hidden dimension. With a vocabulary size of 128000 and a hidden dimension of 640, a single table holds about 128000 × 640 ≈ 81.92 million parameters. If the input embedding table and the output layer do not share weights, there is usually an additional output projection layer that maps to the vocabulary dimension; the two tables together approach 164 million, and adding a small number of other parameters brings the total close to 168 million.

    One common miscalculation is worth clarifying here: 81.92 million is the size of a single table, whereas 168 million typically corresponds to the case where the input embedding and the output layer do not share weights. The two use different bases and cannot be directly subtracted and compared.

    Many models share the same weights between the input embedding table and the output layer—this is weight tying. Weight tying saves one copy of duplicate storage, but it does not compress the vocabulary size itself. After tying, the vocabulary actually has to serve both input lookup and output projection at once, which makes it harder to trim arbitrarily. A more accurate statement is this: the embedding table mainly adds storage and memory-access overhead, but input lookup and the output projection (after weight tying) still produce real computation.

    2. Why the Vocabulary Became an Unavoidable Bottleneck for On-Device Models

    Over the past few years, three trends in the on-device small-model ecosystem have stacked up and pushed the vocabulary problem to the forefront.

    First, extreme weight compression has been proven feasible. Some ternary schemes constrain weights to just three values: -1, 0, and +1. Strictly speaking, ternary weights theoretically need about 2 bits to represent, since log₂3 ≈ 1.58, so packing them gets close to low-bit storage rather than being equivalent to 1 bit. This lets the main body of computation become very small.

    Second, sub-billion-parameter small models are already good enough. Thanks to improvements in training methods, data quality, and evaluation systems, small models on the order of hundreds of millions of parameters can now handle classification, summarization, simple Q&A, code completion, and local assistants—they are no longer just toys.

    Third, these models have started to actually run on local devices like phones and laptops. Once deployed on-device, every megabyte of installation-package size, every memory read, and every cold start translates into a perceptible user-experience cost.

    Stack these three trends together and an awkward result emerges: the model’s “computational body” keeps getting slimmer, but the vocabulary table—long neglected—has become the largest part of the file. A rough estimate: if the non-embedding part is compressed to about 20 MB while the embedding table is still stored at 16-bit precision, then 168 million parameters × 2 bytes gives a vocabulary size of about 336 MB. At this point the vocabulary is no longer excess fat—it is the absolute majority.

    3. Why Quantization Techniques Often Bypass the Vocabulary

    Since quantization can compress weights, why not simply compress the vocabulary too? The reason is not mysterious: many quantization schemes give the embedding layer a pass.

    First, some ternary or low-bit methods mainly compress the linear layers of the computational body while the embedding table stays at 16-bit. Second, the default settings of some mainstream quantization frameworks skip the vocabulary dimension of the embedding or output layer and only handle the regular weights in attention and feed-forward. Not all frameworks behave this way—it depends on the implementation and configuration. Third, common local inference engines, even when they allow quantizing the output layer, usually only compress to 6–8 bits and rarely touch the input embedding.

    The result is that the computational body is compressed to near its limit while the vocabulary does not budge. More telling is the evaluation metric. The memory-usage figures reported in some ternary schemes’ technical materials may note “computational body only” or “excluding the embedding layer.” Such figures may be perfectly valid in specific comparison scenarios, but they easily lead readers to overlook one fact: the memory and storage cost of the embedding layer during deployment does not disappear—it is simply left out of that polished report.

    So a responsible evaluation should not only look at how much the main body was compressed, but should also ask: is this table that occupies 60% of the parameters really worth its size?

    4. Why the Vocabulary Is Inherently Hard to Compress

    To optimize the vocabulary, first understand why it resists compression.

    4.1 The embedding table is a lookup table, not an ordinary computation graph

    When we quantize regular weights, we mainly care about accumulation error in matrix multiplication. But the embedding table is retrieved directly by index and then feeds into downstream computation, so it is more sensitive to numerical flips. If a low-frequency token’s vector is severely distorted, it can directly hurt generation quality or retrieval recall.

    4.2 Token distribution has long-tail characteristics

    In real corpora, a tiny number of high-frequency tokens carry the vast majority of occurrences, while a large number of low-frequency tokens never learn enough signal for their vectors—yet they cannot be deleted arbitrarily, or an out-of-vocabulary token will cause a collapse. This long tail makes uniform low-bit quantization easy to misfire on the low-frequency portion.

    4.3 The input embedding and output layer may be coupled

    Under weight tying, the embedding table also has to project hidden states back into a probability distribution over the vocabulary. The input side and the output side do not necessarily have the same precision requirements, so one-size-fits-all quantization often sacrifices one for the other.

    4.4 Outliers stretch the quantization range

    A few dimensions carry significantly larger-magnitude outliers, and they end up determining the overall quantization range. Handled conventionally, this forces most normal dimensions to share one coarse quantization grid, amplifying the precision loss.

    5. Practical Optimization Paths

    Engineering has accumulated several complementary ideas for the difficulties above, and in practice they are usually combined. A sensible order is: first do weight tying, then group quantization or low-rank decomposition, and finally apply vocabulary pruning and hashing based on task needs.

    5.1 Weight sharing and freezing

    If the input embedding and output layer are not yet tied, prioritize weight tying to first eliminate the duplicate storage. After tying, the vocabulary can be managed separately as a “frozen” dense structure, no longer forced to follow the main body’s quantization strategy.

    The frozen embedding table is best stored in a compressed, packed format—for example, quantized integer tensors plus scale factors. At deployment it can be loaded as a separate lookup resource, avoiding being mixed in with the main body and making it easy to replace.

    5.2 Low-bit quantization with a grouping strategy

    When enabling low-bit quantization on the embedding table, do not use a single global bit-width; use group quantization instead. Chunk by row or by dimension and compute the scale factor and zero point independently per chunk, so high-frequency, important tokens can retain more effective precision while the low-frequency portion is compressed more aggressively.

    The example below shows 4-bit per-row group quantization, converting the result to an integer type before deployment. In a real deployment, 4-bit values can be further packed for storage.

    1. import torch
    2. def quantize_embedding(weight: torch.Tensor, group_size: int = 128, bits: int = 4):
    3. """
    4. Group-wise quantization of the embedding table, chunked by row.
    5. weight: [vocab_size, dim]
    6. group_size: number of dimensions per group
    7. bits: target bit-width, e.g. 4
    8. """
    9. vocab, dim = weight.shape
    10. assert dim % group_size == 0
    11. n_groups = dim // group_size
    12. w = weight.view(vocab, n_groups, group_size)
    13. qmax = 2 ** (bits - 1) - 1
    14. # Compute the quantization range independently per group
    15. scale = w.abs().amax(dim=-1, keepdim=True).clamp(min=1e-8) / qmax
    16. q = torch.round(w / scale).clamp(-qmax - 1, qmax)
    17. # 4-bit results can be stored as integers; higher bits can use int32 or int16
    18. q = q.to(torch.int8)
    19. # At deployment, store the quantized integers together with the scale
    20. return q, scale
    21. def dequantize_embedding(q: torch.Tensor, scale: torch.Tensor, dtype=torch.float16):
    22. """
    23. Dequantization: approximately restore the embedding vectors.
    24. During inference, you can feed the quantized integers directly into the
    25. lookup and downstream computation, depending on the inference engine.
    26. """
    27. return q.to(dtype) * scale

    The key point is that deployment stores the quantized integers and the scale, not the original floating-point table. During dequantization, the weights are approximately recovered by multiplying the quantized integers by the scaling factor. For dimensions with severe outliers, you can clip before group quantization, or keep a higher bit-width for those specific groups.

    5.3 Low-rank decomposition

    If the vocabulary cannot tolerate full precision, you can approximate the large table with two small matrices, reducing parameters from vocab × dim to vocab × r + r × dim. When the rank r is much smaller than dim, the compression ratio is substantial.

    1. import torch
    2. import torch.nn as nn
    3. class LowRankEmbedding(nn.Module):
    4. """Approximate the full embedding table with low-rank decomposition; r is the rank."""
    5. def __init__(self, vocab_size: int, dim: int, rank: int = 64):
    6. super().__init__()
    7. self.a = nn.Embedding(vocab_size, rank) # [vocab, r]
    8. self.b = nn.Linear(rank, dim, bias=False) # r -> dim
    9. def forward(self, idx):
    10. return self.b(self.a(idx))

    Taking 128000 × 640 as an example, with r = 64 the parameter count is 128000 × 64 + 64 × 640 ≈ 8.23 million—nearly an order-of-magnitude reduction compared with 81.92 million.

    But note that low-rank embeddings add a rank-to-dim projection computation and memory-access overhead per token. It is not simply a matter of “swap out one big table and you’re done.” A common practice is to first do low-rank initialization from the original embedding table and then train jointly with the main body; if you only replace the module without training or fine-tuning, accuracy may drop noticeably.

    5.4 Vocabulary pruning, hashing, and product quantization

    In scenarios with a well-defined task and a relatively fixed vocabulary, you can prune the vocabulary—keeping only high-frequency, useful tokens—and build a fallback strategy for out-of-vocabulary tokens.

    There are also two common techniques. Product quantization splits high-dimensional vectors into several low-dimensional sub-vectors, each encoded with a codebook, which greatly compresses storage. Hash embeddings use a hash function to map tokens onto a smaller set of vectors, trading a few collisions for a smaller table.

    It must be emphasized that the effect of these techniques has to be measured per task—generation tasks may lose quality, especially for long-tail tokens, proper nouns, code symbols, and few-shot scenarios. Engineering should focus on observing collision rates, out-of-vocabulary fallback behavior, and task-metric changes on the calibration set.

    6. Engineering Tradeoffs and Deployment Recommendations

    Embedding-layer optimization has no free lunch; the core is tradeoffs.

    Task type Compressibility Recommended approach Main risk
    Text classification, retrieval, intent recognition Higher Group quantization, vocabulary pruning, low-rank decomposition Lower recall on low-frequency tokens
    Summarization, simple Q&A Medium Low-rank decomposition, group quantization, moderate pruning Reduced generation stability
    On-device generation, code assistants Lower Cautious low-rank, group quantization, hash fallback Accuracy loss on proper nouns and long-tail generation
    Cold-start priority on device Higher Frozen embedding table, independent compressed storage Increased loading complexity and compatibility issues

    A general recommendation is to follow this order:

    1. First do weight tying to reduce duplicate storage.
    2. Evaluate the embedding table separately and compress it with group quantization or low-rank decomposition.
    3. After clarifying the task boundaries, apply vocabulary pruning or hash embeddings.
    4. After each compression step, always run regression validation on a fixed calibration set—never judge by file size alone.

    After optimization, it is recommended to measure at least these six items:

    1. Calibration set: whether the fixed calibration set covers the real task distribution.
    2. Task metrics: whether classification accuracy, retrieval recall, generation quality, or business metrics stay stable.
    3. File size: both the overall model size and the embedding table size on its own.
    4. Peak memory: runtime peak memory, not just the weight-file size.
    5. Inference latency: first-token latency, average latency, and throughput changes.
    6. Low-frequency token fallback: whether out-of-vocabulary tokens, long-tail tokens, or proper nouns produce obvious errors.

    7. Frequently Asked Questions

    How do I calculate how many parameters the embedding table takes?
    The basic formula is: vocabulary size × hidden dimension × number of tables. If the input embedding and the output layer do not share weights, the number of tables is usually 2.

    Does weight tying compress the model?
    No, not the vocabulary size directly. Weight tying only removes one copy of duplicate storage; the vocabulary itself still has to serve both the input and the output.

    How should I choose the bit-width for low-bit quantization?
    4-bit group quantization is a common starting point for on-device use. Generation tasks are sensitive to low-frequency tokens, so it is usually not advisable to compress straight to extremely low bit-widths. If you must go lower, focus on calibration, outlier clipping, and group-granularity tuning.

    What should I do about hash collisions?
    The key with hash embeddings is controlling the collision rate and the fallback strategy. You can increase the number of buckets, use a multi-hash scheme, or keep a small high-frequency original vocabulary and build a dedicated mapping for the colliding tokens.

    8. Conclusion

    That the vocabulary occupies more than 60% of a small model’s parameters is not an exaggerated figure of speech, but an engineering fact that on-device model optimization has to face head-on. It is neither an ordinary weight nor a forbidden zone that cannot be touched—it is a lookup structure that needs to be managed, calibrated, and evaluated on its own. In on-device deployment, where every byte counts, treating the embedding layer as an ordinary structure that can be frozen, group-quantized, low-rank decomposed, and pruned is the key step to genuinely slimming the model down.