Getting the most out of your tokenizer for pre-training and domain adaptation

Gautier Dagan, Gabriele Synnaeve, Baptiste Rozière
2/12/2026

No official code found. Best implementation: gautierdag/tokenizer-bench (22 stars, MIT, last commit 2024-02-14).

Abstract

Tokenization is an understudied and often neglected component of modern LLMs. Most published works use a single tokenizer for all experiments, often borrowed from another model, without performing ablations or analysis to optimize tokenization. Moreover, the tokenizer is generally kept unchanged when fine-tuning a base model. In this paper, we show that the size, pre-tokenization regular expression, and training data of a tokenizer can significantly impact the model's generation speed, effective context size, memory usage, and downstream performance. We train specialized Byte-Pair Encoding code tokenizers, and conduct extensive ablations on the impact of tokenizer design on the performance of LLMs for code generation tasks such as HumanEval and MBPP, and provide recommendations for tokenizer hyper-parameters selection and switching the tokenizer in a pre-trained LLM. We perform our experiments on models trained from scratch and from pre-trained models, verifying their applicability to a wide range of use-cases. We find that when fine-tuning on more than 50 billion tokens, we can specialize the tokenizer of a pre-trained LLM to obtain large gains in generation speed and effective context size.

View on arXivView PDF

Code Implementations(1)

MIT

Code for the paper "Getting the most out of your tokenizer for pre-training and domain adaptation"

221Python, Jupyter NotebookFeb 14, 20242 years agoMIT

Similar Papers

Cite this paper

@article{dagan2026getting,
  title  = {Getting the most out of your tokenizer for pre-training and domain adaptation},
  author = {Gautier Dagan and Gabriele Synnaeve and Baptiste Rozière},
  year   = {2026},
  eprint = {2402.01035},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2402.01035},
  journal = {ICML 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.01035.svg)](https://codeofpaper.com/paper/2402.01035)

Discussion