Module 21 · How Chatbots Work

How does a model know “kitten” is close to “cat”?

Lesson 21.2 · Words as Places on a Map

Felix · Rosa

Rosa: “Show me the map where whip is next to car.” Felix: “There’s a map?”

Felix tells the chatbot about his “whip” and it talks about cars, not dessert toppings.

Nobody defined “whip” for it. Somehow it landed near “car” on some map inside the model. Rosa wants to see the map.

The short answer

It read a few trillion words and noticed that “kitten” and “cat” keep the same company. So it placed them next to each other on its map. “Whip” landed near “car” for the same reason, and the map is why the chatbot talked about Felix’s Civic instead of cream.

Try it yourself

Tap around the word map. Words that mean similar things sit near each other. Nobody placed them by hand.

Tap around the word map. Words that mean similar things sit near each other. Nobody placed them by hand.catkittendogpuppyhamstercartruckengineCivicwhipteacherhomeworkquizessayclassroombasketballdunkreboundcoachgymvideothumbnailviewersstreamuploadAB

What you just did has a name

Embeddings

An embedding is a word (or a token, or a sentence, or an image) turned into a list of numbers that places it in a space where similar things are close together.

Models learn the placement from context: words that appear in the same kinds of sentences end up as neighbors.

“Whip” lands near “car” because people use them the same way.

A few more things

Meaning from company

The model never gets a dictionary. It sees “kitten” and “cat” used in the same kinds of sentences, next to the same kinds of words, and nudges their points together. Meaning, for a model, is who you hang out with.

Directions mean things too

In a well-trained map, the arrow from “king” to “queen” looks a lot like the arrow from “man” to “woman.” Nobody built that in. It fell out of the data, and it means the map has structure, not just neighborhoods.

This cracks Ashley’s comments

Embed all 640 comments as points and cluster them (Module 17). One dense cluster is comments that mention a bigger streamer. Ashley’s eyes skated over them for months. The map put them in one place.

Go deeper

The longer version, if you want it.

Hundreds of dimensions

The app’s map is two-dimensional so you can see it. Real embeddings have hundreds or thousands of dimensions, one list of numbers per token, and “close” is the distance formula from lesson 17.1 extended that far. Two-dimensional pictures of them are made by squashing the real space down, which keeps neighborhoods roughly right and distorts everything else.

Embeddings are the bridge between Module 17’s clustering and Module 21’s chatbot: once text is points, every tool for points applies. Search engines, recommendation systems and spam filters all run on some version of this map.

Quick check

A model trained only on cooking blogs learns embeddings. Where does “whisk” probably land?

Let’s take it slower

Try it this way: imagine a school gym where everyone drifts over to stand next to the people they’re always seen with. Nobody assigned spots. From across the room you can now tell who hangs out together without knowing anyone’s name. Embeddings do that with words. Every time two words show up in the same sort of sentence, the model nudges their spots a little closer. After a trillion nudges, the distance between any two words is a measure of how alike they are, and nobody drew the map.

More examples

1

Search that forgives your wording

Type “cheap shoes for running” into a store search and it returns “budget sneakers.” Not one word matched, and plain keyword matching would have shown you nothing. The store embedded your query and its products as points, and the closest points won.

2

The playlist that gets your mood

A music app embeds songs from which ones people play back to back. Two tracks from different decades that share no words in their titles end up neighbors because the same listeners play them together. That’s why the song after your favorite feels right.

Back to the question

So how does it know kitten is near cat?

Show the answer

It read a few trillion words and noticed that “kitten” and “cat” keep the same company. So it placed them next to each other on its map. “Whip” landed near “car” for the same reason, and the map is why the chatbot talked about Felix’s Civic instead of cream.

More on this: How does ChatGPT work?

One last question

Felix explains embeddings to Owen. Trust him?

“Similar words end up close together because they’re used in similar sentences.”

“Someone at the company placed each word on the map by hand.”

“You can embed comments as points and then cluster them.”

Talk Card

Talk Card · 21.2

Embeddings turn words into points on a map where similar meanings sit close together, learned from which words keep the same company.

Data to AI · pettigrewlab.com/learn

Next lesson