AIML
Hanoi, 5 - 2018
1
Contents
1
• Fundamentals
2
• AIML Syntax
3
• Chatbot training and demo
4
• Conclusion
5
• Further development
2
Everything has a story
3
1. Fundamentals
• What is a chatbot?
▫ A chatbot (or bot) is a conversational software program designed to chat with
humans via voice or text.
▫ It is a natural language processing (NLP) chatbot designed to engage in a
conversation by reacting to human input and responding as naturally as possible.
▫ ALICE has won three times Loebner Prize winner (2000, 2001, 2004) - an award
for accomplished humanoid and talking robots.
▫ Turing test: a test for intelligence in a computer, requiring that a human being
should be unable to distinguish the machine from another human being by using
the replies to questions put to both.
▫ Talk with ALICE: https://www.pandorabots.com/pandora/talk?botid=a847934aae3456cb
4
1. Fundamentals
• AIML stands for Artificial Intelligence Modelling Language.
• AIML is a simple, XML-based scripting language and the open
standard for writing chatbots
5
1. Fundamentals
• There are many script languages supporting writing a chatbot
▫ AIML (1995)
▫ Façade (2005)
▫ RiveScript (2009)
▫ ChatScript (2010)
• Why we use AIML?
 Easy to learn and implement for beginners for its based on XML
 Strong support interpreters with popular programming languages (Java,
Python, Ruby …)
 Various available platforms, AIML resources and documents for
inheritance
6
1. Fundamentals
• AIML interpreter
▫ a program that can load and run an AIML bot and provide responses to
conversational requests according to the AIML specification in this
document.
▫ Program O is an AIML interpreter written in PHP
▫ Program Y is an AIML interpreter written in Python
▫ Program AB is an AIML interpreter written in Java (used in TIMA chatbot)
7
1. Fundamentals
• Chatbot using AIML workflow
8
User input
to-text
converter
AIML
Intepreter
data text
AIML
dataset
query
Output match
F
T
2. AIML syntax
• Structure tags
<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version="2.0">
<category>
<pattern>
hello alice
</pattern>
<template>
Hello User
</template>
</category>
</aiml>
9
S.No. Tag
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.
2. AIML syntax
• Content tags - <star>
▫ <star> Tag is used to match wild card * character(s) in <pattern> Tag.
▫ <star index = "n"/>
<category>
<pattern>I LIKE *</pattern>
<template>
I too like <star/>.
</template>
</category>
<category>
<pattern>A * IS A *</pattern>
<template>
How <star index = "1"/> can not be a <star index = "2"/>?
</template>
</category>
10
2. AIML syntax
• Content tags - <srai>
▫ <srai> Tag is a multipurpose tag. This tag enables AIML to define the
different targets for the same template.
▫ <srai> pattern </srai>
▫ Following are the commonly used terms associated with srai −
 Symbolic Reduction
 Divide and Conquer
 Synonyms resolution
 Keywords detection
