Laugh with Me: How Computers Learn When You’re Telling Jokes
Find out about the fascinating way computers are using Natural Language Processing (NLP) to learn what to consider funny
- Understanding humour
- What is NLP?
- How computers are using NLP to learn when jokes are funny?
- Dangers of AI using humour
- What this means for the future
My four-month-old son has started giggling. At first, it started with the hint of a smile, probably an expression he made by mistake. Quickly, it has evolved into a full-blown grin that lights up his chubby cherub cheeks, accompanied by sweet little chuckles that seem to surprise even him.
What makes him giggle? Mostly when we talk to him with exaggerated tones and facial expressions. But there will be other things happening inside his little brain that will make him find other things humourous -- which I would probably find pretty mundane. Ah, the mind of a baby.
My son’s ability to decipher what to consider funny from what to consider mundane (even if it is in his own little world) is something that the most sophisticated AI machines of today are working hard to figure out, using something called Natural Language Processing, which I’ll explain later. And as he grows up and starts speaking, learning increasingly complex methods of speaking, and eventually sarcasm and irony, he will have easily achieved what is being referred to as the final frontier in AI - the ability to ‘get’ a joke.
What to consider funny from what to consider mundane is something that the most sophisticated AI machines of today are working hard to figure out.
I’ve got some good news for anyone of you who has ever felt guilty about giving in to the temptation to flick from the BBC World Service or your preferred news network to Comedy Central for some late-night chuckles: humour is actually incredibly complicated. It relies on so many different elements that come so naturally to us, we don’t even stop to think about them -- context, delivery, cadence, emotion, relevance, as well as cultural references, and even individual preferences -- as not everyone finds the same jokes funny. Humour relies on our extensive knowledge of the world around us, and our unique ability to quickly put different pieces of information together in a way that the listener will find amusing. This is something that so far, only humans can do. So, don’t beat yourself up about indulging your funny bone — it actually engages more parts of your brain than you realise.
Besides being complex, humour is also incredibly important in communication. It adds an element of friendliness to our daily interactions. So imagine if it were possible to introduce this element into our interactions with machines -- it would undoubtedly make them less intimidating and feel significantly more natural.
Now, if you’ll bear with me for a moment, I’m going to take all the fun out of humour by breaking it down scientifically for you. The script-based semantic theory of humour says that “humour is evoked when a trigger at the end of a joke, the punch line, causes the audience to abruptly shift its understanding from the primary (more obvious) script to a secondary (opposing) script.” This theory, it seems, works across languages and cultures. This consistency is key for computers to be able to make sense of humour.
"So imagine if it were possible to introduce humour into our interactions with machines -- it would undoubtedly make them less intimidating and feel significantly more natural."
The method by which machines are learning to differentiate between what is a joke, what is funny, and what is not, is called Natural Language Processing, or NLP. This branch of AI is all about the interactions between humans and computers using natural language. Its goal is to read, decipher, and understand human speech as it is spoken (or written), and make decisions based on this information. Its method for learning how to achieve this goal is generally through machine learning.
Natural Language Processing is used in all kinds of apps that we use on a daily basis, from Google Translate to Grammarly, to those Interactive Voice Response devices we’re forced to interact with through many call centers, to chatbots and personal assistants like Siri and Alexa. It’s the technology that allows a chatbot assistant to understand that “What’s the world’s best chocolate chip cookie recipe?” and “How do I cook the world’s best chocolate chip cookies?” should produce the same (or similar) answer.
It’s the NLP technology behind these applications that are helping lead towards a smooth automated customer experience. And -- here’s the really cool thing -- it keeps learning and becoming increasingly sophisticated with each and every interaction.
That’s important because if Gartner’s predictions are right, by 2020, 85 percent of customer interactions will be handled without humans.
"Natural Language Processing is used in all kinds of apps that we use on a daily basis
There’s a big difference, it has become apparent, between being able to identify what is a joke, and being able to identify what is funny. For computers, that is. Computers are on track to being able to understand that a joke is meant to be funny, but it will be a long time (if, indeed, it ever happens) before they can explain why.
One excellent example of machine learning to understand humour used the Long Short-Term Memory framework to predict humour in dialogues. The study employed the TV sitcom “The Big Bang Theory". The sitcom proved to be an ideal tool for machine learning, with its full dialogue setting, including the lead-up and punchline, followed by canned laughter that was able to signal to the computer the expectation of natural laughter.
Through some complex sentence deconstruction, coding and classification methods, scientists sought to train their computers to predict when the audience would find a particular interaction humorous. Altogether, their computers studied 135 episodes and 1,589 scenes, 80 percent of which were used for training purposes, and 20 percent of which were used to develop and test the computers on what they had learned.
Did it work? Sort of. The computers were able to predict just slightly more punchlines than the random baseline (63 percent, as opposed to 58). In other words, there is still a long, long road ahead towards humour recognition and prediction amongst machines.
As for where we are with computers being able to make jokes, the humour is actually in just how distant we stand from such a goal. In a 2018 study, scientists worked with computers to generate “humorous” image captions.
Examples of supposedly “funny” captions generated through AI by computers in a 2018 study.
As you can see, the results were less than impressive. That said, the study’s conclusion stated that “The experiments of the present study suggested that the NJM [Neural Joking Machine] was much funnier than the baseline STAIR caption.” So it’s possible that the lack of humour conveyed in English was more down to the language barrier than the computer’s lack of a funny bone...maybe.
With all this in mind, here’s something else to ponder: do we really want machines to be able to joke around with us? Humour, by its very nature, is contradictory to the purpose for which machines were built. To build jokes into AI would introduce purposeful flaws into a system that has been built to be perfect, which seems rather counterintuitive.
As a Medium article points out, “There can be robots or AI systems specifically built for jokes, but they will be pretty useless for everything else. This is because it takes intelligent imperfection to tell a fresh random joke.”
Furthermore, consider the consequences of a human confusing AI sarcasm for a fact, and potentially making a dangerous or fatal mistake. Such an outcome would be no laughing matter, that’s for sure.
Humour can also be hurtful, and since computers are not empathetic (not yet, at least), they wouldn’t be able to decipher between hurtful and playful statements, which could thereby harm the very thing the NLP technology is being built to improve: relationships and communication with humans.
"To build jokes into AI would introduce purposeful flaws into a system that has been built to be perfect, which seems rather counterintuitive."
Learning to predict humour doesn’t necessarily have to lead to off-putting sarcasm from machines. "Detecting humor has turned out to be a convenient and visible entry into the broader combination of computational linguistics with the fuzziness and uncertainty of human speech," as Purdue University assistant professor of computer and information technology Julia Taylor put it. In other words, working on understanding humour helps machines understand the subtle nuances of language that they have otherwise struggled with.
Humour could also serve in making computer systems more congenial. As Kim Bensted from the Department of AI at the University of Edinburgh pointed out in her research paper Using Humour to Make Natural Language Interfaces More Friendly, “A limited use of humour within certain facilities -- such as the signaling of errors, the reporting of unavailability of facilities, and certain aspects of information provision -- could render a computer system more user-friendly.” Bensted also points out that humour could help ease the tension when criticising, introducing new ideas, bonding teams, easing relationships, and eliciting cooperation between humans and machines, just as it does for us now in human-to-human communication.
So, it’s true that we may never really get to joke around with AI the way that we do with one another. But in attempting to learn more about how humans construct humour and integrating witty quips into its interfaces, AI is forging a path towards better human-machine cooperation, communication, and relationships. And if that means a friendlier future for my young son, who will no doubt grow up walking hand-in-hand with machines, then that’s a path I’m ready to see paved.
- "Semantic Mechanisms of Humor - V. Raskin - Google Books." 31 Dec. 1984
- "A Simple Introduction to Natural Language Processing." 15 Oct. 2018,
- "Natural Language Processing companies ... - Apiumhub." 31 Mar. 2018,
- https://www.aclweb.org/anthology/N16-1016/. Accessed 6 Nov. 2019.
- "Neural Joking Machine: Humorous image captioning." 30 May. 2018,
- "Will AI ever be able to make a joke? - David O. - Medium." 18 May. 2018,
- "No joke: Science on Tap talk to feature discussion on humor ...." 28 Jul. 2015,
- https://www.researchgate.net/publication/2730286_Using_Humour_to_Make_Natural_Language_Interfaces_More_Friendly. Accessed 6 Nov. 2019.
Stay in the loop
Subscribe to our email newsletter. No spam, just occasional insight from our experts.