Skip to content

NLP (Concepts & Pipeline)

Tokenization

In shortSplitting text into smaller units called tokens, such as words, subwords or characters, so a model can process it. The first step in most NLP pipelines.

Updated 24 Oct 2026· 2 min read

Tokenisation is the step in natural language processing that splits text into smaller units called tokens. Depending on the method, a token can be a word, part of a word, a punctuation mark or a single character. Every NLP model, from topic modelling to large language models, works on tokens rather than raw text, so tokenisation shapes what the model can see.

How it works

There are three broad approaches:

  • Word tokenisation splits on spaces and punctuation, so “Don’t index this page.” becomes tokens like do, n’t, index, this, page and the full stop. Libraries such as NLTK and spaCy apply language-specific rules for contractions, hyphens and URLs.
  • Subword tokenisation, used by BERT (WordPiece) and most LLMs (byte-pair encoding and similar methods), breaks rare words into frequent pieces, so a new term like “tokenisation” might become token, isation. This keeps the vocabulary manageable and handles unseen words.
  • Character tokenisation treats each character as a token, which is useful for fuzzy matching on character n-grams.

In classic pipelines, tokenisation is followed by lower-casing, stop word removal and stemming or lemmatisation before text is turned into vectors such as a bag of words or TF-IDF.

How it’s used in SEO and marketing

  • Topic modelling: LDA needs clean word tokens to build its dictionary and corpus.
  • Keyword extraction: KeyBERT uses scikit-learn’s CountVectorizer to tokenise text into candidate unigrams, bigrams and trigrams before embedding them.
  • N-gram analysis of keyword lists to find common modifiers.
  • LLM costs and limits: API pricing and context windows are measured in tokens, so long pages cost more and may need splitting.
  • Chunking for AI search: retrieval systems split pages into token-limited chunks, which is one reason self-contained sections matter.

Example

Running MLforSEO’s LDA notebook on a site crawl, each page’s main text is tokenised, lower-cased, stripped of stop words, numbers and punctuation, and lemmatised. “Optimising” and “optimised” both become “optimise”, so they count as one term, and the topics that come out are built from meaningful words instead of filler.

Limitations and things to watch

  • Tokenisers differ between models, so token counts from one LLM do not transfer to another.
  • Splitting can break meaningful phrases such as “New York” unless you add n-grams or phrase detection.
  • Languages without spaces between words, such as Chinese and Japanese, need specialised tokenisers.
  • Over-aggressive cleaning removes words that matter in your niche; review your stop word list.

Learn it on MLforSEO

Where Tokenization shows up on MLforSEO

Sources and further reading

Other terms from NLP (Concepts & Pipeline)

See all 17 NLP (Concepts & Pipeline) terms →