Small Language Model Embedding Compression: Why 60% of Parameters Live in the Vocabulary

    Small language models look like they are dominated by attention and feed-forward blocks, but on a 268M-parameter on-device model roughly 168M parameters (about 63%) belong to the embedding table alone. This article explains why vocabulary size is a depth-independent fixed cost that hurts small models far more than large ones, why embedding layers resist the quantization methods that work on transformer bodies, and how to reduce them with a four-stage approach: vocabulary pruning with byte fallback, low-rank decomposition of the output head, codebook quantization, and high-bit residuals for outlier tokens. It also covers treating bit width as a design budget, evaluating beyond perplexity, and the open problems that still lack reproducible baselines.

    Small Language Models Put 60% of Their Parameters in the Vocabulary: The Embedding Compression Problem

    1. A counterintuitive fact: a small model’s real weight is in the vocabulary

    When people discuss small models, attention goes to the parts that look like they are thinking: layer count, attention heads, hidden dimension. Take apart a 268M-parameter on-device model designed for phones and laptops, though, and an uncomfortable fact appears. The feed-forward and attention blocks that actually do per-token computation hold only about 71M parameters. The embedding table that maps discrete tokens to vectors holds 168M — close to 63% of the total.

    This ratio is not an outlier. It is structurally inevitable. Language model parameters fall into four buckets:

    • Embedding table: shape vocab_size × hidden_dim, parameter count = V × d
    • Output projection (language model head): same shape as the embedding table, and weight-tied to it in some models
    • Transformer layers: parameter count scales with depth L
    • Normalization, biases, etc.: rounding error

    The key point: of the first three, only the second grows with depth. The embedding table is a fixed cost that is independent of depth. The fewer layers a model has, the larger that table’s relative share becomes. That is exactly why this effect is completely masked in large models and amplified into the main problem in small ones.

    2. Why smaller models lose out: a parameter composition formula

    Write the output-layer part of end-to-end inference as:

    1. Output projection FLOPs ≈ 2 × V × d # independent of sequence length
    2. Weight traffic of this matrix during decode ≈ V × d × b # b = bytes per parameter

    For a model with a 260K vocabulary and d = 768: one output projection costs about 2×10⁸ floating-point operations, and the matrix holds 200M parameters. A 28-layer decoder with d_ff = 2048 costs about 4.7M parameters and 160MB per layer; processing tokens one at a time, total weight traffic across the stack comes to roughly 4.5 GB. The output projection alone is on the order of half the compute of the entire decoder stack, yet its weight traffic is 60× that stack.

    The reason is straightforward. On the input side, the embedding table is a sparse lookup — fetch the row matching a token id — and generates almost no compute. On the output side, it becomes a dense matrix multiplication over the whole vocabulary, an unavoidable cost at every layer that does not depend on sequence length.

    For a cloud-scale model, this is noise. For a 268M-parameter model whose main body can be ternarized down to roughly 1.58 bit, this is the entire conflict.

    3. Three waves of slimming, and nobody touched the vocabulary

    Three things have happened in the small-model space over the past few years:

    1. Extreme low-bit quantization was proven viable. Ternary networks constrain weights to {-1, 0, +1}, about 1.58 bit effective; with scaling factors the quality loss stays limited, and mobile can adopt integer matrix-multiplication kernels designed for low bit widths.
    2. Sub-billion-parameter models turned out to be good enough. Everyday rewriting, classification, extraction, code completion, and local question answering are already served acceptably by models of a few hundred million parameters plus targeted fine-tuning.
    3. On-device deployment became a real scenario. Models run on phones, PCs, and edge devices, where every MB of package size, every GB of resident memory, and every byte of per-token read bandwidth translates directly into cost.

    The vocabulary, however, is the one part that has been left almost entirely unaddressed:

    • Mainstream post-training quantization methods (layer-wise and channel-wise calibration approaches like GPTQ and AWQ) generally exclude the embedding layer and output head from quantization, or assign them extremely conservative bit widths.
    • Ternarization schemes compress linear-layer weights; the vocabulary stays in float or bf16.
    • Common local inference engines typically offer only a 6–8 bit option for the output layer, and often keep input embeddings at 16 bit.
    • Even the vendors behind 1.58-bit quantization, when they quote numbers like a “0.4 GB memory footprint,” explicitly note that it excludes the embedding layer — effectively removing the biggest item from the accounting.

    The result is an absurd ledger: ternarize the body and it comes to about 20 MB, while a 16-bit vocabulary takes about 335 MB. You compressed 90% of the body, and because of one table that was never touched, the whole file barely shrank at all. It is worth asking: this 335 MB lookup table is read in full every time a token is generated — is it really worth that price?

    4. Why embedding layers are hard to compress: four technical root causes

    Root cause 1: it is backed up at both ends. The input lookup and the output projection have identical shapes, and many models share the same weights (tied embeddings). Sharing is good news — compress once, save twice. If a model does not share, you have to compress two copies. Confirming this is the first thing to do before any embedding optimization.

    Root cause 2: on the output side you cannot allocate bits by row importance. Quantizing the body can rely on a calibration set plus layer-wise error compensation to protect important channels. But every row of the output layer corresponds to the logits of one token, and errors there are not a smooth degradation — they directly change the top-1 choice. One token quantized wrong shifts the entire logits distribution, which can trigger repetition, loops, or a sudden language switch. The failure mode moves from “perplexity goes up a little” to “behavior breaks,” and that is the fundamental reason embedding layers are far more sensitive than the body.

    Root cause 3: activation outliers concentrate on a few tokens. A large body of work shows that punctuation, beginning-of-sequence markers, and common stop words can have activation norms more than 20× the mean. When you apply per-channel per-row scaling or grouped quantization, these outlier rows inflate the group scale and the effective bit width of all remaining tokens collapses.

    Root cause 4: it is memory-bandwidth bound, so compression does not necessarily make it faster. On-device decoding is memory-bound. Taking 168M parameters from 16 bit to 4 bit drops traffic from 336 MB to 84 MB, but the lookup/gather and dequantization work is irregular memory access. It cannot be amortized across SIMD the way a matrix multiply can, so real speedups tend to fall well short of the compression ratio.

    5. A four-stage plan you can actually ship

    Stage 1: vocabulary pruning + low-frequency fallback (biggest win, lowest risk)

    Count frequencies on your corpus, prune the vocabulary down to V’ (for example 64K), keep full embeddings for high-frequency tokens, and route low-frequency tokens through a uniform byte fallback path:

    1. # Frequency counting and pruning
    2. freq = Counter(tokenize_corpus(corpus)) # match your real production distribution, not a generic corpus
    3. keep = {t for t, c in freq.most_common(V_PRUNE)}
    4. def encode(text):
    5. out = []
    6. for t in tokenize(text): # smallest usable subword unit
    7. out.append(t if t in keep else ("<byte>", t.encode()[0]))
    8. return out
    9. # Decouple the output head from the embedding, and re-initialize the pruned rows
    10. emb_new = emb_w[V_PRUNE_KEEP] # keep high-frequency rows only
    11. head = nn.Linear(d, V_FULL, bias=False) # no longer shared; keep full-vocabulary logits
    12. head.weight.data[:V_PRUNE_KEEP] = emb_new # high-frequency rows inherit the original weights

    The important point: do not prune the output side as well, or the model will be unable to generate the removed tokens. Keep the head at full vocabulary and decoupled from the embedding. At this point, at 16 bit the input side drops from 336 MB to about 126 MB while the head is still 336 MB — which is why this stage has to be combined with stages 2 and 3.

    Stage 2: low-rank decomposition of the output head (optional, depends on the rank spectrum)

    Apply truncated SVD to the output head weights, W ≈ U·Σ·Vᵀ, keeping the top r singular values. Storage cost becomes r×(V+d). But measure the singular value decay first:

    1. import numpy as np
    2. U, S, Vt = np.linalg.svd(head.weight.float().cpu().numpy(), full_matrices=False)
    3. for r in (128, 256, 512, 768):
    4. err = np.linalg.norm(S[r:]) / np.linalg.norm(S) # relative Frobenius error
    5. print(r, err)

    In practice vocabulary matrices show fast singular value decay; setting r to roughly half the hidden dimension usually brings relative error into the 1% range. Low-rank decomposition also multiplies cleanly with the original weights, which makes it naturally suited to quantization — you get decomposition and quantization gains stacked on each other.

    Stage 3: codebook quantization (the best fit for a lookup structure)

    Split each d-dimensional row into g groups of k dimensions, represent each group with a shared codebook (k-means clustering), and store only the codebook index inside the row. With d=768, g=32, k=24, 256 entries per codebook, 4 bit per code:

    1. Per-group codebook: 256 × 24 × 4 bit = 3 KB # 96 KB across 32 groups, shared by the whole model
    2. Per-row indices: 32 × 4 bit = 16 B
    3. Input-side storage: 16 B/token vs. 1536 B/token raw (~96× reduction)

    Dequantization is a pure integer gather plus additions, with no multiplication, which is friendly to on-device implementations:

    1. def dequant_row(idx, codebooks): # idx: (g,) int
    2. return np.concatenate([codebooks[g][idx[g]] for g in range(idx.shape[0])])

    The value of codebook quantization is that it turns “each row quantized independently” into “the whole vocabulary shares one codebook,” which sidesteps the problem of outlier tokens inflating the scale.

    Stage 4: high-bit residuals + cold token downgrade

    Keep a bf16 or 8-bit residual for low-frequency and outlier tokens: store full copies only for the top-k high-frequency anomalous rows, and route everything else through the codebook path. At lookup time, a hit in the anomaly table returns the high-bit value; otherwise fall through to the codebook. This layer typically only needs to cover a few thousand tokens and costs on the order of 1 MB extra, while solving most “behavior breaks.”

    Addendum: spend less on this at training time

    Everything above is post-hoc compression. The real fix is to not make the vocabulary that large in the first place. Vocabularies with byte fallback, whitespace-free pre-tokenization in the style of SentencePiece, and larger, more uniform subword units can all cut V by 20%–40% at equivalent coverage. Because V × d is a multiplicative cost, a 30% smaller vocabulary saves 30% on both embedding and output — more thorough than any post-hoc quantization.

    6. Treat the bit budget as a design variable

    The endpoint of compression is not “as small as possible.” It is treating bit width as a budget you can allocate:

    Component Original Conservative budget Aggressive budget
    Transformer body bf16 4 bit (~1/2) ternary 1.58 bit
    Input embedding bf16 codebook ~0.5 B/param pruning + codebook ~0.1 B
    Output head bf16 8 bit 4 bit + low-rank decomposition
    Low-frequency / outlier rows — keep bf16 residual keep 8-bit residual

    Two allocation principles. First, protect precision where errors are most sensitive: the output head affects generation behavior far more than the body layers, so it should not be first in line to be compressed. Second, reduce V before b, because V × d × b is multiplicative and shrinking the vocabulary amplifies the gains from bit compression.

    7. Evaluation: don’t just look at perplexity

    Prepare at least four comparison groups: original bf16 / body ternarized with the vocabulary untouched / the four-stage plan above / the four-stage plan plus training compensation. Record for each:

    • Size and memory: peak RSS, and resident memory after cold start (this is the real threshold for on-device experience)
    • Throughput: tokens/s for prefill and decode, reported separately, since the two have completely different bottlenecks
    • Quality: perplexity, downstream task accuracy, and output distribution drift (top-1 agreement rate on the same prompt, KL divergence)
    • Extreme behavior: repetition rate, language-mixing rate, truncation rate, validity rate of structured output (JSON)

    The last item is the easiest to overlook and often the first place a low-bit output head fails. If you run LoRA-style adapter fine-tuning for compensation on 1,000–2,000 production prompts, you can usually recover most of the perplexity loss, at the cost of tens of MB of training time and negligible inference overhead.

    8. Checklist

    1. Confirm whether input embeddings and the output head share weights — this decides whether you are optimizing one surface or two.
    2. Compute token frequencies on real production data (not a generic corpus), plot the histogram, and see how many bytes pruning 20% of the vocabulary saves.
    3. Analyze the singular value spectrum of the output head to decide whether low-rank decomposition is worth it.
    4. Pick codebook quantization, validate “top-1 agreement rate” offline first, then measure latency on device.
    5. Keep high-bit residuals for high-frequency outlier tokens and measure their share separately.
    6. Run the four-way evaluation and produce four tables: size / memory / throughput / quality.
    7. If you are in this for the long term, consider a byte-fallback vocabulary at training time to reduce firefighting later.

    9. Three genuinely open problems

    • There is still no public, reproducible baseline for the relationship between compression ratio and generation quality. Many methods work in papers and lose most of their benefit on a specific on-device model, because the calibration set does not match.
    • The payoff from embedding compression depends heavily on hardware. Without dedicated gather/lookup acceleration, dequantization overhead can eat the bandwidth savings, so this has to be measured rather than calculated.
    • The “excludes the embedding layer” convention needs correcting. As long as the vocabulary accounts for two-thirds of the file, any size or memory figure that ignores it is not a valid argument for on-device feasibility.

    10. Conclusion

    The engineering center of gravity for small models is shifting from “how low can we push the body” to “how do we govern the vocabulary.” Once the body can be pushed to 1.58 bit, that 335 MB lookup table stops being rounding error and becomes the whole story. Vocabulary pruning, low-rank decomposition, codebook quantization, and residual fallback are not new inventions, but combined they cut file size by an order of magnitude and startup memory by several times — enough to change what small models can realistically do on-device. Treating the bit budget as a design variable rather than a post-hoc knob is the actual solution.