Implementation of Elementary ChatBot for General purpose
- Get link
- X
- Other Apps
TITLE: -
Implementation of elementary ChatBot an Artificial Conversational Entity
for different purpose
Objective:
·
To study techniques of Artificial
Intelligence
·
To study about AIML & its
Implementation.
Requirements
(Hw/Sw): PC, Netbeans IDE/Text Editor (Linux) OR Windows OS,
Command Prompt & program-ab library.
Theory:-
What is ChatBot?
A
ChatBot (also known as a Talbots, chatterbots,
Bot, IM bot, interactive agent, or Artificial Conversational Entity) is a
computer program or an artificial intelligence which conducts a conversation
via auditory or textual methods.
Bot-a computer program that works automatically, especially one that searches for and finds information
Such programs are often designed to
convincingly simulate how a human would behave as a conversational partner,
thereby passing the Turing test. ChatBot are typically used in dialog systems
for various practical purposes including customer service or information
acquisition. Some chatterbots use sophisticated natural language processing
systems, but many simpler systems scan for keywords within the input, then pull
a reply with the most matching keywords, or the most similar wording pattern,
from a database.
The term "Chatterbots"
was originally coined by Michael Mauldin (creator of the first Verbot, Julia)
in 1994 to describe these conversational programs.Today, most chatbots are
either accessed via virtual assistants such as Google Assistant and Amazon
Alexa, via messaging apps such as Facebook Messenger or WeChat, or via
individual organizations' apps and websites.
Chatbots can be classified into usage
categories such as conversational commerce (e-commerce via chat), analytics,
communication, customer support, design, developer tools, education,
entertainment, finance, food, games, health, HR, marketing, news, personal,
prod
ChatBot creation
The
process of creating a ChatBot follows a pattern similar to the development of a
web page or a mobile app. It can be divided into Design, Building, Analytics
and Maintenance.
Design
The
ChatBot design is the process that defines the interaction between the user and
the ChatBot. The ChatBot designer will define the ChatBot personality, the
questions that will be asked to the users, and the overall interaction.
It can be viewed as a subset of the
conversational design. In order to speed up this process, designers can use
dedicated ChatBot design tools that allow for immediate preview, team collaboration
and video export. An important part of the ChatBot design is also centered
around user testing. User testing can be performed following the same
principles that guide the user testing of graphical interfaces.
Building
The
process of building a ChatBot can be divided into two main tasks: understanding
the user's intent and producing the correct answer. The first task involves
understanding the user input. In order to properly understand a user input in a
free text form, a Natural Language Processing Engine can be used. The second
task may involve different approaches depending on the type of the response
that the ChatBot will generate.
Analytics
The
usage of the ChatBot can be monitored in order to spot potential flaws or
problems. It can also provide useful insights that can improve the final user
experience.
Maintenance
To
keep ChatBot up to speed with changing company products and services,
traditional ChatBot development platforms require ongoing maintenance. This can
either be in the form of an ongoing service provider or for larger enterprises
in the form of an in-house ChatBot training team.
To
eliminate these costs, some startups are experimenting with Artificial
Intelligence to develop self-learning chatbots, particularly in Customer
Service applications.uctivity, shopping, social, sports, travel and utilities.
Conversational AI chat-bot — Architecture
overview
It is a AI / ML driven architecture: The model learns the actions
based on the training data provided (unlike a traditional state machine based
architecture that is based on coding all the possible if-else conditions for each
possible state of the conversation.)
Here is a high level overview of such an architecture
for a chat-bot
Refer to the components in the
above diagram, as we go through the flow. First, lets see what all things do we
need to determine an appropriate response at any given moment of the
conversational flow?
1. We need to know the user’s intent — We
will call these as intents. Few examples of intents
are — ‘request weather’, ‘request restaurant’ etc., The intent in the above
example is ‘request weather’.
2. We need to know the specific intents
in the request (we will call them as entities), for eg — the
answers to the questions like when?, where?, how many? etc., that correspond to
extracting the information from the user request about datetime, location,
number respectively. Here datetime, location, number are the entities.
Quoting the above weather example, the entities can be ‘datetime’ (user
provided information) and location (note — location need not be an explicit
input provided by the user and will be determined from the user location as
default, if nothing is specified).
The intent and
the entities together will help to make a corresponding API call to a weather
service and retrieve the results, as we will see later.
Now refer to
the above figure, and the box that represents the NLU component (Natural
Language Understanding) helps in extracting the intent and
entities from the user request.
NLU component constitues —
·
A supervised
intent classification model that is trained on varieties of sentences as input
and intents as target. Typically, a linear SVM will be enough as an intent
classification model.
·
Entity
extraction model — This can be a pre-trained model like Spacy or StanfordNLP
library (OR) it can be trained using some probabilistic models like CRF (conditional
random fields).
3. Now, since
ours is a conversational AI bot, we need to keep track of the conversations
happened thus far, to predict an appropriate response. For this purpose, we
need a dictionary object that can be persisted with information about the
current intent, current entities, persisted information that user would have
provided to bot’s previous questions, bot’s previous action, results of the API
call (if any). This information will constitute our input X, the
feature vector. The target y, that the dialogue model
is going to be trained upon will be ‘next_action’ (The next_action can
simply be a one-hot encoded vector corresponding to each actions that we define
in our training data).
Then, that
brings us to the next question — how do we get the training values for our
feature vector, input X?
·
Getting the
information regarding the intent and entities is straightforward as we have
seen from the NLU component.
·
Getting the
remaining values (information that user would have provided to bot’s
previous questions, bot’s previous action, results of the API call etc.,)
is little bit tricky and here is where the dialogue manager component takes
over. These feature values will need to be extracted from the training data
that the user will define in the form of sample conversations between
the user and the bot. These sample
conversations should be prepared in such a fashion that they
capture most of the possible conversational flows while pretending to be both
an user and a bot.
·
Referring to the above figure, this is what the ‘dialogue
management’ component does. Why LSTM is more appropriate? — As
mentioned above, we want our model to be context aware and look back into the
conversational history to predict the next_action. This is akin to a time-series
model and hence can be best captured in the memory state of the LSTM model. The
amount of conversational history we want to look back can be a configurable
hyper-parameter to the model.
Now, the predicted value of the next_action can be something like —
·
Respond to the user with an appropriate message
·
Retrieve some data from a database (if we have any)
·
Make an API call and get some results matching the
intent.
If it happens to be an API call
/ data retrieval, then the control flow handle will remain within the ‘dialogue
management’ component that will further use/persist this information to predict
the next_action, once again. The dialogue manager will
update its current state based on this action and the retrieved results to make
the next prediction. Once the next_action corresponds to
responding to the user, then the ‘message
generator’ component
takes over.
Message generator component consists of several
user defined templates (templates are nothing but sentences with some
placeholders, as appropriate) that map to the action names. So depending
on the action predicted by the dialogue manager, the respective template
message is invoked. If the template requires some placeholder values to be
filled up, those values are also passed by the dialogue manager to the
generator. Then the appropriate message is displayed to the user and the bot
goes into a wait mode listening for the user input.
·
Set-up
steps(Using NetBeans):
·
Step
1 - Set up Java Development Kit (JDK)
·
Step
2 - Set up Program AB(https://code.google.com/archive/p/program-ab/downloads
Ø Download
the program-ab file.
Ø Copy
the bots folder into project
folder.
Ø Add
the Ab.jar file to the
project libraries.
Ø Create
the .aiml file in bots/super/aiml folder.
Ø Create
the .aiml.csv file in bots/super/aimlif
folder.
Program-AB File:
Program AB is an experimental platform for the development
of new features and serves as the reference implementation. You can use Program AB in a variety of ways: Run Program AB to chat with a bot. Analyze log files and develop bot content.
.Jar File
A JAR (Java ARchive) is a package file format typically used to aggregate
many Java class files and associated metadata and resources
(text, images, etc.) into one filefor
distribution.
AIML
AIML
stands for Artificial Intelligence Markup Language. AIML was
developed by the Alicebot free software community and Dr. Richard S. Wallace
during 1995-2000. AIML is used to create or customize Alicebot which is a
chat-box application based on A.L.I.C.E. (Artificial Linguistic Internet
Computer Entity) free software.
.aiml.csv file
AIMLIF (AIML Intermediate Format) is a hybrid of CSV and XML. It is what I developed for fast loading and editing of AIML files for Program AB.
AIMLIF (AIML Intermediate Format) is a hybrid of CSV and XML. It is what I developed for fast loading and editing of AIML files for Program AB.
Data tables are presented in Comma
Delimited, CSV text file format. Although this file
format allows for the data table to be easily retrieved into a variety of
applications, they are best viewed within one that will allow one to easily
manipulate data that is in columnar format. Common examples of such
applications are those that are used to create spreadsheets and databases.
AIML Tags
Following
are the important tags which are commonly used in AIML documents.
S.No.
|
AIML
Tag / Description
|
1
|
<aiml>
Defines
the beginning and end of a AIML document.
|
2
|
<category>
Defines
the unit of knowledge in Alicebot's knowledge base.
|
3
|
<pattern>
Defines
the pattern to match what a user may input to an Alicebot.
|
4
|
<template>
Defines
the response of an Alicebot to user's input.
|
AIML Vocabulary
AIML
vocabulary uses words, space and two special characters * and _ as
wild cards. AIML interpreter gives preference to pattern having _ than
pattern having *. AIML tags are XML compliant and patterns are
case-insensitive.
Example
<aiml version = "1.0.1" encoding = "UTF-8"?>
<category>
<pattern> HELLO ALICE </pattern>
<template>
Hello User!
</template>
</category>
</aiml>
Let us
start creating first bot which will simply greet a user with Hello
User! when a user types Hello Alice.
Create
the Project Structure
As
in AIML Environment Setup, we've
extracted content of program-ab in C > ab with the
following directory structure.
S.No.
|
Directory & Description
|
1
|
c:/ab/bots
Stores
AIML bots
|
2
|
c:/ab/lib
Stores
Java libraries
|
3
|
c:/ab/out
Java
class file directory
|
4
|
c:/ab/run.bat
batch
file for running Program AB
|
Now,
create a directory test inside C > ab > bots and create
the following directories in it.
S.No.
|
Directory & Description
|
1
|
c:/ab/bots/test/aiml
Stores
AIML files
|
2
|
c:/ab/bots/test/aimlif
Stores
AIMLIF files
|
3
|
c:/ab/bots/test/config
Stores
configuration files
|
4
|
c:/ab/bots/test/sets
Stores
AIML Sets
|
5
|
c:/ab/bots/test/maps
Stores
AIML Maps
|
Create Source Files
Create test.aiml
inside C > ab > bots > test > aiml and
test.aiml.csv inside C > ab > bots > test > aimlif directories.
test.aiml
<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version="1.0.1" encoding = "UTF-8"?>
<category>
<pattern> HELLO ALICE </pattern>
<template>
Hello User
</template>
</category>
</aiml>
test.aiml.csv
0,HELLO ALICE,*,*,Hello User,test.aiml
Execute
the Program
Open the
command prompt. Go to C > ab > and type the following
command
java -cp lib/Ab.jar Main bot = test action = chat
trace = false
ab.jar
aiml
aiml tags
Artificial Conversational Entity
artificial intelligence
chatbot
chatterbot
jdk
netbeans
nlu components
program-ab library
talkbot
- Get link
- X
- Other Apps
Popular Posts
Vivo Z1 Pro will be the first smartphone that comes with 712 chipset, Learn the specialty of this processor.
Vivo Z1 Pro is going to launch in India on July 3. Certain specifications of the phone include the Snapdragon 712 chipset with Enhanced GPU and 5000 mAh battery. The latest Social Media Review reveals that the company has focused on gamers for its new phone. Better cooling, better connectivity, Net Turbo and Turbo have also given many other features, which will further improve the phone's performance. Vivo Z1 Pro will provide users with a good gaming experience with a special game countdown without any interruption. You can also change your PUBG Voice when you are gaming. After the game has started, the phone will also provide 4D vibration and 3D surround sound. Other specification of the phone has a punch-hole design with 32MP sleigh shooter and a triple setup on the rear. The 18W Fast-Charging Capabilities is also given in the phone with the bigger battery. The phone will work on Android Pie Function OS 9. The main feat
Comments
Post a Comment