Privacy note: We capture your IP address to provide customised and focused services. See our Privacy Policy.

Generative AI & Large Language Models — Alpha School

Lesson 4: From Words to Meaning: Language and Context

When you read the word 'dog', a whole cloud of meaning arrives with it: an animal, a pet, loyal, barks, needs walks. A language model has no such cloud — it has numbers. Yet those numbers carry something surprisingly like meaning, and understanding how is the key to understanding what these models can and cannot do. The trick is that meaning, for a model, is a position in a space.

Imagine every word placed as a point in a vast space with hundreds of directions. Words that appear in similar contexts sit near each other: 'dog' near 'cat' and 'puppy', 'king' near 'queen' and 'prince'. Words that mean very different things sit far apart. This is what an embedding is: a list of numbers that places a word in that space, learned from the contexts in which the word appears. The famous demonstration is arithmetic with words: the position of 'king', minus 'man', plus 'woman', lands close to the position of 'queen'. Nobody programmed that in; it fell out of the patterns of language itself.

Meaning from company kept

The principle behind embeddings is old and simple: you shall know a word by the company it keeps. Words that show up beside similar words — 'bark' beside 'dog' and 'tree', but in different senses — end up with embeddings that capture those associations. Attention then refines those embeddings in context, so the same word 'bark' ends up in a different place in the space when the sentence is about a dog than when it is about a tree. That is how a model, which only ever sees numbers, can still behave as if it knows what words mean.

But there are limits, and they matter. An embedding captures how a word is used, not what it refers to in the world. The model knows that 'Paris' sits near 'France' and 'capital', but it has never seen Paris, and it cannot check whether a claim about Paris is true. It knows the pattern of a recipe, but it has never tasted food. Its meaning is entirely second-hand, built from text about the world rather than from the world itself. That is why it can write beautifully about things it does not understand, and why its confident statements about the real world always need checking.

Words that change with time

Embeddings are learned from the text of a particular time, and language moves on. The word 'cloud' once sat near 'rain' and 'sky'; in text from the last twenty years it also sits near 'computing' and 'storage'. A model trained mostly on older text will know the older meaning better, and one trained on recent text will know the newer one. New words appear too — names of new technologies, new slang, new public figures — and a model whose training ended before they appeared has no embedding for them at all, only the pieces they split into. This is one more reason a model's knowledge has a date on it, and why the question 'when was this model trained?' matters whenever you ask it about something recent. It is also why retrieval, in Lesson 11, matters so much: documents written today can supply the meanings and facts that the model's frozen embeddings cannot.

This also explains one of the model's most human-seeming behaviours: it is good at analogy and association, because those live in the geometry of the embedding space. Ask it to complete an analogy and it will often succeed, not by reasoning but by moving through that space. Keep that picture in mind when you use these models: you are navigating a map of how words are used, drawn from an enormous library of text — a powerful map, but a map of language, not of the world.

Watch & Learn

One video to watch for this unit, from a trusted educator.

Key Terms

Embedding
A list of numbers placing a word in a space where words used in similar contexts sit near each other.
Embedding space
The vast space of numbers in which words are placed; distance in the space reflects similarity of use.
Context
The words around a word, which decide its meaning in a particular sentence and refine its embedding.
Analogy
A comparison such as king is to man as queen is to woman, which embeddings can capture through positions in the space.
Semantics
Meaning in language; for a model, meaning is captured by patterns of use, not by experience of the world.
Polysemy
One word having several meanings, such as 'bark' for a dog's sound and a tree's covering, which context must sort out.

Discussion Questions

  1. If meaning for a model is just a position in a space, what is missing compared with how you understand a word?
  2. Why can a model be good at analogies while still not understanding anything?
  3. Two words appear in very similar contexts but mean opposite things, like 'hot' and 'cold'. How would their embeddings compare, and why?

Practice Questions

  1. What is an embedding, in one sentence?
  2. What does 'you shall know a word by the company it keeps' mean?
  3. Why can the same word 'bark' end up in different places in the space?
  4. What is missing from a model's understanding of 'Paris'?
  5. Give one thing embeddings are good at, and one thing they cannot do.
Show answers
  1. A list of numbers placing a word in a space where words used similarly sit near each other. It is learned from the contexts in which the word appears.
  2. A word's meaning is learned from the words that appear around it. Words that show up beside similar words end up with similar embeddings.
  3. Because attention refines its embedding using the context of the sentence. In a sentence about a dog it means one thing; in a sentence about a tree, another.
  4. Any experience of the real place; it only knows how the word is used in text. It knows 'Paris' sits near 'France' and 'capital', but it has never seen Paris and cannot check facts about it.
  5. They are good at analogy and association; they cannot check whether a claim about the world is true. Analogy lives in the geometry of the space, but truth needs contact with the world, which the model does not have.
Keep reading to complete this lesson