This repository contains the training and evaluation code for the TokSuite paper. It is built on top of Meta Lingua — see README_lingua.md for framework setup, SLURM job launching, debugging, and checkpoint management. Meta Lingua is a minimal and fast LLM training and inference library for research.
Set up the Python environment, we recommend uv but you can use the original conda setting as well:
bash setup/create_env.sh
# or, on a SLURM cluster
sbatch setup/create_env.sh
# then activate the environment created by the script
source .venv/bin/activateIn the paper we train multiple models from the same initialization. To do this we compute a unified "super-vocabulary"
Practical note: the repository includes utilities to generate the per-tokenizer configs and to save/load checkpoints that use the shared super-vocabulary; follow the apps/main/configs/toksuite/create_toksuite_configs.py workflow and point init_ckpt_path to the downloaded initialization to reproduce the shared initialization setup.
Before running the config generator, fill in these variables in apps/main/configs/toksuite/create_toksuite_configs.py:
dump_dir: where generated configs and experiment outputs should be writtenroot_dir: the local path to the downloaded TokSuite pretraining datainit_ckpt_path: the local path to the downloaded initialization checkpoint
Download the required assets first:
- TokSuite training data:
huggingface-cli download toksuite/toksuite_pretraining_data --repo-type dataset --local-dir /path/to/toksuite_pretraining_data - Initializations: download one of the model folders from toksuite/initializations into
/path/to/init_ckpt
Create the TokSuite configs by editing LLAMA_1B_OPTIONS in apps/main/configs/toksuite/create_toksuite_configs.py and then running:
python apps/main/configs/toksuite/create_toksuite_configs.pyThe script writes generated YAMLs next to itself in apps/main/configs/toksuite/ and will stop with a clear message if any of dump_dir, root_dir, or init_ckpt_path are still empty.
The steps below reproduce the TokSuite training runs. Follow them in order; for full-scale runs use SLURM and multiple GPU nodes.
- Prepare the environment, see above
- Download data and initial checkpoint
huggingface-cli login
huggingface-cli download toksuite/toksuite_pretraining_data --repo-type dataset --local-dir /path/to/toksuite_pretraining_data
huggingface-cli download <INIT_MODEL_FROM_COLLECTION> --local-dir /path/to/init_ckpt- Edit the generator
Open apps/main/configs/toksuite/create_toksuite_configs.py and set:
dump_dir→ where outputs and generated configs will be savedroot_dir→ path to/path/to/toksuite_pretraining_datainit_ckpt_path→ path to/path/to/init_ckpt
- Generate configs
python apps/main/configs/toksuite/create_toksuite_configs.pyThis writes _toksuite_llama_1B.yaml (shared base config) and toksuite_<tokenizer>.yaml files for each tokenizer into apps/main/configs/toksuite/.
- Representative training recipe (paper)
- Steps:
100000 - Effective batch: bs (4) x grad_accum (8) x n_gpus (8) x seq_len (4096) => 1,048,576 tokens (set
data.batch_sizeand distribute across GPUs accordingly, in the paper we use 8 gpus) - Optimizer:
AdamW, weight decay0.1 - Peak LR:
1e-3with cosine decay and2000warmup steps - Model: Llama-3.2-style 1B (untied embeddings)
- Launch a single run
python -m lingua.stool \
script=apps.main.train \
config=[apps/main/configs/toksuite/_base.yaml,apps/main/configs/toksuite/_toksuite_llama_1B.yaml,apps/main/configs/toksuite/toksuite_meta-llama-Llama-3.2-1B.yaml] \
nodes=1 launcher=sbatch - Launch the full suite (all tokenizers)
for cfg in apps/main/configs/toksuite/toksuite_*.yaml; do
python -m lingua.stool \
script=apps.main.train \
config=[apps/main/configs/toksuite/_base.yaml,apps/main/configs/toksuite/_toksuite_llama_1B.yaml,$cfg] \
nodes=1 launcher=sbatch &
done
wait- Checkpoints & resuming
- Checkpoints are saved under
<dump_dir>/checkpointsby default (configured in generated YAMLs). - Resume by setting
checkpoint.pathor passing a CLI override pointing to the checkpoint directory.
- Reproducibility tips
- Use the same
init_ckpt_pathfor all tokenizers to ensure identical initialization. - Use explicit seeds (see
apps/main/configs/toksuite/ablations/for examples). - Keep
_toksuite_llama_1B.yamlas the shared base for all runs to avoid path-dependent differences.
TokSuite training data should be provided as jsonl files and chunked using the same layout expected by Lingua, i.e. max. 1 chunk per device, with each line having the text key.
Each chunk should follow the Lingua data conventions used by the training code, so the data loader can read it without extra conversion steps.
For the full project documentation, setup instructions, and experiment details, see README_lingua.md.
If you use TokSuite or Meta Lingua in your work please cite the papers/projects below. BibTeX entries are provided for convenience.
@inproceedings{altintas2026toksuite,
author = {G{"u}l Sena Altınta\c{s} and Malikeh Ehghaghi and Brian Lester and Fengyuan Liu and Wanru Zhao and Marco Ciccone and Colin Raffel},
title = {{TokSuite}: Measuring the Impact of Tokenizer Choice on Language Model Behavior},
booktitle = {Proceedings of the 43rd International Conference on Machine Learning (ICML)},
year = {2026},
eprint = {2512.20757},
archivePrefix= {arXiv},
url = {https://arxiv.org/abs/2512.20757}
}@misc{meta_lingua,
author = {Mathurin Videau and Badr Youbi Idrissi and Daniel Haziza and Luca Wehrstedt and Jade Copet and Olivier Teytaud and David Lopez-Paz},
title = {{Meta Lingua}: A minimal {PyTorch LLM} training library},
year = {2024},
url = {https://github.com/facebookresearch/lingua}
}