ChatGPT answers questions about: How LLMs work, part 2
How LLMs Work, Part 2
Where knowledge seems to live inside the model: embeddings, latent space, and concept relationships.
Purpose of this document
This page continues the earlier conversation in the same educational style. It is meant to be readable and explanatory rather than formal or academic. The goal is to help the reader build a practical mental model of how a language model represents relationships between ideas.
Conversation Transcript
User Prompt
Continue from the earlier discussion and go deeper into how knowledge is represented inside an LLM. Explain embeddings, latent space, and why the model can generalize instead of only repeating memorized text.
Assistant Response
1. Knowledge is not stored like a database
A language model does not usually store facts as neat sentences in a lookup table. Instead, it learns statistical relationships between words, phrases, and concepts.
So rather than storing a sentence such as “Paris is the capital of France” in a literal way, the model learns patterns connecting ideas like France, capital, and Paris.
2. Embeddings
After text is broken into tokens, each token is converted into numbers. That numerical representation is called an embedding.
The numbers are not meaningful by themselves. Their value comes from how one embedding relates to other embeddings.
Paris → [ 0.21, -0.88, 0.47, 0.02, ... ]
3. Latent space
You can think of an embedding as a location in a very large mathematical space. This is often called latent space.
It is not a physical space like a room or a map on paper. It is a space with many dimensions where related concepts tend to end up closer together and less related concepts tend to be farther apart.
4. Concepts form regions
Single words may be represented as points, but broader meanings are better thought of as regions or clusters. Countries tend to group near other countries, cities near other cities, and related ideas near one another.
Countries: France, Germany, Italy, Spain
Cities: Paris, Berlin, Rome, Madrid
5. Relationships can behave like directions
An important idea in this kind of representation is that relationships can sometimes act like directions in the space. A classic example is the intuition:
King − Man + Woman ≈ Queen
The point of the example is not that the model is doing symbolic algebra. The point is that it has learned patterns of relationship that can sometimes be expressed geometrically.
6. Why the model can generalize
The model can answer new questions because it has learned patterns rather than only memorized exact sentences. If it sees enough examples of countries, capitals, and cities, it can apply that pattern when a new prompt asks for a capital.
capital(Italy) → Rome
capital(Germany) → Berlin
capital(Spain) → Madrid
capital(France) → Paris
In simple terms, the model learns how pieces of meaning tend to fit together.
7. Why hallucinations happen
When the prompt is incomplete or the learned relationships are ambiguous, the model can move toward the wrong answer region. That is one way to think about hallucinations: the output sounds plausible because it follows patterns, but it lands in the wrong place.
Prompt = starting point
Context = guidance
Answer = next path through learned patterns
8. Practical takeaway
A useful mental model is that an LLM works with patterns of relationship in a high-dimensional space. It does not “look up” meaning the way a database would. It builds a response by using context to navigate those learned relationships one token at a time.
Key takeaway
What looks like stored knowledge is better understood as learned structure. The model represents relationships between concepts, and that is why it can both generalize impressively and also sometimes produce confident but incorrect answers.
Better prompts and better context improve the odds that the model will move through the right conceptual neighborhood.