Tokenization and text normalization
Problems
- Language identification
Decide the natural language in which a text or a short string is written, from a fixed set of candidate languages.
intro - Lemmatization
Map each inflected word form in context to its dictionary form, such as was to be, using morphology and the part of speech.
intro - Sentence boundary detection
Decide which periods, question marks and other candidate marks in a text end a sentence, despite abbreviations, numbers and ellipses.
intro - Tokenization
Split a raw text into a sequence of units such as words, punctuation marks, subwords or bytes that later stages of a pipeline process.
intro - Word segmentation
Insert word boundaries into text written without spaces, as in Chinese, Japanese or Thai, or into a string of characters such as a URL.
intro - Morphological analysis
Map a word form to its lemma and features, such as cats to cat plus noun plus plural, and the reverse map for generation.
core - Truecasing
Restore the proper capitalization of text that is all lower case or all upper case, a sequence labeling problem solved for example by a trigram model over case variants with Viterbi decoding.
advanced
Algorithms
- Maximum matching segmentation
Segment a string into words by repeatedly taking the longest dictionary word that starts at the current position, from left to right.
1 languagesintro - Penn Treebank tokenization
Rule-based English word tokenization by regular expressions that splits off punctuation and clitics such as n't and 's, as in the Penn Treebank.
1 languagesintro - Cavnar-Trenkle n-gram text categorization
Identify the language of a text by comparing the rank order of its most frequent character n-grams with stored profiles under the out-of-place distance.
1 languagescore - Punkt sentence tokenizer
Unsupervised sentence boundary detection of Kiss and Strunk. It finds abbreviations, initials and ordinal numbers by collocation statistics on raw text.
1 languagescore - WordPiece
Learn subword units by merging the pair that most raises a unigram likelihood, then encode each word by greedy longest match with
1 languagescore - Byte-level BPE
Byte-pair encoding run on the UTF-8 bytes of a text instead of its characters, so the base vocabulary has 256 symbols and no input is out of vocabulary.
1 languagesadvanced - Morfessor
Unsupervised morphological segmentation of Creutz and Lagus that splits words into morphs by minimizing a two-part MDL code length of lexicon and corpus.
1 languagesadvanced - Unigram language model tokenization
Kudo's subword method. Fit a unigram model over pieces by EM, prune pieces that least lower the likelihood, and segment by Viterbi.
1 languagesadvanced - BPE-dropout
Apply the BPE merges in order but skip each candidate merge with probability p at training time, which yields random segmentations of each word.
1 languagesresearch - Fast WordPiece tokenization
Linear-time greedy longest-match WordPiece encoding with a trie extended by failure links and failure pops, in the style of Aho-Corasick.
1 languagesresearch
Techniques
- Subword regularization
Sample a different segmentation of each training sentence from a unigram tokenization model, so the network sees many splits and grows robust.
1 languagesadvanced
Concepts
- Out-of-vocabulary word
A word at test time that is not in the fixed vocabulary of a model. Handled by an UNK token, by smoothing, or by splitting words into subwords.
intro - Subword tokenization
Represent words as sequences of frequent pieces learned from data, so that a fixed vocabulary covers every word and rare words share pieces.
core
Theorems
- NP-hardness of optimal tokenization
Deciding whether K new pieces or K merges can shrink a corpus to a given number of tokens is NP-complete, so the optimization is NP-hard and greedy BPE is a heuristic.
research
Models
- Two-level morphology
Koskenniemi's model in which parallel finite-state transducers relate lexical and surface forms, so a lexicon and rules give analysis and generation.
core