How we got here

Sign in to save progress
0:00
0:00

On this lesson: How machines played chess using logic

The discussion is for premium members.Go premium
  • Be the first to say something about this lesson.

Prefer reading? Every lesson in this course as text

Read this lesson as text: How machines played chess using logic

How machines played chess using logic

How does a chess machine work? Let's try to understand. In a simple way. The first chess machines never learned anything.

Everything they knew, a human typed in by hand. The rules, and what makes a position good. So how does it pick a move? It lists every legal move from this position.

Then every reply to each of those. That fan is the game tree. But branches are just shapes. To compare two positions it needs a number.

So a human wrote a scoring rule. A pawn is one point, a knight three, a rook five. That is the evaluation function. Now the logic.

On its own turn the machine takes the highest score. On your turn, it assumes you take the lowest. It plans against your best reply, not your worst. Those scores flow back up the tree.

Each position takes the value of the branch beneath it. That is minimax. The best move on top wins. It can never search to the end of the game.

So it stops at a fixed depth, a few moves ahead, and scores what it finds there. Deep Blue beat the world champion this way, in nineteen ninety seven. Two hundred million positions a second. No understanding.

Just search, and a human's score. And here is the strange part. It has no idea it is playing chess. Swap that scoring rule, and the same machine plays checkers.

So, chess by logic is a tree of moves, a handwritten score, and minimax picking between them. Knowledge in, by hand. Quick check now. One question is coming up.

Let's see if it clicked.

Read this lesson as text: Why simple rules fail at complex problems

Why simple rules fail at complex problems

What exactly is a brittle rule? Let's try to understand. In a simple way. Chess fell to handwritten rules.

But chess is a closed world. Every legal move is listed, nothing is hidden, and winning has one clean definition. Now ask the same machine to spot a bird in a photo. There is no rulebook for that.

Nobody wrote one down. So you write it yourself. If it has wings and it flies, it is a bird. That works on the first ten photos.

Then reality arrives. A penguin cannot fly. Neither can an ostrich. A bat flies and is not a bird.

Each one needs its own patch. And the patches need patches. Every exception can collide with a rule already there. Ten rules take a morning.

Ten thousand take years, and they contradict each other. Here is the real trouble. Inside the cases you covered, the system is perfect. One step outside, it does not bend.

It snaps. That is what brittle means. And the deeper problem. You cannot write down most of what you know.

You spot your mother's face in a crowd, and you cannot say one rule for how. So the machine never knows more than the person typing. That is the wall the rules era hit. Which forces the flip.

Stop typing rules. Show the machine thousands of labeled photos, and let it find the rule itself. So, rules fail because the exceptions never end, and because we cannot say what we know. Learn the rule.

Do not type it. Quick check now. One question is coming up. Let's see if it clicked.

Read this lesson as text: What is an expert system's knowledge base

What is an expert system's knowledge base

What exactly is an expert system's knowledge base? Let's try to understand. In a simple way. Back in the nineteen seventies, people wanted a computer to make expert decisions.

Like a doctor, or a geologist. These programs were called expert systems. Every expert system splits into two parts. One part does the thinking.

The other part holds what the system actually knows. That second part is the knowledge base. So what is inside it? First, facts.

Plain statements the system treats as true. The patient has a fever. The rock contains iron. Second, rules.

Each one is an if then statement. If the patient has a fever and a rash, then suspect measles. Human knowledge, written as a rule. Where do the rules come from?

A person sits with a real expert for weeks, and writes their know how down, one rule at a time. Then a separate program, the inference engine, reads the base. A known fact triggers a rule. That rule adds a new fact.

Which can trigger the next rule. Why keep them apart? Because now the knowledge is just data. You can add or fix a rule without rewriting the program that reasons over it.

And every rule is written in plain sight. So the system can show its work. It concluded measles because rule twelve fired. Nothing hidden.

So a knowledge base is a human expert's know how, written out as facts and if then rules, kept separate so a machine can reason over it. Quick check now. One question is coming up. Let's see if it clicked.

Read this lesson as text: How a single neuron learns to classify

How a single neuron learns to classify

How does classifying with one neuron work? Let's try to understand. In a simple way. Picture one tiny neuron with a simple job.

Sort each example into one of two groups. It takes in the features of the example, a few numbers. Each input gets its own weight, a dial for how much it matters. The neuron multiplies every input by its weight.

Then it adds all those weighted inputs into one number. That number is the neuron's score for this example. Now compare that score to a threshold. Above it, the neuron fires and calls the example group one.

Below it, it stays quiet and says group two. Here is the hidden picture. The weights quietly draw a straight line through the data. Group one on one side, group two on the other.

The neuron just picks a side. At the start, the weights are random, so the line sits in the wrong place. Show it an example, it guesses a group, and often it guesses wrong. Now the real learning.

