Skip to content

← Grade 6 Computing

Computers That Learn

Unit 9 · Artificial intelligence

Hide the stories, facts, photos, activities and interactives, for revising before an exam
In this unit 9 sections
  1. What is artificial intelligence?
  2. What AI is not
  3. Learning from examples
  4. Why it makes mistakes
  5. AI around you
  6. When to trust it
  7. Project
  8. In short
  9. Exercise

Open the photo gallery on a phone and type “momo” in its search box. Up come your photos of momos: on a plate at a party, in a steamer at a shop, half eaten. Nobody typed the word “momo” beside those photos. The phone looked at them and found the momos by itself.

How? In Unit 3 and Unit 4 you learned that a computer does exactly what its program says. But try writing the rules for “a photo with momos in it”. Round? White? Folded at the top? On a plate? A bowl of rice is round and white. A momo seen from the side isn’t round at all. Fried momos aren’t white. You will never finish the list. So nobody wrote those rules. Instead, the computer was shown a great many photos, each with the right answer, and it learned from them.

In this unit you will find out what that kind of computer, an artificial intelligence, is and what it is not. You will teach one yourself, on this page, and watch it make mistakes. You will find the AI hiding in the phones and apps around you, and learn when to trust it and when to check.

What is artificial intelligence?

Think of how you learned to tell a kagati from a suntala. Nobody gave you a rule book. When you were small, people showed you fruit and said its name: “this is a suntala”, “that’s a kagati”. After enough of them, you could name a fruit you had never seen before. You learned from examples.

There are two ways to make a computer sort fruit.

  • Write the rules. A person thinks hard and writes the rules down: “If the fruit is smaller than 5 cm across, say kagati. Otherwise, say suntala.” The computer follows them exactly, like the programs you wrote in Unit 4. This is an ordinary program.
  • Give it examples. A person collects many fruits, each with its right answer, and gives them to the computer. The computer finds the pattern in them by itself, and uses the pattern to name new fruit. This is a program that learns.
An ordinary programA person writes the rules:If it is smaller than 5 cm, say kagati.Otherwise, say suntala.The programfollows the rulesa new fruitanswer:kagatiA program that learns from examplesExamples, with the right answerskagatikagatisuntalasuntalakagatisuntalaTrainingfinds the patternThe modelmade by the computera new fruitanswer:suntala An ordinary programA person writes the rules:If it is smaller than 5 cm, say kagati.Otherwise, say suntala.a new fruitThe programfollows the rulesanswer:kagatiA program that learns from examplesExamples, with the right answerskagatikagatisuntalasuntalakagatisuntalaTrainingfinds the patternThe modelmade by the computera new fruitanswer:suntala
Figure 9.1 Two ways to make a program that sorts fruit. Above, a person writes the rules. Below, nobody does: the computer is given examples with the right answers, and training turns them into a model, which then answers for new fruit.

Finding the pattern in the examples is called training, and what the computer ends up with, the pattern it found, is called a model. Once it is trained, the model can answer for things it has never seen. Learning from examples like this is called machine learning.

Now we can say what AI is. Artificial intelligence (AI) is a computer doing a job that, when a person does it, we say needs a mind: recognizing faces and things in pictures, understanding speech, translating, choosing. Almost all the AI around you today does it by machine learning: it learned from examples.

Try it

Learned, or written by a person?

For each one, decide: did it learn from examples, or does it just follow rules that a person wrote?

A calculator app working out 25 × 4

Did it learn from examples, or does it follow rules a person wrote?

Tap a group above.

Card
1 of 10
Right the first time
0

Which of these is a program that learns?

Pick an answer to see why.

What is a model, in AI?

Pick an answer to see why.

What AI is not