11
2. AIML syntax
• Content tags - <srai> - Symbolic Reduction
▫ The symbolic reduction technique is used to simplify patterns. It helps to
reduce complex grammatical patterns with simple pattern(s).
<category>
<pattern> WHO IS ALBERT EINSTEIN </pattern>
<template>Albert Einstein was a German physicist.</template>
</category>
<category>
<pattern> WHO IS Isaac NEWTON </pattern>
<template>Isaac Newton was a English physicist and mathematician.</template>
</category>
<category>
<pattern>DO YOU KNOW WHO * IS</pattern>
<template>
<srai>WHO IS <star/></srai>
</template>
</category>
12
2. AIML syntax
• Content tags - <srai> - Divide and Conquer
▫ Divide and Conquer is used to reuse sub sentences in making a
complete reply. It helps to reduce defining multiple categories.
<category>
<pattern>BYE</pattern>
<template>Good Bye!</template>
</category>
<category>
<pattern>BYE *</pattern>
<template>
<srai>BYE</srai>
</template>
</category>
13
2. AIML syntax
• Content tags - <srai> - Synonyms Resolution
▫ Synonyms are words with similar meanings. A bot should reply in the
same manner for similar words.
<category>
<pattern>AIML</pattern>
<template>It’s a script language!</template>
</category>
<category>
<pattern>HTML</pattern>
<template>
<srai>AIML</srai>
</template>
</category>
14
2. AIML syntax
• Content tags - <srai> - Keywords Detection
▫ Using srai, we can return a simple response when the user types a specific keyword, say, School, no matter where
"school" is present in the sentence.
<category>
<pattern>SCHOOL</pattern>
<template>School is an important institution in a child's life.</template>
</category>
<category>
<pattern>_ SCHOOL</pattern>
<template>
<srai>SCHOOL</srai>
</template>
</category>
<category>
<pattern>_ SCHOOL</pattern>
<template>
<srai>SCHOOL</srai>
</template>
</category>
<category>
<pattern>SCHOOL *</pattern>
<template>
<srai>SCHOOL</srai>
</template>
</category>
<category>
<pattern>_ SCHOOL *</pattern>
<template>
<srai>SCHOOL</srai>
</template>
</category>
15
2. AIML syntax
• Content tags - <set> and <get>
▫ <set> and <get> tags are used to work with variables in AIML. Variables
can be predefined variables or programmer created variables.
<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>
16
2. AIML syntax
• Content tags - <that>
▫ <that> Tag is used in AIML to respond based on the context.
<category>
<pattern>WHAT ABOUT MOVIES</pattern>
<template>Do you like comedy movies</template>
</category>
<category>
<pattern>YES</pattern>
<that>Do you like comedy movies</that>
<template>Nice, I like comedy movies too.</template>
</category>
<category>
<pattern>NO</pattern>
<that>Do you like comedy movies</that>
<template>Ok! But I like comedy movies.</template>
</category>
17
2. AIML syntax
• Content tags - <condition>
▫ <condition> Tag is similar to switch statements in programming
language.
<category>
<pattern> HOW ARE YOU FEELING TODAY </pattern>
<template>
<think><set name = "state"> happy</set></think>
<condition name = "state" value = "happy">
I am happy!
</condition>
<condition name = "state" value = "sad">
I am sad!
</condition>
</template>
</category>
18
3. Chatbot training and demo
• Reversed AIML
▫ http://www.novashore.fr/charlix/reversedaiml-demo.php
• Demo
▫ TIMA chatbot
19
4. Conclusion
• Implementation
Implementing AIML is easy.
All the data is precompiled into a tree structure and input is matched in a
specific order against nodes of the tree, effectively walking a decision tree.
The first matching node then executes its template, which may start up a
new match or do something else.
20
4. Conclusion
• Downsides
▫ Inherent weakness
 Recursively self-modifying input creates problems.
 You can't see a rule and know if it will match the input. You have to know all the
prior transformations. Because of this, writing and debugging become hard,
and maintenance impossible.
▫ Unreadability
 XML is not reader friendly. It's wordy, which is fine for a machine but hard on a
human.
▫ Redundancy
 If you want the system to respond to a keyword, either alone or as a prefix,
infix, or suffix in a sentence, it takes you four categories to do so.
 If synonyms are added, it also wastes whole 4 categories.
▫ Overlapping
 As soon as the first complete match is found, the process stops, and the