On every mistake, nudge each weight a little toward the right answer. That shove pushes the line in the direction that fixes this example. Sweep through the examples again and again. Each mistake shifts the line a bit more.

When one line can split the two groups, the mistakes stop. That is the perceptron learning rule. So, a single neuron weighs its inputs, adds them up, and fires past a threshold. Each mistake nudges the weights, until the line separates the two groups.

Quick check now. One question is coming up. Let's see if it clicked.

Read this lesson as text: How networks learn together from their mistakes

How networks learn together from their mistakes

How does learning from mistakes work? Let's try to understand. In a simple way. A single neuron can only learn simple splits.

So we stack neurons into layers and wire them into a network. Now it can learn much richer patterns. You feed an example in at the front. It flows through the layers, and out comes a guess.

Say it should read a digit, and it answers seven. But the real answer was three. So the guess was wrong. We measure exactly how wrong with a single number.

That number is the error. Here is the hard part. Hundreds of neurons all touched that answer. When it comes out wrong, which one is to blame?

Each one played a part. The trick is to send the error backward through the network. Layer by layer, from the output toward the input. This is called backpropagation.

As the error travels back, every neuron learns its own share of the blame. How much its weights pushed the answer in the wrong direction. Then each neuron nudges its weights a little, in the direction that shrinks the error. Small steps, downhill, toward a better answer.

And they all do this at once. The whole network adjusts together, from one shared mistake. Then the next example arrives, and it happens again. Repeat over millions of examples, and the network slowly gets good.

This one idea, from nineteen eighty six, is what let deep networks finally learn. So, guess, measure the error, send it backward, and let every neuron fix its share. That is how networks learn together. Quick check now.

One question is coming up. Let's see if it clicked.

Read this lesson as text: Why early neural networks hit a wall

Why early neural networks hit a wall

What exactly is the wall that early neural networks hit? Let's try to understand. In a simple way. By the late nineteen eighties, the recipe worked.

Small networks learned real tasks. But when researchers stacked the layers deeper, progress stopped. Depth was supposed to be the prize. Each layer builds on the last, so a deeper network should see richer patterns.

But something odd showed up. The layers near the output learned fine. The layers near the input barely changed at all. Here is why.

Every layer squashed its signal through a sigmoid curve. Sending the error back through that squash shrinks it, by about one quarter or worse. Now shrink it once per layer. After five layers the correction is a thousandth of its size.

After ten, it is basically nothing. So the early layers got almost no correction. They stayed near their random starting values. Deep in name only.

This is the vanishing gradient. Two more walls stood alongside it. Datasets held only a few thousand examples. And one training run could take weeks on the processors of that era.

So results looked weak next to simpler methods. Funding dried up, and most researchers walked away from neural networks for years. The wall fell when three things arrived. Activations that do not squash.

Datasets with millions of examples. And graphics chips that train in hours. So, the wall was a fading signal. The correction died before it reached the early layers.

Fix that, and depth finally pays off. Quick check now. One question is coming up. Let's see if it clicked.

Read this lesson as text: How computers learned to recognize images

How computers learned to recognize images

How does image recognition work? Let's try to understand. In a simple way. To a computer, a photo is just a grid of numbers.

One number for each pixel, saying how bright that spot is. Early networks flattened that grid into one long list. Every pixel got its own weight, so the weights exploded. And shifting the cat broke everything.

So stop looking at the whole picture at once. Slide a small window across it, and read one little patch at a time. The window carries a filter. A tiny grid of learned numbers.

It scores the patch underneath, and fires hardest when the patch matches its pattern. The same filter runs at every position. A pattern learned in one corner is then found anywhere in the frame. That is weight sharing.

Each filter leaves a map, bright wherever its pattern appeared. Many filters run side by side, so one image becomes a stack of maps. Then each map is shrunk, keeping only the strongest score in every small block. That is pooling.

Small shifts stop mattering. Stack these layers and the patterns grow up. Edges first. Then corners and textures.

Deeper layers respond to eyes, wheels, whole faces. This design is the convolutional network. By nineteen eighty nine, one was reading handwritten digits on mail. In twenty twelve, a deep one on graphics chips cut the ImageNet error from twenty six percent to fifteen.

So, small filters, reused everywhere, stacked into layers. That is how computers finally learned to see. Quick check now. One question is coming up.

Let's see if it clicked.

Read this lesson as text: How networks developed a short term memory

How networks developed a short term memory

How does a network's short term memory work? Let's try to understand. In a simple way. Early neural networks had no memory at all.

Feed in one input, get one answer, and everything is wiped. The next input starts from nothing. But language is a sequence. In the phrase, he sat on the river bank, the word bank only makes sense because of the words before it.

