liveBook · Manning

Out-of-vocabulary word

As explained in Build a Text-to-Image Generator (from Scratch)

An unknown token is a special marker representing a token not present in the model's vocabulary.

An out-of-vocabulary word is a token absent from the model’s vocabulary. A reserved unknown marker—UNK or <unk>—stands in for it, allowing the token sequence to become an integer sequence that the model can accept. section 2.2.1 section 4.2.2

Handle an unknown token through the vocabulary pipeline:

  • Look up each token with a fallback to UNK or <unk> when the token is missing. section 4.2.2
  • Use the resulting index sequence as model input; reverse dictionaries can reconstruct known tokens, while unknown entries remain represented by the marker. section 2.2.1

Caption vocabulary

An image-captioning vocabulary assigns <pad> to 0, <start> to 1, <end> to 2, and <unk> to 3. A caption token missing from word2idx therefore becomes index 3. section 4.2.2

How Build a Text-to-Image Generator (from Scratch) covers it

How deep it goes
Traces dictionary construction, fallback lookup, and reverse mapping, stopping at token representation rather than model behavior.
Examples
Uses English and German translation dictionaries plus an image-captioning vocabulary with <unk> assigned index 3.
What it assumes
Assumes tokenized text and teaches vocabulary lookup, reserved indices, and index-to-token conversion.
What you can do after
Builds token-index dictionaries that safely encode missing vocabulary entries for transformer inputs.
How it connects
Connects tokenization, vocabulary, padding tokens, sentence boundary tokens, reverse mapping, and transformers.

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 Text-to-Image Generator (from Scratch). The section links point to the parts of the book it draws on.