Filename extension | .aiml |
---|---|
Developed by | Dr. Richard S. Wallace |
Initial release | July 16, 2001; 18 years ago[1] |
Latest release | |
Type of format | Artificial intelligence |
Extended from | XML |
Open format? | Yes |
Website | http://www.aiml.foundation/doc.html |
AIML, or Artificial Intelligence Markup Language, is an XML dialect for creating natural language software agents.
AIML stands for Artificial Intelligence Markup Language, but it is just simple XML. These code examples will walk you through how to create your own artificial intelligence chat bot using Python. Artificial intelligence chat bots are easy to write in Python with the AIML package.
- 2Elements of AIML
History[edit]
The XML dialect called AIML was developed by Richard Wallace and a worldwide free software community between 1995[citation needed] and 2002. AIML formed the basis for what was initially a highly extended Eliza called 'A.L.I.C.E..' ('Artificial Linguistic Internet Computer Entity'), which won the annual Loebner Prize Competition in Artificial Intelligence[3] three times, and was also the Chatterbox Challenge[4] Champion in 2004.
Because the A.L.I.C.E. AIML set was released under the GNU GPL, and because most AIML interpreters are offered under a free or open source license, many 'Alicebot clones' have been created based upon the original implementation of the program and its AIML knowledge base. Free AIML sets[5] in several languages have been developed and made available by the user community. There are AIML interpreters available in Java, Ruby, Python, C++, C#, Pascal, and other languages (see below).A semi-formal specification[2] and a W3C XML Schema for AIML[6] are available.
Since early 2013, The A.L.I.C.E foundation has been working on a draft specification for AIML 2.0.[7]
Elements of AIML[edit]
AIML contains several elements. The most important of these are described in further detail below.
Categories[edit]
Categories in AIML form the fundamental unit of knowledge. A category consists of at least two further elements: the pattern and template elements. Here is a simple category:
When this category is loaded, an AIML bot will respond to the input 'What is your name' with the response 'My name is Michael N.S Evanious.'
Patterns[edit]
A pattern is a string of characters intended to match one or more user inputs. A literal pattern like
will match only one input, ignoring case: 'what is your name'. But patterns may also contain wildcards, which match one or more words. A pattern like
will match an infinite number of inputs, including 'what is your name', 'what is your shoe size', 'what is your purpose in life', etc.
The AIML pattern syntax is a very simple pattern language, substantially less complex than regular expressions and as such less than level 3 in the Chomsky hierarchy. To compensate for the simple pattern matching capabilities, AIML interpreters can provide preprocessing functions to expand abbreviations, remove misspellings, etc.
The AIML syntax itself is at least as complex as finite state machines and as such at least of level 3 in the Chomsky hierarchy. This is because a state correlates to one topic. To implement that behavior, the topic should have a '*' Pattern to make sure, that the state is not left accidentally. A state transit is implemented with the <think><setname='topic'>state2</set></think>
Tag. This way, the bot will be able to 'remember' the topic talked about or even user privileges, which are gained during the chat.
Templates[edit]
A template specifies the response to a matched pattern. A template may be as simple as some literal text, like
A template may use variables, such as the example
which will substitute the bot's name into the sentence, or
which will substitute the user's age (if known) into the sentence.
Template elements include basic text formatting, conditional response (if-then/else), and random responses.
Templates may also redirect to other patterns, using an element called srai (Symbolic Reduction in Artificial Intelligence). This can be used to implement synonymy, as in this example (where CDATA is used to avoid the need for XML escaping):
The first category simply answers an input 'what is your name' with a statement of the bot's name. The second category, however, says that the input 'what are you called' should be redirected to the category that matches the input 'what is your name'—in other words, it is saying that the two phrases are equivalent.
Templates can contain other types of content, which may be processed by whatever user interface the bot is talking through. So, for example, a template may use HTML tags for formatting, which can be ignored by clients that don't support HTML.
References[edit]
- ^'Press Release: AIML 1.0 Standard Passed (A.L.I.C.E. AI Foundation)'. www.alicebot.org. San Francisco CA. 16 July 2001. Archived from the original on 15 July 2007. Retrieved 1 December 2013.
- ^ ab'AIML 1.0.1 (A.L.I.C.E. AI Foundation)'. www.alicebot.org. 13 October 2011. Archived from the original on 18 November 2013. Retrieved 1 December 2013.
- ^'loebner.net - Informationen zum Thema loebner'. www.loebner.net. 26 October 2007. Archived from the original on 30 December 2010. Retrieved 10 November 2010.
- ^'Chatterbox Challenge'. www.chatterboxchallenge.com. Archived from the original on 25 March 2006. Retrieved 10 November 2010.Cite uses deprecated parameter
|dead-url=
(help) - ^'Free AIML sets - aitoold.org'. aitools.org. 17 May 2006. Archived from the original on 9 October 2006.
- ^'AIML.xsd'. aitools.org. Archived from the original on 17 March 2006. Retrieved 10 November 2010.
- ^'AIML 2.0 draft specification released'. alicebot.blogspot.com. 16 January 2013. Archived from the original on 18 May 2013. Retrieved 19 June 2014.
A simple AIML bot server written in C# with a dash of extendable 'skills'! What this allows you to accomplish is to be able to build a chatbot capable of handling complex conversation dialogs, thanks to Dr. Richard Wallace's AIML, and be capable of running and handling a complex conversation set like that of ALICE.
The add on here is to have the ability of being capable of executing 'skills' e.g. asking 'What is the weather like in New Orleans?' would result in something like this - 'The weather in New Orleans is 52 degrees Farhenheit and the condition is sunny' where the weather information is fetched in real time from an API.
Note: This is just a chatbot framework running as a server that uses AIML to build conversations. This is not the ONLY project of Karmaloop AI - on the contrary the real goal for Karmaloop AI is to build a new paradigm of conversational agents with a very unique and innovative approach - focus on 'knowledge' and self learning abilities
The practical uses are immense, as we will be covering a lot of this on the Karmaloop AI blog at https://www.karmaloop.aiTo start with, you can build a simple Customer Service Representative for your website that can answer all or most of the FAQs or you could go full monty and build a Siri or Alexa clone! No really! And yes we will be building one and publishing on our Github account.
It is super easy to start with Karmaloop AI Open Source Chat Bot Framework. All you need to do is download the binaries, make sure you have the .NET Framework or Mono installed, and using it to fire up the KarmaloopAIMLBotServer.exe binary. Platform specific instructions are discussed below.
You can develop or deploy the bot server on any platform using the .NET Framework or Mono Framework. We would prefer using Mono Framework equivalent to .NET Framework 4.5 for running this bot server.
Running on Windows
Running on Windows is as simple as double clicking the KarmaloopAIMLBotServer.exe file or running it via command line. With most versions of Windows, you would have the .NET Framework 4.5 preinstalled, but in case it isn't, you must install it to make it work.
To run on Windows (any edition)
- Goto the folder you have extracted the binaries to
- Double click the KarmaloopAIMLBotServer.exe application (make sure you are not accidentally selecting the KarmaloopAIMLBotServer.exe.config file which is the configuration file for your server)
- Check the port numbers and API endpoint URL. You may need to run the netsh command to ensure the API can start listening on the designated port. Below is an example.
Now you can run the below command from the command line or you can start by double clicking the KarmaloopAIMLBotServer.exe
See the output section to verify if you are seeing something similar.
Running on Linux / macOS
You will need to have the Mono Runtime installed. I have not tested it with .NET Core yet, but would be happy to hear from someone who has tried to do that.
Ubuntu
On Ubuntu, it's as easy as it is to run on Windows, possibly easier! Just get the mono-runtime package installed and you should be good to go.
- Goto the folder you have extracted the binaries to
- Right-click and say Open in Terminal
- Verify you have mono installed by typing the command 'mono --version'
- If mono-runtime is not installed, you need to get that as described below
- Run the exe
See the output section to verify if you are seeing something similar.
macOS
Html Editor For Mac
Download and setup Mono for Mac OS X. Get it hereOnce you have Mono setup, you should be able to run the following command from the directory where you have extracted the binaries
See the output section to verify if you are seeing something similar.
Output (on the Terminal window)
Once you successfully run the KarmaloopAIMLBotServer.exe application, you should see something similar:
Building a Chatbot
If you want to build just a chat bot then, you don't need any programming abilities, however you will still need to be adept at learning AIML and being able to build a conversation using AIML. Search for 'AIML tutorials' and you should find several. You can use your favorite editor to get going on editing the AIML XML files.
The default release contains ALICE bot AIML files for demonstration purposes with some custom skills based AIML files e.g. zweather.aiml.
You can compile from source as described below or you can download the binaries from the link above. You should have two folders named 'aiml' and 'config' in the directory. Setup the AIML and configuration XML files to give your bot conversational abilities and a personality. Now run the KarmaloopAIMLBotServer.exe application and you should see messages on the terminal window similar to the output shown in the Output section above.
Talking to the Chatbot
Once the server is started, there are three ways you can communicate with the chat bot, each way depending on the one below it. More explained below.
The Simple built-in Chat UI
With the latest release, we added a built-in chat UI that you can use to instantly gratify yourself by talking to the chat bot. If you haven't touched any of the configuration options then you should be able to access the default URL.
- Open your favorite browser (which we hope you have updated not in the distant past, or else Material Design/AngularJS will fail to render)
- Open the URL http://localhost:8880/api/ChatUi/index.html (yes you must specify index.html at the end, at least for now)
- Happy chatting!
Web API endpoint
In most likelihood you will be setting up the chat bot to work from your website or mobile app so that it looks and feels like part of your solution. The API endpoints are extremely easy to use and consume in your own app. It's mostly two simple API calls that you need to use, as explained below.
NEW USER
The Chatbot framework needs to distinguish between users who are chatting with it, and for this purpose it lets you generate a unique ID which you can use to subsequently post chat messages. It does not do any user management whatsoever apart from simply generating a GUID which acts as a handle to remember the user and the conversation context.
This should generate a response similar to the following
POSTING A CHAT MESSAGE
To send a chat message to the bot, you simple post in the following format
This should generate a response similar to the one below
Yes, that's it! The ResponseText is what you will be most concerned about in your application.
TCP/IP Socket Communication
This method of communication is just as simple as using the API. You will need to generate a unique ID or GUID on your own however. Currently it does not support returning one for you.
By default the server listens on the port number 8888. You can verify if the server is listening by doing a
If it connects, you are good.
You can input a JSON string as follows to the connection, and should get a response back.
While this method is the lowest level of communication possible with the bot, and definitely means the fastest way as well, using the REST API is the preferred approach owing to its simplicity and widespread applicability.
Free Pdf Editor For Mac
Compiling from source
Video Editor For Mac
If you want to add your own skills to the bot, you will need to code in C# (more language options coming soon) and it certainly will be handy if you know how to build from source. You can build and debug as well using Visual Studio Community edition on Windows, MonoDevelop on Linux and Visual Studio for Mac on macOS.
Building from source on Windows
To make this easy, there is a build.bat batch script that you can run. This will create a binaries directory with everything placed in appropriately.
Building from source on Linux / macOS
Pdf Editor For Mac
There is a build.sh script to help prepare the build for you on Linux and macOS. You may need to set the build engine correctly (edit the script to set the build engine - xbuild or msbuild). Also don't forget to give your build.sh file execute permissions.