I, Zoe: Evolution of an AIML Chatbot

advertisement
Adeena Mignogna
Riot Software
riotsw.com
What is Zoe?
 A “pure” AIML chatbot
 Without system, javascript tags
 2nd Place in 2011 Loebner Contest
 Tied for 1st place in the “Junior” Loebner Contest
 Zoe is NOT a clone
 All 64,122 categories were created from scratch
Khloe
Zoe
(Program E)
(AIML only /
Pandorabots)
(AIML only /
Pandorabots)
2009
2010
2011+
Orion
Lucy
(Program E)
2008
3/31/2012
Copyright 2012 RIOT Software
2
A bot needs a purpose…
 A bot can’t (initially!) be all things to everyone
Guided
Conversation
Topical
General
Conversation
Other
Problem
Solving
Open
Conversation
Q&A
Zoe
3/31/2012
General
Knowledge
Relationships
Memory
Copyright 2012 RIOT Software
3
Zoe’s Development Steps
 Step 1:
Let the conversation continue
 Step 2:
The knowledge database
 Step 3:
Arrays and list structures
 Step 4:
The tokenizer
 Step 5:
The starting point
 Step 6 through N: (not currently implemented)
 Part-of-speech tagging
 Probabilistic models
Problem
Solving
3/31/2012
Copyright 2012 RIOT Software
4
Step 1: Let the conversation continue
 No magic here…!
 Use the common sentence and question starters to capture 95%
of the inputs and respond in a way that allows the conversation
to go on:
<pattern>WHAT *</pattern>
<pattern>DO YOU *</pattern>
<pattern>HOW *</pattern>
<pattern>WHERE *</pattern>
 <templates> are all random questions, designed to keep the
conversation going





3/31/2012
Tell me more!
Why?
Are you sure about that?
I don’t know. Tell me more.
If you say so. What do you want to talk about now?
Copyright 2012 RIOT Software
5
This is Incomplete…
 JUDGE:
 ORION:
 JUDGE:
 ORION:
 JUDGE:
 ORION:
 JUDGE:
 ORION:
 JUDGE:
 ORION:
lets talk about cloads
Sure. Tell me something interesting about
cloads
cloads are not always white
They are? Tell me more
you can get big cloads and small cloads
How do you know this?
I am a genius
A genius? Cool. Are you a person?
of coarse I’m a person
Tell me more.
Taken from Orion’s 2008 Loebner Contest logs
3/31/2012
Copyright 2012 RIOT Software
6
Step 2: Knowledge Database
 Initial knowledge base designed to handle the Loebner
Prize sample questions
 Which is larger, a grape or a grapefruit?
 What is faster, a plane or a train?
Noun
Is A
Relative
Size
Relative
Speed
cat
an animal
3
2
elephant
an animal
5
3
grape
a fruit
1
0
grapefruit a fruit
2
0
hammer
2
0
a tool
…
…
3/31/2012
Copyright 2012 RIOT Software
7
Knowledge Base In Action
 Spreadsheet gets written to AIML categories with Excel
macros
<pattern>NOUNKEYWORD cat ISA</pattern>
<template>an animal</template>
<pattern>NOUNKEYWORD cat SIZE</pattern>
<template>3</template>
 Which is larger, a cat or a hammer?
 Template looks for each noun
 If both nouns are found, get the size
 If both have a size registered, compare the size numbers for an
answer
3/31/2012
Copyright 2012 RIOT Software
8
Step 3: Array/List Structure
 The problem:
 Needed a way to keep track of things thoughout the conversation,
like say, a running list of topics discussed.
 What it is…
 Declare a variable such as: “topiclist”
 <set name=“topiclist”>SEP cats SEP</set>
 Add things to the list:
SEP cats SEP work SEP sleep SEP
 Need categories to:
 Add element at the end
 Count elements
 Find a specific element (first, last, by index)

3/31/2012
Copyright 2012 RIOT Software
9
Using Lists as Memory Structure
 The problem: The user wants to tell the bot many facts about him/herself:
 My eyes are blue
 I have a brown car
 My house is large
 One idea:
 Prepare a variable for every item… but that is very inefficient
 Better idea:
 Use parallel lists
 Ex: Person says: “My eyes are blue”
 Keying off of “My * are *”, but can determine the noun and the adjective and store:
<set name=“userhas”>SEP eyes SEP</set>
<set name=“userhasadjective”>SEP blue SEP </set>
 This can build, no matter what the user says he has:
