Conceptintro
Out-of-vocabulary word
Also called OOV word, unknown word problem.
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.
An out-of-vocabulary (OOV) word is a word token in the input of a model, at test or use time, whose type is not in the fixed vocabulary that the model was built with. A word-level model cannot score or produce such a word directly, so every system with a fixed vocabulary needs a plan for it. The three usual plans are to map unknown words to one special token UNK, to reserve probability for unseen words by smoothing, and to remove the problem by subword tokenization, which writes every word with smaller known pieces. The OOV rate of a test text is the fraction of its tokens that are OOV.
In plain words
A model learns its words from training text. Later it meets a word it has never seen: a new name, a rare word, a spelling error, or a number. It has no entry for that word. You can treat all such words as one "unknown" word, you can save a little probability for anything new, or you can cut words into pieces, such as "un", "believ" and "able", that the model knows. New words never stop coming: the more text you read, the more new words you find.
The idea
Let be the vocabulary of a model, a set of V word types, for example all types seen at least times in the training text, or the V most frequent ones. A token of a new text is OOV if . The idea rests on three facts.
- New words keep coming. By Heaps' law, the number of distinct types in tokens grows like with near one half, so the vocabulary does not converge as a corpus grows. This is a measured law, not a theorem. It follows that a fixed vocabulary has a non-zero OOV rate on new text, and the rate is higher in a new domain.
- Most types are rare. By Zipf's law, a large share of the types in any corpus occur once or twice. Cutting the vocabulary to frequent types removes many types but only a small share of the tokens. This is also a measured law.
- The unseen mass can be estimated. The Good-Turing estimate of the probability that the next token is a type not seen so far is , the fraction of tokens whose type occurs exactly once. This is an estimator with known properties, not a measurement of one corpus.
The main ways to handle OOV words follow from these facts:
- UNK token. Replace OOV tokens by one token UNK, and train its probability by replacing rare training words with UNK too. The model then gives one probability to all unknown words together.
- Smoothing. Add-one smoothing, Good-Turing and later methods move probability from seen to unseen events.
- Word features. A tagger can guess the tag of an unknown word from its suffix, capital letters and digits, as in the unknown-word models of HMM part-of-speech taggers.
- Subwords, characters or bytes. Byte-pair encoding, WordPiece and the unigram model split a word into known pieces. Byte-level BPE starts from all 256 byte values, so no input is OOV. Sennrich, Haddow and Birch (2016) used BPE to translate rare and unseen words.
- Composed representations. Subword information embeddings build a vector for an unseen word from the vectors of its character -grams.
Examples
OOV rate. Train on "the cat sat on the mat" and take = {the, cat, sat, on, mat}, so V = 5. The test text "the dog sat on the rug" has 6 tokens, of which "dog" and "rug" are OOV, so the OOV rate is 2/6, about 33%.
Good-Turing. In the training text, the type "the" occurs twice and "cat", "sat", "on" and "mat" occur once each, so and . The estimate of the probability that the next token is a new type is . In a large corpus is much smaller, but by Heaps' law new types keep coming, so it stays above zero.
Perplexity with UNK. Perplexities are comparable only between models with the same vocabulary. Take the extreme vocabulary = {UNK}: every token maps to UNK, the model gives it probability 1, and the perplexity of every text is 1, although the model has learned nothing. A smaller vocabulary in general maps more tokens to UNK and lowers perplexity for this reason alone. So report the OOV rate and the vocabulary with the perplexity, or compare models that write every text with the same units.
Where it is used
- Language models. Word -gram models use UNK and smoothing; neural language models mostly use subword or byte vocabularies, so OOV words become sequences of pieces.
- Speech recognition. A word that is not in the pronunciation lexicon cannot be recognized, and the recognizer outputs a similar known word instead, which also hurts the words around it. Systems add subword units or grow the lexicon, see automatic speech recognition.
- Machine translation. Names and rare words must be copied, transliterated or built from subwords, see machine translation.
- Tagging and parsing. Unknown words are harder to tag than known words, so taggers use suffix and shape features for them.
- Search. A query term that is not in the index matches nothing, which is one reason for stemming and spelling correction, see noisy channel spelling correction.
References
- Rico Sennrich, Barry Haddow and Alexandra Birch, Neural machine translation of rare words with subword units, ACL 2016, pages 1715 to 1725 (open-vocabulary translation by splitting rare words into subword units learned by byte-pair encoding)
- Christopher D. Manning, Prabhakar Raghavan and Hinrich Schuetze, Introduction to Information Retrieval, Cambridge University Press, 2008, Chapter 5, Section 5.1.1 (Heaps' law, the growth of the vocabulary with the size of the collection)
- Daniel Jurafsky and James H. Martin, Speech and Language Processing, 3rd edition draft, the chapter on n-gram language models (unknown words and the UNK token)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag RMX04P Edit this page History Report an error Markdown