Skip to content

Step-by-step build path + extra help

Web Presence Workshop

Figure out your message, choose the look, add proof, and publish without getting lost.

Lesson 2 · Module 2

How models learn

You do not need to be a mathematician. You need to understand what happens when you type a prompt — from words to numbers to meaning.

This lesson walks through the pipeline step by step: words become numbers, numbers capture meaning, and the model uses that meaning to generate a response. Every concept here connects to something you will do when you write prompts.

Step 1

Words as numbers

Each word gets turned into a list of numbers called an embedding. The numbers encode meaning, not just spelling.

When you type a prompt, the model does not read words. It converts each token — roughly a word or word-piece — into a vector: a list of numbers that represents its meaning.

What an embedding looks like

mathbfe=[e1,e2,ldots,en]\\mathbf{e} = [e_1, e_2, \\ldots, e_n]

Each eie_i is a number. A typical model uses hundreds or thousands of dimensions — far more than we can picture, but the principle is the same as placing a pin on a map.

The key insight: words with similar meanings get similar numbers. “Dog” and “puppy” end up close together. “Dog” and “spreadsheet” are far apart. The model learns these positions during training — nobody hand-codes them.

Step 2

Similarity as closeness

Words that mean similar things end up near each other in this space. We measure closeness with cosine similarity.

If two vectors point in nearly the same direction, their meanings are related. The technical name is cosine similarity: it measures the angle between two vectors.

textsimilarity(mathbfa,mathbfb)=fracmathbfacdotmathbfb∣mathbfa∣,∣mathbfb∣\\text{similarity}(\\mathbf{a}, \\mathbf{b}) = \\frac{\\mathbf{a} \\cdot \\mathbf{b}}{\\|\\mathbf{a}\\| \\, \\|\\mathbf{b}\\|}

Close to 1 means very similar. Close to 0 means unrelated. You never need to compute this yourself — the model does it billions of times during training and inference.

Embeddings neighborhood diagramA schematic embeddings workflow showing a user query becoming a query vector, comparing against stored document vectors, retrieving nearest neighbors, and passing retrieved context into an LLM response.User queryfind similar notesEmbedding modelmaps text to coordinatesQuery vector[0.12, -0.40, ...]Vector storenearest neighbors cluster around the queryRetrieved chunksdoc A, doc B, doc CContext bundleranked passages + queryLLM responseretrieval uses vector similarity before generation
Schematic, not literal. The goal is to show why embeddings are useful: learned coordinates make nearest-neighbor retrieval possible before the language model writes an answer.

The diagram above shows how embeddings power retrieval: your query becomes a vector, the system finds the nearest stored vectors, and those retrieved passages become context for the language model's response.

Step 3

Latent space — the learned map of meaning

Think of it as a map the model builds during training. Every word, sentence, and concept gets a location.

Visualization of a latent space landscape — a terrain map where nearby peaks represent similar concepts

The space of all embeddings forms what researchers call a latent space. “Latent” means hidden — these dimensions are not visible to us, but the model uses them constantly.

Neighboring regions in latent space capture related ideas. Move in one direction and the tone shifts from formal to casual. Move in another and the topic shifts from cooking to chemistry. The model navigates this space every time it generates a word.

Why this matters for prompting

When you write a clear, specific prompt, you are giving the model better coordinates. Vague prompts land in a crowded region of latent space where many possible responses overlap. Specific prompts point to a smaller, more useful neighborhood.

Step 4

The pipeline: token → representation → attention → output

Here is what happens inside the model when you type a prompt.

Diagram showing the pipeline from text tokens through representation learning to model output
  1. 1. Tokenization. Your text is split into tokens — roughly words or word-pieces. Each token gets an ID.
  2. 2. Embedding lookup. Each token ID is converted to a vector (the embedding). Now the model has numbers instead of text.
  3. 3. Self-attention. The model looks at every token in relation to every other token. This is the “attention” in “Attention Is All You Need.” It lets the model understand context — what “it” refers to, which words modify which.
  4. 4. Feed-forward layers. The contextualized representations pass through dense layers that transform and combine information.
  5. 5. Output prediction. The model predicts the next most likely token. Then it feeds that prediction back in and repeats — one token at a time — until the response is complete.

This entire pipeline runs in the Transformer architecture — the same design behind GPT, Claude, Gemini, and every modern foundation model. The details vary, but the pattern is always: tokenize, embed, attend, predict.

Takeaway

Why this matters for your work

Understanding the pipeline helps you write better prompts and evaluate model output more clearly.

When you write a clear prompt, you are giving the model better coordinates to work with. When the model hallucinates, it is because it landed in a region of latent space where plausible- sounding text exists but truth does not.

You do not need to understand the math to use these tools well. But knowing that the model works with learned representations — not understanding — helps you stay honest about what it can and cannot do.

Now you know how models turn words into meaning and meaning into responses. Next, meet the people who built these systems — and understand why their choices shaped the tools you use today.

Continue to Lesson 3 →