NEW
Also known as: WordPiece tokenization
Subword tokenization algorithm that greedily segments text into frequent subword units learned to maximize corpus likelihood.
DESCRIPTION
WordPiece constructs a subword vocabulary by optimizing likelihood on training data, then tokenizes with a greedy longest-match-first algorithm. It underpins models like BERT and handles rare words by splitting into subwords. Compared to BPE, its training objective differs, affecting token distributions. Implementations are available in TensorFlow Text and tokenizers for model pretraining and inference.
ALTERNATIVE DEFINITIONS
TensorFlow
Wordpiece tokenization splits text into subword units using a greedy longest-match-first algorithm over a fixed vocabulary.
Defines the core greedy segmentation behavior in official library docs.
Wikipedia
WordPiece is a subword segmentation algorithm used for natural language processing that builds a vocabulary of frequent subword units.
General explanation of subword segmentation and vocabulary learning.
RELATED TERMS
Tokenization Subword BERT SentencePiece Vocabulary Out-of-Vocabulary Greedy Matching Language Model
COMPETING TERMS
Byte Pair Encoding Unigram
KNOWLEDGE AREAS
TARGET AUDIENCE
AI Engineer Data Scientist MLOps Engineer Software Developer
EXTERNAL SOURCES
- Wikipedia - WordPiece
- TensorFlow - Official WordPiece tokenizer docs
- Devlin et al., arXiv - BERT paper using WordPiece
- Hugging Face - Tokenizer methods overview
TOP QUESTIONS
Why is WordPiece popular in transformer models?
It balances vocabulary size and coverage, reduces unknown tokens, and suits pretraining objectives like masked language modeling used in BERT.
Category: Relevancy
How does WordPiece differ from BPE?
Both create subwords, but WordPiece typically optimizes likelihood and uses greedy matching, whereas BPE applies iterative merge operations by frequency.
Category: Alternatives
What determines WordPiece vocabulary size?
A chosen size trades compression and generalization. It’s learned from corpus statistics and validated by downstream model performance.
Category: Requirements
How are out-of-vocabulary words handled in WordPiece?
Words are split into known subwords using greedy longest-match rules, minimizing reliance on unknown tokens.
Category: Example
What are common WordPiece training pitfalls?
Mismatched training and deployment corpora, poor normalization, and overly small or large vocabularies can degrade model quality.
Category: Mistakes
Is WordPiece language-agnostic?
It can support many languages, though languages with complex morphology may benefit from larger vocabularies or additional preprocessing.
Category: Opinion
Does WordPiece require special pre-processing?
Consistent normalization and casing rules are important. Some pipelines use Unicode normalization and lowercasing for stability.
Category: Best practices
How does WordPiece impact sequence length?
Efficient subwords reduce the number of tokens for frequent patterns, helping training and inference efficiency.
Category: Example
Where should I start learning WordPiece?
Review TensorFlow Text or Hugging Face tokenizer docs and examine BERT’s preprocessing pipeline for practical examples.
Category: Requirements