Kelly Mears

Token

The sub-word unit a language model actually reads and writes; the unit of cost and of context.

Agents & Language Models1 min read199 words13 out · 20 in
also calledTokensTokenization

A token is the atomic unit a Large Language Model processes. Tokens are not words or characters but fragments produced by a learned segmentation — common words are usually a single token, rare words split into several, and whitespace and punctuation carry tokens of their own. English text averages roughly four characters per token.

Tokens matter for three practical reasons. They are the unit in which the Context Window is measured, so "how much can I show the model" is a token question. They are the unit of billing, so they are the unit of Token Budget. And they are the unit of latency, since generation is sequential.

Tokenization also explains a family of otherwise-strange model behaviors: difficulty with character-level tasks like counting letters or reversing strings, uneven handling of unusual formatting, and the fact that the same content costs different amounts depending on how it is written. Dense structured formats and long identifier names are more expensive than their information content suggests.

Because tokens are consumed by everything in the request — instructions, tool definitions, prior turns, retrieved documents — reducing any of these frees capacity for the rest. That trade is the whole subject of context engineering.

See also10

Prompt

The text supplied to a language model to elicit a response.

Agents & Language Models14 connections

Constrained Decoding

Restricting a model's next-token choices to those a formal grammar permits.

Agents & Language Models11 connections

Prompt Engineering

Shaping a model's input to make the desired behavior reliable rather than occasional.

Agents & Language Models22 connections

Structured Output

Constraining a model to emit data conforming to a declared schema rather than free text.

Agents & Language Models13 connections

Character Encoding

The mapping between characters and bytes, and the source of a specific family of invisible bugs.

Systems & Tooling31 connections

Nondeterminism

The property that identical inputs may produce different outputs, and what it costs to test around.

Agents & Language Models24 connections

Tool Use

Giving a model a set of callable functions so it can act on the world rather than only describe it.

Agents & Language Models27 connections

Stemming and Lemmatization

Reducing words to a common base form so a search for "running" also finds "runs" and "ran," with stemming chopping suffixes by rule and lemmatization looking up the dictionary form.

Data & Content7 connections

Lexical Analysis

The first stage of reading a program, which groups a stream of characters into tokens such as names, numbers, operators and keywords, usually using regular expressions compiled into a finite automaton, so the parser can work with words rather than letters.

Computation & Algorithms9 connections

Byte-Pair Encoding

The compression trick that splits text into the tokens a language model reads, by repeatedly merging the most frequent pair of symbols into a new one.

Agents & Language Models8 connections

Linked from20