Films are full of robots that think, feel and plan. Real AI is very different, and knowing what it is not keeps you from trusting it too much.

  • It is not alive, and it doesn’t think or feel. It has no wishes, no feelings, no idea that you are there. When a chatbot writes “I think” or “I’m sorry”, it has learned that people write those words; it doesn’t feel sorry.
  • It doesn’t understand the way you do. A fruit sorter that names a suntala doesn’t know it is a fruit, that it is sweet, or that it grows on a tree in Gorkha. It knows only the few measurements it was given.
  • It is not always right. A model learned from examples, and examples never cover everything. Every AI makes mistakes. You will see why in this unit.
  • It doesn’t know what it doesn’t know. Show the fruit sorter a ball, and it will still say “kagati” or “suntala”: they are the only answers it was taught.
  • It is not every clever machine. A rice cooker that switches to keep-warm, or a robot arm in a factory repeating the same weld, follows rules people wrote. Not every robot is AI, and not every program that seems clever is AI.
  • It is not magic. Inside, it is a computer doing arithmetic on numbers, very fast: on zeros and ones, as in Unit 5.
A black-and-white passport photo of a teenage boy with short dark hair, in a jacket and tie
Figure 9.2 Alan Turing at 16. Years later he asked whether machines could think, and guessed that they might have to learn, like children. Photo: Possibly Arthur Reginald Chaffin (1893-1954), Public domain

A chatbot writes: “I’m so happy to help you!” What is really going on?

Pick an answer to see why.

Learning from examples

Let’s look inside a program that learns. It is simpler than you might think.

A computer can’t look at a fruit the way you do. It can only work with numbers, so first it measures the fruit. Our fruit sorter measures just two things:

  • its size: how many centimeters across it is;
  • its color: from green, through yellow, to orange.

Two numbers are enough to put each fruit on a map: size along the bottom, color up the side. A small green fruit goes at the bottom left; a big orange one at the top right. Each example on the map has a ring that shows its right answer.

Now a new fruit comes along. The sorter measures it, puts it on the map, and asks: which example is closest to it? Then it gives the same answer as that example. That’s all. Closest to a kagati example? Then it says kagati. This way of deciding is called nearest neighbor: your neighbor is whoever lives closest to you.

The shading on the map shows what the sorter would say for a fruit anywhere on it: blue where its nearest example is a kagati, red where it is a suntala. The shading is the model. Change the examples and the shading changes, so the model changes: that is training.

Try it

Teach the fruit sorter

The sorter starts with just two examples, one kagati and one suntala. Press Test a new fruit several times and watch. The dashed line goes to the example it copied. When it makes a mistake, press Teach it this one to add that fruit to its examples, or pick Kagati or Suntala and tap the map to add your own examples. Tap an example to take it away. Watch the ✓ and ✗ of the fruit already tested change as you teach it.

23456789Size (cm) →greenyelloworange↑ Color
Tap the map to add:
Examples
2
Tested
0 of 12
Right, as it is now
–

Press Test a new fruit to start. You can also pick a kind and tap the map to add an example, or tap an example to take it away.

A new fruit: where is it on the map, and which example is closest? Say what the model will answer, then press Show its answer.

Added an example. Look at how the shading changed, and at the ✓ and ✗ of the things already tested.

Took that example away. The shading and the ✓ and ✗ changed with it.

With no examples, the model knows nothing and can’t answer at all.

The model says kagati, because the example closest to it is a kagati. It was a ripe suntala: a mistake.

The model says suntala, because the example closest to it is a suntala. It was a ripe suntala: right.

The model says kagati, because the example closest to it is a kagati. It was a green kagati: right.

The model says suntala, because the example closest to it is a suntala. It was a green kagati: a mistake.

The model says kagati, because the example closest to it is a kagati. It was an unripe suntala: a mistake. Suntala are green until they ripen.

The model says suntala, because the example closest to it is a suntala. It was an unripe suntala: right. Suntala are green until they ripen.

The model says kagati, because the example closest to it is a kagati. It was a ripe kagati: right. Kagati turn yellow as they ripen.

The model says suntala, because the example closest to it is a suntala. It was a ripe kagati: a mistake. Kagati turn yellow as they ripen.

The model says kagati, because the example closest to it is a kagati. It was a suntala starting to ripen: a mistake.

