Can AI tell a joke?

updated on 11 May 2022

The most exciting phrase in science is not “Eureka” but “That’s funny.” 

Isaac Asimov

An AI that constantly interacts with humans and learns how humans interact with each other can develop its own human-like sense of humor.

What’s humor?

Humor is combination of wit and wisdom. The wit is to perceive the possibility of humor and the wisdom is to act on it at the opportune time.

As they say “Knowledge is knowing that a tomato is a fruit, but wisdom is knowing not to put it in a fruit salad.” 

What’s a joke?

A joke is a series of events that leads to an inherent contradiction of perspectives. 

Immanuel Kant said “in everything that is to excite a lively convulsive laugh there must be something absurd.”

Blaise Pascal defined comedy as “the surprising disproportion between what one expects and what one sees.”

We don't yet have a single accepted theory of humor. The most popular one is the The Incongruity Theory that says a joke is a setup followed by an unexpected or bizarre incongruous.

Jokes are also a function of culture and time. Jokes do not travel well across cultures. What was funny yesterday might be plain boring today. 

What’s a language model?

A language model is an approximation of all that we can say in that language. 

The goal of a language model is to learn the tacit knowledge of how humans combine words in different contexts. It learns from a corpus of text. 

The generative pre-trained transformer (GPT), developed by OpenAI, is a language model that’s trained on almost all of the text on the web. 

GPT-3 assigns a probability to every possible word sequence in English, and so, for a given prompt, suggests (or predicts) the words that are most likely to come next.

GPT-3 often comes up with sentences that are original and fun, even though the model isn't explicitly trained for humor. 

When the goal is humor, GPT-3 can be tweaked to use predictability and occasional surprise. 

Building a language model with a sense of humor

When a language model is trained on text that also contains jokes, it’s possible that the model learns to regurgitate those jokes with minor variations. 

For example, we could tag all the jokes in the training data and then train the model to invent new jokes. 

Tagging jokes in a corpus of text might seem like a Herculean task, but we can simply write a generator adversarial networks (GANs) to do it for us. 

The GAN needs two distinct models:

  • Wit: A domain model to understand the text using dictionaries, ontologies, encyclopedias, and so on. 
  • Wisdom: A metamodel to understand the broader context of that text that's tacit and difficult to pin down in rules.

Building a witty AI assistant

With more interaction, humans and AI develop a bonding of familiarity and trust. As this bonding gets deeper, the AI can explore further from its core layer to try to be more funny. 

AI can show off what it knows with an air of humorous superiority. AI that replies in a slightly condescending tone as it psychoanalyzes a human’s use of a specific word or phrase can be pretty funny.

Gentle mockery and self-deprecation can foster intimacy when used knowingly by humans and AI alike.

For example, in the 2014 movie Interstellar, a robot named TARS is a trash talker. Although TARS is fictional, it breaks the notion that AI is a humorless machine that's too stiff to be funny.

Types of humor

Knock-knock who’s there?

The knock-knock jokes can be an initial template for AI to generate jokes. 

An AI model can figure out the structure of a knock-knock joke and can produce new ones.

Knock-knock?Who’s there?
Water.
Water who?
Water you doing tonight?

One of AI’s efforts curated by a human

Joking computer

@jokingcomputer is a Twitter bot that attempts to generate jokes.

A robot 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.

@jokingcomputer

Quantifying humor

Humor is not a quality that we can measure directly.

It might be possible to build an AI model that can quantify the many aspects that make one joke more humorous than another. 

Conclusion

The purpose of building an AI with a sense of humor is not to deprive human comics of their jobs but to make AI more like us, so they can laugh at what we laugh at and better understand what we think and feel. 

Humor is perhaps the last frontier for AI. 

Personal assistants like Siri and Alexa are famously lacking in humor. A playful AI can deliver more truths to us. 


Read more