Lect 07
Lect 07
By Ivan Wong
Introduction
• Chatbots are interactive systems that allow users to interact in
natural language.
• They generally interact via text but can also use speech
interfaces.
• Early 2016 saw the introduction of the first wave of chatbots that
soon became ubiquitous.
• Platforms like Facebook Messenger, Google Assistant, and
Amazon Alexa are some examples of chatbots.
• There are now tools that allow developers to create custom
chatbots for their brand or service so that consumers can carry
out some of their daily actions from within their messaging
platforms.
Introduction
• The history of chatbots and of artificial intelligence in general are
pretty intertwined.
• In the 1950s and ’60s, computer scientists Alan Turing and Joseph
Weizenbaum contemplated the concept of computers
communicating like humans do.
• Later, in 1966, Joseph Weizebaum built Eliza, the first chatterbot
ever coded, using only 200 lines of code.
• Eliza imitated the language of a Rogerian Psychotherapist using
regular expressions and rules.
• Humans knew they were interacting with a computer program,
and yet, through the emotional responses Eliza would offer, still
grew emotionally attached to the program during trials.
Introduction
• Later, in the advent of powerful signal processing tools,
researchers focused on building spoken dialog tools with
the goal of improving user experience.
• Many spoken dialog systems were built between 1980
and 2000 and started as military-based projects (by
DARPA) aimed mainly at improving automated
communication with soldiers.
• The systems were used to provide instructions, which
later translated into chatbots capable of helping users
get answers to frequently asked questions for various
services.
Introduction
• In recent years, chatbots have become more feasible
and useful, both due to the ubiquity of smartphones and
recent advances in ML and DL.
• In addition to APIs to create chatbots on popular
messaging platforms like Facebook Messenger, we now
have various platforms to create the AI and logic behind
the chatbots.
• This has allowed folks and companies with limited AI
background and experience to deploy their own
chatbots easily.
Applications
• Shopping and e-commerce
• Recently, chatbots are being used for various e-commerce operations, including placing
or modifying an order, payment, etc.
• News and content discovery
• Similar to e-commerce, chatbots can be used in news and content discovery.
• Customer service
• Customer service is another area where bots are used heavily. They’re used to lodge
complaints, help answer FAQs, and navigate queries in pre-defined conversational
flows set by the business requirements.
• Medical
• In health and medical applications, FAQ bots are of great use. These bots can help
patients fetch relevant information quickly based on their symptoms.
• Legal
• In legal applications, bots can also be used to serve FAQs for users. They can even be
used for more complex goals, such as asking follow-up questions.
A Simple FAQ Bot
• A FAQ bot is generally a search-based system where,
given a question, it looks for correct answers and
provides them to the user.
• It’s essentially a bot that allows a user to ask questions
in different ways to get a response.
• Such bots are quite useful for providing a conversational
interface to a complex set of questions.
E.g., Amazon ML FAQ to be used for
a FAQ bot
Questions Answer
What can I do with Amazon Machine You can use Amazon Machine Learning to create
Learning? a wide variety of predictive applications. For
How can I use Amazon Machine example, you can use Amazon Machine Learning
Learning? to help you build applications that flag suspicious
What can Amazon Machine Learning transactions, detect fraudulent orders, forecast
do? demand, etc.
What algorithm does Amazon Machine Amazon Machine Learning currently uses an
Learning use to generate models? industry-standard logistic regression algorithm to
How does Amazon Machine Learning generate models.
build models?
Are there limits to the size of the Amazon Machine Learning can train models on
dataset I can use for training? data
What is the maximum size of training
dataset?
A Taxonomy of Chatbots
• Chatbots can be classified in many ways, which affects how
they’re built and where they’re used.
• A way of looking at these chatbots is how they interact with the user:
• Exact answer or FAQ bot with limited conversations
• These chatbots are linked to a fixed set of responses and retrieve a
correct response based on understanding the user’s query
• Flow-based bot
• Flow-based conversational bots are generally more complex than FAQ
bots in terms of the variability of their responses.
• Open-ended bot
• Open-ended bots are intended mainly for entertainment, where the bot
is supposed to converse with the user about various topics.
A Taxonomy of Chatbots
• Chatbots are classified into two broad categories: (1)
goal-oriented dialogs and (2) chitchats.
• FAQ bots and flow-based bots fall into the first category,
whereas open-ended bots are mainly chitchat types.
• Both of these types of bots are used heavily in industry
and are also in the active area of research in academia.
Goal-Oriented Dialog
• It is easy to design any chatbot or conversation agent
for a specific use case where the end goal is known.
• The user interacting with the chatbot should have
complete information about what they want to achieve
after the conversation.
• For example, looking for a movie recommendation or booking
flight reservations through chatbots or conversational agents
are examples of goal-oriented dialog where the goal is to
watch a movie or book a flight.
• The goal-oriented systems are domain-specific, which
requires domain-specific knowledge in the system.
Chitchats
• Apart from goal-oriented conversations, humans also engage
in unstructured, open-domain conversations without any
specific goals.
• These human-human conversations involve free-form,
opinionated discussions about various topics.
• Having a conversational agent that can have a chitchat with a
human is challenging due to the absence of objective goals.
• A conversational agent must generate coherent, on-topic, and
factually correct responses to make the dialog more natural.
• The application of chitchat bots is futuristic but holds immense
potential.
A Pipeline for Building Dialog Systems
Speech recognition
• Usually, the dialog system works as an interface
between human and machine, so the input into the
dialog system is human speech.
• Speech recognition algorithms transcribe speech to
natural text. In industrial dialog systems, state-of-the-
art speech-to-text models are used, which is beyond the
scope of this book.
Natural language understanding
(NLU)
• After transcribing, the system tries to analyze and
“understand” the transcribed text.
• This module encompasses various natural language
understanding tasks.
• Examples of such tasks are sentiment detection, named entity
extraction, coreference resolution, etc.
• This module is primarily responsible for gathering all
possible information that is implicitly (sentiment) or
explicitly (named entities) present in the input text.
Dialog and task manager
• Once we obtain information from the input, a dialog manager, as
shown in the figure, gathers and systematically decides which
pieces of information are important or not.
• A dialog manager is a module that controls and guides the flow
of the conversation.
• Imagine this as a table containing information extracted in NLU steps
and stored concurrently for all utterances in the ongoing conversation.
• The dialog manager develops a strategy via rules or other
complex mechanisms, such as reinforcement learning, to
effectively utilize the information obtained from the input.
• Dialog managers are mostly prevalent in goal-oriented dialogs
since there’s a definite objective to reach via the conversation.
Natural language generation
• Finally, as the dialog manager decides a strategy for
responding, the natural language generation module
generates a response in a human-readable form
according to the strategy devised by the dialog
manager.
• The response generator could be template based or a
generative model learned from data.
• After this, a speech synthesis module converts the text
back to speech to the end user.
Dialog Systems in Detail
• The main idea of a dialog system or chatbot is to
understand a user’s query or input and to provide an
appropriate response.
• This is different from typical question-answering systems
where, given a question, there has to be an answer.
• In a dialog setup, users may ask their queries in “turns.”
• In each turn, a user reveals their interest about the topic
based on what the bot may have responded with.
• So, in a dialog system, the most important thing is
understanding nuances from the user’s input in a turn-by-
turn way and storing them in context to generate responses.
Dialog act or intent
• This is the aim of a user command. In traditional
systems, the intent is a primary descriptor.
• Often, several other things, such as sentiment, can be
linked to the intent.
• The intent is also called a “dialog act” in some
literature.
• These intents are usually pre-defined based on the
chatbot’s domain of operation.
Slot or entity
• This is the fixed ontological construct that holds
information regarding specific entities related to the
intent.
• The information related to each slot that’s surfaced in
the original utterance is “value.”
• The slots and value together are sometimes denoted as
an “entity.”
Dialog state or context
• A dialog state is an ontological construct that contains
both the information about the dialog act as well as
state-value pairs.
• Similarly, context can be viewed as a set of dialog
states that also captures previous dialog states as
history.
Example of
different
terminology
used in
chatbots
Dialogflow by Google
• Dialogflow is a conversational agent–building platform
by Google.
• By providing the tools to understand and generate
natural language and manage the conversation,
Dialogflow enables us to easily create conversational
experiences.
• While there are many other tools available, we chose
this one because it’s easy to use, mature, and is being
improved constantly.