Abstract
Byte Pair Encoding (BPE) is the standard subword tokenization method for modern Large Language Models (LLMs). However, BPE's greedy merging process often creates "Scaffold Tokens"—low-frequency intermediate subwords that exist primarily to build longer tokens but rarely appear independently. These tokens lead to a learning imbalance and inefficient vocabulary usage. We present Scaffold-BPE, a simple, parameter-free modification that dynamically identifies and "demolishes" these scaffolds back into high-frequency components during encoding. Our results demonstrate that Scaffold-BPE achieves more balanced token distributions and significant performance improvements across various LLM benchmarks and machine translation tasks.
Introduction
Most modern LLMs, such as LLaMA or GPT-4, rely on BPE to convert raw text into tokens. BPE iteratively merges the most frequent pairs of characters or bytes. A significant flaw in this greedy process is the creation of "Scaffold Tokens." For example, to create the frequent token Arizona, BPE might first merge zon + a to get zona, and then Ari + zona to get Arizona. While Arizona is frequent, the intermediate token zona may rarely appear in other contexts.
These "zombie" tokens occupy vocabulary space but have extremely low frequencies, making them difficult for neural networks to learn effectively. This inefficiency hampers model performance and wastes computational resources by populating the embedding layer with poorly-learned parameters.
Methods
Scaffold-BPE introduces a two-phase approach to manage vocabulary more effectively without adding significant computational overhead:
- Training (Dynamic Marking): During vocabulary generation, the algorithm tracks the frequency of every token. If a token’s standalone frequency drops below a certain threshold (specifically, if it's less frequent than the next candidate pair to be merged), it is marked as a Scaffold Token.
- Encoding (Scaffolding & Demolishing):
- Scaffolding: The tokenizer first uses the full expanded vocabulary (including scaffolds) to greedily represent the text, allowing it to identify long, frequent tokens like
Arizona.
- Scaffolding: The tokenizer first uses the full expanded vocabulary (including scaffolds) to greedily represent the text, allowing it to identify long, frequent tokens like
- Demolishing: If any Scaffold Tokens (like
zona) remain in the final sequence because they could not be merged into a longer "normal" token, they are "demolished" back into their shortest non-scaffold components (e.g.,zonanda).
This ensures that the final sequence fed into the LLM contains only high-frequency, well-learned tokens.
Experimental Setup
The authors validated Scaffold-BPE using a diverse set of benchmarks and datasets:
- Training Data: The Pile (800GB+ diverse English text).
- LLM Benchmarks: Seven common-sense reasoning tasks (including BoolQ, HellaSwag, and WinoGrande) and two closed-book QA tasks (TriviaQA and WebQuestions).
- Machine Translation: WMT’14 English-German (En-De) and English-French (En-Fr) datasets.
- Model Scales: Testing ranged from 468M to 6.7B parameter models.
Analysis and Key Insights
Scaffold-BPE improves vocabulary efficiency by replacing "junk" tokens with useful, high-frequency ones. In a 32K vocabulary, approximately 6.07% of tokens were identified as scaffolds. Removing these leads to a more uniform embedding distribution and higher Shannon Entropy in token representations, indicating increased information density. Furthermore, the method is orthogonal to other BPE enhancements like BPE-Dropout, meaning they can be combined for additive gains.
Key Results
Scaffold-BPE consistently outperformed standard BPE across all model sizes and vocabulary configurations. For a 6.7B parameter model, Scaffold-BPE showed a 2.08% improvement on BoolQ and a 2.90% boost on OpenBookQA.
Beyond reasoning tasks, the method achieved higher BLEU scores in machine translation, proving its utility beyond English-centric contexts. Surprisingly, despite "demolishing" some tokens, Scaffold-BPE achieved a higher compression rate (bytes per token) because it allowed the vocabulary to include more useful, longer "normal" tokens that were previously crowded out by scaffolds.
Conclusion and Future Work
Scaffold-BPE offers a simple yet effective way to optimize subword tokenization for LLMs. While the method is parameter-free, future work could explore alternative marking strategies for scaffolds. Although encoding overhead is minimal, it may be a consideration for ultra-high-throughput systems. Additionally, further study on highly agglutinative languages is needed to fully understand the impact of scaffold removal in diverse linguistic structures where subword patterns are more complex.
Summary updated