What Really Happens When You Chat with AI
A second later, a response appears. Clear. Relevant. Almost natural. But what actually just happened is something very different.

A Look Inside Large Language Models

It starts simply.
You open a chat window and type:
“I want coffee.”
A second later, a response appears. Clear. Relevant. Almost natural.
It feels like a conversation.
But what actually just happened is something very different.
A Conversation That Isn’t One

When we talk to another person, a lot happens beneath the surface:
- We recall memories
- We interpret tone
- We infer intent
- We respond based on experience
When you type that same sentence to an AI, none of that happens.
There is no memory of drinking coffee. No preference. No intention.
Instead, the system begins a transformation.
The Moment Your Words Stop Being Words
The first thing the model does is break your sentence apart:
["I", "want", "coffee"]If you’ve ever learned compiler design, this step feels familiar. It’s similar to lexical analysis.

But then each token becomes a vector:
"I" -> [0.12, -0.98, ...]
"want" -> [0.44, 0.21, ...]
"coffee" -> [0.91, -0.33, ...]At this point, your sentence is no longer language.
It has become mathematics.
A World Made of Coordinates
Imagine a massive, invisible space.

Every word lives somewhere inside it — not as text, but as coordinates.
- “coffee” sits close to “tea”
- “engine” sits near “car”
- “happy” drifts far from “failure”
Meaning, in this world, is distance.
The Guessing Game
Now comes the core of everything.
Given:
“I want coffee”
The model predicts what comes next.
But it’s not choosing from a small list.
It is evaluating thousands of possible tokens at once .
For simplicity, we can imagine a tiny slice of that:

These are not the only options — just a simplified snapshot.
In reality, the model assigns probabilities across its entire vocabulary.
Why These Words?
Because the model has learned patterns from data:
- “coffee”, “tea”, “water” → often appear in similar contexts
- “pizza” → still possible, but less related
So the model is not thinking:
“Do I want coffee or pizza?”
It is computing:
“Given this context, how likely is each possible next token?”
Key Insight

The model doesn’t pick from a shortlist.
It ranks everything — and then selects.
From Prediction to an Answer
At this point, it’s tempting to think:
“So AI is just autocomplete?”
That’s partially true — but incomplete.
The model is not simply continuing your sentence. It is completing the assistant’s role within a conversation , step by step.
Let’s walk through what happens, systematically.
Step 0 — Build the Full Context
What you type is wrapped with instructions and conversation history. Conceptually, the model sees something like:
[System]
You are a helpful assistant.
[Conversation]
User: What is cappuccino?
Assistant:This matters because the model is asked to continue the assistant’s turn , not your sentence.
Step 1 — Tokenization
The entire context is split into tokens:
["User", ":", "What", "is", "cappuccino", "?", "Assistant", ":"]These tokens are the units the model works with.
Step 2 — Embedding (Numbers, Not Words)
Each token is mapped to a vector (a list of numbers). The sequence becomes a matrix the model can process.

Step 3 — Context Processing (Transformer + Attention)
The model processes all tokens together using attention:
- Which tokens matter most?
- How do they relate?
For example, “cappuccino” strongly influences what comes next, and the presence of Assistant: signals the role to play.

Intuition
- Not all words are equally important
- The model assigns weights (attention scores)
- Important tokens influence the next prediction more
Step 4 — Compute Probabilities (First Token)
The model produces a probability distribution over the entire vocabulary for the next token after Assistant:.
A simplified slice might look like:

Then one token is selected (depending on sampling settings).
Assume it picks: “A”
Step 5 — Append and Update Context
The generated token is appended to the sequence:
... Assistant: ANow the model has a new context and repeats the same process.
Step 6 — Repeat (Autoregressive Loop)
The loop continues:
- Next prediction → “cappuccino”
- Append → Assistant: A cappuccino
- Next prediction → “is”
- Append → Assistant: A cappuccino is
- Next prediction → “a”
- Next → “coffee”
- Next → “drink”
- …
Each step:
- Re-reads the entire current sequence
- Recomputes attention
- Predicts the next token
Step 7 — Stopping Condition
The generation stops when one of the following happens:
- An end-of-sequence token is produced
- A length limit is reached
- The system decides the answer is complete
What Emerges From This Loop
At no single step does the model “know” the full answer.
There is no moment where it plans everything from beginning to end. No internal outline. No deliberate reasoning in the human sense.
Instead, something more subtle happens.
As the model generates one token at a time, each new token becomes part of the context for the next prediction. With every step, the model re-evaluates the entire sequence — what has been said, what role it is playing, and what typically comes next in similar situations.
Gradually, structure begins to emerge.
A definition appears before an explanation. A sentence flows naturally into the next. The response maintains coherence, even though it was never fully “planned” in advance.
This is the surprising part.
What looks like a carefully constructed answer is actually the result of many small, local decisions — each one selecting the most likely next token given the current context. Over time, these local predictions accumulate into something that feels globally consistent.
In other words, the response doesn’t come from a single act of thinking.
It emerges from a continuous process of prediction.
Key Insight
A full answer is not generated at once.
It is constructed incrementally , where each token is:
- locally optimal (most likely next step)
- conditioned on everything generated so far
Why It Feels Like Reasoning
Because this loop creates structure.
The model:
- Maintains context
- Follows patterns
- Produces logical flow
But it is not planning ahead.
It is continuously adjusting.
Closing Thought
When you chat with AI, you are not interacting with a thinking system.
You are interacting with a system that:
- Turns language into numbers
- Maps meaning into space
- Predicts one token at a time
It doesn’t think.
It predicts.
And somehow, that prediction becomes something that feels like understanding.
At least, that’s how I currently understand it — CMIIW.
References
- Artificial Intelligence: A Modern Approach Russell, S., & Norvig, P. (2021). Artificial Intelligence: A Modern Approach (4th ed.). Pearson.
- Compilers: Principles, Techniques, and Tools Aho, A. V., Lam, M. S., Sethi, R., & Ullman, J. D. (2006). Compilers: Principles, Techniques, and Tools (2nd ed.). Pearson.
- Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., & Polosukhin, I. (2017). Attention is all you need . In Advances in Neural Information Processing Systems (NeurIPS).
- Brown, T. B., Mann, B., Ryder, N., Subbiah, M., Kaplan, J., Dhariwal, P., et al. (2020). Language models are few-shot learners . In Advances in Neural Information Processing Systems (NeurIPS).


Discussion
Comments
Replying to