Hey, I’m the cold starter, so I think it’s pretty safe to say that the chat GBT is taking the world completely by storm. It has worked its way into nearly everything, trying to catch our eye with all the exciting possibilities and making promises of what generative AI can do for pretty much everything that we touch. But this isn’t the first time that a generative program has tried to capture our hearts and minds. In fact, the very first computer program that was ever designed to generate text had that exact aim in mind. Enter Christopher Strachy and his Love Letter Algorithm from all the way back in 1952.
If you haven’t heard of Christopher Strachy before, he was one of the pioneering computer researchers back in the early days of computer science and is responsible for a lot of the firsts in the field. For example, some of his firsts include the first piece of electronically produced music (a rendition of ‘God Save the King’) and one of the very first video games (a clone of checkers). But he was also the first to create a program to procedurally generate text - the Love Letter Algorithm.
Strachy was also a close colleague of Alan Turing, yes, the Alan Turing. In 1951, both Strachy and Alan found themselves working at the Manchester University computer lab. Alan, then an assistant director, was asked by Strachy for a copy of the Mark 1 programming handbook for the newly created Mark 1 computer in the lab. In typical programmer style, whenever he got the handbook, he pulled an all-nighter, creating the longest program that the computer had run up to that point. This earned him Alan’s personal praise. While I can’t find any details on what the program he built actually did, I’d like to think it was the checkers program.
So Strachy and Turing actually had a lot in common, both in their professional and personal lives. And so it’s not a big surprise that the two began to follow each other’s work. While waiting for a new assignment from the research department, Strachy actually read and then further took inspiration from Turing’s ‘Computing Machinery and Intelligence’ essay, where Alan actually proposed the famous imitation game and pondered the question, ‘Can machines think?’ Strachy then asks the question, ‘Can a machine produce human-like love letters that elicit feelings and emotions?’ Or, to put it another way, ‘Can I get a program to put the moves on somebody for me?’ Let’s face it, every computer science student has thought this at one point or another. And so, Strachy rushed off to the computer lab to create a program that would do just that.
Now, let’s move on to the actual algorithm itself. If you’ve ever played a game of Mad Libs, this is going to sound very, very familiar. The program relies heavily on random selection of templates and word lists and can be roughly divided into three sections: the introduction, the main body, and the salutation.
In the introduction, there’s going to be a list of possible salutations that the program can select from. It selects two of these salutations at random and smashes them together. Examples of this process can be something like ‘dearly gorgeous darling’, ‘sweetheart darling’, ‘dearly dearly darling’, and so on. That’s what it uses for the salutation for the letter itself.
Now, let’s move on to the main body of the letter itself. The process is going to be similar, with one additional tweak. Instead of just randomly selecting completed sentences, it will actually select templated sentences with slots in the sentence where things like nouns, verbs, and adverbs can go. The program is going to select one sentence template at random and then go through each of the possible word slots and select a word that is appropriate to that slot. It does this three or four times, generating three or four different sentences. That is how the body is generated.
The last piece that the algorithm needs to generate is the salutation. This is generated much in the same way that the greeting is. Internally, there’s a list of possible words to use in the salutation, and it selects two at random and smashes them together. It then signs the letter ‘MUC’, which stands for the Manchester University Computer. It then prints out the completed love letter to the user, so they may do with it what they will. And that’s the algorithm.
While pretty straightforward and simple to explain, it can actually produce some pretty nice-sounding love letters. One example of a love letter that this algorithm can generate is as follows: ‘Darling sweetheart, you are my avid fellow feeling. My affection curiously clings to your passionate wish. My liking yearns for your heart. You are my wistful sympathy, my tender liking. Yours beautifully, MUC.’ While it may not win any literature awards, I believe that this poem is worthy enough to go on a Hallmark card, which is a pretty good result from a program from the 50s.
So, the algorithm is able to construct millions of variations of love letters. And this was really impressive at the time because it was the first example of procedurally generated text. Programs up to that point were very much input in, expected output out. But the fact that you could run this program over and over again and get different results was really impressive. It did cause quite a bit of stir whenever the results of this program were actually shown in various publications and shared around the research lab.
Strachy would later write how it was interesting that a simple trick such as this template substitution technique can produce the illusion that the computer is thinking and composing, and that these simple tricks can lead to quite unexpected and interesting results. These simple tricks would then be repurposed for some of the earliest examples of chatbots, such as Eliza.
But we’ll get to those bots in a different video. Just know that the same sort of template and substitution techniques were used long after this algorithm was created. Researchers would continue the work of AI, having computers generate text and making them more advanced and closer to human with each generation. Leading to today, with the massive explosion of AI that we’re experiencing, where it’s touching every part of our lives. And a key part to all of this is a simple love letter composed by a romantically-minded computer looking for its significant other. And that’s the story of the Love Letter Algorithm, a historical program from the 50s that is more relevant than ever in the present day.
Hope you enjoyed this article. If you did and have some extra time, please check out my other articles talking about various topics in computer science. And as always, thanks for reading.