template that belongs to the category whose pattern was matched is
processed by the AIML interpreter to construct the output. This can lead to
mismatching.
21
4. Conclusion
• AIML is clever and simple, and a good start for beginners writing
simple bots. But after 15 years, A.L.I.C.E has a meager 120K rules.
AIML depends on self-modifying the input, so if you don't know all
the transformations available, you can't competently write new rules.
And with AIML's simple wildcard, it's easy to get false positives
(matches you don't want) and hard to write more discriminating
patterns.
• Still, A.L.I.C.E. is a top chatbot, coming in 2nd in the 2010 Loebner
Competition.
22
5. Further development
23
User
Speech to text
converter
NLP
AIMLPre-processingOutput
References
• Introduce AIML and ChatScript
▫ https://journals.ala.org/index.php/ltr/article/view/4505/5283
• Quick guide AIML
▫ https://www.tutorialspoint.com/aiml/aiml_quick_guide.htm
▫ https://arxiv.org/ftp/arxiv/papers/1307/1307.3091.pdf
• AIML/Chatscript/Facarde
▫ https://www.gamasutra.com/view/feature/6305/beyond_fa%C3%A7ade_pattern_matching_.php?print=1
• Spec of AIML 2.0
▫ https://docs.google.com/document/d/1wNT25hJRyupcG51aO89UcQEiG-HkXRXusukADpFnDs4/pub
24

AIML Introduction

  • 1.
  • 2.
    Contents 1 • Fundamentals 2 • AIMLSyntax 3 • Chatbot training and demo 4 • Conclusion 5 • Further development 2
  • 3.
  • 4.
    1. Fundamentals • Whatis a chatbot? ▫ A chatbot (or bot) is a conversational software program designed to chat with humans via voice or text. ▫ It is a natural language processing (NLP) chatbot designed to engage in a conversation by reacting to human input and responding as naturally as possible. ▫ ALICE has won three times Loebner Prize winner (2000, 2001, 2004) - an award for accomplished humanoid and talking robots. ▫ Turing test: a test for intelligence in a computer, requiring that a human being should be unable to distinguish the machine from another human being by using the replies to questions put to both. ▫ Talk with ALICE: https://www.pandorabots.com/pandora/talk?botid=a847934aae3456cb 4
  • 5.
    1. Fundamentals • AIMLstands for Artificial Intelligence Modelling Language. • AIML is a simple, XML-based scripting language and the open standard for writing chatbots 5
  • 6.
    1. Fundamentals • Thereare many script languages supporting writing a chatbot ▫ AIML (1995) ▫ Façade (2005) ▫ RiveScript (2009) ▫ ChatScript (2010) • Why we use AIML?  Easy to learn and implement for beginners for its based on XML  Strong support interpreters with popular programming languages (Java, Python, Ruby …)  Various available platforms, AIML resources and documents for inheritance 6
  • 7.
    1. Fundamentals • AIMLinterpreter ▫ a program that can load and run an AIML bot and provide responses to conversational requests according to the AIML specification in this document. ▫ Program O is an AIML interpreter written in PHP ▫ Program Y is an AIML interpreter written in Python ▫ Program AB is an AIML interpreter written in Java (used in TIMA chatbot) 7
  • 8.
    1. Fundamentals • Chatbotusing AIML workflow 8 User input to-text converter AIML Intepreter data text AIML dataset query Output match F T
  • 9.
    2. AIML syntax •Structure tags <?xml version = "1.0" encoding = "UTF-8"?> <aiml version="2.0"> <category> <pattern> hello alice </pattern> <template> Hello User </template> </category> </aiml> 9 S.No. Tag 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.
  • 10.
    2. AIML syntax •Content tags - <star> ▫ <star> Tag is used to match wild card * character(s) in <pattern> Tag. ▫ <star index = "n"/> <category> <pattern>I LIKE *</pattern> <template> I too like <star/>. </template> </category> <category> <pattern>A * IS A *</pattern> <template> How <star index = "1"/> can not be a <star index = "2"/>? </template> </category> 10
  • 11.
    2. AIML syntax •Content tags - <srai> ▫ <srai> Tag is a multipurpose tag. This tag enables AIML to define the different targets for the same template. ▫ <srai> pattern </srai> ▫ Following are the commonly used terms associated with srai −  Symbolic Reduction  Divide and Conquer  Synonyms resolution  Keywords detection 11
  • 12.
    2. AIML syntax •Content tags - <srai> - Symbolic Reduction ▫ The symbolic reduction technique is used to simplify patterns. It helps to reduce complex grammatical patterns with simple pattern(s). <category> <pattern> WHO IS ALBERT EINSTEIN </pattern> <template>Albert Einstein was a German physicist.</template> </category> <category> <pattern> WHO IS Isaac NEWTON </pattern> <template>Isaac Newton was a English physicist and mathematician.</template> </category> <category> <pattern>DO YOU KNOW WHO * IS</pattern> <template> <srai>WHO IS <star/></srai> </template> </category> 12
  • 13.
    2. AIML syntax •Content tags - <srai> - Divide and Conquer ▫ Divide and Conquer is used to reuse sub sentences in making a complete reply. It helps to reduce defining multiple categories. <category> <pattern>BYE</pattern> <template>Good Bye!</template> </category> <category> <pattern>BYE *</pattern> <template> <srai>BYE</srai> </template> </category> 13
  • 14.
    2. AIML syntax •Content tags - <srai> - Synonyms Resolution ▫ Synonyms are words with similar meanings. A bot should reply in the same manner for similar words. <category> <pattern>AIML</pattern> <template>It’s a script language!</template> </category> <category> <pattern>HTML</pattern> <template> <srai>AIML</srai> </template> </category> 14
  • 15.
    2. AIML syntax •Content tags - <srai> - Keywords Detection ▫ Using srai, we can return a simple response when the user types a specific keyword, say, School, no matter where "school" is present in the sentence. <category> <pattern>SCHOOL</pattern> <template>School is an important institution in a child's life.</template> </category> <category> <pattern>_ SCHOOL</pattern> <template> <srai>SCHOOL</srai> </template> </category> <category> <pattern>_ SCHOOL</pattern> <template> <srai>SCHOOL</srai> </template> </category> <category> <pattern>SCHOOL *</pattern> <template> <srai>SCHOOL</srai> </template> </category> <category> <pattern>_ SCHOOL *</pattern> <template> <srai>SCHOOL</srai> </template> </category> 15
  • 16.
    2. AIML syntax •Content tags - <set> and <get> ▫ <set> and <get> tags are used to work with variables in AIML. Variables can be predefined variables or programmer created variables. <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> 16
  • 17.
    2. AIML syntax •Content tags - <that> ▫ <that> Tag is used in AIML to respond based on the context. <category> <pattern>WHAT ABOUT MOVIES</pattern> <template>Do you like comedy movies</template> </category> <category> <pattern>YES</pattern> <that>Do you like comedy movies</that> <template>Nice, I like comedy movies too.</template> </category> <category> <pattern>NO</pattern> <that>Do you like comedy movies</that> <template>Ok! But I like comedy movies.</template> </category> 17
  • 18.
    2. AIML syntax •Content tags - <condition> ▫ <condition> Tag is similar to switch statements in programming language. <category> <pattern> HOW ARE YOU FEELING TODAY </pattern> <template> <think><set name = "state"> happy</set></think> <condition name = "state" value = "happy"> I am happy! </condition> <condition name = "state" value = "sad"> I am sad! </condition> </template> </category> 18
  • 19.
    3. Chatbot trainingand demo • Reversed AIML ▫ http://www.novashore.fr/charlix/reversedaiml-demo.php • Demo ▫ TIMA chatbot 19
  • 20.
    4. Conclusion • Implementation ImplementingAIML is easy. All the data is precompiled into a tree structure and input is matched in a specific order against nodes of the tree, effectively walking a decision tree. The first matching node then executes its template, which may start up a new match or do something else. 20
  • 21.
    4. Conclusion • Downsides ▫Inherent weakness  Recursively self-modifying input creates problems.  You can't see a rule and know if it will match the input. You have to know all the prior transformations. Because of this, writing and debugging become hard, and maintenance impossible. ▫ Unreadability  XML is not reader friendly. It's wordy, which is fine for a machine but hard on a human. ▫ Redundancy  If you want the system to respond to a keyword, either alone or as a prefix, infix, or suffix in a sentence, it takes you four categories to do so.  If synonyms are added, it also wastes whole 4 categories. ▫ Overlapping  As soon as the first complete match is found, the process stops, and the template that belongs to the category whose pattern was matched is processed by the AIML interpreter to construct the output. This can lead to mismatching. 21
  • 22.
    4. Conclusion • AIMLis clever and simple, and a good start for beginners writing simple bots. But after 15 years, A.L.I.C.E has a meager 120K rules. AIML depends on self-modifying the input, so if you don't know all the transformations available, you can't competently write new rules. And with AIML's simple wildcard, it's easy to get false positives (matches you don't want) and hard to write more discriminating patterns. • Still, A.L.I.C.E. is a top chatbot, coming in 2nd in the 2010 Loebner Competition. 22
  • 23.
    5. Further development 23 User Speechto text converter NLP AIMLPre-processingOutput
  • 24.
    References • Introduce AIMLand ChatScript ▫ https://journals.ala.org/index.php/ltr/article/view/4505/5283 • Quick guide AIML ▫ https://www.tutorialspoint.com/aiml/aiml_quick_guide.htm ▫ https://arxiv.org/ftp/arxiv/papers/1307/1307.3091.pdf • AIML/Chatscript/Facarde ▫ https://www.gamasutra.com/view/feature/6305/beyond_fa%C3%A7ade_pattern_matching_.php?print=1 • Spec of AIML 2.0 ▫ https://docs.google.com/document/d/1wNT25hJRyupcG51aO89UcQEiG-HkXRXusukADpFnDs4/pub 24

Editor's Notes

  • #4 Pandorabots, Inc. is an artificial intelligence company that runs a web service for building and deploying chatbots.[1]The Pandorabots Platform is "one of the oldest and largest chatbot hosting services in the world."[2] Clients can create "AI-driven virtual agents" to hold human-like text or voice chats with consumers.[3] Pandorabots implements and supports development of the AIML open standard[4] and makes portions of its code accessible for free[5] under licenses like the GPL or via open APIs.[6] https://www.pandorabots.com/mitsuku/
  • #5 Pandorabots, Inc. is an artificial intelligence company that runs a web service for building and deploying chatbots.[1]The Pandorabots Platform is "one of the oldest and largest chatbot hosting services in the world."[2] Clients can create "AI-driven virtual agents" to hold human-like text or voice chats with consumers.[3] Pandorabots implements and supports development of the AIML open standard[4] and makes portions of its code accessible for free[5] under licenses like the GPL or via open APIs.[6] https://www.pandorabots.com/mitsuku/
  • #6 Example to use AIML: https://howtodoinjava.com/ai/java-aiml-chatbot-example/ Program AB is a compiler supporting AIML 2.0 and is written in Java It takes a lot of data to make any plausible approximation to natural language understanding.
  • #8 Program O is an AIML interpreter written in PHP Program Y is an AIML interpreter written in Python Program AB is an AIML interpreter written in Java Example to use AIML: https://howtodoinjava.com/ai/java-aiml-chatbot-example/
  • #10 Check out my bot: https://home.pandorabots.com/en/
  • #11 Check out my bot: https://home.pandorabots.com/en/
  • #12 Check out my bot: https://home.pandorabots.com/en/
  • #13 Check out my bot: https://home.pandorabots.com/en/
  • #14 Check out my bot: https://home.pandorabots.com/en/
  • #15 Check out my bot: https://home.pandorabots.com/en/
  • #16 Check out my bot: https://home.pandorabots.com/en/
  • #17 Check out my bot: https://home.pandorabots.com/en/
  • #18 Check out my bot: https://home.pandorabots.com/en/
  • #19 AIML can not parse ? ! … ???
  • #20 AIML can not parse ? ! … ???
  • #21 This rule responds to a simple yes only if the last output was a "Do" question that ends in sushi. With pattern augmentation, you can write some obscurely clever code. But obscure code is generally self-punishing and few people can write or read such code.
  • #22 This rule responds to a simple yes only if the last output was a "Do" question that ends in sushi. With pattern augmentation, you can write some obscurely clever code. But obscure code is generally self-punishing and few people can write or read such code.
  • #23 Once downloaded from Google Play Store and installed on your phone. Tala Loan App scans your SMS folder for Mpesa transaction history and your voice call pattern history to build a credit score. https://urbankenyans.com/tala-loan-app-application-download/
  • #24 Once downloaded from Google Play Store and installed on your phone. Tala Loan App scans your SMS folder for Mpesa transaction history and your voice call pattern history to build a credit score. https://urbankenyans.com/tala-loan-app-application-download/