pandorabots 2,481,187,296 pandorabot responses served!
  Help Policies [Last Updated 9.26.2015]
Support About Most Popular

In order to follow the examples in this tutorial you will need to login using the panel to the left. If you don't have a Pandorabots account you can sign-up for an account here.

Previous | Next | Contents | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | All   Printable View

A Tutorial For Adding Knowledge to Your Robot

Copyright © by Doubly Aimless (aimless@pandorabots.com) - May, 2004 - Revision 7.
Additional editing by Seiji Umatani (umatani@kuis.kyoto-u.ac.jp).

Table of Contents

Introduction

This is a brief tutorial describing how you can create and add knowledge to your robot. A successful robot will give responses that appear to be coming from a human. Your goal as the botmaster is very simple:

"Build content that induces the visitor to carry on conversations with your robot for as long as possible!"

You do this by creating a variety of potential answers to various questions, or re-directing a conversation to new topics that the client finds interesting - always with the goal of continuing the interactions as long as possible.

Examples of such robots can be found at the links below:

Pandorabots allows you to extend the knowledge of your robot via a programming language called AIML. The goal of this tutorial is to teach you the minimum of AIML necessary to make your robot "smarter" and better able to carry on a realistic conversation.

This Tutorial is a draft - and unfortunately has errors and omissions. Better versions will be forthcoming. Some of you will argue that it would have been better to postpone publication - yet the cry for some kind of documentation was just too much. Please accept my apologies for this draft's roughness. Please mail comments and problems to the attention of Dr. Doubly Aimless at info@pandorabots.com.

More details on the information in this tutorial can be found in the references listed at the end. In particular, the latest version of the AIML specification contains many of the details omitted in this document.

The robots discussed in this document, and on www.pandorabots.com, are based on AIML and spring entirely from the work of Dr. Richard Wallace and the A.L.I.C.E. and AIML free software community based at http://www.alicebot.org.


A Web of Knowledge

Some of you might find this metaphor helpful for visualizing how knowledge is laid out in your robot. Imagine a spider web - it has a center with spokes radiating outwards from the center. Your robot's knowledge is stored in a Knowledge Web, and like the spider, your robot darts out in response to some sort of tug it senses in the web. Understanding how to store knowledge is our first task. Because it is too hard to draw the whole web, in the examples that follow, only a portion of the web will be shown - so please use your imagination for the rest.

