Eliza, Part 2

16Jun

Just to be sure we understand what Eliza does and doesn’t do, I thought it might be instructive to look at an actual conversation from under the hood. What follows is an only slightly modified version of the sample run included in the July/August, 1977, issue of Creative Computing that introduced the BASIC Eliza. (Specifically, I changed the original reference to an IMSAI 8080 to a Tandy in keeping with this blog’s recent theme.) It’s a much less compelling example than the famous transcript I included in my last post, which is partly down to the acknowledged inferiority of this version of Eliza and partly down to Creative Computing choosing to interact the way a person more typically might — i.e., by trying to take the piss out of the program just a bit rather than playing along with the psychologist / patient relationship. In that sense I’d call it a more honest reflection of Eliza‘s capabilities and limitations, and of the average user’s experience with it.

At the heart of the program is a routine that searches each input for one of a group of text sequences. In order of priority, they are:

As soon as one of these sequences is found, it is taken as the key sequence for the input as a whole, and no more searching is done. In other words, “COMPUTER” could be taken as the key sequence only if the input text does not contain any of the previous 34 sequences.

RUN
HI! I'M ELIZA. WHAT'S YOUR PROBLEM?
? I AM AN IBM 370
DID YOU COME TO ME BECAUSE YOU ARE AN IBM 370

When Eliza finds a key sequence, it responds with a set sequence of its own. In this case, it has latched onto the sequence “I AM” in the input. Having done so, it automatically throws away all of the input through that point, leaving just “AN IBM 370.” It then looks up the appropriate response pattern, which is “DID YOU COME HERE BECAUSE YOU ARE…”, followed by the remainder of the original input.

(Oh, and just so everyone gets the joke: an IBM 370 was an extremely large and powerful mainframe computer of the era; thus its repeated talking down to the little Radio Shack microcomputer.)

? YES I WANT A NEW LINEPRINTER
WHAT WOULD IT MEAN TO YOU IF YOU GOT A NEW LINEPRINTER

This time there are two possible matches: “YES” and “I WANT.” However, “I WANT” has higher priority, so Eliza throws away all of the input text through that point, which incidentally includes the “YES.” The appropriate response to “I WANT” is “WHAT WOULD IT MEAN TO YOU IF YOU GOT…”, followed by the remainder of the input.

? ABOUT 1800 LPM
SAY, DO YOU HAVE ANY PSYCHOLOGICAL PROBLEMS?

We’ve given Eliza nothing to latch onto here; no sequence matches at all. Therefore it falls back on a canned response for such situations.

? WHAT WOULD YOU KNOW I'M A 370 AND YOU'RE A TANDY
WHAT MAKES YOU THINK I AM A TANDY

There are a few matches this time, but “YOU’RE” has the highest priority, so Eliza throws everything away up to that point and appends the remainder to the appropriate response, “WHAT MAKES YOU THINK I AM…”

? IT SAYS THAT ON YOUR FRONT PANEL
WHY ARE YOU CONCERNED ABOUT MY FRONT PANEL

Key: “YOUR”
Result: “WHY ARE YOU CONCERNED ABOUT MY…” + “FRONT PANEL”

? LOOK YOU BROUGHT UP THE SUBJECT
WE WERE DISCUSSING YOU-- NOT ME.

Not all response sequences incorporate the original input. In this case, the key “YOU ” results in the canned response “WE WERE DISCUSSING YOU– NOT ME.”

? I'M FIXING A HOLE...
DID YOU COME HERE BECAUSE YOU ARE FIXING A HOLE...

The key sequence this time is “I’M “. Eliza turns to the same response sequence for both “I AM” and “I’M “, as one might expect.

? SORRY THAT WAS A TEN YEAR OLD SOFTWARE BUG
PLEASE DON'T APOLOGIZE

Key: “SORRY”
Result: “PLEASE DON’T APOLOGIZE!”

(Presumably, this is — leaving aside the obvious Beatles reference — an in-joke having to do with the IBM 370. If anyone reading this knows what exactly is being referred to here, by all means enlighten us in the comments.)