The model says suntala, because the example closest to it is a suntala. It was a suntala starting to ripen: right.

The model says kagati, because the example closest to it is a kagati. It was an unripe suntala: a mistake. Suntala are green until they ripen.

The model says suntala, because the example closest to it is a suntala. It was an unripe suntala: right. Suntala are green until they ripen.

The model says kagati, because the example closest to it is a kagati. It was a small ripe suntala: a mistake.

The model says suntala, because the example closest to it is a suntala. It was a small ripe suntala: right.

The model says kagati, because the example closest to it is a kagati. It was a big ripe kagati: right.

The model says suntala, because the example closest to it is a suntala. It was a big ripe kagati: a mistake.

The model says kagati, because the example closest to it is a kagati. It was a kagati starting to ripen: right.

The model says suntala, because the example closest to it is a suntala. It was a kagati starting to ripen: a mistake.

The model says kagati, because the example closest to it is a kagati. It was a big ripe suntala: a mistake.

The model says suntala, because the example closest to it is a suntala. It was a big ripe suntala: right.

The model says kagati, because the example closest to it is a kagati. It was an unripe suntala: a mistake. Suntala are green until they ripen.

The model says suntala, because the example closest to it is a suntala. It was an unripe suntala: right. Suntala are green until they ripen.

The model says kagati, because the example closest to it is a kagati. It was a green kagati: right. That was the last one: now change the examples and watch the ✓ and ✗.

The model says suntala, because the example closest to it is a suntala. It was a green kagati: a mistake. That was the last one: now change the examples and watch the ✓ and ✗.

This model runs in your browser. Nothing you do here is sent anywhere.

What you should see

Notice what the sorter did not do. Nobody wrote “a suntala is bigger than 5 cm” into it. Its answers came only from the examples. Give it different examples and it gives different answers. A model is only as good as the examples it learned from.

Real AI works the same way, on a much bigger scale. A model that finds momos in photos doesn’t measure two things; it measures many thousands of tiny things about the colors and shapes in a photo, too many to draw on a map. And it isn’t trained on ten examples but on millions. But the idea is the one you just used: measure, compare with the examples, answer.

How does our fruit sorter decide what a new fruit is?

Pick an answer to see why.

A sorter gets a lot of fruit wrong. What will most likely help it?

Pick an answer to see why.

Why it makes mistakes

When the sorter got a fruit wrong, there was always a reason, and the map showed it. Before you read the reasons, find them yourself.

Try it

Why did it say that?

This sorter has eight examples. Press Show a new fruit. Before you press Show its answer, find the example closest to the new fruit and say what the sorter will answer. Then check. When it is wrong, ask why. Some of the new things are not a kagati or a suntala at all: watch what it says for those.

23456789Size (cm) →greenyelloworange↑ Color
Tap the map to add:
Examples
8
Tested
0 of 6
Right, as it is now
–
Never taught (not scored)
0

Press Show a new fruit to bring a new fruit. Before you see its answer, say what the model will answer.

A new fruit: where is it on the map, and which example is closest? Say what the model will answer, then press Show its answer.

Added an example. Look at how the shading changed, and at the ✓ and ✗ of the things already tested.

Took that example away. The shading and the ✓ and ✗ changed with it.

With no examples, the model knows nothing and can’t answer at all.

The model says kagati, because the example closest to it is a kagati. It was a ripe suntala: a mistake.

The model says suntala, because the example closest to it is a suntala. It was a ripe suntala: right.

The model says kagati, because the example closest to it is a kagati. It was an unripe suntala: a mistake. It had seen only ripe suntala, which are orange.

The model says suntala, because the example closest to it is a suntala. It was an unripe suntala: right. It had seen only ripe suntala, which are orange.

The model says kagati, because the example closest to it is a kagati. It was a very big ripe kagati: right. It is bigger and yellower than any kagati it had seen.

The model says suntala, because the example closest to it is a suntala. It was a very big ripe kagati: a mistake. It is bigger and yellower than any kagati it had seen.

