Abstract
Modern Large Language Models (LLMs) predominantly utilize Byte Pair Encoding (BPE) for tokenization. However, the iterative merging process of BPE often introduces "scaffold tokens"—infrequent subwords that primarily serve as intermediate steps to form longer, more frequent tokens. These scaffold tokens lead to a frequency imbalance in the vocabulary, hindering the model's ability to learn robust embeddings for rare units. We present Scaffold-BPE, a parameter-free enhancement that identifies these tokens during training and dynamically "demolishes" them back into their components during encoding. Our results demonstrate significant performance improvements across diverse LLM benchmarks and machine translation tasks without increasing model complexity.
Introduction: The Problem of Scaffold Tokens
Byte Pair Encoding (BPE) constructs a vocabulary by iteratively merging the most frequent adjacent pairs of tokens. While effective, this greedy approach often creates a structural flaw: the creation of "junk" or "scaffold" tokens.
Consider the word "Arizona." To reach this frequent token, BPE might first merge "zon" and "a" to create "zona," and then merge "Ari" and "zona" to produce "Arizona." If "zona" rarely appears outside of the context of "Arizona," it becomes a scaffold token. Because these tokens have low standalone frequency, the model cannot learn high-quality embeddings for them, wasting valuable vocabulary space and creating a learning bottleneck.
Methodology: Scaffolding and Demolishing
Scaffold-BPE introduces a two-stage modification to the standard BPE pipeline to handle these infrequent intermediate units. The authors use a "ladder" analogy: scaffold tokens are like rungs needed to reach the roof (the long, frequent word), but one should not be forced to stand on a single, flimsy rung in isolation.
1. Dynamic Scaffold Marking
During vocabulary construction, the algorithm monitors the frequency of every token. A token is marked as a Scaffold Token if its standalone frequency falls below the frequency of the current top pair in the priority queue. Unlike standard pruning, these tokens are not discarded; they are retained in an "expanded vocabulary" to facilitate the construction of even longer, more frequent tokens.
2. Scaffolding and Demolishing
The encoding process is split into two steps:
- Scaffolding: The tokenizer uses the expanded vocabulary to find the longest possible matches in the text, potentially utilizing scaffold tokens to reach longer "normal" tokens.
- Demolishing: If a scaffold token remains in the final sequence (i.e., it was not merged into a longer non-scaffold token), it is "demolished"—broken back down into its constituent non-scaffold subwords.
This ensures that the tokens actually processed by the LLM are always high-frequency, well-represented units, while maintaining the compression efficiency of BPE.
Experimental Setup and Results
The researchers evaluated Scaffold-BPE by training models ranging from 468M to 6.7B parameters on the Pile dataset (825 GiB). Scaffold-BPE consistently outperformed standard BPE across all tested scales and tasks:
- Reasoning and QA: On a 6.7B parameter model, Scaffold-BPE showed a 2.08 percentage point (pp) improvement on BoolQ and a 3.23pp improvement on TriviaQA compared to the original BPE.
- Information Efficiency: By removing rare tokens, the method increases the information entropy of the token distribution and reduces redundancy, ensuring each token carries a more potent learning signal.
- Efficiency and Compression: The "demolishing" step is highly optimized ($O(1)$ per token). Furthermore, Scaffold-BPE achieved a higher compression rate (bytes per token) than original BPE, representing the same text with fewer total tokens.
- Orthogonality: The method is compatible with other techniques like BPE-Dropout, providing additive gains when combined.
Conclusion
Scaffold-BPE offers a simple, automated, and parameter-free solution to the frequency imbalance inherent in standard BPE. By treating rare intermediate tokens as temporary scaffolds rather than permanent vocabulary members, it allows LLMs to focus their representational capacity on high-utility tokens. Future work may explore the method's effectiveness on morphologically rich languages and the impact of varying scaffold marking criteria.
Summary updated