Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

What AI is and what it is not

After this lesson: I can explain what AI is and what it is not.

45 min lessonNo commands

The phone that guesses your next word

Artificial intelligence, or AI, is a computer program that finds patterns in examples and uses them to guess. Your phone does it when it suggests the next word of a message.

AI is in apps you use every day. Knowing what it is, and what it is not, helps you use it well.

By the end of this lesson

Note

I can explain what AI is and what it is not.

Key words

WordWhat it means
AIa program that makes guesses from patterns in examples
Patternsomething that happens again and again
Exampleone piece of data the program learns from
Trainingshowing a program many examples
Guessan answer that may be right or wrong

The cells students fill in are left blank in this preview.

AI finds patterns and makes a guess

An ordinary program follows rules that a person wrote. An AI program is shown thousands of examples instead. This is called training. The program finds the patterns, then uses them to guess.

A junk mail filter is one. It has seen many messages marked junk or not junk. It guesses which kind a new message is.

A tiny pattern-finder you can run

The program below has four messages that a person already sorted. For a new message, it counts the words it shares with each sorted one. The side with more shared words wins.

Press Run. Then change the last message to one of your own and run it again.

Guess junk or not junk

Code: python
# Messages a person has already sorted.
examples = [
    ["win a free phone now", "junk"],
    ["free prize click now", "junk"],
    ["are you at football tonight", "ok"],
    ["see you at the bus stop", "ok"],
]

def guess(message):
    junk = 0
    ok = 0
    for example in examples:
        for word in message.split():
            if word in example[0].split():
                if example[1] == "junk":
                    junk = junk + 1
                else:
                    ok = ok + 1
    if junk > ok:
        return "junk"
    if ok > junk:
        return "ok"
    return "not sure"

print(guess("free phone"))
print(guess("football tonight"))
print(guess("hello there"))

A new example changes the guess

A pattern-finder only knows its examples. Give it a new one and its guesses can change.

Below, an ok message about a phone has been added. Press Run. In the first Run, a message about a phone was guessed as junk.

Add one more example

Code: python
examples = [
    ["win a free phone now", "junk"],
    ["free prize click now", "junk"],
    ["are you at football tonight", "ok"],
    ["see you at the bus stop", "ok"],
    # The new example.
    ["my new phone is great", "ok"],
]

def guess(message):
    junk = 0
    ok = 0
    for example in examples:
        for word in message.split():
            if word in example[0].split():
                if example[1] == "junk":
                    junk = junk + 1
                else:
                    ok = ok + 1
    if junk > ok:
        return "junk"
    if ok > junk:
        return "ok"
    return "not sure"

print(guess("new phone"))

What AI is not

AI is not a person. It has no feelings, no opinions and no idea what is true. It does not understand a message the way you do.

It can only be as good as its examples. Wrong examples give wrong guesses. One-sided examples give one-sided guesses.

Worked example: where you meet AI

WhereWhat it guesses
A phone keyboardThe next word you will type
A music appA song you may like
A maps appHow long the bus will take
A junk mail filterWhether a message is junk
A chatbotThe words of a reply
A shop websiteWhat you may want to buy next

The cells students fill in are left blank in this preview.

A common mistake

Warning

Many people think AI understands them like a person does. It does not. It matches patterns from examples, so it can sound clever and still get simple things wrong.

Going further: what if the examples are one-sided?

In the Run, both junk examples are about prizes and phones. So a real message about a new phone could be marked junk.

Add two more examples to the list, one junk and one ok. Which new messages does the program now guess better?

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.