Scaffold-BPE: Enhancing Byte Pair Encoding with Simple and Effective Scaffold Token Removal

Haoran Lian, Yizhe Xiong, Jianwei Niu, Shasha Mo, Zhenpeng Su, Zijia Lin, Peng Liu, Hui Chen, Guiguang Ding

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.

Relative frequency of tokens containing "ing" and "zona", illustrating how intermediate tokens like "zona" have significantly lower standalone frequency than the final words they build.

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:

  1. 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.
  2. 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.
  3. 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., zon and a).

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.

Performance comparison between Original BPE and Scaffold-BPE across various benchmarks and vocabulary sizes, showing consistent improvements.

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

Abstract

Byte Pair Encoding (BPE) serves as a foundation method for text tokenization in the Natural Language Processing (NLP) field. Despite its wide adoption, the original BPE algorithm harbors an inherent flaw: it inadvertently introduces a frequency imbalance for tokens in the text corpus. Since BPE iteratively merges the most frequent token pair in the text corpus while keeping all tokens that have been merged in the vocabulary, it unavoidably holds tokens that primarily represent subwords of complete words and appear infrequently on their own in the text corpus. We term such tokens as Scaffold Tokens. Due to their infrequent appearance in the text corpus, Scaffold Tokens pose a learning imbalance issue for language models. To address that issue, we propose Scaffold-BPE, which incorporates a dynamic scaffold token removal mechanism by parameter-free, computation-light, and easy-to-implement modifications to the original BPE. This novel approach ensures the exclusion of low-frequency Scaffold Tokens from the token representations for the given texts, thereby mitigating the issue of frequency imbalance and facilitating model training. On extensive experiments across language modeling tasks and machine translation tasks, Scaffold-BPE consistently outperforms the original BPE, well demonstrating its effectiveness and superiority.
BibTeX
@inproceedings{lian2025scaffold,
  author = {Haoran Lian and Yizhe Xiong and Jianwei Niu and Shasha Mo and Zhenpeng Su and Zijia Lin and Peng Liu and Hui Chen and Guiguang Ding},
  title = {{Scaffold-BPE: Enhancing Byte Pair Encoding with Simple and Effective Scaffold Token Removal}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i23.34633},
}
Figure