Freezing the Embedding Layer in Small Language Models: Why 60% of Parameters Are Just Vocabulary

    A small on-device language model can weigh several hundred megabytes, yet more than 60% of its parameters do nothing but look up word vectors. This article breaks down where those parameters actually sit, explains why the vocabulary table has long been treated as untouchable dead weight, and shows how freezing the embedding layer during fine-tuning works in practice — with sample code, parameter and memory estimates, signals for deciding whether freezing is safe, guidance on when to unfreeze, and a companion toolkit for shrinking the vocabulary itself through byte fallback, low-rank factorization, product quantization and mixed-precision quantization applied after freezing.

    When you run a few-hundred-megabyte language model on a phone, few people stop to ask: how many of those parameters are actually “thinking,” and how many are just memorizing words? Lay out the parameter ledger and the answer is a little surprising. This article starts with the ledger, explains why the vocabulary table has always been treated as dead weight nobody wants to touch, and then introduces the main subject: freezing the embedding layer.

    1. The “brain” and the “dictionary” inside a model

    1.1 A counterintuitive ledger

    Take a small-parameter language model designed for phones and thin-and-light laptops. It has roughly 268 million parameters in total. Broken down:

    • Input-side embedding layer (the vocabulary): about 168 million parameters, or 63%. It is a “token → vector” lookup table, with one row of vectors per token.
    • The part that actually computes: attention, feed-forward networks and the rest, about 71 million parameters combined, roughly 27%.
    • Everything else: about 11%, spread across normalization, the output projection and similar modules.

    Put differently, more than 60% of this model’s “body weight” is rows of vectors sitting in a dictionary — not weights doing inference.

    1.2 The division of labor between “memory” and “computation”

    Dimension Embedding layer (vocabulary) Compute layers
    Core operation Look up a row of vectors by token ID Matrix multiplications and activations
    How it participates in the math Does not compute at all; only supplies the input Directly determines the output of the forward pass
    Parameter count vocabulary size × hidden dimension layers × hidden dimension²
    Source of knowledge Token and context distributions in the pretraining corpus Regularities and capabilities learned during pretraining
    Inference bottleneck Memory footprint, random reads, latency Compute throughput, memory bandwidth
    What quantization buys Clear reduction in size, but introduces lookup error Reduces both size and multiplication cost

    Once that division of labor is clear, the motivation for freezing the vocabulary becomes obvious: since the table only looks things up, don’t let it take part in “changing things” without a strong reason. Pin it during training, and all of the update pressure lands on the weights that actually compute.

    1.3 Why it is specifically small models that get held back

    The embedding parameter count depends only on vocabulary size V and hidden dimension d, and is essentially independent of depth. The compute layer grows roughly with the number of layers L and d². Ignoring the handful of normalization parameters, the vocabulary share can be approximated as:

    1. vocab share ≈ V / (V + 12 × L × d)

    (12L·d² comes from estimating about 4d² per attention layer and about 8d² per feed-forward layer; real architectures will differ.)

    • Large models: V ≈ 32K, d = 4096, L = 32 → about 2%. The vocabulary is a rounding error in the total, so optimizing it buys very little.
    • Small models: V ≈ 260K, d = 640, with far fewer layers → the share easily climbs past 60%.

    The reason is that once the hidden dimension is squeezed down, d² shrinks faster than d. The compute layer collapses quickly, and the vocabulary’s “fixed cost” is suddenly exposed. The same table is irrelevant in a large model, but in a small one it can decide the final size.

    2. Why the vocabulary stayed the dead weight nobody touched

    Over the past few years, the center of gravity in the small-model ecosystem has been the compute layer:

    • Ternarization techniques emerged that compress weights to just three values — -1, 0 and +1. Multiplication degrades into addition and subtraction, with almost no quality loss.
    • Sub-billion-parameter models are already good enough for everyday work, from chat assistants to on-device text classification and information extraction.
    • They genuinely get shipped into phones, laptops and all kinds of terminal devices, where every megabyte and every memory read becomes a real cost.

    The vocabulary, meanwhile, has barely been touched. Roughly four reasons:

    1. The payoff is asymmetric. Compressing the compute layer lowers size and compute at the same time. Compressing the embedding layer to low bit widths does shrink the file, but the vectors retrieved by the lookup feed into everything downstream, so quantization noise is injected straight into every layer’s representations. The risk far outweighs the reward.
    2. Everything is coupled to it. The vocabulary is tightly bound to the tokenization rules, the pretraining corpus and the downstream data pipeline. Trimming it changes how sequences are segmented, which changes sequence lengths and the entire input distribution. Pull one thread and the whole thing moves.
    3. It gets mistaken for a training problem. Many people attribute a large vocabulary to “we need to fine-tune,” and then reach for parameter-efficient schemes that train only part of the model. But adapters sit alongside the compute layer while the embedding table stays exactly as it was in storage — the inference footprint doesn’t shrink by a single byte.
    4. It only became fatal in the small-model era. At 2% of the total, a large model doesn’t care. In a small model, compressing the vocabulary can pay off more than every compute-layer optimization combined.

    3. Freezing the vocabulary: look it up, don’t change it

    3.1 Definition and boundaries

    Freezing the vocabulary means marking the embedding table as non-trainable during fine-tuning or adaptation, and updating only the remaining trainable parts. How much you freeze depends on the training regime:

    • Full-parameter fine-tuning: train only the compute layer.
    • Parameter-efficient fine-tuning: add low-rank adapters next to the linear layers in attention and the feed-forward networks. The frozen set now includes both the embedding table and the entire base model.

    A few boundaries worth clarifying, because they are easy to mix up:

    • Freezing is a training-side strategy. It does not directly shrink the model file used at inference. The inference-size reduction comes from the quantization and embedding compression that follow. The value of freezing is that it makes that step safer and more controllable.
    • Weight tying. Many small models share a single weight matrix between the embedding table and the output projection. Freezing the vocabulary then also freezes the output side’s vocabulary, but the final softmax computation still runs as usual.
    • It does not mean “never again.” Freezing is a stage-level choice; it can be lifted when conditions change (see 3.5).

    3.2 Sample code

    1. # Illustrative code; adapt to your framework and model structure
    2. EMBED_KEYWORDS = ("embedding", "embed") # covers input embedding and output projection naming
    3. def freeze_embedding(model, freeze=True):
    4. """Freeze or unfreeze the vocabulary. With tied weights, the output projection follows the embedding table."""
    5. n_frozen = 0
    6. for name, param in model.named_parameters():
    7. if any(k in name.lower() for k in EMBED_KEYWORDS):
    8. param.requires_grad_(not freeze)
    9. n_frozen += param.numel() if freeze else 0
    10. return n_frozen
    11. def split_param_groups(model):
    12. """Keep embedding and normalization parameters out of weight decay; decay the rest normally."""
    13. embed, norm, decay = [], [], []
    14. for name, param in model.named_parameters():
    15. if not param.requires_grad:
    16. continue
    17. if any(k in name.lower() for k in EMBED_KEYWORDS):
    18. embed.append(param)
    19. elif "norm" in name.lower() or param.ndim == 1:
    20. norm.append(param)
    21. else:
    22. decay.append(param)
    23. return {"embed": embed, "norm": norm, "decay": decay}

    Three engineering details matter here:

    • Freeze before you build the optimizer. An optimizer collects trainable parameters at construction time. If freezing happens after the optimizer is created, the vocabulary will still be allocated state such as momentum.
    • If “frozen but not effective,” suspect tying. Confirm the parameter’s gradient is empty after training. If it shares weights with another parameter, it is still being updated in practice.
    • Adjust settings per parameter group. Vocabularies generally should not receive weight decay, so use grouping to override the global setting.

    3.3 Stacking with low-rank adaptation

    Take “frozen vocabulary + low-rank adapters” as the example. Next to each target linear layer, add two small matrices — A (d × r) and B (r × d) with rank r — and train only A and B. The parameter math:

    1. adapter parameters = number of target linear layers × (d + d_in) × r
    2. trainable = adapter parameters (embedding layer and base fully frozen)

    With d = 640, r = 8 and 7 covered linear layers, that is roughly 70K trainable parameters — less than one thousandth of the base.

    The VRAM savings from freezing are just as significant. For an Adam-style optimizer in mixed precision, each trainable parameter costs about 16 bytes: bf16 weights (2 bytes), fp32 master weights (4 bytes), first and second moments (8 bytes combined), and gradient storage (2 bytes).

    • Fully fine-tuning a compute layer of about 100M parameters (output projection included) takes roughly 1.6 GB just for parameter-related memory.
    • Freeze the embeddings and add a low-bit base, and that drops to a few hundred MB — or even a few tens of MB, depending on base precision, batch size and sequence length.

    On consumer GPUs with only a few GB of VRAM, or even laptops with unified memory, that gap is what decides whether domain adaptation is possible at all.

    3.4 Three signals for deciding whether freezing will work

    1. Data volume. A few thousand to a few hundred thousand high-quality samples is usually not enough to reliably re-estimate hundreds of thousands of rows of word vectors.
    2. Token distribution. If most tokens in the domain corpus already appeared frequently during pretraining, the risk of freezing is low. A large number of entirely new terms means word meanings have to be relearned, and caution is warranted.
    3. A baseline comparison. Using the same data and the same number of training steps, compare perplexity and downstream metrics between an “unfrozen” run and a “frozen” run. Let the experiment decide, not intuition.

    3.5 When to unfreeze or compromise

    • Large-scale continued pretraining. Once the data reaches the order of a billion tokens, the vocabulary needs to keep absorbing new knowledge and should stay trainable.
    • Terminology-dense domains. In settings like healthcare, law or code, you can do a short unfreezing pass on high-quality domain data only, paired with a smaller learning rate (for example, 1/10 of the global rate).
    • Partial unfreezing. Unfreeze only the top-N rows of word vectors with the highest frequency. They contribute most of the quality, and the trainable parameter count stays manageable.
    • Layered unfreezing. Freeze for a number of steps so the rest converges, briefly unfreeze the vocabulary, then freeze it again.

    4. The vocabulary slimming toolbox

    Freezing answers “should this be changed or not.” How heavy the vocabulary is in the first place is a separate question — “should it be made smaller” — and the techniques below handle it. The two are complementary.

    4.1 Vocabulary construction: start by asking how cost-effective it is

    parameters = vocabulary size × hidden dimension is the vocabulary’s most fundamental cost formula. Common vocabulary sizes range from twenty or thirty thousand to well over a hundred thousand, and multilingual models go larger. Too small, and common words get split into multiple pieces, so sequences get longer and attention and decoding costs climb. Too large, and the embedding matrix and output projection inflate together.

    • Byte fallback. Use subword tokenization with byte fallback. Anything outside the vocabulary can be encoded byte by byte, so there is no such thing as an unrepresentable input. When you trim low-frequency tokens, the worst case becomes “a few extra splits” rather than an error.
    • Frequency-driven trimming. On a validation set, compare perplexity, task metrics and average sequence length across different vocabulary sizes to find the point where returns flatten out. Some models chasing extreme lightness on-device will settle for a small vocabulary of only tens of thousands of tokens.
    1. # Illustrative code: evaluating the vocabulary payoff
    2. report = {
    3. "vocab_size": len(tokenizer), # number of vocabulary entries
    4. "avg_tokens_per_sample": mean_tokens, # average sequence length; lower means less compute
    5. "byte_fallback_ratio": fallback_ratio, # share of inputs encoded as raw bytes
    6. "val_perplexity": ppl,
    7. "embedding_params": len(tokenizer) * hidden_dim,
    8. }

    4.2 Compressing the embedding table: four mainstream approaches

    • Low-rank factorization. Split the large V × d matrix into the product of two smaller ones. V × r handles “token → low-dimensional code,” and r × d handles “low-dimensional → hidden dimension.” At r = 64, the parameter count drops to about 1/10, at the cost of one extra small matrix multiplication.
    • Sharing and clustering. Cluster semantically similar or low-frequency tokens, let each cluster share a codeword, and keep a small personalized offset per token. Parameters go from “one row per token” to “one row per cluster plus a small correction per token.”
    • Product quantization. Split each row vector into several sub-segments and quantize each one independently to 256 codewords, so each token stores only a string of codeword indices. With 8 segments, that is 16 bytes per token (indices included); if it is shared with the output projection, the output side needs no separate storage either.
    • Frequency-aware mixed precision. Keep high-frequency tokens at 8 bits or higher, and use 4 bits for mid- and low-frequency ones. Most of the generation quality is determined by high-frequency tokens, so this trades very little accuracy for a clear reduction in size.

    4.3 Making the lookup faster

    At inference time the embedding layer faces random reads: two adjacent tokens in the same sequence may sit far apart in the table, so the cache hit rate is naturally low. Two comparatively cheap fixes:

    • Reorder the vocabulary by frequency. Group high-frequency tokens into a contiguous region at the front to improve locality in cache and memory pages. Note that the tokenizer, the vocabulary indices and the input/output mapping must all be updated together, and the data pipeline must stay consistent.
    • Tier the placement by access heat. Keep resident hot tokens in a faster memory tier and load cold tokens on demand.
    1. # Illustrative pseudocode: reordering the vocabulary by frequency (must stay in sync with the tokenizer)
    2. old_ids = build_frequency_ordered_ids(token_counts) # old token id -> new position after the frequency sort
    3. new_vocab = [old_vocab[i] for i in old_ids]
    4. save(tokenizer, new_vocab)
    5. reindex_dataset(tokenizer, old_ids) # remap all training and evaluation data
    6. assert decode(new_vocab, old_ids[123]) == "example token" # read-back check against mismatched mappings

    4.4 Mixed-precision quantization: do it after freezing

    Freezing first and then picking precision per module is the safest order:

    Module Suggested precision Reason
    Attention and feed-forward weights 3–4 bits They do the bulk of the multiply-accumulate work, so low bits pay off most
    Embedding table 8 bits to start, higher for high-frequency tokens Quantization noise directly alters every token’s representation
    Small layers such as normalization Keep higher precision Tiny parameter count, but sensitive to numerical stability
    Final softmax computation Higher precision Low-precision outputs can scramble the ordering of the probability distribution

    5. Rollout checklist and common pitfalls

    1. Quantify before you act. Use a parameter-counting script to confirm the vocabulary’s share, and to see how many extra trainable parameters and how much extra VRAM unfreezing would add.
    2. Stage freezing and quantization separately. Freeze first, complete domain adaptation, then quantize the adapted model and compress the embedding table, and re-evaluate afterwards.
    3. Prefer low-bit packed formats. If ternary values like -1/0/+1 are stored one full byte each, you get only about 2.7 bits per parameter of effective compression, nowhere near the theoretical ~1.58 bits. Only when multiple values are packed into a single byte does the size advantage of ternarization actually materialize.
    4. Build a before/after evaluation for freezing. At minimum, cover perplexity, downstream task metrics, time-to-first-token, decoding throughput and peak memory.
    5. Manage the vocabulary as a resource. After freezing, the embedding table is a read-only static asset that can be versioned and loaded on demand. For example, keep static resources like the embedding table under managed versioning in object storage, distribute the runtime environment through a container platform, and track load time, time-to-first-token and memory usage via logging and monitoring with alerting.

    Common pitfalls:

    • Assuming adapters “optimized” the vocabulary. Adapters don’t change the base model’s size; inference footprint is determined by quantization and compression.
    • Forgetting what gradient clipping covers. Whether the embedding layer takes part in clipping changes the global gradient norm, so the clipping threshold needs recalibration before and after unfreezing.
    • Tied weights silently defeating the freeze. When the embedding table and the output projection share a matrix, any attempt to “fine-tune” the output side changes the vocabulary at the same time.
    • Reordering the vocabulary without syncing the data pipeline. Different vocabulary mappings in training and inference produce garbage output.
    • Trimming the vocabulary while ignoring byte fallback. Inputs that cannot be encoded may raise an error or be silently replaced with an unknown token.

    Closing

    The center of gravity in small-model optimization is shifting from “make the matrix multiplications cheaper” to “freeze what should be frozen, and compress what should be compressed, precisely.” The vocabulary accounts for 60% of the size yet only does lookups. Freezing it buys the maximum stability for the minimum training cost; compressing it is the cut that actually takes weight off the model. Run the two together, and small models can be both fast and reliable on phones and laptops.