Vocabulary Slimming for Small Language Models: Trade-offs and Practice of Freezing the Embedding Layer

    This article explains why the vocabulary embedding matrix can take a large share of the parameters in small language models, and when freezing it helps during fine-tuning. It compares freezing strategies from full freezing to low-rank adapters, shows how to estimate the parameter share before deciding, and covers implementation details and an evaluation checklist.

    1. Background: Parameter Budgets Matter More Once Small Models Are “Good Enough”

    Small language models with under one billion parameters are becoming practical. For everyday tasks such as text classification, information extraction, summarization and rewriting, question answering and retrieval, and lightweight dialogue, a well-tuned small model can cover many scenarios. But “good enough” does not mean “free of cost.” When the total parameter count shrinks, the vocabulary embedding matrix takes up a noticeably larger share of the model.

    Let (V) be the vocabulary size and (d) the hidden dimension. The input embedding has about (V \times d) parameters. If the input embedding and the output projection share weights, the vocabulary-related parameters total about (V \times d). If they do not share weights, the total is close to (2 \times V \times d). For example, with (V=50000) and (d=512), one embedding matrix holds about 25.6 million parameters. If the model has 100 million parameters in total, a single embedding matrix already accounts for about a quarter of them, and the share is higher without weight sharing. With a larger vocabulary, a smaller hidden dimension, and fewer total parameters, vocabulary-related parameters can approach 60% of the model. This is not unusual.

    This is the technical meaning of “the vocabulary eats a small model’s body weight.” The problem is not necessarily that the middle layers are too weak. The vocabulary matrix uses much of the parameter budget. Freezing the vocabulary layers is therefore an attractive option. During training, the embedding matrix is no longer updated, so the limited trainable capacity goes to the middle layers and task heads.

    One common misconception needs to be clarified first: freezing the vocabulary does not reduce the model file size at inference time. The embedding matrix still has to be stored and loaded. Freezing mainly affects training. It reduces trainable parameters, optimizer state, gradient computation, and gradient synchronization. If the goal is a smaller deployed footprint, you also need vocabulary pruning, quantization, sparse storage, or sharded loading.

    2. Why Freezing the Vocabulary Can Work

    First, vocabulary embeddings encode general token-level representations. After large-scale pretraining, the embedding matrix usually has learned a stable semantic space. When downstream data is limited, continuing to update the full vocabulary can push the representations of high-frequency tokens off course with task data, which interferes with general capabilities. Freezing the vocabulary acts as a regularization constraint on these low-level representations. It directs more of the training signal to the middle layers and task-specific modules.

    Second, freezing significantly lowers training cost. Optimizers typically keep state for every trainable parameter. The vocabulary matrix is large, so freezing it reduces both the trainable parameters and the optimizer state. In distributed training, vocabulary gradients are often a major part of the communication volume, and freezing them reduces gradient synchronization pressure. For fine-tuning small models with limited resources, this benefit is direct.

    Third, freezing helps stability in small-data settings. A small model has limited capacity. If the downstream dataset is small and the domain shift is modest, fully fine-tuning the vocabulary can cause overfitting and catastrophic forgetting. Freezing the vocabulary lets the model still adapt to the task through the upper layers while preserving the general semantics of the pretrained vocabulary.

    However, freezing is not always the best default. If the downstream task includes many domain-specific terms, new words, or multilingual fragments, or if the tokenizer covers the target domain poorly, freezing the vocabulary limits the model’s ability to learn representations for new tokens. In that case, it is more reasonable to use partial freezing, layer-wise learning rates, low-rank adapters, or first improve the vocabulary and tokenizer.

    3. Do the Math First: Decide Whether Freezing Is Worth It

    Before deciding to freeze, quantify the share of vocabulary-related parameters. You can estimate it with the following pseudocode:

    1. def vocab_param_ratio(total_params, vocab_size, hidden_dim, shared_embedding):
    2. vocab_params = vocab_size * hidden_dim
    3. if not shared_embedding:
    4. vocab_params = vocab_params * 2
    5. return vocab_params / total_params

    As a rule of thumb, if vocabulary-related parameters make up a large share, the downstream dataset is limited, and the domain shift is small, freezing is worth trying first. If the share is low, freezing saves little and may restrict adaptation. If the domain has many new words, or the share of out-of-vocabulary tokens after tokenization is high, consider expanding the vocabulary or re-tokenizing instead of simply freezing.

    You also need to distinguish the input embedding from the output projection. If the two share weights, freezing the vocabulary locks both the input representations and the output token distribution. If they do not share weights, you can freeze only the input embedding and keep the output projection trainable, or the reverse. For generation tasks, freezing the output projection may limit the model’s ability to adjust the distribution over specific words. For classification tasks, the task head is usually newly initialized and should remain trainable.

    4. A Spectrum of Freezing Strategies: Not Just “Freeze All” or “Freeze None”

    In practice, several compromise strategies are available:

    1. Full freezing of the vocabulary layers: Freeze the input embedding and the shared output projection, and train the remaining parameters. This suits small datasets, small domain shifts, and a high vocabulary parameter share. Its advantages are simplicity, stability, and lower resource use. Its drawback is weak adaptation to new and domain-specific words.

    2. Freezing only low-frequency tokens: Build a mask based on token frequency or domain coverage. Freeze high-frequency general tokens, and keep low-frequency or new tokens trainable. This preserves general semantics while leaving room for domain terms to update. In practice, you can mask the gradients or split the vocabulary parameters into trainable and frozen groups.

    3. Layer-wise learning rates: Instead of freezing the vocabulary completely, assign the vocabulary layers a learning rate much smaller than that of the middle layers. This is smoother than hard freezing and suits medium-sized datasets with some domain shift. However, it saves less optimizer state and gradient communication than full freezing.

    4. Frozen original matrix with a low-rank bypass: Keep the original embedding matrix unchanged and add a small trainable projection or bottleneck layer alongside it. Task signals then flow through the low-rank path. This balances parameter efficiency and adaptation capacity, but it adds implementation complexity.

    5. Vocabulary pruning and re-tokenization: Reduce (V) at the source. Use domain corpus statistics to prune extremely rare tokens, or train a subword vocabulary that fits the target domain better. After pruning, you must update the embedding matrix and output projection to match, and evaluate the out-of-vocabulary rate and downstream performance.

    6. Hybrid strategies: Freeze the vocabulary and add lightweight adaptation modules, or freeze most layers and unfreeze only the top layers and the task head. This suits settings with tight training resources that still need domain adaptation.

    5. Implementation Essentials and Pseudocode

    When freezing, the key is to keep the tokenizer, embedding matrix, and output projection consistent. If you add new tokens, you must initialize their embeddings and make sure they are trainable. Otherwise, the new words never get useful representations. The following pseudocode shows the logic only:

    1. def freeze_vocab_layers(model):
    2. for p in model.input_embedding.parameters():
    3. p.requires_grad = False
    4. if not model.share_embedding:
    5. for p in model.output_projection.parameters():
    6. p.requires_grad = False
    7. def build_optimizer_params(model):
    8. return [p for p in model.parameters() if p.requires_grad]

    For partial freezing, you can build a mask based on token frequency:

    1. def apply_freq_mask(embedding_weight, token_freq, min_freq):
    2. mask = token_freq >= min_freq
    3. # Pseudocode: freeze the rows corresponding to low-frequency tokens
    4. for token_id in range(len(mask)):
    5. if not mask[token_id]:
    6. embedding_weight[token_id].requires_grad = False

    There are several engineering points to watch. Frozen parameters do not take part in optimizer updates, but the forward pass still needs them. In distributed training, confirm that frozen parameters are excluded from the gradient synchronization group. Under mixed-precision training, frozen parameters must still take part in the forward pass correctly. Checkpoint saving must not omit frozen parameters. If you use parameter groups, print the trainable and total parameter counts explicitly so you do not assume a layer is frozen when it is not.

    6. Training and Evaluation Checklist

    After freezing the vocabulary, do not look only at training loss. Run small-scale ablations: full fine-tuning, full freezing, partial freezing, and layer-wise learning rates. Then compare validation metrics, out-of-vocabulary hit rate, recall of domain terms, shifts in the word distribution for generation tasks, and training memory and throughput. If validation metrics drop noticeably after freezing, check whether the domain terms are poorly covered or whether the output projection has been locked.

    For monitoring, you can track the gradient norm of the vocabulary layers (when partially frozen), the degree of embedding drift, the update ratio of low-frequency tokens, and the convergence speed of the task head. When data is limited, freezing usually provides a regularization benefit. When data is plentiful and the domain shift is large, unfreezing the vocabulary or using partial freezing is more appropriate. Base the final choice on reproducible ablation results, not on the intuition that freezing is always cheaper or that full fine-tuning is always better.

    7. Conclusion

    In small models, the vocabulary embedding takes up a high share of parameters, which is one of the core tensions in the parameter budget. Freezing the vocabulary reduces trainable parameters, optimizer state, and gradient synchronization overhead, and it provides regularization in small-data settings. However, it does not shrink the model at inference time, and it can weaken adaptation to new domain words. A safer approach is to first estimate the vocabulary share and the out-of-vocabulary rate. Then compare full freezing, partial freezing, layer-wise learning rates, and vocabulary engineering in small-scale ablations. For small models, freezing the vocabulary is not a universal switch. It is a parameter-budget tool that needs quantitative validation.