You're previewing the student experience. You don't need to complete this lesson — your progress and XP aren't saved.
Scratch
Beginner
40 mins
Teacher/Student led
+145 XP

What AI Models Are, from Chatbots to Agents

Teacher Class Feed

Load previous activity

    1 - Start: What We're Building ~4 mins

    Illustration for Start: what we're buildingSoftware decides things for you all day: what appears at the top of a feed, whether a photo has your face in it, what word you meant when you mistyped. The part of a program that decides is called an AI model.

    Today you will

    • meet the main kinds of AI model
    • build one yourself in Scratch: a guesser made of rules that tells a cat from a dog
    • find where it works and where it falls apart, which is the problem you solve next lesson

    2 - Guess the Model ~4 mins

    Here are five real things software does. Your teacher will take them one at a time. For each one, call out the kind of model you think is behind it.

    Choose from these four kinds of model:

    • Generative: it makes something new, such as text, a picture or code.
    • Recommendation: it picks what to show you next, from what you liked or watched before.
    • Classifier: it sorts something into a group, such as cat or dog, or spam or not spam.
    • Agent: it is given a goal and works through the steps to reach it on its own.
    1. It recommends the next video you should watch.
    2. It turns a sentence you typed into a picture.
    3. It finishes the line of code you started.
    4. It spots a face in a photo.
    5. It books a table at a restaurant for you, on its own.

    3 - Four Kinds, and What Each Is for ~2 mins

    KindWhat it doesWhere you meet it when coding
    GenerativeProduces something new: text, an image, codeAn assistant that drafts a function or explains code
    RecommendationRanks options for one personWhat a shop or a feed shows a given user
    ClassifierSorts an input into categoriesCat or dog, spam or not, rock or paper
    AgentTakes a goal, plans, uses tools, acts in a loopSoftware that carries out a multi-step task

    The one you are about to build is a classifier. It takes something in and puts a label on it, and it is the simplest of the four to build by hand.

    4 - Create a New Scratch Project ~2 mins

    Go to scratch.mit.edu and click Create to start a new project. Call it Cat or Dog.

    You will write all of today's code on the cat sprite that is already there, so you do not need to add anything.

    5 - Your First Rule: Does It Bark? ~3 mins

    Your guesser asks yes-or-no questions. The player presses y for yes or n for no.

    Build this from Events (yellow), Looks (purple), Control (orange), Sensing (light blue) and Operators (green, where the or block lives). The wait until block holds the script until a key goes down.

    Read it and predict: if you answer n, what will the cat do?

    when green flag clicked say [Think of a pet: a cat or a dog. Answer with y or n.] for (3) seconds say [Rule 1. Does it bark?] wait until <<key [y v] pressed?> or <key [n v] pressed?>> if <key [y v] pressed?> then say [I think it is a DOG.] for (4) seconds stop [this script] end
    The Scratch editor with rule 1 built: the cat asks 'Does it bark?' and, if you press y, says 'I think it is a DOG.'

    6 - Test It, and Find the Gap ~3 mins

    Click the green flag and answer y. The cat says DOG, which is right.

    Now run it again and answer n. Nothing happens: the script just ends. One rule is not a classifier, it is an opinion. You need a rule for every answer.

    7 - Rule 2: Does It Purr? ~3 mins

    Add a second rule underneath the first. The extra wait until waits for the key to come back up: without it, one long press on n would answer every question at once.

    Run it and answer n then y. The cat should say CAT.

    when green flag clicked say [Think of a pet: a cat or a dog. Answer with y or n.] for (3) seconds say [Rule 1. Does it bark?] wait until <<key [y v] pressed?> or <key [n v] pressed?>> if <key [y v] pressed?> then say [I think it is a DOG.] for (4) seconds stop [this script] end wait until <not <key [n v] pressed?>> say [Rule 2. Does it purr?] wait until <<key [y v] pressed?> or <key [n v] pressed?>> if <key [y v] pressed?> then say [I think it is a CAT.] for (4) seconds stop [this script] end
    The Scratch editor with rule 2 added: if the answer was n, the cat asks 'Does it purr?' and, if you press y, says 'I think it is a CAT.'

    8 - Rule 3, and an Answer for Everything ~3 mins

    Add the last rule: if it fetches a ball, it is a dog, otherwise it is a cat. This one uses if / else, so every answer now leads somewhere.

    Your guesser is finished. It is three rules long, and it is a real classifier.

    when green flag clicked say [Think of a pet: a cat or a dog. Answer with y or n.] for (3) seconds say [Rule 1. Does it bark?] wait until <<key [y v] pressed?> or <key [n v] pressed?>> if <key [y v] pressed?> then say [I think it is a DOG.] for (4) seconds stop [this script] end wait until <not <key [n v] pressed?>> say [Rule 2. Does it purr?] wait until <<key [y v] pressed?> or <key [n v] pressed?>> if <key [y v] pressed?> then say [I think it is a CAT.] for (4) seconds stop [this script] end wait until <not <key [n v] pressed?>> say [Rule 3. Does it fetch a ball?] wait until <<key [y v] pressed?> or <key [n v] pressed?>> if <key [y v] pressed?> then say [I think it is a DOG.] for (4) seconds else say [I think it is a CAT.] for (4) seconds end
    The Scratch editor with all three rules: after 'Does it purr?' the cat asks 'Does it fetch a ball?', and every path ends in an answer

    9 - Run It on the Easy Cases ~3 mins

    Test it the way you would test any program, with cases where you already know the answer.

    • A noisy Labrador: y. Expect DOG.
    • A cat on a windowsill: n, y. Expect CAT.
    • A collie that rarely barks but loves a tennis ball: n, n, y. Expect DOG.

    Three for three. A handful of if/else rules is a genuinely working classifier.

    The guesser running on the Scratch stage: the cat asks rule 1, rule 2 and rule 3 in turn, and after three n answers says 'I think it is a CAT.'

    10 - Now the Awkward Ones ~4 mins

    Try these:

    • A basenji, a dog that genuinely cannot bark, and will not fetch: n, n, n. Your guesser says CAT. It is wrong.
    • A cat that fetches, and some do: n, n, y. Your guesser says DOG. Wrong again.

    You could add more rules, but every new animal needs another one, and they start to contradict each other. This is where hand-written rules run out.

    11 - Your Turn ~3 mins

    Find a case your guesser gets wrong, then try to fix it with one more rule.

    Before you finish, check: you can name an animal it fails on, you added a rule to catch it, and you can say what your new rule broke or nearly broke.

    12 - Make Sense: What Worked, What Broke ~3 mins

    You built a classifier out of rules you wrote yourself. On clear cases it was right every time. On the awkward ones it was confidently wrong, and adding rules made it worse, not better.

    A model that learns from examples does not need you to think of every case in advance. That is what you build next.

    13 - Reflect ~2 mins

    Think about

    • Your guesser was confidently wrong about the basenji. Where else might software be confidently wrong about you?
    • You could read every rule in your guesser. Is that worth something, even though it was less accurate?

    14 - What You Covered ~1 mins

    Today you:

    • Named the four kinds of AI model: generative, recommendation, classifier and agent
    • Built a classifier by hand in Scratch, out of three yes-or-no rules
    • Found the cases it gets wrong, and why adding rules does not fix them

    Save your project where your class keeps its work (your teacher will show you where), so you can open it again.

    End of lesson
    123learn · Sample lesson

    That was a sample lesson from Exploring Artificial Intelligence

    Every lesson in the course is ready to teach like this one. See what else comes with it, and how to order it.

    Copyright Notice
    This lesson is copyright of Coding Ireland 2017 - 2026. Unauthorised use, copying or distribution is not allowed.

    Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more