Abstract
While scaling laws for large language models (LLMs) typically focus on parameter count and training data size, the role of vocabulary size ($V$) remains under-explored. This research demonstrates that the compute-optimal vocabulary size is not a constant but scales with the model size and training budget. By analyzing models ranging from 33M to 3B parameters, we establish a power-law relationship for vocabulary scaling. Our findings suggest that many state-of-the-art models, such as Llama 2, are significantly "under-vocabbed," and that optimizing vocabulary size can yield substantial performance gains on downstream tasks without increasing total compute.
Introduction
In the development of LLMs, the optimization of parameters ($N$) and data volume ($D$) has been formalized through scaling laws like those proposed by Chinchilla. However, the vocabulary size ($V$)—the discrete set of tokens the model processes—is frequently treated as a fixed hyperparameter, often set to 32K or 50K tokens regardless of model scale. This leads to significant inconsistencies in the field; for instance, Llama 2-7B and Gemma-7B share similar parameter counts but differ in vocabulary size by a factor of eight. This paper investigates the existence of a "compute-optimal" vocabulary size that balances tokenization efficiency with parameter allocation.
The Vocabulary Trade-off
Choosing a vocabulary size involves a fundamental trade-off between two competing forces:
- Tokenization Fertility: A larger vocabulary allows the model to represent a string of text with fewer tokens, thereby increasing the information density of each training step and improving efficiency.
- Training Efficiency: A larger vocabulary increases the number of parameters in the embedding and output layers. If the vocabulary is too large for the given data budget, rare tokens may not be sufficiently trained, leading to under-fitting and wasted compute.
Methodology
To identify the optimal $V$, the authors trained a diverse suite of models (33M to 3B parameters) on up to 500B characters from the SlimPajama dataset. To ensure fair comparison across different vocabulary sizes, they introduced the Unigram-normalized loss ($\mathcal{L}_u$). Standard cross-entropy loss is inherently biased toward smaller vocabularies because they have fewer possible outcomes to predict. $\mathcal{L}_u$ adjusts for this by measuring the model's improvement over a simple unigram baseline.
The study utilized three complementary approaches to predict the optimal vocabulary size:
- IsoFLOPs Analysis: Comparing models trained with the same total compute budget but varying vocabulary sizes to find the performance peak.
- Derivative-based Estimation: Calculating the theoretical minimum by taking the derivative of the FLOPs equation with respect to $V$.
- Parametric Fit: Extending the Chinchilla scaling laws with vocabulary-dependent terms and fitting the resulting function to experimental data.
Key Insights: The Power Law of Vocabulary
The research reveals that the optimal vocabulary size ($N_v^{opt}$) scales with non-vocabulary parameters ($N_{nv}$) according to a power law:
$$N_v^{opt} \propto (N_{nv})^\gamma$$
where $\gamma \approx 0.83$. This indicates that as models grow, the vocabulary should also grow, albeit at a slightly slower rate than the core model parameters.
A significant finding is that most contemporary LLMs utilize vocabularies that are far too small for their scale. For example, the analysis predicts that the optimal vocabulary size for Llama 2-70B should have been at least 216K—nearly seven times larger than its actual 32K vocabulary. Even with Llama 3's increase to 128K, the vocabulary may still be insufficient for its largest 400B+ parameter iterations.
Results and Validation
The theoretical predictions were validated through empirical testing on standard zero-shot benchmarks, including ARC-Challenge, Hellaswag, and MMLU. By increasing the vocabulary size of a 3B parameter model from the standard 32K to the predicted optimal of 43K (at a fixed FLOP budget), the researchers observed a significant improvement in downstream performance. Specifically, the ARC-Challenge score rose from 29.1 to 32.0. These gains were achieved without any increase in total compute, demonstrating that proper vocabulary scaling is a "free" performance boost.
Conclusion
This work highlights that vocabulary size is a critical dimension of model scaling that has been largely overlooked. By jointly optimizing tokenization and model architecture, researchers can achieve higher efficiency in pre-training. While this study focused on dense Transformers and English-centric data, the underlying principle—that larger models deserve larger vocabularies—provides a new roadmap for the next generation of efficient large-scale language modeling.
Summary updated