Scaling Laws with Vocabulary: Larger Models Deserve Larger Vocabularies

Chaofan Tao, Qian Liu, Longxu Dou, Niklas Muennighoff, Zhongwei Wan, Ping Luo, Min Lin, Ngai Wong

Abstract: Research on scaling large language models (LLMs) has primarily focused on model parameters and training data size, overlooking the role of vocabulary size. We investigate how vocabulary size impacts LLM scaling laws by training models ranging from 33M to 3B parameters on up to 500B characters with various vocabulary configurations. We propose three complementary approaches for predicting the compute-optimal vocabulary size: IsoFLOPs analysis, derivative estimation, and parametric fit of the loss function. Our approaches converge on the conclusion that the optimal vocabulary size depends on the compute budget, with larger models requiring larger vocabularies. Most LLMs, however, use insufficient vocabulary sizes. For example, we predict that the optimal vocabulary size of Llama2-70B should have been at least 216K, 7 times larger than its vocabulary of 32K. We validate our predictions empirically by training models with 3B parameters across different FLOPs budgets. Adopting our predicted optimal vocabulary size consistently improves downstream performance over commonly used vocabulary sizes.

Introduction: The Missing Dimension in Scaling Laws

While LLM scaling laws—such as the famous Chinchilla study—typically focus on model parameters and training data, this research demonstrates that vocabulary size is a critical, often-overlooked third dimension. By training over 1,000 model configurations, the authors prove that the compute-optimal vocabulary size follows a predictable power law: as models grow, their vocabularies must also expand to maintain efficiency.

Currently, vocabulary sizes are chosen somewhat arbitrarily. For example, Llama 2-7B uses a 32K vocabulary, while Gemma-7B uses a massive 256K vocabulary. This inconsistency suggests a lack of consensus on the "optimal" size. If a vocabulary is too small, the model wastes compute by chopping words into too many tiny pieces (low "tokenization fertility"). If it's too large, the model wastes parameters on rare tokens that it never sees enough of to learn properly. This paper seeks the mathematical "Goldilocks" zone for vocabulary scaling.

Methodology: Finding the Optimal Vocabulary

The authors investigate the relationship between compute, model size, and vocabulary using three distinct but converging approaches:

  1. IsoFLOPs Analysis: They trained groups of models (from 33M to 1.13B parameters) across different FLOP budgets. For each budget, they varied the vocabulary size to find the point that yielded the lowest loss.
  2. Derivative-based Estimation: They derived a mathematical formula for FLOPs that includes vocabulary parameters. By finding where the derivative of this function equals zero, they could analytically solve for the optimal vocabulary size ($V$).
  3. Parametric Fit of Loss Function: They modified the standard Chinchilla loss formula to include a specific term for vocabulary parameters ($N_v$). They then fitted this new formula to their experimental data to predict performance for models far larger than those they actually trained.

Crucially, to compare models with different vocabulary sizes fairly, they used a unigram-normalized loss ($L_u$). Standard cross-entropy loss is naturally higher for larger vocabularies (more options to choose from), so $L_u$ adjusts for this bias to provide a "vocabulary-insensitive" metric.

IsoFLOPs analysis showing unigram-normalized loss across different vocabulary sizes and FLOP budgets.

Models were pre-trained on the SlimPajama dataset (a 627B token cleaned version of RedPajama) and evaluated on a suite of standard zero-shot benchmarks, including ARC-Challenge, Hellaswag, OpenBookQA, Winogrande, PIQA, and BoolQ.

Key Insights: The Power Law of Vocabulary

The core finding of the paper is that the optimal vocabulary size ($N_v^{\text{opt}}$) scales with non-vocabulary parameters ($N_{\text{nv}}$) according to the relation $N_v^{\text{opt}} \propto (N_{\text{nv}})^{0.83}$. This means that while the vocabulary should grow as the model grows, it should grow slightly slower than the rest of the model.

Scaling law predicting optimal vocabulary size for Llama 2 models based on non-vocabulary parameters.
  • Current LLMs are "Vocab-Anemic": Most popular models use vocabularies that are far too small. As shown in the scaling projections, the authors predict that Llama 2-70B should have had a vocabulary of at least 216K (nearly 7x larger than its actual 32K) to be compute-optimal.
  • The Efficiency Trade-off: A larger vocabulary increases "tokenization fertility"—it represents the same text with fewer tokens. This allows the model to process more characters for the same number of training steps, effectively making it more data-efficient.
  • Lexicon Coverage vs. Training Frequency: The balance between coverage and learning is critical. A huge vocabulary covers more concepts but risks "under-fitting" rare tokens because the model doesn't see them often enough during training. The scaling law identifies the mathematical sweet spot for this trade-off.

Empirical Validation and Results

To validate their predictions, the authors trained a 3B parameter model. Using the predicted optimal vocabulary size of 43K instead of the standard 32K improved ARC-Challenge performance from 29.1 to 32.0 using the exact same compute budget (2.3e21 FLOPs).

Furthermore, all three methodological approaches (IsoFLOPs, Derivative, and Parametric) converged on nearly identical scaling coefficients ($\gamma \approx 0.83$ to $0.86$), lending high confidence to the results. Interestingly, the recently released Llama 3 moved to a 128K vocabulary. The authors' predictions align much more closely with Llama 3's configuration than Llama 2's, suggesting the industry is already moving toward these findings.

Limitations and Future Work

While comprehensive, the study has a few limitations:

  • Architecture Scope: The study focused exclusively on dense Transformer models. It remains unclear if these laws hold for Mixture-of-Experts (MoE) or non-Transformer architectures like Mamba.
  • Language Bias: Experiments were primarily conducted on English-centric data. Multilingual models likely require even larger vocabularies to account for diverse scripts and morphologies, which might alter the scaling exponent.
  • Parameter Cap: While the laws predict behavior for 70B+ models, the direct empirical training was capped at 3B parameters due to compute constraints.

Future research should explore how vocabulary scaling interacts with "over-training" (training models far past the Chinchilla-optimal point), a common practice for modern production LLMs. Ultimately, this work highlights the necessity of jointly considering tokenization and model scaling for efficient pre-training.

Summary updated

BibTeX
@inproceedings{tao2024scaling,
  author = {Chaofan Tao and Qian Liu and Longxu Dou and Niklas Muennighoff and Zhongwei Wan and Ping Luo and Min Lin and Ngai Wong},
  title = {{Scaling Laws with Vocabulary: Larger Models Deserve Larger Vocabularies}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=sKCKPr8cRL},
}
Figure