liveBook · Manning

Subword tokenization

Subword tokenization is a method of representing text with tokens that may be whole words or smaller word fragments, allowing unfamiliar words to be encoded as combinations of units.

How 7 Manning books explain it

Natural Language Processing in Action, Second Edition

A subword is a word fragment, character sequence, or complete word treated as a unit in subword-based language modeling.

How it is used
Uses character-derived units to balance vocabulary size, sequence coverage, and generalization in deep-learning NLP pipelines.
How deep it goes
Explains token construction, character n-gram statistics, vocabulary coverage, and embedding composition, but does not specify a complete tokenizer algorithm.
Examples
Demonstrates character bigram counts with CountVectorizer and composes fastText representations for rare or unseen words.
What you can do after
Apply it via CountVectorizer or fastText to inspect character fragments and improve representations for rare and unseen words.

Read how Natural Language Processing in Action, Second Edition explains subword tokenization →

Deep Learning with R, Third Edition

A subword token is a token representing a complete word, a word fragment, or a character-level fallback unit.

How it is used
Preprocesses text into integer-token sequences for text classification, pretrained Transformers, and language-model training.
How deep it goes
Works through frequent-pair merging and R tokenizer code, then uses pretrained tokenizers without detailing their internal implementations.
Examples
Uses repeated fox sentences for pair merges, Moby-Dick for vocabulary comparisons, and RoBERTa and SentencePiece tokenizers for pretrained workflows.
What you can do after
Build it from scratch with byte-pair merges, or apply it via KerasHub tokenizers to produce integer sequences.

Read how Deep Learning with R, Third Edition explains subword tokenization →

Learn Generative AI with PyTorch

A partial word unit produced by subword tokenization, smaller than a whole word but larger than a character.

How it is used
Prepares English and French phrases as tokens for vocabulary indexing and Transformer translation.
How deep it goes
Explains tokenization tradeoffs and works through pretrained-tokenizer outputs and token-index mapping, but defers detailed BPE workings.
Examples
Uses split English and French phrases, XLMTokenizer output, and dictionaries that convert tokens to indexes and back.
What you can do after
Apply it via XLMTokenizer to tokenize translation pairs and map their tokens to integer sequences.

Read how Learn Generative AI with PyTorch explains subword tokenization →

Deep Learning with Python, Third Edition

A tokenization method that splits text into units smaller than words but larger than characters to balance vocabulary size and sequence length.

How it is used
Balances sequence length and vocabulary size when turning text into integer inputs for models.
How deep it goes
Works through frequency-weighted byte-pair merges and a tokenizer vocabulary, then compares resulting sequence lengths.
Examples
Uses repeated fox sentences for merges, a sample line for token counts, and RoBERTa for pretrained-model use.
What you can do after
Build it from scratch with byte-pair merges, or apply it via KerasHub’s pretrained RoBERTa tokenizer.

Read how Deep Learning with Python, Third Edition explains subword tokenization →

How Large Language Models Work

A subword is a word fragment that lies between a complete word and an individual character and can carry part of a word's meaning.

How it is used
Supports language-model tokenization by representing familiar words and unfamiliar words as reusable fragments.
How deep it goes
Explains subword meaning, BPE construction, vocabulary tradeoffs, and token-relationship limitations, but stops short of model-training internals.
Examples
Uses schoolhouse, thoughtful, and repeated merging of the frequent letter pair ng to demonstrate subword segmentation.
What you can do after
Evaluate how tokenization represents unfamiliar words and why vocabulary choices affect model coverage, storage, and computation.

Read how How Large Language Models Work explains subword tokenization →

LLMs in Production

A subword is a tokenization unit corresponding to part of a word rather than necessarily a complete word.

How it is used
Determines the textual units and numerical inputs available to an LLM during embedding, inference, and arithmetic tasks.
How deep it goes
Explains splitting and numbering, contrasts frequency grouping with per-digit handling, and demonstrates tokenizer training without covering model internals.
Examples
Uses arithmetic prompts, digit-level Llama tokenization, token ID output, and a Python ByteLevel BPE training listing.
What you can do after
Build it from scratch with Python tokenizers by training a ByteLevel BPE tokenizer on local text files.

Read how LLMs in Production explains subword tokenization →

Build a Large Language Model (From Scratch)

A token fragment smaller than a full word, used by subword tokenizers to represent rare or unseen words.

How it is used
Uses subword units to tokenize rare or unseen words before converting text into token IDs and embeddings.
How deep it goes
Defines BPE’s iterative merging process and demonstrates encoding, decoding, and unknown-word handling, but defers a detailed implementation.
Examples
Demonstrates “someunknownPlace,” “Akwirw ier,” character fallback, and tiktoken encode–decode round trips.
What you can do after
Apply it via tiktoken to encode unfamiliar words, inspect token IDs, and verify decoded text.

Read how Build a Large Language Model (From Scratch) explains subword tokenization →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.