liveBook · Manning

SentencePiece

As explained in Natural Language Processing in Action, Second Edition

SentencePiece tokenization is a subword tokenization technique that divides text into character-based pieces without requiring whitespace-delimited words.

SentencePiece treats text as reusable subword pieces rather than assuming that human words are indivisible units. This matters when spaces do not cleanly mark meaningful boundaries, compound words contain internal structure, or unfamiliar words need to be represented through related pieces. section 2.2

SentencePiece is useful because it can:

  • Split words into meaningful parts such as prefixes, suffixes, and interior syllables, allowing patterns learned from one word to transfer to another. section 2.2
  • Represent text with characters, graphemes, or other smaller pieces when word-level units are ambiguous or vocabularies are large. section 2.2
  • Support natural-language understanding of new words and natural-language generation of newly formed expressions. section 2.2

From words to pieces

Instead of treating a word as one opaque token, imagine analyzing it as pieces such as “pre,” “la,” and “fix.” The same strategy can preserve useful structure in compounds and named entities while avoiding a vocabulary made entirely of whole words. section 2.2

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains the motivation and benefits of subword encoding but stops short of algorithmic training or implementation details.
Examples
Uses prefixes, suffixes, syllables, compound words, named entities, characters, and graphemes as illustrative units.
What it assumes
Begins with familiar words and progressively reframes tokens as smaller meaningful pieces, without assuming formal tokenization knowledge.
What you can do after
Evaluate when subword or character-based units may represent language more efficiently than whole-word tokens.
How it connects
Connects subword tokenization with word tokenization, byte pair encoding, wordpiece encoding, characters, graphemes, NLU, and NLG.

Also explained in

Compare how 3 books explain SentencePiece →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.