Title: The Learning Chatbot
1The Learning Chatbot
- Bonnie Chantarotwong
- IMS-256 Fall 2006
2What is wrong with state of the art chatbots?
- They are repetitive
- They are predictable
- simple pattern matching set response
- They have no memory
- can lead to circular conversations
- They dont sound like real people
3Proposed Solution
- Train chatbots on a corpora of conversations in
order to mimic a given personality
4Filtering the training corpus
- Need a lot of conversations containing query
screen name - Eliminate undesirable data
- phone numbers
- Addresses
- sensitive gossip
- Eliminate highly technical data
- since most tech problems are very specific,
unless the bot was trained on a newsgroup,
learned responses are not likely to be useful for
tech support
5Parsing the training corpus
- Extract messages from HTML
- Group together consecutive messages by the same
screen name - Simplify prompt messages
- !!!!!!!??????? -gt !?
- Ohhhhhhhhhhhh! -gt ohh!
- WhATz uP?? -gt whatz up?
- hahahahaha -gt haha
- Break prompts into word sequences (eliminating
stop words) - I took the cat to a vet -gt i, took, cat, to,
vet
6Constructing the CFD
- CFD conditions are prompt words
- FD samples are string responses, with numeric
count indicating strength of correlation - Example
- Cfdsleep.sorted_samples() -gt
- sleep is the best thing ever, are you
tired?, maybe after I eat., hang on a sec.
7Constructing the CFD
Simple Concept If a prompt is n words long,
then each word is 1/n likely to have caused the
response
i
1/3
Can we put mittens on it?
1/3
want
1/3
kitten
1/3
1/3
Me too, Im hungry.
food
1/3
1/6
they
1/6
What kind did they have?
1/6
had
1/6
good
1/6
1/6
at
restaurant
Original ConversationA I want a kittenB Can
we put mittens on it?A I want foodB Me too,
Im hungryA They had good food at the
restaurantB What kind did they have?
8Using the CFD
- Problem
- Each word in a prompt is not equally likely to
have caused the response - More common words (such as I) are less
indicative of meaning - Solution
- Take into account the commonality of the word
over all conversations - Divide the weight of the word/response pair by
the weight sum over all samples for that word - Rare words are weighted more using a dynamic
scale - This improved quality of bot responses greatly!
9Using the CFD - Example
CFD Cfdi (Can we put mittens on it?,
1/3), (Me too, Im hungry, 1/3) Sum
2/3 Cfdwant (Can we put mittens on it?,
1/3), (Me too, Im hungry, 1/3) Sum
2/3 Cfdkitten (Can we put mittens on
it?, 1/3) Sum 1/3 Cfdfood (Me too,
Im hungry, 1/3), (What kind of food did they
have?, 1/6) Sum 1/2 Cfdthey (What
kind of food did they have?, 1/6) Sum
1/6 Cfdhad (What kind of food did they
have?, 1/6) Sum 1/6 Cfdgood (What
kind of food did they have?, 1/6) Sum
1/6 Cfdat (What kind of food did they
have?, 1/6) Sum 1/6 Cfdrestaurant
(What kind of food did they have?, 1/6) Sum
1/6 Responses (how is your kitten?)
(Can we put mittens on it?, (1/3 / 1/3)
1) Responses (the food was good) (Me too,
Im hungry, (1/3 / 1/2) 2/3), (What
kind of food did they have?, (1/6 / 1/2 1/6 /
1/6) 4/3
10Using the CFD
- Responses (the food was good) (Me too, Im
hungry, (1/3 / 1/2) 2/3), - (What kind of food did they have?,
(1/6 / 1/2 1/6 / 1/6) 4/3 - Given the CFD, the response to any prompts
containing food and good will give back What
kind of food did they have? - Problem This can lead to redundancy
- A The food was good
- B What kind of food did they have?
- A Didnt you think the food was good?
- B What kind of food did they have?
- Solution Store an FD of used responses, and
dont use them again - A The food was good
- BWhat kind of food did they have?
- A Didnt you think the food was good?
- B Me too Im hungry
11What if we have no responses?
- Because
- Weve never encountered any of the prompt words
- Weve used up all relevant responses
- We can
- Find a random response
- Enhance randomness by favoring unlikely responses
(near the end of association lists) to reduce
redundancy - Fabricate a response based on pattern matching
- Select a response from a default list of
responses (i.e. Lets talk about something else,
I dont know anything about that - All my bots implement 1 2, and one bot
(bonnie) also implements 3 4
12Interactive Webpages are not trivial
- Especially if you want to retain some memory of
the past - First CGI problem A new bot is created with
every web prompt - all memory is lost - Solution
- Write all bot state changes to a file, including
used responses. - Run this file with every prompt, and reset it
when a new conversation starts - The bot loads the huge CFD all state changes
from scratch with EVERY call. Slow, but works.
13Interactive Webpages are not trivial
- Memory Self-modifying code
14Interactive Webpages are not trivial
- Memory Self-modifying code
15Demo
http//ischool.berkeley.edu/bonniejc/