The model says kagati, because the example closest to it is a kagati. It was a tennis ball: neither! No answer it knows could be right, so this one isn’t scored. It was taught only two answers, so it gives one of them even for a ball.

The model says suntala, because the example closest to it is a suntala. It was a tennis ball: neither! No answer it knows could be right, so this one isn’t scored. It was taught only two answers, so it gives one of them even for a ball.

The model says kagati, because the example closest to it is a kagati. It was a kagati starting to ripen: right.

The model says suntala, because the example closest to it is a suntala. It was a kagati starting to ripen: a mistake.

The model says kagati, because the example closest to it is a kagati. It was a nibuwa, a big hill lemon: neither! No answer it knows could be right, so this one isn’t scored. It never saw a nibuwa, so it calls it the nearest thing it knows. That was the last one: now change the examples and watch the ✓ and ✗.

The model says suntala, because the example closest to it is a suntala. It was a nibuwa, a big hill lemon: neither! No answer it knows could be right, so this one isn’t scored. It never saw a nibuwa, so it calls it the nearest thing it knows. That was the last one: now change the examples and watch the ✓ and ✗.

This model runs in your browser. Nothing you do here is sent anywhere.

What you should see

A model that learned from examples gets things wrong for a few reasons, and they are the same for the biggest AI in the world:

  1. Too few examples. With two examples, the sorter knows almost nothing. A real model needs a great many.
  2. Examples that don’t look like the new thing. If every suntala it saw was ripe and orange, a green suntala looks to it like a kagati. A model knows only what its examples showed it. In Grade 7 you will see how this makes AI unfair to some people, and how to fix the examples.
  3. It measures only some things. Size and color can’t tell a tennis ball from a fruit. You would feel the fuzz, smell it or squeeze it; the sorter can’t. A model is blind to everything it doesn’t measure.
  4. It can only give the answers it was taught. Asked about something new, it doesn’t say “I don’t know”. It gives the nearest answer it has.
  5. Wrong examples. If someone put the wrong ring on an example, calling a kagati a suntala, the model learns the mistake and repeats it.
A woman with shoulder-length dark hair speaking at a lectern with two microphones
Figure 9.3 Fei-Fei Li, speaking at a meeting about AI in 2017. Photo: ITU Pictures, CC BY 2.0

A sorter has learned from photos of ripe red tomatoes only. Shown a green tomato, it says “not a tomato”. Why?

Pick an answer to see why.

AI around you

You use AI many times a day, often without knowing. Here are some of the jobs it does, in Nepal as everywhere:

  • Finding things in photos. A phone’s gallery finds faces, momos, dogs and mountains by a model trained on millions of named photos. A phone that unlocks when it sees your face uses one too.
  • Voice typing. In Unit 2 you typed by speaking, in Nepali too. A model learned which sounds go with which words from many hours of people speaking, with what they said written out. That is why it stumbles on names and on words it rarely heard.
  • Translation. Apps that turn English into Nepali, and Nepali into English, learned from a great many sentences that people had already translated. They do better with languages they have more examples of, so they still make many mistakes in Nepali, and more in languages like Tamang or Nepal Bhasa that have fewer examples online.
  • Recommendations. Video and shopping apps choose what to show you next with a model that learned from what millions of people watched, clicked and bought. It learned to keep you watching, which is not the same as showing you what is good for you.
  • Checking payments. Many banks and payment apps check each payment with a model trained on past payments, both honest ones and frauds. When a payment doesn’t fit the pattern, like a large one at midnight from a new phone, the bank may hold it and ask you.
  • Helping farmers. Some apps look at a photo of a sick leaf, from a tomato, potato or rice plant, and suggest which disease it might be, trained on many photos of leaves whose disease an expert had named.
  • Keeping out spam from an email inbox, and predicting traffic on a map app.
