SentencePiece
A language-agnostic subword tokenization tool supporting multiple algorithms including BPE and Unigram. It is widely used as a tokenizer for large language models and can learn tokenization models directly from raw text.
Core Facts
SentencePiece is a language-agnostic tokenization framework proposed by Google that models directly on raw text and is suitable for multilingual use and languages without clear word boundaries.
Subword tokenization cuts words into smaller segments, common algorithms include BPE, WordPiece and Unigram, and SentencePiece is one language-agnostic engineering implementation among them.
Different models use different tokenization schemes (such as BPE, SentencePiece, etc.), and the same piece of text may be counted as a different number of tokens across different models.
Timeline (last 90 days)
WordPiece and SentencePiece are different implementations of the same line of thinking in subword tokenization, among which SentencePiece supports training directly from raw text without pre-splitting words by spaces, making it friendlier to languages without spaces such as Chinese.
llama.cpp's tokenizer implementation follows the two mainstream schemes of SentencePiece and BPE, and provides a unified abstraction for the vocabulary embedded in GGUF, covering details such as special tokens, byte fallback and normalization rules.
TinyLlama's UNK rate is 0.0% on all tested scripts, because SentencePiece's byte fallback mechanism never produces UNK tokens.
When encountering a character that does not exist in the vocabulary, SentencePiece's byte fallback mechanism decomposes the character into a sequence of raw UTF-8 bytes, mapping each byte to a token, thereby avoiding UNK tokens.
Across 9,000 greedy-decoding questions covering all three splits, token ID 3582 (corresponding to the bare word 'yes') and 1217 (corresponding to the bare word 'no') were never once generated by LLaVA-1.5-7B; what the model actually outputs is ' Yes' (token 3869) and ' No' (token 1939).
The researchers conducted a four-reading audit on another four VLMs covering three tokenizer families, concluding that the Yes/No reading confusion is a protocol-level rather than model-level issue.
Porting LLaVA-1.5's token IDs as-is to two models with disjoint vocabularies drops F1 straight to 0.00, whereas using tokenizer-derived readings keeps F1 stable between 0.80 and 0.92.
SentencePiece treats spaces as ordinary characters (denoted by ▁), and when the prompt ends with 'ASSISTANT:' it retains the space byte after the colon, so the next token the model predicts is actually the space-prefixed form ' Yes'/' No'.
ArcLM provides both a word-level tokenizer and SentencePiece support.
The ArcLM core installation automatically pulls in dependencies such as NumPy and SentencePiece, but does not pull PyTorch.
9 more timeline events
All Facts (20)
SentencePiece is a language-agnostic tokenization framework proposed by Google that models directly on raw text and is suitable for multilingual use and languages without clear word boundaries.
75%VerifiedSubword tokenization cuts words into smaller segments, common algorithms include BPE, WordPiece and Unigram, and SentencePiece is one language-agnostic engineering implementation among them.
70%VerifiedDifferent models use different tokenization schemes (such as BPE, SentencePiece, etc.), and the same piece of text may be counted as a different number of tokens across different models.
65%VerifiedTokens are generated by the BPE (Byte Pair Encoding) algorithm; in English text, each token corresponds on average to approximately 4 characters (about 0.75 words).
65%UnverifiedA Tokenizer is responsible for splitting raw text into token sequences that the model can process; mainstream approaches include BPE, WordPiece, and SentencePiece.
60%UnverifiedOpenAI uses the BPE (Byte Pair Encoding) algorithm for tokenization, while Google's SentencePiece adopts a language-agnostic tokenization method trained directly on raw text.
60%UnverifiedLLM tokenizers (such as BPE) are designed for natural language and decompose numerical values into multiple unrelated tokens, destroying the continuity and magnitude semantics of numbers.
60%UnverifiedOpenAI uses the tiktoken tokenization algorithm, and Google uses the SentencePiece tokenization algorithm.
60%UnverifiedWordPiece and SentencePiece are different implementations of the same line of thinking in subword tokenization, among which SentencePiece supports training directly from raw text without pre-splitting words by spaces, making it friendlier to languages without spaces such as Chinese.
50%Unverifiedllama.cpp's tokenizer implementation follows the two mainstream schemes of SentencePiece and BPE, and provides a unified abstraction for the vocabulary embedded in GGUF, covering details such as special tokens, byte fallback and normalization rules.
50%UnverifiedTinyLlama's UNK rate is 0.0% on all tested scripts, because SentencePiece's byte fallback mechanism never produces UNK tokens.
50%UnverifiedWhen encountering a character that does not exist in the vocabulary, SentencePiece's byte fallback mechanism decomposes the character into a sequence of raw UTF-8 bytes, mapping each byte to a token, thereby avoiding UNK tokens.
50%UnverifiedAcross 9,000 greedy-decoding questions covering all three splits, token ID 3582 (corresponding to the bare word 'yes') and 1217 (corresponding to the bare word 'no') were never once generated by LLaVA-1.5-7B; what the model actually outputs is ' Yes' (token 3869) and ' No' (token 1939).
50%UnverifiedPorting LLaVA-1.5's token IDs as-is to two models with disjoint vocabularies drops F1 straight to 0.00, whereas using tokenizer-derived readings keeps F1 stable between 0.80 and 0.92.
50%UnverifiedThe researchers conducted a four-reading audit on another four VLMs covering three tokenizer families, concluding that the Yes/No reading confusion is a protocol-level rather than model-level issue.
50%UnverifiedSentencePiece treats spaces as ordinary characters (denoted by ▁), and when the prompt ends with 'ASSISTANT:' it retains the space byte after the colon, so the next token the model predicts is actually the space-prefixed form ' Yes'/' No'.
50%UnverifiedArcLM provides both a word-level tokenizer and SentencePiece support.
50%UnverifiedThe ArcLM core installation automatically pulls in dependencies such as NumPy and SentencePiece, but does not pull PyTorch.
50%UnverifiedMetaspace is a special pre-tokenization processing technique common in the SentencePiece tokenization system, which replaces spaces between words with a special underscore character (▁).
50%UnverifiedThe byte fallback mechanism decomposes characters not found in the vocabulary into their corresponding UTF-8 byte sequences when the tokenizer encounters them, mapping each byte to a special token in the form of <0xE4>.
50%