🤖📚 How does an AI learn?

Date

Date

Date

March 13, 2023

March 13, 2023

March 13, 2023

Author

Author

Author

Matias Hoyl

Matias Hoyl

Matias Hoyl

We are surrounded by AI algorithms. Some are more obvious (like the YouTube or TikTok algorithm that chooses what you will see next) and others less obvious (did you know that 75% of stock trading is done by algorithms?). In fact, we have been using a simpler version of what would eventually become ChatGPT in Google Docs for some time now.

undefined

The great-grandfather of ChatGPT

All these algorithms have one thing in common: they use neural networks to learn.

Neural networks attempt to replicate the complexity of our own neurons. Even though no one really knows how the brain works, somehow the 120 billion neurons connect in a way that allows us to understand our environment.

To understand what a neural network is, let's look at a simple example. Suppose we want to train a bot to distinguish between pictures of bees and the number 3.

undefined

A task that is relatively simple for my two-year-old son is a complex engineering feat. In fact, no programmer knows how to write an algorithm that does that directly.

But what they do know how to do is build other bots that help them achieve that task: a bot that builds other bots, and a bot that teaches them.

undefined

Builder Bot and Teacher Bot.

The process of training a bot resembles The Hunger Games. Builder Bot is not very good at making bots that can distinguish between bees and the number 3. In fact, the first versions it builds have neural networks connected in a practically random way.

undefined

The first creations of Builder Bot are quite “special.”

Teacher Bot's task is not to teach them to distinguish between bees and 3s. In fact, it doesn't even know how to do that. But it does know how to do something that many traditional education teachers do very well: test them with an exam.

undefined

The frustration of Teacher Bot when seeing the students it has. They do their best. It's not their fault; Builder Bot didn't put much effort into the first batch.

The exam that Teacher Bot gives is simple: it shows them pictures of bees and 3s, and the bots have to try to guess as many as possible correctly. How does Teacher Bot grade the exams if it doesn't know how to distinguish between a bee and a 3?

Because the exams come with answers.

The programmers of these algorithms provide a “training set” that consists of pictures of bees and 3s with their correct answers.

With the exam results in hand, Builder Bot keeps only those bots that performed better and uses them as a basis to create the new batch of bots.

undefined

“May the odds be ever in your favor!” Katniss.

This new generation undergoes Teacher Bot's exam, and this cycle repeats a huge number of times. Each new generation “inherits” the characteristics that allowed their ancestors to survive.

In a surprisingly and incomprehensible way, this cycle (creating bots with almost random characteristics, testing them, and keeping the best) works.

The key is that programmers run this cycle billions of times, with exams of millions of questions. If each generation is a little better than the previous one, then with enough time (iterations), a bot that knows how to distinguish bees from the number 3 will eventually emerge.

undefined

The winning bot, whose neural networks are immensely complex.

What surprises me the most is that nobody knows how the winning neural network works. The random connections that were modified generation after generation result in something too complex for a human to understand.

But it works.

P.S.: The drawings and central idea of this post come from this excellent video by CGP Grey.

P.S.2: There are many different ways to teach a neural network. The one I explored in this post is commonly called a genetic algorithm, due to its parallel with natural selection. If you're interested in learning more about other types of learning, particularly Reinforced Learning, this video with a simulation of race cars learning to drive is fascinating.

P.S.3: If you're interested in the more mathematical side of how neural networks work, this video helped me a lot. It goes deep but in an accessible way.

Related posts

August 30, 2023

🤖🏆 The Ultimate Battle: Chatbots in the Ring.

August 30, 2023

🤖🏆 The Ultimate Battle: Chatbots in the Ring.

August 30, 2023

🤖🏆 The Ultimate Battle: Chatbots in the Ring.

July 26, 2023

⏰🚀 Racing Against Time: AI Surpasses Predictions.

July 26, 2023

⏰🚀 Racing Against Time: AI Surpasses Predictions.

July 26, 2023

⏰🚀 Racing Against Time: AI Surpasses Predictions.

Matias Hoyl · mhoyl@stanford.edu

© 2024 Matías Hoyl. All Rights Reserved.

Matias Hoyl · mhoyl@stanford.edu

© 2024 Matías Hoyl. All Rights Reserved.

Matias Hoyl · mhoyl@stanford.edu

© 2024 Matías Hoyl. All Rights Reserved.