Small Models Have Heavy Vocabularies: Is Freezing the Embedding Layer Viable?
This article explains why the vocabulary matrix can make up most of a small language model's parameters, and what freezing it does and does not achieve for training and on-device deployment. It covers parameter budgets, the difference between freezing and compressing, a freezing workflow, and compression options including quantization, low-rank factorization, vocabulary pruning, hashed embeddings, and tokenization changes.
In on-device deployment of small models, a common oversight is that parameter count does not equal effective compute. Take a model with about 270 million parameters. Its feed-forward layers, which do most of the computation, may hold only about 71 million parameters. Attention, normalization, and other compute layers together hold tens of millions more. The vocabulary matrix, shared by the input embedding and the output projection, can reach about 168 million parameters, more than 60% of the total. The model looks small, but a large part of its size is a static lookup table. The weights that transform features layer by layer are fewer than they appear.
This raises a practical question: can the vocabulary be frozen? Does freezing make training cheaper and the model smaller, or does it only reduce gradient computation? To answer this, we need to separate the parameter structure, training cost, and inference cost of the vocabulary.
1. Mismatched Parameter Budget: Light Compute Layers, Heavy Vocabulary
A language model usually contains an embedding table that maps discrete tokens to continuous vectors. With vocabulary size V and hidden dimension d, the embedding matrix has roughly V×d parameters. Many models tie the input embedding and output projection weights to reduce the total parameter count. Sharing weights avoids storing the matrix twice, but it does not make the matrix smaller.
Take a model with a hidden dimension of 768 and a vocabulary of about 218,000 tokens. Its embedding matrix has about 218,000 × 768 ≈ 167 million parameters. If the total is about 270 million, the vocabulary accounts for more than 60% of the parameters. Vocabularies tend to be large because they cover multiple languages, code, punctuation, numbers, subword fragments, and long-tail symbols. A finer tokenizer with broader coverage increases V. A higher hidden dimension increases d. Multiplied together, they can easily form a large block in the parameter budget.
More importantly, the embedding table and the output layer cost different amounts at inference. Input embedding is a lookup: each token reads only one row, so the compute is small. If the output projection is tied to the embedding, however, each generated token still requires a V×d linear projection to compute logits. The larger the vocabulary, the heavier the compute and memory bandwidth load on the output layer. On edge devices, disk size, weight loading at cold start, peak memory, and the memory bandwidth needed per token are all affected. The vocabulary is therefore more than a training parameter cost. It is also a static burden on the deployment path.
2. Freezing the Vocabulary Does Not Compress It
Freezing usually means setting requires_grad to false for the parameters, so training no longer computes gradients or updates them. The direct benefit is lower training cost. With the embedding table frozen, no gradients are stored for those parameters, and no optimizer state is maintained for them. In small-data fine-tuning or task adaptation, freezing also reduces drift in the embedding space and concentrates the limited updates on task-related layers.
Freezing does not automatically reduce the inference file size or the cost of the output matrix multiplication. An embedding table with 168 million parameters still has 168 million parameters after freezing. To make an edge model smaller, you also need compression methods such as quantization, low-rank factorization, vocabulary pruning, hashed sharing, or changes to the tokenization strategy.
Whether the input and output weights are tied is another decision point. If they are tied, freezing the input embedding usually means freezing the output projection too. If they are untied, evaluate each one separately. The output layer strongly affects classification, generation, and domain adaptation. Freezing it without checking can make it hard to adjust the probability distribution over new domain tokens. A safer approach is to measure vocabulary coverage first, freeze the shared vocabulary, and train the task layers. If validation metrics drop noticeably, unfreeze the output layer in the later stage of training, or add a small low-rank adaptation matrix instead of unfreezing everything.
3. Freezing Strategy and Training Recipe
A practical workflow starts by measuring how well the existing vocabulary covers the training data. Check the share of long-tail tokens, technical terms, and multilingual fragments. Next, freeze the input embedding and the shared output projection, and set up the optimizer by parameter group. During training, monitor task metrics, perplexity, and the output distribution. Finally, based on the results, decide whether to unfreeze some layers or add lightweight adaptation modules.
The following framework-agnostic pseudocode only illustrates parameter freezing and counting logic:
def freeze_vocab(model, tie_input_output=True):for p in model.input_embedding.parameters():p.requires_grad = Falseif tie_input_output:for p in model.output_projection.parameters():p.requires_grad = Falsedef build_param_groups(model, base_lr):trainable = [p for p in model.parameters() if p.requires_grad]frozen = [p for p in model.parameters() if not p.requires_grad]return [{"params": trainable, "lr": base_lr}], frozendef report(model):total = sum(p.numel() for p in model.parameters())train = sum(p.numel() for p in model.parameters() if p.requires_grad)emb = sum(p.numel() for p in model.input_embedding.parameters())print("total=", total,"trainable=", train,"train_ratio=", round(train / total, 4),"embedding=", emb,"emb_ratio=", round(emb / total, 4))
With the vocabulary frozen, the learning rate for the task layers can stay near the normal value, but it should not be too large. If you unfreeze the output layer, use a smaller learning rate and apply gradient clipping. With very little data, freezing the embedding helps stabilize training. When the data distribution differs sharply from pretraining, freezing may limit the model’s ability to learn new word meanings. In that case, use adapters, a domain vocabulary extension, or post-hoc calibration to compensate.
4. Meaningful Size Reduction Requires Several Techniques Combined
If the goal is a smaller model and lower latency on edge devices, treat freezing as a training optimization and compression as a deployment optimization. Use both together.
First, quantization. Quantizing the embedding table to 8-bit, 4-bit, or lower bit widths, using group-wise schemes, can reduce file size and memory bandwidth. Embedding lookups are sensitive to precision, so calibrate per channel or per group, and check long-tail tokens and the output distribution closely. Extremely low-bit methods such as ternary quantization suit weight compression in general, but quality loss must be verified for each model.
Second, low-rank factorization. Approximate the V×d embedding matrix with two smaller matrices, V×r and r×d. When r is much smaller than d, the parameter count drops. The cost is an extra small matrix multiplication after each lookup. The reduced rank may also limit the model’s capacity to represent long-tail meanings.
Third, vocabulary pruning. Keep high-frequency tokens, and map very rare tokens to an unknown token or fall back to smaller subword units. This directly reduces V. Pruning can hurt multilingual text, code, technical terms, and long-tail symbols, so measure coverage and fallback rates on real business corpora.
Fourth, hashed embeddings and shared buckets. Hashing maps multiple tokens to fewer vector buckets. This compresses the parameters but introduces collisions. It suits scenarios where precision on long-tail tokens matters less.
Fifth, tokenization changes. A smaller subword vocabulary or a byte-level scheme can reduce V. However, sequences may become longer, which raises the per-layer compute cost. Compare the vocabulary savings against the extra compute from longer sequences.
5. On-Device Deployment Checklist
When deploying, do not look only at the total parameter count. Check the following together: the size of the model file and the embedding table, cold-start loading time, peak memory, memory bandwidth needed per token, output projection latency, vocabulary coverage and fallback rate, quality of long-tail tokens after quantization, task metrics and generation stability, and a rollback plan. Freezing the vocabulary can be one of the default options during fine-tuning. Whether it actually makes the model smaller, however, should be decided by compression and deployment metrics.
In short, a high vocabulary share in small models is a structural result of vocabulary size multiplied by hidden dimension. Freezing the vocabulary lowers training cost and stabilizes small-data fine-tuning, but it does not shrink the inference footprint on its own. For edge-friendly models, combine freezing, quantization, low-rank factorization, pruning, and tokenization strategy in one evaluation framework. Weigh them using real business corpora and on-device metrics.
