Chatbots: in This Project You Will Make A Chatbot That Can Answer Questions About A Topic of Your Choice

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Chatbots

In this project you will make a chatbot that can answer questions
about a topic of your choice.

This project worksheet is licensed under a Creative Commons Attribution Non-Commercial Share-Alike License
http://creativecommons.org/licenses/by-nc-sa/4.0/

Page 1 of 12 Last updated: 14 April 2019


1. Decide on a topic for your chatbot
Choose something that you know well enough to be able to answer
questions about.
It could be a place (e.g. The town where you live?)
It could be an animal (e.g. Tigers? Dinosaurs?)
It could be an organisation (e.g. Your school)
It could be something from history (e.g. Vikings? Romans?)
For the rest of this worksheet, I’ll be using owls

2. Think of five things someone might ask about your topic


e.g. for owls, this could be:
* What do owls eat?
* Where in the world do owls live?
* How long do owls live?
* What types of owls are there?
* How big do owls grow?

3. Go to https://machinelearningforkids.co.uk/ in a web browser

4. Click on “Get started”

5. Click on “Log In” and type in your username and password


If you don’t have a username, ask your teacher or group leader to create
one for you.
If you can’t remember your username or password, ask your teacher or
group leader to reset it for you.

6. Click on “Projects” on the top menu bar

7. Click the “+ Add a new project” button.

Page 2 of 12 Last updated: 14 April 2019


8. Name your project and set it to learn how to recognise “text”.
Click the “Create” button

9. Click on your new project in the projects list

10. Click the Train button.

11. Click the “+ Add new label” button

Page 3 of 12 Last updated: 14 April 2019


12. Type in one word that sums up the first of your things from Step 2,
then click Add.
I used “food” to sum up questions like “What do owls eat?”

13. Do that again for all of the things in your list from Step 2
The words you choose don’t really matter, as long as you understand
what they mean.

14. Click the “+ Add example” button in one of the buckets

Page 4 of 12 Last updated: 14 April 2019


15. Type in an example of how someone might ask that question

16. Click “Add”

17. Repeat until you’ve got five examples of how to ask that question.

18. Repeat until you’ve got at least five examples in every bucket

Page 5 of 12 Last updated: 14 April 2019


19. Click on the “< Back to project” link

20. Click the “Learn & Test” button

21. Click the “Train new machine learning model” button


As long as you’ve collected enough examples, the computer should start
to learn how to recognise questions from the examples you’ve given to it.

22. Wait for the training to complete.


This might take a couple of minutes.
It’s finished once you see the “status” change to “Available”

23. Click the “< Back to project” link

Page 6 of 12 Last updated: 14 April 2019


24. Click the “Make” button

25. Click “Scratch 3”

26. Click the “Open in Scratch” button

27. Open the Owls project template


Click Project templates and find Owls in the list of templates

Page 7 of 12 Last updated: 14 April 2019


28. Create this little snippet of script but don’t attach it to anything yet
Make sure you choose “owl says” for the orange block.

29. Duplicate it four times and join them all together


Right-click on it, and click “Duplicate”

30. Fill in each copy of the block


Drag the label for one of your questions into the top space, and
Type the answer to the question into the bottom space

Page 8 of 12 Last updated: 14 April 2019


31. Drag this new block into the Green Flag block prepared for you.
Remove the “Sorry. I haven't been taught anything yet.” block and
replace it with your new chunk of script.

32. Draw your chatbot


Unless you’ve chosen owls as a topic, you’ll need to draw your own character
If you provide different costumes, you can animate your character while it talks.

Page 9 of 12 Last updated: 14 April 2019


33. Test your chatbot!
Click the green flag and try asking the owl a question

What have you done so far?

You’ve started to train a computer to recognise questions on a topic.


Instead of trying to write rules to be able to do this, you did this by
collecting examples. These examples were used to train a machine
learning “model”.

This is called “supervised learning” because of the way you are


supervising the computer’s training.

The computer will learn from patterns in the examples you’ve given it,
such as the choice of words, and the way questions are structured. These
will be used to be able to recognise new questions.

The biggest problem with this is that if you ask it something unexpected,
it will still give you one of the answers you’ve written

Page 10 of 12 Last updated: 14 April 2019


34. Create this little chunk of script, that you can use when someone
asks a question that wasn’t on your list from step 2.
The confidence score is a percentage (from 0 to 100).
It will be lower if someone asks a question that isn’t similar to any of the
examples you used to train the machine learning model.
Use this to return a “I don’t understand” message if the score is too low.

35. Add this into your script from before.

Page 11 of 12 Last updated: 14 April 2019


Ideas and Extensions

Now that you’ve finished, why not give one of these ideas a try?

Or come up with one of your own?

Try other chatbots


http://talktothetrex.com is a good example of the sort of
thing you’ve made. Give it a try and see if you can get any
ideas of how to improve your bot.

Add more topics


Can you add more topics to your chatbot, so that there are
more types of question that it can answer?

Provide alternate answers


If someone asks the same question more than once, they’ll
get the exact same answer every time.

Can you update your Scratch script so that it varies the


answers each time a little? Or just starts the answer with
“You’ve asked me this before, but”

Ask follow-up questions


Can you update your Scratch script so that it replies with a
question? It can then recognise the answer to that question,
in a similar way to how you made it recognise questions.

Page 12 of 12 Last updated: 14 April 2019

You might also like