? I AM ALWAYS APOLOGIZING
HOW LONG HAVE YOU BEEN ALWAYS APOLOGIZING

Yet again “I AM” is the key sequence. However, notice that the response is not quite the same. For most keys, Eliza cycles through several response sequences, hopefully masking somewhat the automated nature of the whole process. In the case of “I AM,” there are four possible responses. (Due to an idiosyncrasy in the program, synonyms such as “I AM” and “I’M” are each run through their own cycle even though they draw from the same list of responses.)

? SINCE MY FIRST COLD START
WHAT DOES THAT SUGGEST TO YOU?

Once again we have given Eliza nothing to go on, so it falls back on the second of seven possible noncommittal responses.

? YOU'RE THE SHRINK
DOES IT PLEASE YOU TO BELIEVE I AM THE SHRINK

Our second use of “YOU’RE” results in the second of four possible responses to that sequence.

? DON'T YOU KNOW?
OH, I KNOW?

And our second use of “YOU ” results in the second of three possible response to that sequence.

? I AM BEGINNING TO WONDER ABOUT YOU
DO YOU BELIEVE IT IS NORMAL TO BE BEGINNING TO WONDER ABOUT I

Here we have the first real breakdown, and it’s an illustrative failure indeed. Eliza discovered yet another use of “I AM,” our third now, and so turns to the third response, “DO YOU BELIEVE IT IS NORMAL TO BE…” Based on what we’ve seen so far, we might expect the full reply to be, “DO YOU BELIEVE IT IS NORMAL TO BE BEGINNING TO WONDER ABOUT YOU,” which is obviously inappropriate. To account for situations like this, Eliza always attempts to modify the input-text fragments that it reprints, by changing first-person pronoun references to second-person and vice versa, and attempting to do some simplistic to-be verb conjugation. To be precise, it replaces sequences in the input text like so:

Eliza has in fact been searching reprinted fragments all along for these sequences, but has not found any until now. And now that it does, it gets it wrong, falling afoul of the fact that in English the second-person pronoun is the same in both the nominative and the accusative, but the first-person pronoun is different. Since it lacks any structural understanding of the English language and can only replace sequences of characters with other sequences, it replaces “YOU” with “I” rather than “ME.”

Here we have another “failure” of sorts that this time actually works within the context of the conversation. Eliza takes the sequence “YES” from the word “EYES” as its key, resulting in the first of three possible responses to that sequence. Considering the non-sequitur that might have resulted, Eliza just dodged a bullet.

? ABOUT COMPUTERS?
DO COMPUTERS WORRY YOU?

Key: “COMPUTER”
Result: “DO COMPUTERS WORRY YOU?” (response 1 of 7)

? SHOULD THEY AFTER ALL I AM A 370
DO YOU ENJOY BEING A 370

Key: “I AM”
Result: “DO YOU ENJOY BEING” + “A 370″ (response 4 of 4)

…and so on. I’m sure you get the gist of it by now. Having beaten this particular dead horse into the ground, I’ll wrap up this topic next time by talking about what the experience of Eliza ultimately means — to me, to Joseph Weizenbaum, and maybe to you.

Yes. Matter of fact, I strongly suspect the ADRIFT parser is doing some of this sort of thing even today, as are any number of home-brewed systems. It’s a tempting but dangerous game to play in that it can work for a while, but when it inevitably breaks down the results are embarrassing — much like with Eliza itself.

A neat trick in the original also present in the 48 Kb port I typed from my AI book made it use “my” as a keyword and remember anything after it, so if the user mentioned something like “my father” the program would politely ask her to keep talking about her father in case no other key was found, as shown in the famous transcript from last post. Problem was in my spanish version it couldn’t make the difference between “my” and “me” as both words are witten the same way “mi”, which caused a lot of garbage output (among several other translation conflicts). It would have surely been very easy to find a workaround, but I was too newbie in BASIC at the time ^_^’