RSS

Eliza, Part 1

15 Jun

In 1965 a professor at MIT, Joseph Weizenbaum, introduced a computerized conversation simulator he called ELIZA. The most famous ELIZA transcript was published soon after in an article Weizenbaum wrote for the January, 1966, volume of Communications of the ACM. It is a record of a conversation between the program and a young woman; the program’s responses in the text below are in all caps.

Men are all alike.
IN WHAT WAY
They’re always bugging us about something or other.
CAN YOU THINK OF A SPECIFIC EXAMPLE
Well, my boyfriend made me come here.
YOU BOYFRIEND MADE YOU COME HERE
He says I’m depressed much of the time.
I AM SORRY TO HEAR YOU ARE DEPRESSED
It’s true. I am unhappy.
DO YOU THINK COMING HERE WILL HELP YOU NOT TO BE UNHAPPY
I need some help, that much seems certain.
WHAT WOULD IT MEAN TO YOU IF YOU GOT SOME HELP
Perhaps I could learn to get along with my mother.
TELL ME MORE ABOUT YOUR FAMILY
My mother takes care of me.
WHO ELSE IN YOU FAMILY TAKES CARE OF YOU
My Father.
YOUR FATHER
You are like my father in some ways.
WHAT RESEMBLANCE DO YOU SEE
You are not very aggressive but I think you don’t want me to notice that.
WHAT MAKES YOU THINK I AM NOT VERY AGGRESSIVE
You don’t argue with me.
WHY DO YOU THINK I DON’T ARGUE WITH YOU
You are afraid of me.
DOES IT PLEASE YOU TO BELIEVE I AM AFRAID OF YOU
My father is afraid of everybody.
WHAT ELSE COMES TO MIND WHEN YOU THINK OF YOUR FATHER
Bullies.
DOES THAT HAVE ANYTHING TO DO WITH THE FACT THAT YOUR BOYFRIEND MADE YOU COME HERE

It is often assumed that “Eliza” is simply the name of the psychotherapist with which the human “patient” converses, but this is not in fact the case. ELIZA is actually the name of a generalized conversation system of Weizenbaum’s devising, being a reference to a working-class character in George Bernard Shaw’s play Pygmalion who learns to speak in an upper-class diction in spite of her origins. The metaphor, then, is that the computer has traded in the inflexible diction of a programming language for everyday natural language. Different “scripts” could be plugged into ELIZA to represent different characters. The first of these to be developed by Weizenbaum, as well as the one that generated the transcript above and the one that everyone remembers today, was called simply “Doctor.” In the film Rebel at Work Weizenbaum describes the process that led him to this rather brilliant character choice:

“And then all of a sudden it came to me: the psychiatrist. The psychiatrist asks questions in response to what the patient says. It may be partially or totally irrelevant, but the patient will interpret his words in terms of his own frame of mind. The patient assumes that the psychiatrist knows something, that he understands, that there is some sense to his words. ‘I don’t know what it is yet, but it’s not nonsense.’ And that’s how it started — then came ELIZA.

‘Well,’ says the psychiatrist, ‘perhaps… what does this remind you of?’

‘Hmm, very clever!’ thinks the patient. ‘This is a psychiatrist who really knows what I feel. I’m going to continue working with him.’”

As Weizenbaum was careful to describe in his article, in no sense does ELIZA actually understand anything its interlocutor enters. It is simply an elaborate text-generation engine, which searches for patterns in the entered text which can serve as hooks to be manipulated and recombined into its responses. The genius of the “Doctor” script is that this is also essentially what a psychotherapist often does during a session, at least from the perspective of the layman. Weizenbaum did prepare at least a few other ELIZA scripts, such as (keeping with the mental health theme) one for a paranoid schizophrenic, but these apparently did not have quite the same magic, and aren’t much remembered today. UPDATE: Actually, as Nick points out in the comments below, we have no evidence that Weisenbaum developed any scripts other than “Doctor.”

Even if we confine ourselves to “Doctor,” the famous script I included above is something of a best-case scenario. Weizenbaum, usually quite sober about these things, was stretching the truth considerably when he called it a “typical conversation” in his article. There inevitably comes a point in any ELIZA session that continues for any length of the time when the programs says something that clearly reveals it to be the elaborate parlor trick that it really is. Such breakdowns are at least as common as the several surprisingly apropos responses in the transcript above.