So in the nineteen eighties, researchers added one thing. A loop. The network feeds its own result back into itself, ready for the next word. What travels around that loop is a small bundle of numbers.

The hidden state. A running summary of everything read so far. Each step does the same thing. Take the new word, take the old state, mix them, and produce a new state.

That is the recurrence. Stretch it out in time and you see a chain. One copy of the cell per word, each handing its state to the next. And here is the neat part.

Every copy uses the same weights. One small network, reused, so it reads a sentence of any length. The answer is read off the state. At every step if you want the next word.

Or once at the end for one label. That state is the only memory there is. A fixed bundle, rewritten at every step. That is why we call it short term.

So, a loop, plus a hidden state carrying the past. That is how a network first learned to remember. Quick check now. One question is coming up.

Let's see if it clicked.

Read this lesson as text: Why network memory used to be so short

Why network memory used to be so short

What exactly is the limit on a network's memory? Let's try to understand. In a simple way. Start with a test.

I grew up in France, so I speak fluent, blank. To fill it in, the network needs a clue from twenty words back. The last few words it handles fine. But stretch the gap out, and the clue at the start has faded away.

Why? Look at how it learns. The error at the end must travel backwards along the chain, one step at a time, to reach France. And every step of that journey passes through the same weights.

So the signal is multiplied by the same factor, over and over. Say that factor is eight tenths. Twenty steps back, the signal is about one hundredth of its size. At fifty steps, near enough to zero.

So the correction never reaches France. The link is never learned. It is the vanishing gradient again, fading across time instead of across layers. Nudge the factor above one and you get the opposite.

The signal doubles and doubles, the weights blow up, and training falls apart. Either way the useful memory is short. In practice a plain recurrent network holds about ten words. Fine for a phrase.

Hopeless for a paragraph. The fix came in nineteen ninety seven. Gates. A cell that can hold a value untouched for many steps, so the signal crosses the gap.

So, memory was short because the signal was multiplied at every step. Repeat that enough and it dies. Gates keep a road open. Quick check now.

One question is coming up. Let's see if it clicked.

Read this lesson as text: How words look at each other for context

How words look at each other for context

What exactly is attention? Let's try to understand. In a simple way. Older translation models squeezed a whole sentence into one summary vector.

By the end of a long sentence, the first words were a blur. So in twenty fourteen, researchers tried something else. Keep one vector per word, and let the model look back at all of them. Take this sentence.

The animal did not cross the street because it was too tired. What does the word it point to? To decide, the word it compares itself against every other word in the sentence. Each comparison gives a number.

A relevance score. Those scores go through softmax, so they become weights that add up to one. Animal takes most of the weight. Street takes almost none.

Then the word rebuilds itself as a weighted blend of the others. So it is now mostly made of animal. Context, absorbed. The real machinery has three parts.

Each word sends out a query, what am I looking for. And a key, what I offer. The score is one word's query matched against another's key. Match well, and that word's value, what it passes on, flows across.

Every word does this at once. So bank by a river, and bank holding money, come out as two different vectors. Same word, different context. So, compare, weight, blend.

Attention lets every word look at the others, and pick up the meaning it needs. Quick check now. One question is coming up. Let's see if it clicked.

Read this lesson as text: The architecture that connects all the words

The architecture that connects all the words

How does a transformer work? Let's try to understand. In a simple way. The older networks read a sentence one word at a time.

Word one hundred had to wait for the ninety nine before it. Long texts crawled. In twenty seventeen a team tried something bold. Remove the loop completely.

Let every word of the sentence enter the model at the same moment. But if all the words arrive together, the model no longer knows their order. So every word carries a position number, added straight into the vector that represents it. Now the architecture itself.

It is one block, repeated. Inside a block, step one lets the words look at each other and share information. Step two is a small neural network that runs on each word on its own. The same weights at every position.

Mix, then think. That is the block. Around each step there is a shortcut. The block adds its result to what came in, then normalizes the numbers.

That is what keeps a deep stack trainable. Then you copy that block. Twelve times, ninety six times, sometimes more. Early blocks catch grammar.

Later ones carry meaning across the whole passage. And here is the real prize. With no loop, every position is computed at the same time. Graphics chips stay busy, so training can run on far more text.

So, a transformer is a stack of identical blocks. Words share information, each word is processed on its own, add and normalize, repeat. All positions at once. Quick check now.

One question is coming up. Let's see if it clicked.

Read this lesson as text: How a model learns from the entire internet

How a model learns from the entire internet

How does pretraining work? Let's try to understand. In a simple way. Earlier machine learning needed labelled examples.

A photo, with a human typing cat underneath. Nobody can hand label the whole internet. So pretraining uses a trick. Hide the next word, and ask the model to guess it.

