Small Language Models: Vocabulary Embeddings Can Consume 60% of Parameters—Is Freezing Viable?

    Small language models under one billion parameters are attractive for on-device deployment and low-cost inference, but their vocabulary embeddings can dominate parameter counts. This article breaks down parameter composition, estimates embedding ratios with a simple function, and examines vocabulary-size trade-offs. It then explains what freezing the embedding layer does and does not save, when freezing is appropriate or risky, and how to use token coverage statistics and controlled experiments to decide. It closes with practical engineering recommendations and limitations, including weight sharing, training versus inference optimization, rollback planning, and documentation of vocabulary versions.

    1. Background: Why Small Models Should Care About Vocabulary

    Small models under one billion parameters can already handle everyday tasks such as text classification, information extraction, simple question answering, and code completion. Demand for on-device deployment and low-cost inference has made these models increasingly relevant to developers.

    As model size shrinks, the share of parameters held by different components changes. In large models, Transformer layers usually dominate the parameter count. In small models, vocabulary-related embedding parameters can account for more than half of the total, directly affecting memory usage, training speed, and optimization strategy.

    Understanding the parameter composition of small models is therefore a prerequisite for model pruning, training configuration, and deployment decisions.

    2. Breaking Down Parameter Composition

    A typical language model mainly contains three parameter groups:

    1. Input embedding layer (Embedding): Maps each token in the vocabulary to a vector of length d. The parameter count is V × d, where V is the vocabulary size and d is the hidden dimension.
    2. Output projection layer (LM Head): Maps hidden states back to the vocabulary dimension. Its parameter count is also V × d. When the input embedding and output projection share weights, this part does not add extra parameters.
    3. Transformer blocks: Each layer contains attention and a feed-forward network. Using a common standard-structure estimate with a feed-forward expansion factor of 4, a single layer has about 12 × d² parameters. With L layers, the total is about 12 × L × d². This estimate ignores normalization layers and bias terms, so it is suitable for order-of-magnitude judgments.

    The following function quickly estimates the embedding ratio under different configurations:

    1. def estimate_params(vocab_size, hidden_dim, num_layers, tied_embedding=True):
    2. embed = vocab_size * hidden_dim
    3. head = 0 if tied_embedding else vocab_size * hidden_dim
    4. blocks = num_layers * 12 * hidden_dim ** 2
    5. total = embed + head + blocks
    6. return {
    7. "embedding_ratio": (embed + head) / total,
    8. "total_params": total,
    9. }
    10. # Example: vocabulary size 64000, hidden dimension 512, 12 layers
    11. print(estimate_params(64000, 512, 12, tied_embedding=True))
    12. print(estimate_params(64000, 512, 12, tied_embedding=False))

    With the configuration above:

    • Embedding parameters: 64000 × 512 ≈ 32.8M.
    • Transformer block parameters: 12 × 12 × 512² ≈ 37.7M.
    • When input embeddings and output projection share weights, the embedding ratio is about 46%, and the total parameter count is about 70.5M.
    • When the output projection is independent, embedding-related parameters are about 65.5M, the total is about 103.3M, and the ratio rises to about 63%.

    This shows that vocabulary-related parameters taking around 60% of a small model is not unusual. The key variable is the ratio between vocabulary size and hidden dimension. A smaller hidden dimension and a larger vocabulary lead to a higher embedding share.

    3. Trade-offs in Vocabulary Size

    Vocabulary size determines how text is split into tokens. A larger vocabulary means fewer tokens for the same text, shorter sequence lengths during inference, and lower compute overhead. This is the main benefit of increasing vocabulary size.

    The costs are also clear:

    1. Embedding parameters grow linearly with V, and small models are especially sensitive to this overhead.
    2. Low-frequency token vectors receive very few training samples, so their representations are often poor.
    3. In multilingual scenarios, covering common characters and subword fragments across languages requires a larger vocabulary, which amplifies the problem.

    Vocabulary design is therefore essentially a trade-off between compression rate and parameter count. In engineering practice, decisions should be based on the actual distribution of the target corpus rather than applying a generic configuration directly.

    4. The Idea of Freezing the Embedding Layer

    Freezing the embedding layer means not updating the embedding matrix parameters during training or fine-tuning, and training only the Transformer blocks and other remaining parts. Its core benefit is reducing the extra memory overhead caused by trainable parameters.

    It is important to clarify that freezing does not reduce the storage footprint of model weights, because the full embedding matrix is still needed during inference. Its benefits are mainly at the training stage:

    • No gradients need to be saved for embedding parameters.
    • The optimizer does not need to maintain momentum and other states for embedding parameters.

    For example, in common mixed-precision training with an adaptive optimizer, each trainable parameter usually requires additional storage for a gradient and two optimizer states, totaling about 12 bytes in fp32 terms. For 32.8M embedding parameters, freezing can save about 393 MB of training memory. The actual savings depend on the precision strategy and optimizer implementation, so measurements are required.

    An example configuration for freezing is shown below:

    1. # Pseudocode: freeze input embeddings and train only the remaining parameters
    2. for name, param in model.named_parameters():
    3. if name.startswith("embed_tokens"):
    4. param.requires_grad = False
    5. trainable = [p for p in model.parameters() if p.requires_grad]
    6. optimizer = build_optimizer(trainable, lr=3e-4)

    Note that a frozen embedding layer retains the representation space from pretraining. If the target task differs significantly from the pretraining corpus in language distribution, domain terminology, or character set, freezing will limit the model’s ability to represent new tokens.

    5. When Freezing Applies and What Risks to Watch

    Freezing the embedding layer is usually suitable when:

    1. The target task is highly consistent with the language and domain of the pretraining corpus.
    2. Training resources are tight, and fine-tuning must be completed within limited memory.
    3. The fine-tuning dataset is small, and too many trainable parameters can easily lead to overfitting.

    Caution is needed when:

    1. The target domain contains many professional terms that are missing from the pretraining vocabulary or split into very small fragments.
    2. The model needs to support a new language or character set.
    3. The task is sensitive to word-level semantics, such as fine-grained entity recognition.

    A compromise is partial freezing: keep high-frequency token vectors fixed and train only the vectors of newly added tokens or low-frequency tokens. This requires careful grouping based on data statistics. Implementation costs are higher than full freezing, but it can achieve a better balance between savings and flexibility.

    6. Let Data Decide the Vocabulary

    Before making any pruning or freezing decision, first collect statistics on the token distribution of the target corpus. The core metric is top-k coverage: when the k most frequent tokens are kept, what proportion of token instances in the corpus is covered?

    1. from collections import Counter
    2. def topk_coverage(token_ids, keep_size):
    3. counts = Counter(token_ids)
    4. kept = sum(c for _, c in counts.most_common(keep_size))
    5. return kept / sum(counts.values())
    6. # Example: calculate coverage when keeping the top 8,000 and 16,000 tokens
    7. # coverage_8k = topk_coverage(corpus_token_ids, 8000)
    8. # coverage_16k = topk_coverage(corpus_token_ids, 16000)

    If keeping the top 8,000 tokens covers the vast majority of instances, vocabulary pruning usually brings substantial benefits. After pruning, embedding parameters decrease, and the model can run in less memory. The specific coverage threshold must be determined together with task quality metrics; there is no universal fixed value.

    7. Designing Evaluation Experiments

    The effects of freezing or pruning must be verified through controlled experiments. The following principles are recommended:

    1. Control variables: Keep training data, steps, learning rate schedule, and random seeds consistent, and change only how the embedding layer is handled.
    2. Record both quality and cost: Validation loss, downstream task accuracy, training throughput, and peak memory should all be recorded.
    3. Run ablations: Test full training, full freezing, and partial freezing separately, and observe whether quality differences exceed an acceptable range.
    4. Pay attention to long-tail samples: Measure error rates separately for low-frequency tokens and domain terms so that overall metrics do not hide localized degradation.

    Conclusions should be judged against business goals. If quality degradation is within the error range while memory and training time improve clearly, the freezing approach has engineering value. If key task metrics drop significantly, preserving the trainability of the embedding layer should take priority.

    8. Practical Engineering Recommendations

    1. Measure first, then decide: Use the target corpus to calculate coverage before deciding whether to prune the vocabulary.
    2. Share input and output weights: In small models with large vocabularies, weight sharing can directly reduce embedding-related parameters by half, provided that model quality remains acceptable.
    3. Separate training and inference optimization: During training, freezing embeddings can save memory. During inference, low-bit quantization of the embedding matrix can further compress storage.
    4. Keep a rollback path: Pruned or frozen models should be evaluated in parallel with the original version so that switching back is fast if problems arise.
    5. Document vocabulary versions: The construction data, version number, and coverage metrics of the vocabulary should be recorded together with the model version for reproducibility and troubleshooting.

    9. Limitations and Next Steps

    The parameter estimates in this article are based on approximate formulas for a standard structure. Actual models differ in normalization layers, bias terms, attention variants, and feed-forward expansion factors, so the numbers will vary. The memory savings discussed here are also theoretical magnitudes and should be confirmed by measurements in the actual training framework and hardware environment.

    In addition, embedding quality is highly dependent on pretraining data. Freezing cannot fix an embedding matrix that already has poor representations. When resources are sufficient, letting the embedding layer participate in training or performing targeted vocabulary expansion on the target corpus usually yields more stable results.

    Overall, the bottleneck of small models is often not the Transformer layers but the overlooked vocabulary. Understanding parameter composition, measuring coverage with data, and validating freezing benefits through controlled experiments are the basic path to reliable engineering decisions under limited resources.