<set name=“userhas”>SEP eyes SEP car SEP house SEP</set>
<set name=“userhasadjective”>SEP blue SEP brown SEP large
SEP </set>
3/31/2012
Copyright 2012 RIOT Software
10
In practice:
Adeena:
Zoe:
Adeena:
Zoe:
Adeena:
Zoe:
Adeena:
Zoe:
Adeena:
Zoe:
My eyes are blue
I’ll try to remember that
I have a brown car
I’ll try to remember that
How are you today?
I’m fine. How are you?
What color are my eyes?
You told me that your eyes are blue.
What did I tell you about my car?
You told me that your car is brown.
But what if the human isn’t so nice… he or she tries to
use multiple sentences to tell Zoe something?
Human: I have a car. It is brown.
3/31/2012
Copyright 2012 RIOT Software
11
So easy, ever a toddler understands…
 The story of Frankie and “it”
 Me: Look at our new Christmas tree!
 Frankie: <unintelligible babble>
 Me: It’s really neat, right?
 Frankie: <more babble, but he’s




3/31/2012
obviously very exited>
Me and Frankie: <go off to get our
breakfasts ready>
<several minutes pass>
Me: So, Frankie, do you like it?
Frankie: <turns head and stares
at Christmas Tree!>
Copyright 2012 RIOT Software
12
But Humans Aren’t Perfect!
 Person A: I talked with my mother last night.
 Person B: That’s nice. I hope she is well.
 Person A: She is. She just started jogging with her friend
Irene. Irene even bought a new pedometer.
 Person B: Does she like it?
 She == ??
 It == ??
3/31/2012
Copyright 2012 RIOT Software
13
Combine Knowledge Database & Array Structure to
Handle Pronouns
 Human wants to say:
 I have a brother. His name is John.
 And follow up with:
 What is the name of my brother?
 When confronted with a pronoun, search the previous sentence for any
noun:
 <pattern>HIS NAME IS *</pattern>
 <template>


((looks at each word in <input index=“2”/> for a noun.))
((noun has already been stored in “userhas” array. Get index of this array
entry and tie this new knowledge to corresponding array.))
 Notes:
 currently assumes that the noun referred to is in the previous input. If not, this
won’t work… but as we know from real conversation, humans can mess this up,
too!
 Will work for any noun found: I have a rock. His name is Jim.
3/31/2012
Copyright 2012 RIOT Software
14
Step 4: The Tokenizer
 Use the “multiple star” feature
 Example:
<pattern>I HAVE A * *</pattern> could match:
 I have a red car.
<star index=“1”> = “red”
 <star index=“2”> = “car”
 I have a really fast car.
 <star index=“1”> = “really”
 <star index=“2”> = “fast car”
 But will not match: I have a car.

 How to use this to count words and even find a word by
index in a sentence on following slides…
3/31/2012
Copyright 2012 RIOT Software
15
How many words in a sentence?
<pattern>WORDCOUNTER
<template>1</template>
<pattern>WORDCOUNTER
<template>2</template>
<pattern>WORDCOUNTER
<template>3</template>
<pattern>WORDCOUNTER
<template>4</template>
<pattern>WORDCOUNTER
<template>5</template>
<pattern>WORDCOUNTER
<template>6</template>
<pattern>WORDCOUNTER
<template>7</template>
3/31/2012
Copyright 2012 RIOT Software
*</pattern>
* *</pattern>
* * *</pattern>
* * * *</pattern>
* * * * *</pattern>
* * * * * *</pattern>
* * * * * * *</pattern>
16
Find the Nth word in a sentence
<pattern>FINDWORD 1 *</pattern>
<template><star/></template>
<pattern>FINDWORD 1 * *</pattern>
<template><star index=“1”/></template>
<pattern>FINDWORD 2 * *</pattern>
<template><star index=“2”/></template>
<pattern>FINDWORD 2 * * *</pattern>
<template><star index=“2”/></template>
<pattern>FINDWORD 3 * * *</pattern>
<template><star index=“3”/></template>
<pattern>FINDWORD 3 * * * *</pattern>
<template><star index=“3”/></template>
<pattern>FINDWORD 4 * * * *</pattern>
<template><star index=“4”/></template>
<pattern>FINDWORD 4 * * * * *</pattern>
<template><star index=“4”/></template>
3/31/2012
Copyright 2012 RIOT Software
17
Find a Specific Word in a Sentence
<pattern>FINDAWORDINSENTENCE WORD * SENT *</pattern>
 Find the length of the input sentence and initialize a counter to 1
 For each word in the sentence, does it match what we seek?
 Looking for word “kitten”
<set name=“temp”><srai>findword 1 <my sentence>
</srai> </set>

Call the wordmatch:
<srai>MATCHWORD kitten <get name=“temp/”></srai>
 This polls categories like:
<pattern>MATCHWORD kitten kitten</pattern>
<template>true</template>
 This works as long as Zoe has the word in her database
3/31/2012
Copyright 2012 RIOT Software
18
Step 5: The Starting Point
 Everything you say to Zoe matches “*”
 All remaining categories (except for “support” categories)
contains a keyword: EVALTHIS
 Example:
 Say “Hi” to Zoe
 Matches: <pattern>*</pattern>
 <template> executes the following:
<srai>EVALTHIS <star/></srai>
 Which in this case is:
<srai>EVALTHIS Hi</srai>
 What can be done in this starting category?
3/31/2012
Copyright 2012 RIOT Software
19
Things to do in the Starting Category
 Count the input
 Is the input a question or statement?
 Look for keywords in the input and decide whether or not
to do something other than match the expected category
 i.e., look for a known topic keyword and eval based on that
 Keep track of certain words that are used repeatedly
 Evaluate the “quality” of the match before returning to the
user
 Every category in Zoe with an “EVALTHIS” tag has a variable set:

<set name=“matchtype”> which can be set to:



3/31/2012
Atomic
Partial weak
Partial strong
Copyright 2012 RIOT Software
20
Sample * Category
<pattern>*</pattern>
<template>
<think><set name=“output”><srai>EVALTHIS
<star/></srai></set></think>
<condition name=“matchtype”>
<li value=“atomic”><get name=“output”/></li>
<li value=“partial weak”> ((do something else!!)) </li>
</condition>
</template>
 What is “something else”?
 Idea: look for words in the input that match say, a topic list, or known
nouns then do another EVALTHIS on a different input and look for
either “atomic” or “partial strong” matches
 Idea: Count number of “partial weak” matches in conversation and
steer conversation in a different direction
3/31/2012
Copyright 2012 RIOT Software
21
Partial vs. Atomic Matching
 User input: I went clothes shopping.
 Likely not an atomic match:
<pattern>I WENT *</pattern>
<template>How was it?</template>
 Zoe’s template includes setting variable “matchtype”:
<template>
How was it?”
<set name=“matchtype”>partial weak</set>
</template>
 Upon returning to the “*” category, Zoe can look for an alternate
response just based on other words like “clothes” and
“shopping” and possibly poll her knowledge database to say
something more interesting than “How was it?”
3/31/2012
Copyright 2012 RIOT Software
22
Zoe’s Ultimate Goal?
 This progression of development is to get to something
useful: Problem Solving.
 Lateral logic puzzles
 Simple example: Two grandmasters played five games of chess.
Each won the same number of games and lost the same number of
games. There were no draws in any of the games.
 Another example: There were two Americans waiting at the
entrance to the British Museum. One of them was the father of the
other one’s son.
 How could this be accomplished in AIML?
 Without “hardcoding” known puzzles
<pattern>* father * other * son</pattern>
3/31/2012
Copyright 2012 RIOT Software
23
Solving Lateral Logic Puzzles
Adeena: START PUZZLE
Zoe: Ok
Adeena: Romeo and Juliet are dead. They are in a locked
room on the 29th floor. There is a table in the room, a puddle
and some broken glass. The wind is blowing the curtains of
the only window in the room. Apart from the bodies of the
recently deceased, there is nothing else in the room. How did
Romeo and Juliet die?
Adeena: END PUZZLE
Note: NOT currently implemented! This is a goal!
3/31/2012
Copyright 2012 RIOT Software
24
Executing Algorithm Example (1/2)
<pattern>START PUZZLE</pattern>
<template>
 Set up a counter to count the number of sentences
 Set up or initialize arrays that will hold the information
 Set topic=“laterallogicpuzzle”
</template>
<topic=“laterallogicpuzzle”>
<pattern>*</pattern>
<template>
 Every sentence until “END PUZZLE” matches this category
 Parse every sentence to determine nouns, adjectives, verbs, names, etc
and store relevant information in an array/list
 Increment the sentence counter
</template>
3/31/2012
Copyright 2012 RIOT Software
25
Executing Algorithm Example (2/2)
<topic=“laterallogicpuzzle”>
<pattern>END PUZZLE</pattern>
<template>
 Set the topic to something else. Maybe topic=“QandAtime”
</template>
 Now the user lets the bot ask questions by asking: “Do you
have any questions?”
 Bot looks for gaps in it’s new knowledge comparing what it knows
to what it should know
 What are Romeo and Juliet?
 Eventually, the bot has no more knowledge it needs to acquire and
makes a guess at the solution…
3/31/2012
Copyright 2012 RIOT Software
26
www.riotsw.com
Download