Close-up of a hairy green tomato leaf with a brown patch of dead leaf, ringed by a pale yellow-green halo
Figure 9.4 A tomato leaf with an early spot of late blight, a disease that also attacks potatoes. A crop app trained on photos like this suggests what the disease might be; an agriculture technician can confirm it. Photo: Dwight Sipler from Stow, MA, USA, CC BY 2.0

Which of these uses AI?

Pick an answer to see why.

When to trust it

AI is useful, and it makes mistakes. So the question is never “Is AI good or bad?” but “Can I trust this answer, here?” Ask three questions:

  1. What happens if it’s wrong? If the photo search shows a wrong photo, you scroll on. If an app wrongly tells you a mushroom is safe, someone could die. The worse a mistake would be, the less you should rely on AI alone.
  2. Has it seen things like this? A model is good at what its examples covered. Voice typing does well with everyday Nepali words and badly with your grandmother’s village name. A crop app trained on photos from other countries may not know a disease common in the hills of Nepal.
  3. Can I check it? Read what voice typing wrote. Look at the road. Ask the agriculture technician, the doctor, the teacher. When you can check, use the AI and then check. When a mistake would be serious and you can’t check, don’t rely on it.

Try it

Trust it, check it, or don’t rely on it?

For each, decide how far to trust the AI, using the three questions above.

Your phone’s photo search shows your photos of momos

How far should you trust the AI here?

Tap a group above.

Card
1 of 8
Right the first time
0

Use AI only where it helps

Answering with AI takes much more computing than an ordinary program. The biggest AI models run on thousands of computers in huge buildings called data centers (Unit 8), which use a great deal of electricity, and many use water to keep the computers cool. So don’t use AI for a job a simple tool already does well: a calculator for a sum, a dictionary for a spelling, your own memory for your times tables.

Your data, and your own work

Many AI apps send what you give them, your photos, your voice, your questions, over the internet to the company’s computers, and some keep it to train their next model. So never give an AI app anything private: your address, passwords, photos of your documents, or secrets about other people (Unit 8 has more about privacy).

And what you hand in as schoolwork must be your own. If an AI wrote it, it isn’t, and you learn nothing from it. In Grade 8 you will learn when AI can help with schoolwork, and how to say that you used it.

Voice typing has written a message to your teacher. What should you do before you send it?

Pick an answer to see why.

Project

In short

Exercise

What is machine learning?

Pick an answer to see why.

Which of these is not true of AI today?

Pick an answer to see why.

A nearest-neighbor sorter has two examples: a kagati 4 cm across and yellow, and a suntala 7 cm across and orange. A fruit 4.5 cm across and yellow-orange is tested. What does it say?

Pick an answer to see why.

A sorter was trained on photos of cats and dogs. It is shown a photo of a goat. What happens?

Pick an answer to see why.

Which job is best done by an ordinary program, not AI?

Pick an answer to see why.

a.

Explain in one sentence each: artificial intelligence, machine learning, training, model.

Answer
b.

What is the difference between an ordinary program and a program that learns? Give one example of each from a phone.

Answer
c.

Write four things AI is not, with a sentence on each.

Answer
d.

Describe how a nearest-neighbor fruit sorter decides whether a new fruit is a kagati or a suntala.

Answer
e.

A fruit sorter was trained only on ripe fruit: yellow kagati and orange suntala. It calls a green, unripe suntala a kagati. Give the reason for the mistake, and say how to fix it.

Answer
f.

Give five reasons why an AI model that learned from examples makes mistakes.

Answer
g.

Name four places where AI is used around you, and say what each one learned from.

Answer
h.

What three questions should you ask before trusting an AI answer? Use them to decide what to do in each case:

  • i.A photo app labels your photo of Phewa Lake “beach”.
  • ii.A crop app says your rice has a disease and you should spray a chemical.
  • iii.A chatbot gives the dose of a medicine for your grandfather.
Answer
i.

Your friend uses a chatbot to work out 48 × 25 for homework. Give two reasons why this is not a good use of AI.

Answer
j.

Why should you never type private information, such as your password or your address, into an AI app?

Answer