Hey computer, tell me a joke: the problem of teaching AI humour

Hey computer, tell me a joke: the problem of teaching AI humour

Artificial intelligence can learn the structure of a knock knock joke easily enough. But will it ever understand what makes us laugh?

Published: December 2, 2019 at 12:00 pm

Have you heard the one about a robot who walks into a bar?

“What can I get you?” asks the bartender.

“I need something to loosen me up,” says the robot.

So the bartender serves him a screwdriver.

Not exactly side-splittingly funny but not bad either. I’ll bet you wouldn’t have guessed that a computer wrote it - @jokingcomputer.

Here’s another one told by a computer:

Knock Knock.

Who’s there?

Water.

Water who?

Water you doing tonight?

Not bad either, but no cigar.

So how does Artificial Intelligence (AI) do when it comes to that most human of storytelling activities— telling jokes? At the University of Edinburgh, Graeme Ritchie’s Joking Computer tweets a joke a day – the robot walks into a bar joke is one of them. Here’s another one:

Question: What do you get when you cross a fall with a dictionary? Answer: A spill checker.

It’s early days for the computer, but it’s trying.

The problem is, not only is there no accepted computational theory of humour, there is no single accepted theory of humour at all, despite efforts over the centuries from everyone from Plato and Aristotle to Freud.

This being the case, how on earth are we to begin instructing computers in the art of humour?

Read more about humour:

Computers can beat world champions at complex games like chess and Go, identify patterns in huge sets of data, do massive calculations, even recognise faces in a crowd. But such feats take place inside a machine with limited access to the outside world, particularly in regard to knowledge and feelings. It’s a closed system.

Eventually they will be able to accrue knowledge by scanning the web and will actually take physical form; they’ll be “embodied” as robots, enabling them to interact with the world around them and have and store experiences of their own. They may even begin to create of their own accord.

But will they then start telling jokes? Humour is the last frontier. Getting a joke, cracking a joke— perhaps an off-colour one— employing sarcasm, timing, irony, all require social awareness and a rather wide knowledge base.

Humour is a highly creative activity. It might involve taking a startling new perspective on received wisdom, turning a situation upside down, undermining clichés and commonplaces. Every dimension of intelligence touches on it. Here are a couple of jokes for a start, thought up by humans:

The person who invented the door knocker got a No Bell Prize.

Veni, Vidi, Visa: I came, I saw, I did a little shopping.

Straightforward? Getting the first involves knowing what a Nobel Prize is and what a door knocker is, for a start, punning aside. The second requires a knowledge of rudimentary Latin, of Caesar’s immortal words, and of what a Visa card is.

This knowledge would either have to be programmed into a computer — akin to programming the entire world and all its knowledge into the machine— or it would have to have scanned the web well enough to grasp human language in all its intricacy, including metaphor, irony, and sarcasm; not quite up to the task as yet.

Cracking the problem of humour is akin to solving AI itself: a matter of evolving computers as intelligent as humans.

Researchers prefer to limit themselves to chipping away at well-defined joke scenarios. As Julia Taylor Rayz, a humour researcher at Purdue Polytechnic Institute in West Lafayette, Indiana, explains, there are two aspects of humour that researchers focus on: computers generating jokes and computers recognising jokes.

Read more silly science:

The first step is to feed the computer on a diet of jokes so that it learns to create jokes of its own. The next step is far more challenging. Can the machine ever learn to understand that it cracked a joke or know the proper moment to break into a conversation to make a witty remark?

This is akin to a computer understanding that a work of art or piece of music it has produced is good.

Recognising even the simplest structured jokes, like knock-knock jokes, beloved from childhood, requires some heavy lifting on both the linguistic and the computer fronts. The basic format is overlapping wordplay between two people, resolved with a punch line.

Says Rayz, there are two ways of teaching computers to make jokes. One is to feed in a database of jokes and rules for working on it. The other is to tell the computer a lot of jokes, letting it learn by example. This is the way that artificial neural networks function.

