Lune

ICML2026Top-tier venue

Incremental BPE Tokenization

Shenghu Jiang, Ruihao Gong

2026Year
12Citations

Abstract

We propose a novel algorithm for incremental Byte Pair Encoding (BPE) tokenization. The algorithm processes each input byte in worst-case O(log 2 t) time, leading to an overall complexity of O(n log 2 t), where n is the input length and t is the maximum token length. The algorithm incrementally maintains BPE tokenization results for every prefix of the input text, implementing the standard BPE merge procedure defined by a fixed set of merge rules. This enables efficient partial tokenization in streaming settings. Functioning as a drop-in replacement for standard BPE, our approach achieves a speedup of up to ∼3× over Hugging Face's tokenizers, and demonstrates significant latency reductions over Ope-nAI's tiktoken on pathological inputs. We further introduce an eager output algorithm that enables streaming output, emitting tokens as soon as token boundaries are determined during incremental tokenization. Overall, our results demonstrate that BPE tokenization can be performed incrementally with strong worst-case guarantees, while providing practical latency benefits in modern large language model pipelines. The source code is available at https://github.com /ModelTC/mtc-inc-bpe.

Ask about this paper

Your agent reads all of it.

Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.

Questions to start from

Your agent calls

Luneget_paper_fulltext

Ask in Lune

Free to start. No credit card required.

lune papers fulltext 8afc9596-9e1e-492f-99eb-b49b248b619f

Related papers

Dusk over the sea between two cliffs drawn in fine vertical lines