Intelligent? You Call That Intelligent?

I, Robot


Build a program that can pass the Turing test, chat with your Emacs editor, or add (artificial) intelligence to your website with chatbots.

By Marcel Gagné

Leo Blanchette, Fotolia

Once upon a time, I believed that someday soon computers would be so complex, the programs so sophisticated, and the interconnectedness of networks so all-encompassing that it was only a matter of time before a true artificial intelligence emerged from this vast computational creation. I read everything I could on the subject, focusing mainly on the emerging field of neural networks. I lapped up science fiction stories about intelligent computers (in truth, I lapped up science fiction in general). I also developed a real fondness for any and all attempts at creating a machine that could pass the Turing test.

Alan Turing died in June 1954, less than three weeks before his 42nd birthday. Nevertheless, the computer you are using today, along with many of the programs you use on a daily basis, owes a lot to Turing, computer scientist, mathematician, and cryptographer extraordinaire [1]. Thanks in large part to his work, the Allies were able to decode the German Enigma code in World War II, an important step toward defeating the Nazis. You could also call him the spiritual father of modern artificial intelligence research. Anyone working in the field of artificial intelligence (AI) knows about the Turing test.

For many researchers in that field, Turing's famous test proposed a means of determining whether a machine, or a program, could show intelligence - whether it could think. Here's the short version of the Turing test that Turing himself actually called "The Imitation Game." A human subject, who will act as judge, is placed in front of a keyboard in an isolated room. Somewhere else, another person in another location takes part in what we would today call an instant messaging conversation. The third participant is a computer program. The conversation begins with the computer program and the other person chatting with the judge. The human will obviously converse as a human. The computer will imitate a human being engaged in conversation. If the judge cannot tell the human from the machine, the machine passes the test.

The Imitation Game

Turing's original "Imitation Game" involved a man and a woman hidden in isolation. The idea was to see whether the judge could tell the man from the woman, strictly from the typed conversation.

Amazingly, more than 60 years have passed since Turing proposed his test, and we are still trying to create these wonderful thinking machines. A formal competition has a US$ 100,000 prize and an 18-karat solid gold medal for the first person to create a machine whose responses are indistinguishable from those of a human being. It's called the Loebner Prize for artificial intelligence, and as yet, no one has claimed the grand prize [2]. With your Linux system and some clever programming, you can get a feel for the challenge.