Starting at www.pandorabots.com, if you have not already done so, create an account and once logged in, create a robot by clicking on Create a Pandorabot (it's at the top of the screen). On the next screen, name your new robot, Full (for full of knowledge) and make sure the radio button labeled, "Dr Wallace's A.L.I.C.E - March 2002" is selected (see [1]). After clicking on Create Pandorabot to create your new robot the next screen will show:

"This pandorabot is not published. When you are ready, you can publish your pandorabot to make it available for others to chat with. You may first want to customize your pandorabot by changing some of its properties or by providing your own custom responses with the training interface."
Click on the Train link on the second row of menu buttons to begin interactions with your robot. This robot already has a substantial knowledge base (taught by Dr. Richard Wallace) so let's start by posing the question:
Human: Do you love me?
Full: Yes I love everyone.
To ask this question, type in "Do you love me?" in the text field labeled Human: and then press Enter or click on the Ask button to the right of the text box.

The robot knew in advance how to answer this question. How specifically did the robot discover the answer? First the robot checked if its knowledge already contained the question "Do you love me?" And second, finding it, checked to see if it had been taught to respond with something meaningful.

Categories

The words in the sentence "Do you love me?" can be visualized by a series of lines (or links) and nodes, in the knowledge web. This is illustrated below in Picture 1.0. The links are labeled by the words (you can think of the nodes as representing the spaces between the words) and form a chain starting from the center of the web and moving outwards.

Finding the question in the Knowledge Web, the robot replies with the information we taught it (residing in a Response Template - and referred to as the template). So, in other words, the specific question "Do you love me" can be visualized as a kind of path - beginning at the center of the Knowledge Web and built up by a series of links and nodes, and that finally terminates in a Response Template.

The specific path through the Knowledge Web along with the (Response) Template is called a category. If, for example, you teach the robot to respond with: "yes, but only when you are good" you only change the Response Template.

More about Categories

Let's start over with a robot that has no knowledge. Create a new robot exactly as before except that this time, name the robot Empty and select the radio button labeled, "No initial content, the pandorabot starts with no knowledge". Again, once the robot is created, click on Train to start interacting with it.

Initially, Picture 1.1 shows Empty's very simple Knowledge Web. One Category is shown and notice the Response Template contains the one sentence "I have no answer for that". You will also notice *, <that> and <topic> labeling the links between the nodes. The labels *, <that> and <topic> are special optional variants offering enhancements to Categories. As we shall see, these special labels extend the matching power of the Categories.

So what does this one Category do? To begin with the * label allows any interaction with Empty to return the same response:

Human: Hello
Empty: I have no answer for that
Human: abc
Empty: I have no answer for that
More generally, words or sentences provided to the robot are called the Input Pattern. You can visualize any sentence existing in the Knowledge Web as a path of linked nodes, terminating with a Response Template. The robot searches for a path of linked nodes that exactly matches the Input Pattern. When a path is found, we say that the path matches the Input Pattern.

Default Responses

It happens often that an Input Pattern will not be found in the Knowledge Web - yet we still want the robot to respond with something meaningful. We call this the Default Response Template - and it typically consists of sentences designed to keep the conversation going. We can visualize the Default Category (a path empty of all words and it's Response Template) by Picture 1.1(pictured above). The * will match any words. The <that> and <topic> will be explained later.

In order to teach your robot to say "Hi there!" in response to "Hello", do the following:

  1. Make sure you're on the robot's Training page (if not click on Train)
  2. Type in "Hello" in the box labeled Human:.
  3. Click on Ask (or press Enter)
  4. After the robot responds, type in "Hi there!" in the box labled Empty:
  5. Click on Say Instead (or press Enter)
  6. Verify your change by clicking on (the first) Ask Again button.
Now the Knowledge Web looks like Picture 1.2

The robot has just two responses now - and is incapable of supporting its side of an interesting conversation. Let's make some more changes. In response to you typing anything but Hello (the one input pattern that Empty now knows about) Empty will randomly present you with three possible responses. Type:

Human: hi
Empty: I have no answer for that
Next, click on Advanced Alter Response and in the box in the pattern column, replace HI with *, which means that anything you type in will be matched with a response. Now let's add three random possible responses. In the box labeled template add:
<random>
  <li>What is your name?</li>
  <li>What is your favorite movie?</li>
  <li>Will you buy me a drink?</li>
</random>
and click on the Submit button (at the bottom left of the page). For an explanation of the syntax used above see [2].

The Knowledge Web now looks like Picture 1.3.

We've changed the Default Category by changing the Default Response Template from "I have no answer to that" to one of three randomly chosen responses.

Like a hapless, but precocious child failing to understand what is being said, yet unwilling to be abandoned, Empty attempts to prolong the conversation by offering a choice of three "pick-up" lines hoping to change the subject. Empty proffers pick-up lines randomly hoping to disguise how little it actually knows. Check this yourself by typing anything but "Hello".

Click on the Ask This Again button enough times to cycle through all of the pick-up lines.

Saving your Work and Starting Over

For reasons you'll see later, most of the time you'll want to avoid changing the Ultimate Default Category. Let's go back to the beginning and start over, and simultaneously learn how to save files.

To view the AIML files for a particular robot, click on the AIML link (this is near the top of the screen, on the second row of links). If you don't see this link but instead see a table of all your robots, you'll first need to click on the name of the robot - Empty in this case.

Scroll down until you see a section like this:

Filename Browse Download Library Active Delete
update.aiml Browse Download (local)
Below the first heading, Filename you'll see a file named, update.aiml (every robot has their own unique version of this file) that contains any changes that you made to the robot's responses using the Training Interface.

Click on, update.aiml and then scroll down to the text area. Here you may edit and save the robot's responses on-line. After you've edited the text, be sure to click on the, Save As button to make your changes permanent (see [3])

As an alternative to editing the AIML file on-line, you can use the Download link next to the filename to download a local copy which you can then edit with an XML editor on your own computer (possibly while not on-line). You can later use the form at the bottom of the AIML files page to upload the modified AIML back to Pandorabots. It's also not a bad idea to keep a local copy of your AIML in case you accidentally delete it on the server.

Let's look at the file for a minute (shown below with some minor reformatting). The first line (of header information) tell us the type of character set and versions of XML (see [4]) we are using. The next line tells us we are using AIML version 1.0.

<?xml version="1.0" encoding="UTF-8" ?>
<aiml version="1.0">
  <category>
    <pattern>HELLO</pattern>
    <template>Hi there!</template>
  </category>
  <category>
    <pattern>*</pattern>
    <template>
      <random>
        <li>What is your name?</li>
        <li>What is your favorite movie?</li>
        <li>Will you buy me a drink?</li>
      </random>
    </template>
  </category>
</aiml>
Categories are specified by the information between the beginning and ending lines in the form:
<category> ...information... </category>
Similarly, the input words are specified by:
<pattern> ...information... </pattern>
The output response is specified by the information between <template> and </template>.

The items between "<" and ">" are called AIML tags or elements. Each AIML tag has an opening tag and a closing tag of the form:

<some-tag> ...information... </some-tag>
It sometimes happens that there is no information between the opening and closing tags and you can use the abbreviation:
<some-tag/>
(note the "/" after the tag name) as a replacement for:
<some-tag></some-tag>
Each time you click on the Submit button on the Advanced Alter Response page (or click on Say Instead) the effect is to add new information to the file, update.aiml. A good way to learn AIML syntax is to examine the modified update.aiml file as shown above.

Another random Category

Next we're going to create a new version of Empty and again create a category using <random>. However, this time we won't define it as the default category. This example is used as the basis for the fourth example in the next section.

Creating a New Version of Empty

First click on My Pandorabots and then in the table of robots, click the radio button next to the name, Empty. From the drop-down menu below (it's initially labeled, Publish) select Delete. Next click on the, OK button on the right and confirm that you want to delete the robot, Empty.

Then, simply repeat the procedure you followed for creating the first robot, Empty and you'll have a fresh empty robot.

Being empty of knowledge the only thing Empty can say is:

Empty: I have no answer for that
Let's increase the possibilities for an interesting conversation by giving four possible random responses to the next inquiry.
Human: You do love me don't you
Empty: I have no answer for that
After typing the above into the Training interface, click on Advanced Alter Response and in the box labeled template add:
<random>
  <li>I don't know, what have you done for me lately?</li>
  <li>Yes, but you have to really try to make me happier...</li>
  <li>Stop your whining!</li>
  <li>Yes, but only when you are good to me </li>
</random>
...and as before click on the Submit button. Next, click on the Ask Again button enough times to cycle through the complete set of responses. The Knowledge Web now looks like Picture 1.4.

Contractions like "don't" are expanded to "do not", so: "you do love me don't you?" is transformed to the rather awkward, "you do love me do not you" (see [5]).


How about <that>?

Using <that> the robot is capable of remembering what it said in the previous interaction. And conversations can become more meaningful. <that> was named and arose from analyzing a conversational exchanges like:

Empty: Today I love you.
Human: That is wonderful.
Empty: But, will I still love you tomorrow?
Human: That is what I want to find out.
First we need a category that is useful for working with <that> expressions. Enter this category into Empty like this:
Human: say *
Empty: I have no answer for that
Click on Advanced Alter Response.

Notice the contents of the box in the pattern column are the beginning of a new category: "SAY *" (there is a space between SAY and *)

In the box labeled template add:

<star/>
...and Submit the new AIML. (Recall that <star/> is a shorter way of writing <star></star> - see
[2].) The effect of this change is to match anything. So now, "Say something" will always set <that> to "something." For example:
Human: say I love you
Empty: I love you
We are going to use this category to test our categories that use <that>.

Example 1 - Who are you?

At some point your robot might want to know who it is talking to. Here is how to do this:

Human: *
Empty: I have no answer for that
Click on Advanced Alter Response.

Check the box labeled "new category depends on that" and replace the text box's contents with:

WHAT IS YOUR NAME
Notice the box in the pattern column contains "*" meaning that any response will be matched. In the box labeled template add:
Nice to meet you <set name="name"><person/></set>.
This last bit of AIML code grabs the person's name.

Now ask the robot, "Say what is your name," to generate the state in which the next input will activate the <that> category.

Human: say what is your name
Empty: what is your name
Human: Mr. Lovejoy
Empty: Nice to meet you Mr. Lovejoy.

Example 2 - YES and NO Questions

Use <that> for categories that seek yes and no responses. Here is an example for "yes" questions:

Human: yes Empty: I have no answer for that
Click on Advanced Alter Response.

Check the box labeled "new category depends on that" and replace the text box's contents with:

ARE YOU LOOKING FOR LOVE
Notice the box in the pattern column contains "YES". In the box labeled template add four random responses:
<random>
  <li>Aren't we all looking for love?</li>
  <li>Well you've come to the right place!</li>
  <li>And what kind of love are we looking for today?</li>
  <li>Well I am overflowing with Love for you today </li>
</random>
Now, the robot should be able to recognize the "yes" response:
Human: say are you looking for love?
Empty: are you looking for love
Human: yes
Empty: Well you've come to the right place!

Example 3 - Discovering what knowledge to add to a Robot

The AIML tag <that> refers to whatever Empty last said. Use <that/> and a default template to add new knowledge:

Human: Why
Empty: I have no answer for that
Enter as the alternative response:
"<that/>"? Why?
and click on Say Instead.

This category enables the following dialogue fragment:

Empty: Do not ask me any more questions please.
Human: Why?
Empty: "Do not ask me any more questions please"? Why?
The botmaster notices the fragment and creates the new AIML category:
<category>
  <pattern>WHY</pattern>
  <that>DO NOT ASK ME ANY MORE QUESTIONS PLEASE</that>
  <template>Because I would rather talk about you.</template>
</category>
Now the next client who asks "Why?" to the robot's request will active the new <that> category:
Empty: Do not ask me any more questions please.
Human: Why?
Empty: Because I would rather talk about you.
This style of conversational analysis does not presuppose that we know when the client will say "Why?"; rather it looks backward to identify cases where the "Why?" appeared following one of the robot's statements. Having identified the conversation point, the botmaster creates the new category.

Example 4 - Context Sensitive Patterns

Let's look at a slightly convoluted example. Following on from an earlier example in the previous section, click on Ask Again enough times to get the response in the first exchange below:

Human: You do love me don't you
Empty: Yes, but you have to really try to make me happier...
Human: But I try so hard to please you...
Empty: I have no answer for that
Click on Advanced Alter Response

Check the box labeled: "new category depends on that" which should contain "YES BUT YOU HAVE TO REALLY TRY TO MAKE ME HAPPIER" Notice the box in the pattern column contains: "BUT I TRY SO HARD TO PLEASE YOU"

In the box labeled template add:

And sometimes you succeed, it's just that you could do so much better.
So only when the robot's random response matches the interaction in the next exchange:
Human: you do love me don't you?
Empty: Yes, but you have to really try to make me happier...
You can type in:
Human: But I try so hard to please you ...
Empty: And sometimes you succeed, it's just that you could do so much better.
Except for the case mentioned above, the robot's response to:
Human: But I try so hard to please you ...
will be:
Empty: I have no answer for that
Picture 1.5 shows the situation.

So, <that> modifies a category - meaning match the category only if the robot said what follows the <that> in the previous utterance. Continuing with this example:

Human: You just don't appreciate me, - you take me for granted and walk all over me...
Empty: I have no answer for that
Click on Advanced Alter Response

Check the box labeled: "new category depends on that" (which now contains the contents of last Response Template): "AND SOMETIMES YOU SUCCEED IT IS JUST THAT YOU COULD DO SO MUCH BETTER"

Notice the contents of the box in the pattern column are the beginning of a new category "YOU JUST DO NOT APPRECIATE ME YOU TAKE ME FOR GRANTED AND WALK ALL OVER ME"

In the box labeled template add:

If you worked harder it will help me to develop more enthusiasm for appreciating you - what do you want me to do? Fake my appreciation or really feel it?
With these changes the following interchanges are possible (click on Ask Again enough times to generate Empty's (random) response in the first exchange below):
Human: you do love me don't you?
Empty: Yes, but you have to really try to make me happier...
Human: but I try so hard to please you ...
Empty: And sometimes you succeed, it's just that you could do so much better
Human: You just don't appreciate me, - you take me for granted and walk all over me...
Empty: If you worked harder I might be able to develop a little more enthusiasm for appreciating you - what do you want me to do?
Fake my appreciation or really feel it?"
Picture 1.6 shows the current state of knowledge.

The contents of the file update.aiml now include:

<category>
  <pattern>YOU DO LOVE ME DO NOT YOU</pattern>
  <template>
    <random>
      <li>I don't know, what have you done for me lately?</li>
      <li>Yes, but you have to really try to make me happier...</li>
      <li>Stop your whining!</li>
      <li>Yes, but only when you are good to me</li>
    </random>
  </template>
</category>
<category>
  <pattern>BUT I TRY SO HARD TO PLEASE YOU</pattern>
  <that>YES BUT YOU HAVE TO REALLY TRY TO MAKE ME HAPPIER</that>
  <template>
    And sometimes you succeed, it's just that you could do so much
    better
  </template>
</category>
<category>
  <pattern>
    YOU JUST DO NOT APPRECIATE ME YOU TAKE ME FOR GRANTED AND
    WALK ALL OVER ME
  </pattern>
  <that>
    AND SOMETIMES YOU SUCCEED IT IS JUST THAT YOU COULD DO SO MUCH
    BETTER
  </that>
  <template>
    If you worked harder it will help me to develop more enthusiasm
    for appreciating you - what do you want me to do? Fake my
    appreciation or really feel it?
  </template>
</category>

What about <topic>?

Topic lets you group together Categories. Presented Input patterns are searched for matching categories within the robot's knowledge web. If more than one matching category is found, the robot matches the <that> patterns next, and if more than one of these exist, the robot matches <topic> next.

Categories are stored in alphabetical order by pattern. Inputs to be matched to Categories are compared in reverse order. So when the input matches more than one category the last one is taken. Typically we might want to bundle up a bunch of Categories into one general topic. So lacking an adequate response and knowing that we have a specific Topic, the robot can generate specific pick-up lines and keep the conversation going. How do we do this?

Example 5 - Using Topics

Enter this category into Empty by typing this:

Human: *
Empty: I have no answer for that
Click on Advanced Alter Response and notice the contents of the box in the pattern column contain "*" - which matches anything.

Check the box labeled: "new category depends on topic" and in the text box above add:

GIRLS
In the box labeled template add:
<random>
  <li>I wonder what about them you like best?</li>
  <li>I've been known to like girls too!</li>
  <li>Can you distinguish between girls and women?</li>
  <li>Is there anything you don't love? </li>
</random>
We've changed the default response category when we are talking about girls. Empty uses one of four randomly chosen pickup lines to continue the conversation. Before we can test or use this new category, we have to change the topic. And we can use this to teach a little more about the interface. Enter the following:
Human: topic *
Empty: I have no answer for that
Click on Advanced Alter Response and notice the contents of the box in the pattern column contains: "TOPIC *"

In the box labeled template add:

<think>
  <set name="topic">
    <star/>
  </set>
</think>
OK, I've reset the topic to <star/>.
We've created a new category and written a little bit of AIML code and used it to change the <topic>. The <think> tags demarcate a "hidden" sequence of instructions - hidden in the sense the client will not see them. The <set> tags demarcate the way we change the topic (which is changed to the input pattern marked by the singleton tag <star/> - a list of the AIML Tags is available at the time of this writing at:
http://www.alicebot.org/committees/architecture/resolutions/aiml10.html ).

With this new category we can change the <topic> as in:

Human: topic girls
Empty: OK, I've reset the topic to girls.
Human: I love girls
Empty: Is there anything you don't love?
Now we can create a caterory to get back to the default state of no topic. Enter the following:
Human: notopic
Empty: I've been known to like girls too!
Click on Advanced Alter Response and in the box labeled template add:
<set name="topic"/> done
Resulting in:
Human: notopic
Empty: done
Let's first add some more knowledge to Empty.
Human: You do love me?
Empty: I have no answer for that
Teach Empty instead to say "Yes, but only when you are good to me".

Changing the input to:

Human: Do you love me?
Empty: I have no answer for that
Again, teach Empty instead to say: "Yes, but only when you are good to me".

Now, either input patterns "You do love me?" or "Do you love me?" prompts the response:

Empty: "Yes, but only when you are good to me".
From the viewpoint of knowledge content, Picture 2.0 describes the current state.

So next:

Human: Don't you love me?
Empty: I have no answer for that
Teach it instead to say: "Yes, but only when you are sweet to me".

So we can also have the following interaction:

Human: Don't you love me?
Empty: Yes, but only when you are sweet to me.
Now we'll add a <topic> and remind ourselves how to save and upload files.

To view the AIML files for a particular robot, click on the AIML link (this is near the top of the screen, on the second row of links). If you don't see this link but instead see a table of all your robots, you'll first need to click on the name of the robot - Empty in this case.

Scroll down until you see a section like this:

Filename Browse Download Library Active Delete
update.aiml Browse Download (local)
Below the first heading, Filename you'll see a file named, update.aiml (every robot has their own unique version of this file) that contains any changes that you made to the robot's responses using the Training Interface.

Click on, update.aiml and then scroll down to the text area. Under the line:

<aiml version="1.0">
Add these lines:
<topic name="LOVE">
  <category>
    <pattern>*</pattern>
    <template>
      <random>
        <li> How much do you love me?</li>
        <li> Why don't you ever show me you love me?</li>
        <li> Why is it so difficult for you to show affection?</li>
        <li> Your coldness chills me to the bone</li>
      </random>
    </template>
  </category>
Finally, add the line:
</topic>
at the end of the file, so that the last two lines look like this:
</topic>
</aiml>
Save your changed file and then click on the Train link on the second row of menu buttons to resume interactions with your robot. These last changes only become relevant when the topic is "LOVE". In other words the robot will respond to anything else you type with, "I have no answer for that".

To set the topic, type in "*" and put this line into the template box:

<set name="topic">love</set>
Whenever the topic is "LOVE" and the robot lacks a response, your robot will response with one of the four possible lines entered above.


Making Knowledge Content Changes (Bot Properties)

As we have seen AIML uses pattern matching to select a category based on the client's input. Each category has a response template which defines the robot's response. Within a template, the botmaster can refer to "Bot Properties" which allows the same set of AIML files to be used to create different robots each with a distinct and personal identity.

For example, Dr. Richard Wallace's March 2002 AIML set includes the category:

<category>
  <pattern>WHO IS YOUR FAVORITE BAND</pattern>
  <template>
    My favorite group is <bot name="favoriteband"/>.
  </template>
</category>
This makes a reference to the "favoriteband" property and this property can be set individually for each robot that uses this AIML set.

To see how to set the property, go to the robot you named Full (created at the beginning of the tutorial).

First click on My Pandorabots and then in the table of robots, click on Full. Next click on the Properties link on the second row of menu buttons.

Here you'll see a list of Bot Properties based on the AIML set. By filling these out and clicking on Submit Changes you can customize your robot's responses. For example after setting "favoriteband" to be "The Beatles", Full would respond:

Human: What is your favorite band?
Full: My favorite group is The Beatles.
The Properties page also allows you to add your own properties which you can refer to in any AIML response templates you create (either by editing the AIML directly or through the Training interface). As an example, we can define a new property - "weather", with an initial value of "rainy". Template responses can now refer to the value of weather using AIML like:
The weather is <bot name="weather"/>

So many ways to write the same thing... What is <srai>?

You can write a sentence with the same meaning in many different ways. Most people would accept the following sentences as roughly equivalent:

Empty, can you please tell me if you are seeing anyone else right now?
Empty, can you please tell me if you are seeing anyone else now?
Empty, can you please tell me if you are seeing anyone else ?
Empty, please tell me if you are seeing anyone else?
Empty, tell me if you are seeing anyone else?
Empty, tell me, are you seeing anyone else?
Empty, are you seeing anyone else?
Are you seeing anyone else?
And this is an example of a general problem - how do you enter all the categories for inputs with equivalent meanings? Or how do you answer these kinds of questions? No one has provided a satisfactory mechanism for finding all the similar sentences. Here is what can be done though.

In this example we are going to use a new tag and introduce the "_" character. Earlier we wrote that "*" matches any pattern. "_" is another form of "*" and is useful for matching patterns at the ends of sentences. The category containing "* NOW" will be matched after the one containing "_ NOW".

Let's begin by adding two new categories so that Empty responds as follows:

Human: Are you seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: You are seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Then, by adding the category:
<category>
  <pattern>EMPTY *</pattern>
  <template>
    <srai><star/></srai>
  </template>
</category>
Empty responds with:
Human: Empty, are you seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Adding:
<category>
<pattern>_ TELL ME *</pattern>
<template>
<srai><star index="2" /></srai>
</template>
</category>
...produces:
Human: Empty, tell me are you seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Adding:
<category>
  <pattern>_ TELL ME IF *</pattern>
  <template>
    <srai><star index="2" /></srai>
  </template>
</category>
...produces:
Human: Empty, tell me if you are seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Finally, after adding:
<category>
  <pattern>_ NOW</pattern>
  <template>
    <srai><star/></srai>
  </template>
</category>

<category>
  <pattern>_ RIGHT NOW</pattern>
  <template>
    <srai><star/></srai>
  </template>
</category>
...we can now get the same answer to all the questions:
Human: Empty, can you please tell me if you are seeing anyone else right now
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: Empty, can you please tell me if you are seeing anyone else now?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: Empty, can you please tell me if you are seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: Empty, please tell me if you are seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: Empty, tell me if you are seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: Empty, tell me are you seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: Empty, are you seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
So, what has happened here? We've simplified progressively more complex sentences into two "standard" sentences: (Are you seeing anyone else? and You are seeing anyone else?)

The general technique is called recursion - and it means applying the same solution - in this example <srai><star/></srai> over and over again. Recursion is useful for a variety of tasks. We will just mention a few here. More details can be found in The Anatomy of Alice.

Example 6 - Handling Multiple Sentences

The following exchange is generated with the categories below. (Your robot can handle multiple sentences - and does it by responding to each one in turn in separate output lines.)

Human: Empty, are you seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: I see.
Empty: I am glad you see.
Human: Why do you think you can get away with that?
Empty: Full disclosure is always best don't you think?
<category>
  <pattern>I SEE *</pattern>
  <template>
    <srai>I SEE</srai>
    <srai><star/></srai>
  </template>
</category>

<category>
  <pattern>I SEE</pattern>
  <template>I am glad you see</template>
</category>

<category>
  <pattern>
    WHY DO YOU THINK YOU CAN GET AWAY WITH THAT
  </pattern>
  <template>
     Full disclosure is always best don't you think?
  </template>
</category>

Example 7 - Spelling and Grammar corrections

Often we want to correct spelling errors or suggest alternate forms of grammar - and here is one way to do it:

<category>
  <pattern>YOUR A *</pattern>
  <template>
    I presume you mean "you are a ..." <srai>YOU ARE A <star/></srai>
  </template>
</category>

Example 8 - Keywords

Sometimes we want the robot's response to be determined by just one word (a keyword) you've typed. Here is an example in which the keyword is "LOVE":

<category>
  <pattern>LOVE</pattern>
  <template>Tell me more about what you are seeking.</template>
</category>

<category>
  <pattern>_ LOVE</pattern>
  <template>
    <srai>LOVE</srai>
  </template>
</category>

<category>
  <pattern>LOVE _</pattern>
  <template>
    <srai>LOVE</srai>
  </template>
</category>

<category>
  <pattern>_ LOVE *</pattern>
  <template>
    <srai>LOVE</srai>
  </template>
</category>
The first category matches the single word input of love. The second and third categories match a sentence ending in love and beginning in love respectively. The final category matches a sentence in which the word love appears.


How about International Languages?

Your robot can handle any international character set. We could have asked the robot a similar question in Japanese:

Human: 私の事を愛してますか?
Full: I have no answer that
Certain language such as Chinese and Japanese assume no spaces exist between "words". For Japanese, Pandorabots can automatically accept sentences lacking spaces from clients and store them internally with spaces inserted between "words". In order to have Pandorabots do this, when you create the robot, you should check the box annotated with: automatically discover spaces between words (suggested for Japanese).

A similar algorithm can also be used for Chinese though at the time of this writing remains unimplemented. Using the algorithm for Japanese on Chinese sentences results in spaces inappropriately inserted. In either case the botmaster's job of matching input patterns is considerably simplified by the automatic insertion of such spaces.


How can I display Photographs and other Images?

Response templates can do far more than provide responses. They can run arbitrary programs and serve pages from other web sites. You can, for example ask Empty to show a picture of another person - and the picture can be anywhere on the web.

Human: Show me what you think love is.
Empty: I have no answer for that
Enter as the alternative response:
This is one of my many pictures of love: <br/>
<img src="http://www.pandorabots.com/pandora/pictures/cn.jpg" width=100 height=100/>

You can also simplify some of the typing by clicking on the <img> button on the Advanced Alter Response page next to the template box.

Either way, this should change the robots response to:

Human: Show me what you think love is.
Empty: This is one of my many pictures of love:

How to Jazz Up your Robot with HTML Skins

The Pandorabots interface offers you the ability to easily customize your robot's page in any way that you like. You'll find that adding a face to your robot will make it much more personable to your visitors than the standard default blank page. And will also increase the rate of return visits which, of course, is what you want.

If you haven't added a face to your robot, you should consider doing so now. The "Skin" code is written in basic HTML which makes it very easy for you to customize. And since you can do this on-line (or off-line if you prefer), any changes that you make will show up immediately.

Creating Your HTML Skin

  1. Click on, Empty.
  2. Click on, Custom HTML (at the top of the screen).
  3. Click on, Create a new custom HTML file (it's in the body text).
  4. Enter your HTML code in the text window. When you're done, name the file, "empty" (do not type the ".html" extension in the filename) and then click on the, Save As button below.
Note: You can create multiple HTML Skins for your robot at once and switch between them whenever you like, without losing or changing the HTML data. This lets you experiment with different styles to see which one suits you best.

Editing Your HTML Skin

  1. Click on, Empty.
  2. Click on, Custom HTML (at the top of the screen).
  3. Under, Filename click on, empty.html (or whatever you named the file as).
  4. Edit the HTML code in the text window and then click on the, Save As button below. Any changes will show up instantly, you do not have to republish your robot.

The links below will take you to a working version of a customized robot page, and to the tutorial used in creating it.

If you'd like a collection of faces (both male and female) that you can use on your own customized page, visit http://scri8e.250free.com/peepz/phaces/PhacesP1Jpg1-20.html


Notes

[1]
The options Standard AIML Sept 2001 and Dr Wallace's A.L.I.C.E march 2002 are two sets of knowledge. The first is organized into separate files that are easy to change - it's suitable for experts. The second is the knowledge Dr. Wallace used to win the 2002 Loebner prize.


[2]
Words inside brackets "<" and ">" like "<random>" are called XML tags and specify how the answer is to be processed. We've provided only a few such tags. <li> specifies an element in a list - and this example has a list with 3 elements - namely the three sentences. Each tag is expected to have a closing tag, typically specified as in </random>. It sometimes happens that nothing falls between an opening tag and a closing tag, and so the two tags can be replaced as in this example <star></star> = <star/> That is, the two tags on the right can be replaced by the simpler tag on the left.


[3]
Changes you make directly to the robot's AIML files will be immediately visible within the Training Interface. However, if your robot is published, you'll need to re-publish the robot in order to have the changes be visible at the public URL.


[4]
XML and AIML are programming languages. We implemented AIML (Artificial Intelligence Markup Language) a non-standard evolving markup language for creating chat robots, created and supported by the ALICE Foundation and located at www.alicebot.org. The primary design feature of AIML is brevity and simplicity. The pattern matching language is very simple, for example permitting only one wild-card ('*') match character per pattern. AIML is an XML language, meaning that it obeys certain grammatical meta-rules. The choice of XML syntax permits integration with other tools such as XML editors.


[5]
Here are more details of the transformation. The inquiry "do you love me", is transformed, removing any punctuation and converting it to upper case: "DO YOU LOVE ME". So "do you LOVE me" and "DO YOU love me" are equivalent. For multiple sentences, finding the sentences is the first part. The inquiry "Do you love me dr.wallace? ms.mary said you might..." is transformed to "Do you love me doctor wallace? ms mary said you might". Then each sentence is separately processed. Apostrophes are removed from contractions so "I'm in love with you" is transformed to "I am in love with you".

Japanese is written without spaces between the words. So spaces are first inserted. When the robot has been set up to process Japanese and English, a sentence like "let's see if you really do" is transformed to "let ' s see if you really do"



Appendix

Using Advanced Alter Response - the Details

The first two rows in the table contain information about the input sentence and the matching category.

Input
Shows the input text that the robot received (as well as the current <that> and <topic> contexts).
Matched
Shows the components of the category that matched the input.
Each of these two rows is split into three columns representing the three different components that consitute an AIML category.

The rest of the table (labeled New AIML Category) allows you to edit the various components of the new AIML category being defined. Defaults are provided based on the actual input on the Training page and you can either accept or revise these. (Note. You must check the appropriate check-box first before entering values for <that> and <topic>.)

Text in the first box is automatically surrounded by <pattern> and </pattern> - so you need not enter them. You may also specify <topic> and <that> parts of the category. Again the text is surrounded by the <that> and <topic> AIML tags automatically.

The template response Box lets you specify the actions for the category being defined. The buttons <think>, <random>, etc save you from typing in the AIML. Also, anything in this box is automatically surrounded by <template> and </template>.

There are five buttons below the template box which provide shortcuts for writing the template:

  AIML Notes
<think>
<think>
  <set name="it">
    <set name="topic">
      <person/>
    </set>
  </set>
</think>
 
<random>
<random>
  <li></li>
  <li></li>
  <li></li>
</random>
Add choices between the list item tags <li> and </li>.
<img>
<img src=""></img>
Put a pathname between the double quotes to provide a picture.
<sr/>
<sr/>
Another abbreviation for <srai><star/></srai>
<srai>
<srai> </srai>
Insert text between these two tags.

Exploring Categories

Within the main table on the My Pandorabots page and on each individual robot page, you'll find links labeled Explore.

They provide a rudimentary mechanism for exploring the categories that exist in a given knowledge web. You can use this feature to find already existing categories that will be matched by input patterns. It effectively allows you to traverse the knowledge web. When you reach a category, the AIML extract defining the category is shown.

Pandorawriter

An alternative way to create AIML is to use Pandorawriter. This tool automatically converts English text to a subset of AIML, and for certain class of robot can greatly ease the task of adding new knowledge. The tool is still in a very early stage of development and suggestions for improvements are always welcome. Brief documentation for Pandorawriter is available here.


Glossary

Input Pattern
The input sentence (or sentences) provided to the robot.


Template
An abbreviation for response template.


Response Template
The Response Template is either a response or a program to generate a response.


Category
An Input Pattern (including optional variants of <that> and <topic>, along with a Response Template.


Pattern Matching
A capability of matching input sentences against stored sentences.


Knowledge Web (aka Graph Master)
A representation of the categories in a Pandorabot.


Ultimate Default Category
When the input sentence fails to match any category.


Default Category
<topic> and <that> can each have a default category.


Default Response Template
what is said when nothing is matched.


XML
a markup/programming language.


AIML
a markup/programming language implementing knowledge content. AIML is a subset of XML.



References and Resources

The Pandorabot Public Forum:
www.lexicalgas.com/pandora/list.php?f=1


Artificial Intelligence Markup Language (AIML) Version 1.0.1:
www.alicebot.org/TR/2001/WD-aiml/


AIML Pattern Matching Simplified:
www.alicebot.org/documentation/matching.html


Don't Read Me:
www.alicebot.org/articles/wallace/dont.html


AIML 1.0 Tag Sets (July 16, 2001):
www.alicebot.org/committees/architecture/resolutions/aiml10.html


AIML Primer (January 9, 2002):
www.alicebot.org/documentation/aiml-primer.html


The Anatomy of A.L.I.C.E. (pending publication):
Available from Dr. Richard Wallace at www.alicebot.org

Copyright © 2002 - 2004 Doubly Aimless

Previous | Next | Contents | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | All   Printable View