Module 01 · AI · Neurons to a language model · about 20 min to read
Continue where you left off ×
Tokens & Embeddings
Tokens and Embeddings · Open board
The Tokens and Embeddings board on the How LLMs Work track. This is the story of how people got words into a machine that can only add and multiply, and it ends with a map you can do arithmetic on.
Before you start. From What a Neural Network Is you need one fact: a neural network is votes times dials, added up, row after row, and it eats numbers and nothing else. A sentence is not a number, so something has to happen to text first. That something is this lesson.
The idea in 30 seconds
A network eats numbers, so text is cut into tokens and each token is swapped for its embedding, a list of numbers.
Numbering words invents a false order. One-hot, one drawer per word, invents none but says nothing, because every pair of different words scores exactly zero.
Firth’s idea is that a word is knowable from the company it keeps, and counting company is something a machine can do.
word2vec’s embeddings showed the counted map has directions in it: king − man + woman lands on queen.
BPE finds tokens by merging the commonest adjacent pair over and over, so common text is cheap forever and rare text is expensive forever.
The merges are frozen before training. The embedding table is learned during it.
Read the story
Lesson 7 of 83 in AI
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year .
See plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson The machine that only eats numbers One-hot: one drawer per word, and why it says nothing 1957, London: where to put a word on the map, the company it keeps 2013, Google: word2vec, and the embedding that gave the map directions What gets a row on the map: one per word, or one per letter? 1994: byte-pair encoding, a compression trick nobody meant for language What a token costs: about four characters, and six times more in Hindi The two steps end to end: a frozen tokenizer, then a learned embedding table Where the map lives How near is near? The arrow that says “make it female” Does the map ever change? All of it in code Terms it explains: Tokens and Embeddings, How LLMs Work, one-hot, map, embedding, byte-pair encoding, token, cosine, analogy arithmetic, BPE, cosine similarity, dense vector, dimension d, embedding matrix, positional encoding, semantic search, static vs contextual embedding, token ID, tokenizer, vector database, vector space, vocabulary.
Review AI
Mark as read Saved in this browser, and to your account when you sign in.