They are loosely inspired by how the brain is wired and can learn without being preprogrammed to do so. Rayze opts for the first method because it gives her more control over the joke-creating process, allowing her to explore how computers might be able to generate jokes and recognise them.

To teach her computer knock-knock jokes, Rayz assembled a large number of jokes, including some from the “111 Knock Knock Jokes” website (yes there is one), then grouped them together to make templates to demonstrate how the word play works, by sound association. In this way she constructed the knock-knock joke above.

Rayz is “interested in looking for patterns in humour.” She separates out different types of jokes and tests them to see how people react. “You need not have a huge amount of data” for this, she says. Much has already been published, which means she can now compare computer-generated jokes with real-life jokes and scrutinise them.

Listen to our interview with comedian Dara Ó Briain on theScience Focus Podcast:

A computer joke is not going to be perfect, she says. But you “don’t want to throw away that error when you test it on humans.” We “can learn from computers not understanding humour.”

Seeing patterns in data is a key to understanding them— in this case, understanding what makes a joke a joke. Some recent studies take Rayz’s second route which brings artificial artificial neural networks into play.

Janelle Shane, a researcher in optics, throws data on humour into a neural network to see what happens, just for the joy of it. Shane has used neural networks to come up with absurd recipes, ridiculous paint names, and hilarious pickup lines, all of which have garnered a large web following.

Unlike Rayz, who generates jokes with input rules that work on a database of jokes, Shane leaves the neural network to figure them out from the thousands of jokes she’s put in. At first the results made no sense. Then the machine began to produce more cogent, but still not very funny, results. Finally it produced a completely original joke:

Knock Knock.

Who’s There?

Alec.

Alec Who?

Alec Knock Knock Jokes.

Again not exactly a riot, but there’s certainly something quirky, if not surreal, there. You can almost sense the machine’s presence, complaining that it’s had enough.

Recently, computers have even tried their hands at stand-up comedy. Piotr Mirowski, whose day job is senior research scientist at DeepMind in London, and a small bug-eyed robot called A.L.Ex (for artificial language experiment) have performed improv together on the stand-up circuit in London, Paris, and other places.

To train the artificial neural network that runs A.L.Ex, Mirowski fed it subtitles from one hundred thousand films, from action movies like Deep Impact to the pornographic film Deep Throat.

When it hears someone speaking to it, it seeks out similar exchanges in its database and forms a reply. Mirowski developed this advanced version of his original system with Kory Mathewson, a Canadian AI researcher and fellow improv devotee.

In one routine, they are out on a drive together. Mirowski mimes holding a steering wheel and looks at A.L.Ex expectantly.

“I am not trying to be angry,” the robot says abruptly, destroying the mood. Mirowski is ready with a retort. “I don’t want you to be angry— this is our quality time.”

To which A.L.Ex replies, “I’m sure that you will find love”— a decisive brushoff if ever there was one.

It’s a success. The audience laughs. “I’m so tired,” the robot adds. Mirowski attempts to save the relationship, but A.L.Ex concludes rather insightfully, “You are not me. You’re my friend.”

The key issue is how to get A.L.Ex to stay on topic so that its responses are not merely random. Says Mirowski, the humour tends to be accidental. A.L.Ex’s deadpan remarks can be totally inappropriate, overly emotional, or just plain odd.

It’s like working with a “completely drunk comedian,” he says. The real challenge is for the human improviser, who has to be ready with a response no matter how bizarre the robot’s comments.

Today the field of computational humour is blossoming with (hopefully amusing) conferences dedicated to humour and sessions at AI meetings. Personal assistants such as Siri and Alexa are famously lacking in humour.

If we are going to communicate with machines in a pleasant manner, they will one day have to develop a sense of humour akin to the one we humans possess.

The Artist in the Machine: The World of AI-Powered Creativity by Arthur I Miller (£22.50, MIT Press) is out now.

Follow Science Focus onTwitter,Facebook, Instagramand Flipboard

© Getty Images