Eliza – therapy through randomness.

Photo by Vitaly Gariev on Unsplash

ELIZA was originally a computer program written in the 1960s, using a combination of randomness and pre-written responses to loosely emulate the behaviour of a psychotherapist – mimicking the early stages of working with someone, very focussed on questions and exploration. It responded to statements from its user, using a random selection of pre-programmed responses to imitate the natural conversation of a person, often repeating part of the patient’s statement in its response to emulate relevance.

A full description and history of ELIZA deserves a post all to itself, especially because it touches on a lot of the themes in our upcoming book – for now you can find out more about it on Wikipedia. It’s worth noting that its use started an understanding of the “Eliza effect”, the tendency of humans to ascribe human traits to machines that talk to us via natural language – a phenomenon that plagues us to this day.

I’ve coded a version of this myself. Of course my bot is just rudimentary, and at most “a bit of fun”. Real world computerised psychotherapy is a much more serious issue that I frequently change my opinion on: on the one hand the constant availability of automated therapy is very useful, especially considering the general dearth of trained psychotherapists; and how the pressures of modern society increasingly exploit the weaknesses in human nature, leading to ever more demand. But on the other hand, in rare but all too significant cases, LLMs are clearly not up to any serious version of this task, and are dangerous when doing anything more than beyond saying “you should talk to a professional when one is available” or when providing advice any more complex than the “you got this” of Instagram level “inspo”.

Similarly with regard to LLMs, I’m really interested in the concept of “vibe coding”. For production ready software, LLMs don’t seem to be there yet, but it’s useful for simple tasks and experiments. For example, I say “I’ve coded” above, when actually Claude.AI put together the bulk of the code, I just added many more responses within certain sections.

As always with LLM usage, there’s a “conceptual distance” to make up once the outcomes has been produced – there’s usually a significant gap between what you wanted, and what the LLM produced. In this case, only after working on the original code from Claude, did I learn what the script could be capable of if I’d have planned more thoroughly, or how the original ELIZA actually learnt about its user as the conversation progressed, improving its usefulness. But to get my experiment to that stage would require re-writing the code from scratch, and this has been a useful experiment, and the outcome is better than what I could have achieved through trying to learn Javascript… again1.

Should you want to see how this iteration works, in need of Javascript based therapy, give ELIZA, the Virtual Therapist a try.

Of course if you have a serious problem you should consult a professional. Otherwise, although the code is a bit clanky, do give it something solid to respond to, take its questions seriously, and you might be surprised at how useful the questions are if you treat them sincerely2. Faced with a tricky problem, where you’re stuck, I think interacting with anything outside of your own head is a useful method… that might be an LLM, but also I think less futuristic solutions can work too, anything from flicking to a random dictionary page, to a long walk. If you talk to ELIZA, do share how you get on.

  1. Unlike art, or prose, I think you can learn the practice by working with LLM output. But, again, something for another post. ↩︎
  2. Actually, if you want to see randomly generated output executed much better, using code written by an actual human, check out The Exilian Romantasy Blurb Generator ↩︎

Leave a comment