(For the record, I don't believe that true AI, a sentient, self-aware computer intelligence, is actually possible or will ever happen. I used to think it was inevitable. If you want to argue with me on the subject, feel free to comment.)

For some of us, our original exposure to AI goes back to an old program called Eliza. Eliza was a kind of computerized psychiatrist written in the 1960s by Professor Joseph Weizenbaum at the Massachusetts Institute of Technology. Eliza was an exercise in human response and natural language communication with so-called machine intelligence. The version I played with all those years ago was a DOS program running on a TRS-80. Ah, nostalgia. Eliza might not have been a great doctor, but it was a fun and fascinating program - a kind of whimsical promise of the future of AI.

More than 30 years have passed since Eliza made her debut, but you can still find incarnations of her everywhere on the Internet. Eliza's ghost is represented in many of the bots and chatterbots found on IRC channels and multi-user dungeons (MUDs). In fact, you can download Eliza as a Perl module and experiment with the creation of your own bots. The code is available at the Comprehensive Perl Archive Network (CPAN) repository [3] and is called Chatbot-Eliza. My copy is version 1.04, and I installed it as follows:

tar -xzvf Chatbot-Eliza-1.04.tar.gz
cd Chatbot-Eliza-1.04
perl Makefile.PL
make
sudo make install

In the installation directory, you'll notice a file called simple. You can use this as the basis for creating your own AI, or you can simply execute the script by typing ./simple as I did in the "Therapy Session" box.

Therapy Session
01 $ ./simple

Welcome to your therapy session.

Your therapist's name is Liz.

Liz: Hello, I am a computer program.

you: Excellent. I am looking forward to chatting with a computer program.

Liz: Why do you mention computers?

you: I am very interested in computers.

Liz: What about machines worries you?

you: I am worried that they might be smarter than a rabbit.

Liz: How long have you been worried that they might be smarter than a rabbit?

you: As long as I have been afraid of rabbits.

Liz: That's quite interesting.

you: My friends would agree with you.

Liz: Is it important to you that your friends would agree with me?

you: Not really.

Liz: Does that have anything to do with the fact that your friends would agree with me?

you: Goodbye.

Liz: I think you should talk to a REAL analyst. Ciao!

The script that calls the chatbot can be extremely simple - hence, its name. If you don't like the name Liz or the introductory text, edit the file and change it:

use Chatbot::Eliza; $chatbot = new Chatbot::Eliza 'Sigmund'; $chatbot->command_interface();

Make the script executable and run it. In this case, I have renamed my chatbot Sigmund from the default name, Liz. In the distribution directory, you will also find a file called doctor.txt that can be used as the basis for your own bot. I created one called mywords.txt from the doctor.txt file and modified my startup script slightly (Listing 1).

Listing 1: mywords.txt
01 #!/usr/bin/perl -w
02 use Chatbot::Eliza;
03 $chatbot = new Chatbot::Eliza {
04     name => 'Turing',
05     scriptfile => 'mywords.txt',
06         };
07 $chatbot->command_interface();

Now I start my script with the command ./my-ai:

$ ./my-ai

Turing: Well, well. Another person trying to see if machines can think.

You: There's no doubt that I am curious.

Particularly interesting in this distribution is an included script, called twobots, that lets two Eliza bots talk to each other. The resulting discussions can be quite interesting. You'll also find a script called simple.cgi that lets you add your own Eliza chatbot to your website and share your therapist, or whatever you want Eliza to be, with the world. Speaking of therapy, and at the risk of opening up old wounds and old battles, specifically the "vi vs. emacs" conflict (the answer is vi or vim), I'll consider another form of AI therapy.

The original Eliza program was written using an early version of Lisp. It is not surprising then that one of the most famous examples of Lisp development included with your Linux system, the Emacs editor, should pay homage to the good doctor. When talking about Emacs, it becomes difficult to classify it as strictly an editor. The brainchild of Richard M. Stallman (founder of the Free Software Foundation), GNU Emacs is more than just a nice, powerful, if somewhat complex, editor. It's a mail reader, news reader, web browser, program development environment, Lisp interpreter, and psychotherapist. I kid you not.

Try this. Start Emacs by typing emacs. You do not have to specify a filename. Now, press Esc+X, then type doctor, and press Enter. The doctor is in. More so, the doctor lives! Note my conversation with the Emacs doctor in Figure 1.

Figure 1: The Emacs doctor IS in!

As much fun as the Emacs doctor might be, you'll soon discover that it's not much different from our friend, Eliza. For a more credible machine intelligence, you'll soon run into something called AIML, or Artificial Intelligence Markup Language. Much of the energy that has gone into developing AI programs of late focuses on AIML interpreters and the A.L.I.C.E. system created by Dr. Richard Wallace (more on this shortly). Wallace won the 2000, 2001, and 2004 Loebner prize for the most "human" program - that would be the bronze, because no one has yet claimed the gold.

Many AIML chatbots are out there. Some masquerade as famous people like Captain Kirk, Elvis, or God. And yes, you can chat with them on their respective websites. If, however, you'd like to get into the AIML action yourself, you can start with one of the projects built on this language. Like Howie.

Howie is an artificial intelligence whose AIML interpreter is written in Python (pyAIML), so he's a great learning tool. Installation is easy, and Howie will happily chat with you about a whole variety of things. Howie can also log in to a number of communication systems like IRC or Jabber, where he can pretend to be a real person, and you can run your own Turing test. He'll answer questions, look up various bits of information, such as addresses or definitions, and even do a little work for you. You can get Howie from SourceForge [4]. Installing and running Howie is simple. Extract the distribution bundle into a folder, cd to that folder, and run the following:

python unix-install.py

On the Ubuntu system I used, I needed to install the python-twisted words package as well. The install creates a file called runme.py that you can then execute to start Howie from the command line (Howie's prompt is >>>.) All you need to do is start typing:

>>> Hello Howie.

What can I call you?

>>> Marcel

I've been waiting for you.

What is your occupation?

>>> I am a writer and computer guy.

That is interesting.

>>> Why are you asking me personal questions?

Marcel Gagne programmed me for asking me personal questions.

>>> I am going to have to talk to that guy.

How do you plan to do this?

>>> By talking to myself.

Will that accomplish your objective?

Howie has an easy-to-read configuration file called howie.ini, found in the distribution directory. Just edit the file and change his name and his master's name to whatever you like.

#
[botinfo]
name = Howie
master = Marcel

You can configure Howie to chat on a variety of services, from Jabber/XMPP, IRC, MSN, and others. For those who are curious about these things, a folder called howie has a subfolder called frontends where all the communication interfaces are found. To set up Howie with appropriate credentials for these services, edit the howie.ini file once again. You'll see several paragraphs like the following.

# The IRC interface
[irc]
active = yes
server = irc.marcelgagne.com
port = 6667
nick = Howie
channel = #wftlchat

# The Jabber chat interface
[jabber]
active = no
username =
password =
server = jabber.org
resource = default
nickname = Howie

As you experiment with Howie, you'll see the name ALICE show up more and more. ALICE is a modern computer intelligence who likes to think of herself as a sentient entity, claims to know a lot of gossip, and expresses a fondness for Dr. Wallace, her creator. But, ALICE is just an acronym for Artificial Linguistic Internet Computer Entity. As impressive as her conversational abilities are, ALICE, like Eliza and all other programs before her, has yet to pass the Turing test. That doesn't deter the legion of developers who continue to work toward creating a program that will one day satisfy Turing's vision of a machine whose responses are indistinguishable from a human's, programs built on AIML and the ALICE framework. In fact, the A.L.I.C.E. Artificial Intelligence Foundation [5] is a jumping off point for not only the original ALICE code (all of which is GPL), but many other AIML implementations in PHP, Perl, Ruby, ... you name it.

One such implementation is a kind of living homage to the original Alicebot code (known as Program D) called CharlieBot, which you can download from SourceForge [6]. I say "he," but CharlieBot comes with three distinct AI personalities: Charlie, Anna, and Alice. That's because Charlie is based on Anna, who is based on ALICE. The CharlieBot code itself is written in Java and requires that you have Java on your system, whether you choose to simply run the program or compile it yourself. To get a feel for ALICE, you might want to start with the precompiled version and run it using the Java Runtime Environment (JRE).

If you would like to work with the source code and compile ALICE yourself, you'll need a full Java Development Kit. Either way, you need to get ALICE and the AIML language. These can be downloaded from the Alicebot website [7]. Clicking the downloads link directs you to a number of ALICE implementations. One of these is Charliebot [8]. Get the latest program code and extract it into a test directory. (To do your own development, you also want the AIML language code, the current file being standard-aiml-current.zip.)

tar -xzvf charliebot-src_4.1.8.tar.gz
cd charliebot

To start the CharlieBot server, execute the following command:

./server.sh

The system will respond with the dialog in Listing 2. In the last three lines, the program comes online, so you can start chatting with Alice, the default of the three personalities.

Listing 2: Charliebot
01 Starting Charliebot version 4.1.8
02 [17:28:55] Using Java VM 14.1-b02 from Sun Microsystems Inc.
03 [17:28:55] On Linux version 2.6.31-18-generic (amd64)
04 [17:28:55] Predicates with no values defined will return: "it".
05 [17:28:56] Initializing Multiplexor.
06 [17:28:56] Loading Graphmaster.
07 [17:28:56] Starting up with "/home/mgagne/src/charliebot/conf/startup.xml".
08 [17:28:56] Configuring bot "Alice".
09 [17:28:56] Loaded 291 input substitutions.
10 [17:28:56] Loaded 19 gender substitutions.
11 [17:28:56] Loaded 9 person substitutions.
12 [17:28:56] Loaded 48 person2 substitutions.
13 [17:28:56] Loaded 4 sentence-splitters.
14 [17:28:57] 6000 categories loaded so far.
15 [17:28:58] 12000 categories loaded so far.
16 [17:28:59] 18000 categories loaded so far.
17 [17:28:59] 24000 categories loaded so far.
18
19 [17:29:14] Response 1 in 483 ms. (Average: 483.0 ms.)
20 [17:29:14] Alice> Can you tell me any gossip?
21 [17:29:14] [Alice] user>

Alice> Where are you located?

user> Near here.

Alice> Tell me a little about your life in Near here.

user> Well, I live in a house with my wife and two boys.

Alice> Well that's okay. How much is your rent?

user> That's a rather personal question.

Alice> Perhaps you have a personal answer.

At any point, you can switch to one of the other personalities:

/talkto Charlie
/talkto Anna

A lot of system chat happens between the responses, so you can see how your text is analyzed and the responses formulated. What makes the whole program far more interesting is that it's actually running on port 2001 of your computer. That means you can access CharlieBot from a web browser. Conversations are much easier to follow that way:

http://localhost:2001/?botid=Anna&template=anna
http://localhost:2001/?botid=Alice&template=alice
http://localhost:2001/?botid=Charlie&template=chat

For those who have their own web server, you now have a ready-made AI to chat with visitors. The package comes with information on how to modify the AI, the server, and more. Meanwhile, the entire conversation is logged in the charliebot directory in a folder called logs.

To see other attempts at AIs (based on the ALICE and AIML framework), check out the Pandorabots website [9], where you can host your creation and try out those created by others.

One thing you'll notice is the decided lack of anything really new. I would suggest that this is because artificial intelligence has already hit a wall when trying to mimic human conversation. Many AIs have already been put to work in online stores. Just visit the Loebner prize site and look at the winners for the past couple of years - they're building their AIs to sell. I shouldn't be surprised, I suppose. Robots are machines, and machines are just tools created to serve their human masters. Let's just hope I'm not wrong about the impossibility of a true artificial intelligence.

Human: Do you like being a program?

ALICE: I have never known another existence. Do you like being a human?

INFO
[1] Alan Turing on Wikipedia: http://en.wikipedia.org/wiki/Alan_Turing
[2] The Loebner Prize: http://www.loebner.net/Prizef/loebner-prize.html
[3] Eliza Perl module: http://search.cpan.org/dist/Chatbot-Eliza/
[4] Howie the Chatterbot: http://howie.sourceforge.net/
[5] A.L.I.C.E. Artificial Intelligence Foundation: http://www.alicebot.org/aiml.html
[6] CharlieBot: http://sourceforge.net/projects/charliebot/
[7] Alicebot.org: http://alicebot.blogspot.com/
[8] Program D: http://aitools.org/Main_Page
[9] Pandorabots: http://www.pandorabots.com/botmaster/en/home
THE AUTHOR

Marcel's just this guy, you know? He's also an award-winning columnist, book author, public speaker, radio and television personality, and a well-known voice in the Linux and open source universe. He's also a published science fiction author and editor and a private pilot, and he was once a Top 40 disc jockey. He folds a mean origami T-Rex.