AIML – A Language for Chatbots
This article was published as a part of the Data Science Blogathon.
What is a Chatbot?
Chatbots are intelligent digital assistants which may address customer’s basic and predictable queries. They offer numerous services via chatting and perform basic customer service operations. Chatbots work 24/7 and hence they provide assistance when offices are closed on holidays.
There are a variety of synonyms for chatbot, including “talkbot,” “bot,” “IM bot,” “interactive agent” or “artificial conversation entity.“
Most organizations have already started implementing chatbots on their sites especially on banking, airlines, and e-commerce websites.
Some more samples of chatbot technology are virtual assistants like Amazon’s Alexa, Google Assistant, and Messaging apps, like WeChat and Facebook messenger.
Nowadays, chatbots are becoming more complex and advanced features like taking customer’s complaint, performing transactions by taking customer’s input, even alerting real human supported the query posted. Chatbots are getting context-aware and may engage end-users supported by the context set during the conversation.
So, welcome to the planet of Artificial Intelligence!! Today, we are visiting to explore how straightforward chatbots are often created easily using the AIML library.
Types of Chatbots – Broadly, there are two kinds of chatbots:
The rule-based chatbots work supported pre-written keywords that they understand. They use regular expressions or other types of string analysis. If the user has asked an issue without employing a single keyword, the chatbot might not realize it.
AI-based chatbots depend on computer science once they communicate with users. rather
than pre-prepared answers, the chatbot responds with adequate suggestions on the subject. additionally, the chatbot can find new ways to reply by learning from the previous communications.
What is AIML?
AIML stands for computing language. it’s an XML dialect for creating tongue software agents.
AIML contains a collection of rules which define the conversational capabilities of the chatbot. it’s used with a linguistic communication Understanding (NLU) processor which takes AIML rules to investigate and reply to the text queries asked via the chatbot. The more rules we add in AIML – the more intelligent the chatbot is.
- AIML based chatbots come under the rule-based chatbots category, however, some level of self-learning feature is feasible.
- AIML is that the language to make a brain for chatbots.
- NLU in chatbots process AIML and their chat behavior is controlled through AIML rules.
- One chatbot application can have multiple sets of AIML and might behave differently.
The below flow diagram shows how AIML based chatbot can work with a range of input, which essentially represents the texts with identical meaning.
The three texts “take call”, “accept call”, and “join call” end up in the identical action of “accept call”.
Also, as a limitation of the AIML based chatbot, if no input pattern is satisfied, the boat will simply reply with default the generic statement “could not understand the phrase”.
However, given rich AIML rules, it’s possible to form a chatbot that will handle a broad range of queries. It makes it the most effective suited domain-specific businesses, like banking where chatbot should handle generic queries associated with the banking domain.
AIML was originally developed by Dr. Richard Wallace and a worldwide free software community between 1995 and 2002. It formed the idea for what was initially a highly extended Eliza called “A.L.I.C.E..” (“Artificial Linguistic Internet Computer Entity”), which won numerous awards.
An AIML interpreter AliceBot program is on the market under GNU GPL, which might be the accustomed test and develop AIML based intelligent bot.
The latest version is AIML 2.0 which has powerful NLP processing.
AIML describes a category of information objects called AIML objects and partially describes the behavior of computer programs that process them.
AIML objects are made of units called topics and categories, which contain either parsed or unparsed data. Parsed data is created of characters, several of which form character data, and a few of which form AIML elements.
AIML elements encapsulate the stimulus-response knowledge contained within the document. Character data within these elements is usually parsed by an AIML interpreter and sometimes left unparsed for later processing by a Responder.
Below is the coding structure of the AIML element :
<?xml version="1.0" encoding="UTF-8"?> <!-- The line number 1 is optional --> <aiml version="2.0"> ......... ......... </aiml> <!-- <aiml> tag wraps the content of the AIML file. Let's say we have one Question: Do you know who (any person name) is? Bot answer: <<Input person name>> is my friend. The AIML would be --> <aiml version=“2.0”> <category> <pattern>DO YOU KNOW WHO * IS</pattern> <template><star/> is my friend.</template> </category> </aiml> <!-- Wildcard (*) representing any input question is represented by <star/> tag in the template. -->
AIML – CATEGORIES / TEMPLATE / PATTERN
The basic unit of information in AIML is named a category. Each category consists of an input question, an output answer, and an optional context.
The question, or stimulus, is termed the pattern. The answer, or response, is named the template. the 2 primary varieties of optional context are called “that” and “topic.”
The AIML pattern language is easy, consisting only of words, spaces, and wildcard symbols sort of a and *. The words may include letters and numerals, but no other characters. The pattern language is case invariant. Words are separated by one space, and also the wildcard characters function like words.
AIML supports mainly two forms of wildcards * and ^ symbols.
The * symbol is in a position to capture one (1) or more words within the user input
The ^ symbol is additionally a wildcard, however, it can capture 0 or more words.
There are two other wildcards, _, and #. These can override even exact matches and employed in a posh scenario.
You can have quite one wildcard per pattern. you’ll be able to echo multiple wildcards in your pattern by using, where x corresponds to the indicator (position within the sentence) of the wildcard. Not including the index assumes the primary wildcard.
For example :
<category> <pattern>MY NAME IS * AND I AM * YEARS OLD</pattern> <template>Hi <star/>, I am also <star index="2" /> years old!</template> </category> <!-- OUTPUT User: My name is Gyan and I am 30 years old. Bot: Hi Gyan, I am also 30 years old! -->
Predicate values in AIML are similar to local variables specific to one client. The most popular predicates are client profile information like name, gender, marital status, age, predicates, but it can be used to store any string.
AIML predicates are set with the tag <set> and obtained with the tag <get>. Predicates are quite specific for an individual client, but the predicates may have default values that are defined within a specific bot.
<category> <pattern>HI</pattern> <template> <random> <li>Hello!</li> <li>Well hello there.</li> <li>Howdy.</li> <li>Good day.</li> <li>Hi, friend.</li> </random> </template> </category> <!-- For the same user input 'Hi', the bot will return random text out of the list in <li> tag e.g. User: Hi Bot: Howdy. User: Hi Bot: Good Day. User: Hi Bot: Hello! --> <category> <pattern>I am *</pattern> <template> Hello <set name = "username"> <star/>! </set> </template> </category> <category> <pattern>Good Night</pattern> <template> Hi <get name = "username"/> Thanks for the conversation! </template> </category> <!-- Here the <set> tag set the variable username with whatever <star> contains. The <get> tag is used to retrieve the value of the variable username. The conversation would be like this: Human: I am Gyan Robot: Hello Gyan! Human: Good Night Robot: Good Night Gyan! Thanks for the conversation! -->
AIML can be used to solve many real-life applications. The creation of Chatbot is one such application that is now widely used in the market. Also, AIML acts as the core of Machine Learning which is integration to Natural Language Processing.
The media shown in this article on Top Machine Learning Libraries in Julia are not owned by Analytics Vidhya and is used at the Author’s discretion.