Research map / Large language models / Instruction and fine-tuning
Getting the most out of your tokenizer for pre-training and domain adaptation
Read the paperCheck your idea against 108,967 papers
AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.
Studies how BPE tokenizer size, pre-tokenization regex, and training data affect code LLM compression and downstream code generation, and tests switching tokenizers during fine-tuning of pre-trained LLMs.
Problem
Tokenizer design (vocabulary size, pre-tokenization regex, training data) is usually fixed by borrowing and rarely optimized, and pre-trained LLMs keep their original tokenizer during domain fine-tuning even when it is sub-optimal for the domain, hurting inference efficiency and effective context le
Approach
Systematically ablates BPE tokenizer hyper-parameters for code, derives inference- and memory-optimal vocabulary size formulas, and shows that a pre-trained code LLM can switch to a more compressive tokenizer during fine-tuning (with FVT embedding initialization) given enough tokens (>=50B) without losing downstream performance.
Key results
- Changing the tokenizer of a pre-trained 7B Llama 2 model to GPT-4 80k tokenizer for 500B tokens gives HumanEval Pass@1 of 30.8 vs 32.1 for Code Llama, with comparable MBPP performance.
- GPT-4 style regex tokenizer at 32k compresses code by about 19% relative to the Llama tokenizer (NSL 0.81 on code), with Identity tokenizer achieving up to 0.59 NSL on code at 100k.
- Fine-tuning with a switched tokenizer recovers performance after about 50B tokens; with only 5B tokens a large gap to the Llama tokenizer remains.
Measured effects reported in the paper
| What was changed | Where | Measured | Effect |
|---|---|---|---|
| Switch a Llama 2 7B model to the GPT-4 80k tokenizer | Llama 2 7B · HumanEval | Pass@1: 32.05792683 -> 30.82317073 | Hurt |
| Switch a Llama 2 7B model to the GPT-4 80k tokenizer | Llama 2 7B · MBPP | Pass@1: 41.926 -> 42.594 | Helped |
| Change tokenizer vocabulary size from 32k to 64k (ablation) | GPT-4 tokenizer on model 1.5B · HumanEval | Pass@1: 20.54268293 -> 20.625 | No clear effect |
| Change tokenizer vocabulary size from 32k to 128k (ablation) | GPT-4 tokenizer on model 1.5B · MBPP | Pass@1: 27.245 -> 27.459 | No clear effect |
| Remove FVT initialization (ablation) | GPT-4 tokenizer on model 1.5B · HumanEval | Pass@1: 20.54268293 -> 18.40548780487805 | Hurt |
| Remove FVT initialization (ablation) | GPT-4 tokenizer on model 1.5B · MBPP | Pass@1: 27.245 -> 25.001 | Hurt |
| Replace a distinct tokenizer with an extended Llama tokenizer | model 1.5B fine-tuned for code · HumanEval | Pass@1: 20.54268293 -> 20.84451219512195 | No clear effect |
| Freeze non-vocabulary weights for 100B tokens (ablation) | Punct tokenizer model 1.5B · HumanEval | Pass@1: 22.22560976 -> 21.33231707 | Hurt |
| Freeze non-vocabulary weights for 500B tokens (ablation) | Punct tokenizer model 1.5B · HumanEval | Pass@1: 22.22560976 -> 17.80792683 | Hurt |
| Use the GPT-4 tokenizer instead of the Llama tokenizer after 50B or more fine-tuning tokens | Pre-trained model fine-tuned for code · HumanEval | Pass@1 | No clear effect |
| Use the Punct tokenizer instead of the Llama tokenizer after 50B or more fine-tuning tokens | Pre-trained model fine-tuned for code · HumanEval | Pass@1 | No clear effect |
| Remove token healing (ablation) | Identity tokenizer model fine-tuned from Code Llama · HumanEval | Pass@1: 18.77439024 -> 0.1341463415 | Hurt |
Surprising findings
- Vocabulary size from 32k to 256k has no significant effect on HumanEval Pass@1 (Pearson correlation -0.13, p=0.87).
- Identity tokenizer (no pre-tokenization) gives the best compression but loses significant downstream performance unless token healing is used.
Limitations
- Gains from tokenizer switching require long fine-tuning (>=50B tokens); short regimes degrade performance.
- Evaluation limited to HumanEval and MBPP code generation and models of 1.5B and 7B size.
- Several differences between tokenizers (e.g., Punct vs GPT-4) are not statistically significant.
Experimental setup
Datasets: CCnet Wikipedia The Stack HumanEval MBPP
Benchmarks: HumanEval MBPP
Metrics: Pass@1 Pass@100 Compile@1 Normalized Sequence Length Bytes per Token Renyi entropy
Baselines: Llama tokenizer Code Llama 7B GPT-2 tokenizer Identity tokenizer InCoder tokenizer
Builds on: Byte-Pair Encoding Fast Vocabulary Transfer Code Llama GPT-4 pre-tokenization regex
Closest papers by meaning
- Enhancing Large Language Models through Adaptive Tokenizers (NeurIPS 2024 · similarity 0.89)
- Over-Tokenized Transformer: Vocabulary is Generally Worth Scaling (ICML 2025 · similarity 0.89)
- Exact Byte-Level Probabilities from Tokenized Language Models for FIM-Tasks and Model Ensembles (ICLR 2025 · similarity 0.89)
- Broken Tokens? Your Language Model can Secretly Handle Non-Canonical Tokenizations (NeurIPS 2025 · similarity 0.88)
- zip2zip: Inference-Time Adaptive Tokenization via Online Compression (NeurIPS 2025 · similarity 0.88)
- Model-Aware Tokenizer Transfer (NeurIPS 2026 · similarity 0.88)
Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.
