SentencePiece

Unsupervised subword tokenizer implementing BPE and unigram models directly on raw multilingual text.

Open SourceSelf HostedOffline Capable
0.0 (0)

About

Nearly every modern multilingual language model owes something to SentencePiece, Google's unsupervised subword tokenizer and detokenizer. It trains BPE and unigram language model tokenizers directly from raw text, treating input as a sequence of Unicode characters with no pre-tokenization step, which makes it genuinely language independent and equally at home with Japanese, Chinese, or English. Whitespace is preserved through the tokenization round trip, so detokenization is lossless, and subword regularization plus BPE-dropout provide sampling-based augmentation that makes downstream models more robust. The core is C++ for speed, with the README citing segmentation at around 50,000 sentences per second and a memory footprint of about 6 MB, and Python bindings install with pip install sentencepiece; C++ and command-line interfaces ship as well. Model families including T5 and Gemma tokenize with it, and it remains the default choice for training a tokenizer from scratch on raw corpora. The project is Apache-2.0 licensed, has roughly 12,000 stars, and stays actively maintained.

Should you use SentencePiece?

Pick it when

Pick SentencePiece when you are training a new language model or translation system and need to learn a BPE or unigram vocabulary straight from raw text, especially for languages such as Japanese or Chinese without spaces.

Look elsewhere when

Skip it if you only need to tokenize for an existing model; load that checkpoint's own tokenizer instead. For training BPE or WordPiece vocabularies inside the Hugging Face stack, the Tokenizers library fits more directly.

Alternatives to SentencePiece

  • Hugging Face Tokenizers

    Rust library that trains BPE, WordPiece and unigram vocabularies and plugs straight into Transformers, though you configure pre-tokenizers yourself.

  • Transformers

    Loads the exact pretrained tokenizer for an existing checkpoint, SentencePiece-based ones included, so no training when you are not building a model.

Reviews (0)

Leave a Review

No reviews yet. Be the first to review!

Details

Price
Free
Platform
Local/Desktop
Difficulty
Easy (2/5)
License
Apache-2.0
Added
Jul 29, 2026

Tags