SentencePiece: A simple and language independent subword tokenizer and detokenizer for Neural Text Processing
Written for the Research library (claude-opus-5-5) from the paper text. Original — aclanthology.org/D18-2012.pdf
Summary
Neural text systems such as NMT still often depend on preprocessing that is tied to specific languages. Examples include the rule-based Moses tokenizer and the separate word segmenters needed for Chinese, Japanese and Korean, which make multilingual and reproducible pipelines harder to build. Kudo and Richardson present SentencePiece, an open-source subword tokenizer and detokenizer written in C++ with Python and TensorFlow bindings. It learns BPE or unigram language model vocabularies directly from raw sentences, so no pre-tokenization is needed. Whitespace is treated as an ordinary symbol (U+2581), which makes tokenization fully reversible. The tool also handles vocabulary-to-id mapping and NFKC-based normalization, which users can customize. Everything, including the normalization rules, is stored in a single self-contained model file. In English-Japanese experiments on KFTT with GNMT, subword models beat word-level baselines. Training on raw text matched or beat pre-tokenized training, and the gain was largest when Japanese was the target language. This matters because a single tool can now preprocess any language, including unsegmented scripts and morphologically rich languages such as Ukrainian, with no hand-written rules.
Key points
- Supports two segmentation algorithms (BPE and unigram LM). BPE segmentation uses a binary heap, which brings its cost down from O(N²) to O(N log N). Users set the final vocabulary size (
--vocab_size) rather than a number of merge operations. - Lossless design: decoding an encoded normalized string returns exactly that normalized string. Detokenization only needs to join the pieces and turn the meta symbol back into spaces.
- On KFTT (440k training sentences), shared 8k SentencePiece vocabularies reached 29.55 BLEU for ja→en and 21.62 for en→ja. The 80k word baselines scored 28.24 and 20.06. Adding pre-tokenization lowered en→ja to 20.86.
- On raw Japanese text, SentencePiece trained in 217.3 s versus 528.0 s for subword-nmt. It segmented in 5.9 s versus 216.2 s.
- Released under Apache 2 at github.com/google/sentencepiece. Models are serialized as Protocol buffers, and the API supports on-the-fly subword sampling for subword regularization.
Cited by
- A unified approach to sentence segmentation of punctuated text in many languages
- Semitic Root Encoding: Tokenization Based on the Templatic Morphology of Semitic Languages in NMT
- Unified Pre-training for Program Understanding and Generation
- Yi: Open Foundation Models by 01.AI
- ACES: Translation Accuracy Challenge Sets for Evaluating Machine Translation Metrics
- Massively Multilingual Neural Machine Translation in the Wild: Findings and Challenges
- On the Cross-lingual Transferability of Monolingual Representations
- Program Synthesis with Large Language Models
- The Belebele Benchmark: a Parallel Reading Comprehension Dataset in 122 Language Variants
- Simple, Scalable Adaptation for Neural Machine Translation
- Findings of the 2019 Conference on Machine Translation (WMT19)
- On the Opportunities and Risks of Foundation Models
- Rethinking embedding coupling in pre-trained language models
- Seamless: Multilingual Expressive and Streaming Speech Translation
- SeamlessM4T: Massively Multilingual & Multimodal Machine Translation
- Efficient and Effective Text Encoding for Chinese LLaMA and Alpaca
- BERTje: A Dutch BERT Model
- Moshi: a speech-text foundation model for real-time dialogue
- GLaM: Efficient Scaling of Language Models with Mixture-of-Experts
- MoVoC: Morphology-Aware Subword Construction for Ge'ez Script Languages
- Results of WMT22 Metrics Shared Task: Stop Using BLEU – Neural Metrics Are Better and More Robust
- Continual Pre-Training for Cross-Lingual LLM Adaptation: Enhancing Japanese Language Capabilities
- IndicTrans2: Towards High-Quality and Accessible Machine Translation Models for all 22 Scheduled Indian Languages
- Gemini: A Family of Highly Capable Multimodal Models
- Domain-Specific Language Model Pretraining for Biomedical Natural Language Processing
- Language Is Not All You Need: Aligning Perception with Language Models
- Llama Guard: LLM-based Input-Output Safeguard for Human-AI Conversations
- Challenges and Applications of Large Language Models
- CCAligned: A Massive Collection of Cross-Lingual Web-Document Pairs
- MADLAD-400: A Multilingual And Document-Level Large Audited Dataset
- Data Augmentation using Pre-trained Transformer Models
- BioMistral: A Collection of Open-Source Pretrained Large Language Models for Medical Domains
- Unsupervised Translation of Programming Languages
- Can language models learn from explanations in context?
- Expanding the Lexicon of Ge'ez Based African Languages: A Comparative Study of Amharic and Tigrinya
- Hierarchical Transformers for Multi-Document Summarization
- CamemBERT: a Tasty French Language Model
- EuroLLM: Multilingual Language Models for Europe
- Teaching language models to support answers with verified quotes
- Adaptive Machine Translation with Large Language Models
- When Being Unseen from mBERT is just the Beginning: Handling New Languages With Multilingual Language Models
- Swiss-Judgment-Prediction: A Multilingual Legal Judgment Prediction Benchmark
- The Linear Representation Hypothesis and the Geometry of Large Language Models
- A Recipe For Arbitrary Text Style Transfer with Large Language Models
- Leveraging Pre-trained Checkpoints for Sequence Generation Tasks
- Code Llama: Open Foundation Models for Code
- AudioPaLM: A Large Language Model That Can Speak and Listen
- WikiMatrix: Mining 135M Parallel Sentences in 1620 Language Pairs from Wikipedia
- Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language models
- MobileBERT: a Compact Task-Agnostic BERT for Resource-Limited Devices
- Multilingual Translation from Denoising Pre-Training
- Automatic Machine Translation Evaluation in Many Languages via Zero-Shot Paraphrasing
- Paraphrase Generation as Zero-Shot Multilingual Translation: Disentangling Semantic Similarity from Lexical and Syntactic Diversity
- LaMDA: Language Models for Dialog Applications
- The Tatoeba Translation Challenge – Realistic Data Sets for Low Resource and Multilingual MT
- Multimodal Few-Shot Learning with Frozen Language Models
- Multilingual is not enough: BERT for Finnish
- SimVLM: Simple Visual Language Model Pretraining with Weak Supervision
- VoxPopuli: A Large-Scale Multilingual Speech Corpus for Representation Learning, Semi-Supervised Learning and Interpretation
- Are All Languages Created Equal in Multilingual BERT?
- BloombergGPT: A Large Language Model for Finance
- CLUE: A Chinese Language Understanding Evaluation Benchmark
- XLNet: Generalized Autoregressive Pretraining for Language Understanding
- Multilingual Universal Sentence Encoder for Semantic Retrieval
- Baichuan 2: Open Large-scale Language Models
- mPLUG-Owl: Modularization Empowers Large Language Models with Multimodality
- Big Bird: Transformers for Longer Sequences
- Improving Massively Multilingual Neural Machine Translation and Zero-Shot Translation
- A Survey of Large Language Models
Cite
@inproceedings{kudo2018sentencepiece,
title = {{SentencePiece: A simple and language independent subword tokenizer and detokenizer for Neural Text Processing}},
author = {Kudo, Taku and Richardson, John},
booktitle = {Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing: System Demonstrations},
year = {2018},
doi = {10.18653/v1/d18-2012},
eprint = {1808.06226},
archivePrefix = {arXiv},
url = {https://doi.org/10.18653/v1/d18-2012}
}References
- Mikel Artetxe, Gorka Labaka, Eneko Agirre, and Kyunghyun Cho. 2017. Unsupervised neural machine translation. arXive preprint arXiv:1710.11041. find our card
- Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. 2014. Neural machine translation by jointly learning to align and translate. arXiv preprint arXiv:1409.0473. find our card
- Michael Denkowski and Graham Neubig. 2017. Stronger baselines for trustable results in neural machine translation. Proc. of Workshop on Neural Machine Translation. *Table 2: Segmentation performance. KFTT corpus (440k* find