SentencePiece is a tokenizer (a tool that splits text into symbols) that learns a subword vocabulary directly from text without first splitting it into words, and treats whitespace as an ordinary symbol. It was released by Kudo and Richardson at Google in 2018. It is not a segmentation algorithm in itself but a tool that makes two algorithms, BPE and the Unigram language model, usable in a language-independent way.
Earlier subword tools assumed that text had already been split into words. English can be split on spaces, but Japanese, Chinese, and Korean require running a language-specific word segmenter (such as a morphological analyzer) first. Converting the symbols back into text (detokenization) also required language-specific rules, such as "insert spaces between words in English" and "do not insert them in Japanese."
SentencePiece treats text as just a sequence of Unicode characters, replaces whitespace with the symbol ▁ (U+2581), and learns it like any other character. This made the following possible.
- Training without word segmentation: a subword vocabulary can be learned directly from raw Japanese text.
- Exact restoration of the original text: simply concatenating the symbols and turning
▁back into spaces yields the original (normalized) text. - Preprocessing is stored in the model file: the vocabulary and normalization rules are contained in a single file, so anyone using the same file can reproduce the same segmentation.

