A language model does not “understand” text like a human. It converts text into numerical forms that a neural network processes. Think of this pipeline as: text → tokens → embeddings → transformer layers with attention → next-token prediction.
1. Tokenization — splitting text into model-ready pieces
Start with tokenization. Tokenizers break a sentence into smaller units (tokens) that the model can process. For example, the sentence: “I heard a dog bark at a cat.” can be split into tokens like: I, heard, a, dog, bark, at, a, cat. Tokens may be whole words, parts of words, punctuation, or other fragments depending on the tokenizer (BPE, WordPiece, SentencePiece, etc.). After tokenization, tokens are converted into numerical representations so a neural network can operate on them.
2. Embeddings — mapping tokens to high-dimensional vectors
Embeddings convert tokens into numerical vectors. Instead of feeding the raw token “dog” to the network, the model maps it to a vector such as[10, 3, 2] (toy example). Real embeddings have many more dimensions—commonly hundreds or thousands (1,536 dims is a common size in some models). Each dimension is a learned feature; semantic information is distributed across the vector.
![A slide titled "Generative AI Models" showing the token "dog" being converted via an embedding into a vector [10, 3, 2]. The vector is labeled as encoding semantic meaning and noted to have 1,536 dimensions.](https://mintcdn.com/kodekloud-c4ac6d9a/ZdXEe7d3muXYDMl5/images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Generative-AI-and-Agents/Generative-AI-Models/generative-ai-dog-embedding-1536.jpg?fit=max&auto=format&n=ZdXEe7d3muXYDMl5&q=85&s=9da7a3f41b11f102dd3e565a81e4fe31)
3. Contextualization with Transformers and Attention
Embeddings are static for a token in isolation, but meaning depends on context. Transformers use self-attention to update token vectors based on the entire sequence. Attention computes how much each token should influence another token’s representation—allowing the model to capture long-range dependencies. For example, in the sentence “I heard a dog bark at her,” when processing “bark,” the model should weight “dog” more heavily than unrelated words. The attention mechanism learns these weight patterns from data and produces context-sensitive representations.
- It computes pairwise influence scores between tokens (scaled dot-product attention is common).
- It enables the model to combine information from relevant tokens, even if they are far apart in the sequence.
- Multi-head attention lets the model attend to different aspects of the context simultaneously.
4. Generation — next-token prediction and sampling
Generation is performed by repeatedly predicting the next token conditional on the current context. Given a prefix like: “I heard a dog bark at a” the model computes a probability distribution over possible next tokens (e.g., “cat”, “puppy”, “car”, “skateboard”). It can either:- Choose the highest-probability token (greedy decoding), or
- Sample from the distribution (stochastic decoding) with parameters that control diversity:
- temperature — lower values make the distribution sharper (more deterministic); higher values increase randomness.
- top-k — restricts sampling to the k most probable tokens.
- top-p (nucleus sampling) — restricts sampling to the smallest set of tokens whose cumulative probability ≥ p.

Be careful when interpreting embedding distances or attention weights as direct explanations. They provide useful intuition, but internal representations are distributed and learned jointly across many parameters.
Quick reference: core pipeline
Key takeaways
- Tokenization converts text into units the model processes.
- Embeddings provide numerical vector representations of tokens.
- Transformers (with attention) create context-aware token representations.
- Generation proceeds via iterative next-token prediction; sampling parameters control output diversity.
- The whole pipeline is a sequence of learned transformations from text to numbers back to text.
- ChatGPT — OpenAI — example of iterative next-token generation in deployed LLMs.
- Transformer and attention mechanism papers and tutorials (search for “Attention is All You Need” and “transformer architecture” for in-depth explanations).