The answer already sits in the text, so nobody writes a label. That is self supervised learning. Now the training set can be enormous. Crawled web pages, books, code, encyclopedias.

Cleaned, deduplicated, and chopped into trillions of tokens. One step works like this. Feed in a chunk of text. The model gives every word in its vocabulary a probability.

Compare that with the word that really came next. If the true word got a low score, the guess was poor. That gap is the loss. The loss travels backward, and every weight shifts a hair in the direction that would have made the true word more likely.

Then the next chunk arrives. Repeat that millions of times, on thousands of chips, for weeks. Whatever pattern holds across the whole pile is what sticks. Here is the strange part.

To guess the next word well, you need grammar, facts, style, even a little reasoning. Nobody taught them separately. What comes out is called a base model. It continues text beautifully, but does not yet answer your questions politely.

So, pretraining is one move repeated. Hide the word, guess, measure, nudge. Do that across the internet, and knowledge settles into the weights. Quick check now.

One question is coming up. Let's see if it clicked.

Read this lesson as text: How we specialize a model for one task

How we specialize a model for one task

How does fine tuning work? Let's try to understand. In a simple way. A pretrained model has read the whole internet.

It knows a little about everything. But you want one job done well. Why not train a fresh model on your own data? Language takes trillions of words.

A few thousand examples would teach it almost nothing. So we do the opposite. Take the pretrained weights, and keep training them on your own data. That is fine tuning.

The new data is shaped like the job. An email, and the label you want back. Refund, bug report, or billing. A few thousand pairs is plenty.

The loop itself does not change. Feed one example, compare the output with the answer you wanted, and push the loss backward. One thing does change. The learning rate drops sharply.

Big steps would overwrite what pretraining stored. Small steps only tilt it. Push too hard on too little data, and the model forgets its general skill. That is catastrophic forgetting.

A held out set catches it. Why does this work? The early layers already hold grammar and meaning. Only the last part learns your labels.

That is transfer learning. And it is cheap. Pretraining runs for weeks on thousands of chips. Fine tuning can be one chip and one afternoon.

One base model, many specialists. So, fine tuning starts from a model that knows the world, then nudges it gently on a small pile of your own examples. Quick check now. One question is coming up.

Let's see if it clicked.

Read this lesson as text: Why making models bigger unlocks new skills

Why making models bigger unlocks new skills

How does scaling up a model work? Let's try to understand. In a simple way. Scaling is not one dial.

It is three, turned together. More parameters, more training text, and more compute. Turn all three, and the model's error falls along a smooth curve. Smooth enough that teams can plot it in advance, before the run even starts.

Why does that unlock new skills? Think of a budget. A small model spends all of it on easy patterns. Spelling, word order.

A bigger one has room left for the rarer ones. But watch one task. Three digit addition. Small model, almost never right.

Bigger, still almost never. Then at some size, it jumps. These jumps are called emergent abilities. Following an instruction from two examples in the prompt is one.

Reasoning step by step is another. Why a jump, when the error curve is smooth? Because of how we score it. All or nothing.

The final answer matches, or it does not. Underneath, the model improves the whole way. But a strict score pays nothing until every digit lands. Give partial credit, and the jump softens into a slope.

So nothing new was programmed in. It is still guessing the next word. Scale carried it past the point where the whole skill holds together. One catch.

Parameters alone will not do it. A giant model fed too little text loses to a smaller one that read far more. So, bigger lowers the error smoothly. Skills look sudden because our scoreboards are strict.

The recipe never changed. Quick check now. One question is coming up. Let's see if it clicked.

Read this lesson as text: How AI learns to create images from noise

How AI learns to create images from noise

How does creating an image from noise work? Let's try to understand. In a simple way. Start with a real photo.

Add a speck of static. Then more. Keep going for hundreds of tiny steps, until only pure noise is left. Wrecking a photo is easy.

The interesting half is undoing it. So we show a network a noisy picture and ask, which noise was just added? That question has a free answer. We added the noise, so we already know it.

Every photo becomes training data, and nobody labels anything. So the network never paints a picture. It predicts the noise. Subtract that prediction, and what is left is a little cleaner.

Then repeat. Predict, subtract, look again. Fifty steps, sometimes a thousand. Each pass removes a little, and shapes slowly appear.

Why not jump straight there? From pure static, the best guess is a blur. The average of every image. Small steps let it commit slowly.

Now flip it into a generator. Hand the network a fresh square of random static, and let it start removing noise anyway. Where does the prompt fit? It is fed in at every step.

So it asks, which noise would you remove, if this were a fox in the snow? So nothing is looked up or pasted. The network only learned how noise sits on real pictures. That alone walks static into something new.

So, teach a model to remove a little noise, then run it a few dozen times. Random static becomes a picture that never existed. Quick check now. One question is coming up.

Let's see if it clicked.