Build a Quiz Bot That Teaches Back
- Use text classification to build a quiz bot that recognizes and answers questions about a chosen topic
- Create multiple question categories with varied phrasings to improve recognition accuracy
- Test the quiz with another person and improve the model based on real user input
Teaching AI to Know Stuff
In Lesson 5, you built a chatbot that recognizes the type of message you sent. Today you are going to use the same skill — text classification — to build something different: a quiz bot that knows the answers to questions about a topic you choose.
The clever twist is that the AI does not actually store answers. Instead, it recognizes the shape of the question and matches it to a category you defined. Your Scratch code then picks the correct answer for that category. You are the one who decides what the right answers are — the AI just figures out which question is being asked.
Choose a topic you genuinely know well. The better your knowledge of the topic, the more interesting and accurate your quiz will be. Ideas: animals, space, your favorite sport, cooking, history, your favorite video game, music.
Set Up Your Quiz Model
Go to machinelearningforkids.co.uk and create a new Text project. Name it after your topic — "Space Quiz" or "Animal Quiz" — and create one category per quiz question. For example, if you are making a space quiz:
- Largest planet — add phrases like: "what is the biggest planet", "which planet is the largest", "largest planet in solar system", "biggest planet"
- Closest to Sun — add phrases like: "which planet is closest to the sun", "nearest planet to the sun", "what planet is first from the sun"
- Earth moons — add phrases like: "how many moons does Earth have", "does Earth have more than one moon", "Earth moon count"
Create at least four or five quiz question categories. For each one, add 6 to 8 different ways someone might phrase that question. People ask the same question in many different ways, and your AI needs to learn all of them to be reliable.
When your categories are ready, click Train.
Build the Scratch Quiz Game
Click Make then Scratch 3 to open Scratch with your AI model loaded. Build your quiz game:
- Use the ask [] and wait block to collect a question from the player.
- Use the recognise text block to send the question to your AI and get the category back.
- Use a series of if / else if blocks to check the category and say the correct answer.
Make it interactive and fun. Add a score counter. Give encouraging messages for correct answers. Add a background and character that fit your topic. Let the player ask as many questions as they want.
Bonus challenge: Add a "stump the bot" feature. If the AI receives a question it does not recognize, it says "I do not know that one yet!" and asks the player to rephrase. Then add that phrase to your training data and retrain — your bot gets smarter with every session.
Test It with Someone Else
The real test of a quiz bot is whether it works when someone else uses it — someone who phrases questions differently than you do. Ask a parent, sibling, or friend to try your quiz. Watch how they type questions. If the AI misclassifies anything, write down the exact phrase they used, add it as a training example to the correct category, and retrain your model.
This cycle — build, test with real users, find what breaks, improve — is exactly how professional AI engineers develop products. Every update to voice assistants and smart search tools goes through the same process, just at a much larger scale.
- A quiz bot matches question patterns to categories rather than storing answers in a database
- Providing 6 to 8 different phrasings per question helps the model handle how real people ask questions
- Testing with another person reveals gaps in training data that self-testing almost always misses