liveBook · Manning

Out-of-vocabulary word

As explained in Build a Large Language Model (From Scratch)

A placeholder token used by some tokenizers for out-of-vocabulary words, which BPE avoids here by subword decomposition.

An unknown token is a vocabulary placeholder for text that a tokenizer cannot recognize. SimpleTokenizerV2 replaces out-of-vocabulary words with <|unk|>, allowing encoding to continue. section 2.4

The tokenizer adds <|unk|> to its vocabulary, maps it to an integer ID, and restores the marker during decoding. This preserves token sequence structure but loses the original word.

Byte pair encoding avoids this placeholder: it decomposes unfamiliar words into subwords or characters, so the tokenizer can represent arbitrary input and reconstruct it. section 2.5

SimpleTokenizerV2 output

Encoding “Hello, do you like tea? <|endoftext|> In the sunlit terraces of the palace.” produces <|unk|> for unseen words such as “Hello” and “palace,” while preserving the document separator.

How Build a Large Language Model (From Scratch) covers it

How deep it goes
Explains vocabulary insertion, integer mapping, encoding, decoding, and BPE’s alternative, but defers detailed BPE implementation.
Examples
Demonstrates <|unk|> with unseen words such as “Hello,” “palace,” and “someunknownPlace.”
What it assumes
Assumes basic tokenization and vocabularies while demonstrating special-token addition and integer token mapping.
What you can do after
Apply via SimpleTokenizerV2 by adding <|unk|>, encoding unseen words, and decoding their placeholder IDs.
How it connects
Connects unknown tokens with tokenization, vocabularies, special tokens, byte pair encoding, token IDs, and decoding.

Also explained in

Compare how 8 books explain out-of-vocabulary word →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Large Language Model (From Scratch). The section links point to the parts of the book it draws on.