Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system,...

27
I, Zoe: Evolution of an AIML Chatbot Adeena Mignogna Riot Software riotsw.com

Transcript of Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system,...

Page 1: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

I, Zoe: Evolution of an AIML Chatbot

Adeena MignognaRiot Software

riotsw.com

Page 2: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 2

What is Zoe?A “pure” AIML chatbot

Without system, javascript tags2nd Place in 2011 Loebner Contest

Tied for 1st place in the “Junior” Loebner ContestZoe is NOT a clone

All 64,122 categories were created from scratch

Orion(Program

E)

Lucy(Program

E)

Khloe(AIML only / Pandorabots)

Zoe(AIML only / Pandorabots)

2008 2009 2010 2011+

3/31/2012

Page 3: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software

A bot needs a purpose…A bot can’t (initially!) be all things to everyone

3

General Conversatio

n

Q&A

OtherGuided

Conversation

General Knowledge

Memory

Relationships

Problem SolvingOpen

Conversation

Topical

Zoe3/31/2012

Page 4: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 4

Zoe’s Development StepsStep 1: Let the conversation continueStep 2: The knowledge databaseStep 3: Arrays and list structuresStep 4: The tokenizerStep 5: The starting pointStep 6 through N: (not currently

implemented)Part-of-speech taggingProbabilistic models

Problem Solving

3/31/2012

Page 5: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 5

Step 1: Let the conversation continueNo 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 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?

3/31/2012

Page 6: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 6

This is Incomplete…JUDGE: lets talk about cloadsORION: Sure. Tell me something interesting

about cloadsJUDGE: cloads are not always whiteORION: They are? Tell me moreJUDGE: you can get big cloads and small

cloadsORION: How do you know this?JUDGE: I am a geniusORION: A genius? Cool. Are you a person?JUDGE: of coarse I’m a personORION: Tell me more.Taken from Orion’s 2008 Loebner Contest logs

3/31/2012

Page 7: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 7

Step 2: Knowledge DatabaseInitial knowledge base designed to handle the

Loebner Prize sample questionsWhich 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 a tool 2 0

…3/31/2012

Page 8: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 8

Knowledge Base In ActionSpreadsheet 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

Page 9: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 9

Step 3: Array/List StructureThe 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 SEPNeed categories to:

Add element at the end Count elements Find a specific element (first, last, by index)

3/31/2012

Page 10: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 10

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

Page 11: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 11

In practice:Adeena: My eyes are blueZoe: I’ll try to remember thatAdeena: I have a brown carZoe: I’ll try to remember thatAdeena: How are you today?Zoe: I’m fine. How are you?Adeena: What color are my eyes?Zoe: You told me that your eyes are blue.Adeena: What did I tell you about my car?Zoe: 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

Page 12: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 12

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

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!>

3/31/2012

Page 13: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 13

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

Page 14: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 14

Combine Knowledge Database & Array Structure to Handle PronounsHuman 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

Page 15: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 15

Step 4: The TokenizerUse the “multiple star” featureExample:

<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

Page 16: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 16

How many words in a sentence?<pattern>WORDCOUNTER *</pattern><template>1</template><pattern>WORDCOUNTER * *</pattern><template>2</template><pattern>WORDCOUNTER * * *</pattern><template>3</template><pattern>WORDCOUNTER * * * *</pattern><template>4</template><pattern>WORDCOUNTER * * * * *</pattern><template>5</template><pattern>WORDCOUNTER * * * * * *</pattern><template>6</template><pattern>WORDCOUNTER * * * * * * *</pattern><template>7</template>

3/31/2012

Page 17: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 17

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

Page 18: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 18

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

Page 19: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 19

Step 5: The Starting PointEverything you say to Zoe matches “*”All remaining categories (except for “support”

categories) contains a keyword: EVALTHISExample:

Say “Hi” to ZoeMatches: <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

Page 20: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 20

Things to do in the Starting CategoryCount the inputIs 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 repeatedlyEvaluate the “quality” of the match before returning to

the userEvery category in Zoe with an “EVALTHIS” tag has a variable

set: <set name=“matchtype”> which can be set to:

Atomic Partial weak Partial strong

3/31/2012

Page 21: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 21

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

Page 22: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 22

Partial vs. Atomic MatchingUser 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

Page 23: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 23

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

Page 24: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 24

Solving Lateral Logic PuzzlesAdeena: START PUZZLEZoe: OkAdeena: 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

Page 25: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 25

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

Page 26: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Copyright 2012 RIOT Software 26

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

Page 27: Adeena Mignogna Riot Software riotsw.com. What is Zoe? A pure AIML chatbot Without system, javascript tags 2 nd Place in 2011 Loebner Contest Tied for.

Happy Chatting!

www.riotsw.com