Tokens, Embeddings, and Context

Tokens, Embeddings, and Context

Key jargon

Term Plain-language meaning
Token A model-specific unit of text or bytes represented by an integer ID.
Tokenizer The reversible rules that convert input into token IDs and IDs back into text.
Embedding A learned vector representation used to encode meaning or model state.
Context window The bounded sequence of tokens available to a model for one generation.

Key concepts

Concept map

flowchart LR
    A["Raw input"] --> B["Tokenizer produces IDs"]
    B --> C["Embeddings encode vectors"]
    C --> D["Context drives generation"]

Core concepts

Token count is not character count. Two models may tokenize the same text differently, affecting cost and available context.

Three embedding uses

  1. Input token embeddings inside the language model.
  2. Retrieval embeddings used to compare documents and queries.
  3. Multimodal representations connecting text with images, audio, or other data.

They are related ideas, not necessarily interchangeable models or vector spaces.

Exercise

Use an official tokenizer tool for one model. Compare a paragraph of prose, JSON, code, and a non-English sentence. Record token counts and explain the differences without assuming tokens equal words.

Checklist