Weizenbaum wrote ELIZA in Lisp, a somewhat esoteric programming language developed at MIT for artificial intelligence and natural language processing applications. UPDATE: Make that MAD-SLIP, which originated at the University of Michigan. See Nick’s comment below for more details. However, his detailed ACM article served the same purpose as did Don Woods’s meticulously commented Adventure source code of ten years later, making the porting of ELIZA to other platforms and languages a relatively straightforward task. In the process, Weizenbaum’s original concept of a generalized conversation engine was forgotten, and ELIZA the system became Eliza the female psychotherapist. Creative Computing published a version in BASIC by Jeff Shrager and Steve North in its July/August, 1977, issue. In North’s words, “Although the program is an inferior imitation of the original, it does work.” Its limitations in comparison with Weizenbaum’s original derive from being written in BASIC and from the necessity of running in just 16 K of RAM. It’s nevertheless impressive in its way for what it is, and would serve as a springboard for countless sequels and derivations over the next decade. It seemed no one could own a microcomputer in the 1970s or 1980s without having some sort of Eliza variant somewhere in their software collection.

If you’d like to try out this version of Eliza on a virtual TRS-80, you can do so using the SDLTRS emulator and this state file.

1. Make sure the Level 2 ROM file and the NewDOS boot disk are in the emulator’s root directory, and that the state file is in some known location.
2. Start the emulator.
3. Turn your caps-lock on.
4. Press ALT-L to load a state.
5. Navigate to the state file and select it.

You’ll find yourself at a BASIC READY prompt, from which you can LIST the program, edit it, and of course RUN it. (Yes, it is very, very slow; such is life when doing lots of string processing in BASIC on a 1.78 MHz machine.) Type “SHUT” at any prompt to quit the program — and remember, you must have your caps lock on for it to “understand” you.

Finally, for those who know how to deal with such things, I’ve also made available the tokenized TRS-80 BASIC file of Eliza.

So, having talked about what ELIZA is we can soon get to the more interesting questions of how it works and what it means — and why I felt compelled to backtrack this way in the first place.

Postscript (June 17, 2011):

I’ve grown disenchanted with the SDLTRS emulator, and decided to use the one included with the MESS project from now on. Here’s a state file for use with that emulator. See my recently revised post on emulating the TRS-80 for more details on how to get a virtual TRS-80 working under MESS.

 
 

Tags: ,

8 Responses to Eliza, Part 1

  1. Nick

    June 16, 2011 at 1:56 am

    Jimmy, thanks for this note on Eliza and for documenting the distinction between the overall system (Eliza) and the particular psychotherapist script (Doctor). The BASIC port you describe is certainly significant as an example of AI on microcomputers.

    You mention that among the other scripts Weizenbaum wrote was “one for a paranoid schizophrenic” – did he really? It was Kenneth Colby who wrote PARRY, if that’s the program you have in mind. I’d be very interested to know if Weizenbaum had written one first, or indeed what were any of the other scripts for the Eliza system that Weizenbaum wrote.

    Also, you state that Weizenbaum wrote ELIZA in Lisp, but I think you are referring to a famous port of ELIZA. Weizenbaum wrote the system in MAD (the Michigan Algorithm Decoder) using his own SLIP libraries for that language, see here or here.

     
    • Jimmy Maher

      June 16, 2011 at 8:22 am

      Thanks for the corrections!

      One nice thing about developing this material in a blog is that I have lots of smart people looking over my shoulder, which comes in very handy when I get sloppy in my basic research or overreach in my theory. I’m afraid this is a pretty good example of the former.

      While I wish I could unveil a treasure trove of new Weizenabum-authored ELIZA scripts at this point, I can’t; I was indeed confusing Weizenbaum’s work with that of Colby. And you are of course also correct about the language Weizenbaum used.

       
  2. rockersuke

    June 16, 2011 at 8:42 am

    My first contact with an Eliza port was in the mid 80′s. It was a BASIC conversion I patiently typed from the spanish edition of an AI book by Tim Hartnell. The editor included a port to ZX Spectrum 48k BASIC (which handled character string arrays in its very own and peculiar way) as an appendix to the book. While the Spectrum conversion was quite effective, its real drawback was the spanish translation, which was made just by literally translating every string on its own. That didn’t work at all as a whole (most answers were a total nonsense). In that sense I was working with a limited version from an already limited version, but just like that first BASIC port you mention, it did its job, driving me into learning how the “magic” was done.

     
  3. Austin Seraphin

    June 25, 2011 at 2:54 am

    My parents got me an Apple II/e in 1984 or so, which would have made me seven years old. I only knew how to do a CATALOG or how to RUN a program. Still that proved enough, and one day I ran Eliza. After the session, I tried to think of other commands to try. I figured that LIST would list something, so typed it in, and for the first time saw computer code. It clicked in my little brain! The computer just follows these instructions! I knew right away that I had to learn how to do this. I have programmed ever since. It still feels magical. Thanks Eliza!

     

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>