liveBook · Manning

Vocabulary

As explained in How Large Language Models Work

A language-model vocabulary is the collection of unique tokens and their identifiers observed or defined for the model.

A language-model vocabulary is the collection of unique tokens a tokenizer can represent, with each token assigned a numeric identifier. Tokens may be full words, word pieces, or smaller character sequences rather than words themselves. The model interacts with these identifiers, not directly with human-readable text. section 2.2.1 section 2.6

A tokenizer builds the vocabulary by processing training data: it normalizes text, segments it into tokens, and records each new token with a unique identifier. Byte-pair encoding (BPE) commonly learns frequent subword combinations instead of relying entirely on hand-written splitting rules. section 2.2.1 section 2.2.3

Vocabulary design balances representational coverage against practical cost:

  • Larger vocabularies can represent more words and patterns directly, but increase model size, memory use, storage requirements, and computation. section 2.2.1 section 2.2.2
  • Smaller vocabularies reduce those costs by reusing subwords, but may represent some content less effectively. section 2.2.2 section 2.6
  • Out-of-vocabulary problems occur when text cannot be represented by any available token or combination of subwords. section 2.2.2
  • Numeric token identifiers do not inherently express relationships such as shared prefixes, suffixes, spelling, or meaning; those relationships must be learned from observed data. section 2.6 section 2.2

From text to vocabulary entries

A simple space-based tokenizer might split “hello world” into “hello” and “world,” but “hello, world” can produce separate “hello,” and “hello” tokens. BPE instead learns frequent pieces, so words such as “schoolhouse” may be represented as “school” and “house,” while “thoughtful” may become “thought” and “ful.” section 2.2.3 section 2.2

Figure 2.2 Generically, tokenization involves processing input to produce numeric identifiers for tokens.
figure

Trace the general pipeline from input text through tokenization to numeric identifiers. section 2.2.1

Figure 2.5 A simplified byte pair encoding algorithm for creating tokens: first, find the most frequent pair of characters “ng.” Next, replace all instances of “ng” with a placeholder token “T,” and add “ng” to the vocabulary. Repeat the process until no common byte pairs remain.
figure

Follow a simplified BPE cycle: find a frequent character pair, merge it into a token, add it to the vocabulary, and repeat. section 2.2.3

How How Large Language Models Work covers it

How deep it goes
Explains construction through normalization, segmentation, identifiers, BPE, resource trade-offs, and representation failures.
Examples
Uses space splitting, punctuation, schoolhouse, thoughtful, frequent character pairs, and GPT-3’s 50,257-token vocabulary.
What it assumes
Teaches tokenization from input text through normalization, segmentation, and numeric identifiers without requiring advanced machine-learning background.
What you can do after
Evaluate whether vocabulary coverage, tokenization behavior, and resource costs fit a language-model application.
How it connects
Connects vocabulary to tokenization, normalization, segmentation, byte-pair encoding, feature engineering, and out-of-vocabulary problems.

Also explained in

Compare how 13 books explain vocabulary →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of How Large Language Models Work. The section links point to the parts of the book it draws on.