Teaching AI how to be sarcastic is totally the easiest thing ever

Robots are becoming more lifelike, but something is still a bit off-kilter with their humor.
Robots are becoming more lifelike, but something is still a bit off-kilter with their humor.
Image: Reuters/Bobby Yip
We may earn a commission from links on this page.

Pop culture has primed us to think that our robot friends of the future will be quick-witted quipsters. Television and films have their fair share of sardonic androids, from the foul-mouthed alcoholic Bender in Futurama to the acerbic J.A.R.V.I.S. from Ironman. But the reality of such amusing sidekicks remains far off.

Cognitively speaking, sarcasm is one of the most complex forms of human expression—and it’s therefore one of the hardest to teach AI systems. While voice recognition, machine translation, and other such tools are constantly improving, AI still lacks the ability to detect this uniquely human linguistic trait in either verbal or written conversation.

In order to both create and comprehend sarcasm, you need immense brainpower to understand the contradiction between a statement’s literal and intended meaning. It also often entails incredibly intricate thought processes and the introduction of novelty and humor. Converse to Oscar Wilde’s proclamation that sarcasm is “the lowest form of wit,” researchers from the Harvard Business School have said it is “the highest form of intelligence,” linking it with increased creativity. The most effective sarcasm is also often the most obscure: If it doesn’t make the listener puzzle at least briefly, it’s often not worth the bother.

So why is detecting and interpreting sarcasm such a hard task for AI?

Firstly, because it’s often difficult even for humans to comprehend. The BBC World Service’s “Learn English” pages even have a section dedicated to how to be sarcastic, complete with a quiz to check your skills (have a go!). But not everyone can simply teach themselves to pick up on irony. For example, many people with autism cannot understand sarcasm because they’re used to thinking in more literal terms. Others with various brain-related conditions such as frontotemporal dementia also struggle to comprehend it.

Neurotypical people often struggle too: A study by researchers from Rutgers University found that people were generally very bad at judging the sarcasm of strangers’ tweets. We typically use facial expressions and tone to demonstrate sarcasm when speaking, but we rely on hashtags and emoticons to communicate it on social media. When these indicators aren’t present or are used ambiguously, the tweets can become misleading. For example, a machine may not be able to tell whether a smiley face is being used to indicate happiness, humor, or a sarcastic comment.

Secondly, there’s the matter of conversational and situational context. For example, if a friend posts a positive-sounding statement about Donald Trump, but their previous tweets about him are all negative, we might suspect this comment to be sarcastic. Machines need to be aware of this context in order to detect it. Humans also tend to know which of their friends are likely to make sarcastic comments and what their typical views are. This kind of situational knowledge is much harder for a machine to access, though some success has been achieved in using information derived from Twitter profiles and their related audiences as input to aid machine-learning algorithms.

Thirdly, world knowledge is often needed to understand sarcastic comments. For example, people don’t typically enjoy eating cabbage soup but like eating chocolate cake. So if someone were to post about how delicious their cabbage soup diet is, or how terrible it was that there was free cake at work, there’s a good chance they’re being sarcastic. But how does a machine know that chocolate cake is tastier than cabbage soup?

Linguists use a myriad of analysis tools to understand what people are saying on Twitter and other social media platforms. In order for machines to understand what opinions are being expressed, detecting sarcasm is critical. Even the US Secret Service wants a piece of the pie, putting out a request in 2014 to buy a tool that could detect sarcasm in social media.

The most common technique for analyzing tweets is to use “machine learning,” a method by which endless streams of real human data are fed into computational systems that order and analyze their contents. They do this by giving the system a large number of sarcastic sentences (e.g., tweets with the #sarcasm hashtag) and non-sarcastic sentences (tweets without the hashtag) as training material.  Researchers at the Hebrew University in Jerusalem used machine-learning techniques based on hand-annotated training data to identify comments in Amazon reviews with a 77% success rate, including detecting comments such as “Great for insomniacs” as sarcastic. But asking humans to manually annotate hundreds of thousands of inputs is expensive and time consuming. Furthermore, machine-learning techniques only work if new sentences are somehow similar to the ones the machine has been presented in the past. And people are often very inventive with sarcasm.

The alternative method is to write rules to guide the machines in much the same way that an autistic person might have to “learn” how to be sarcastic. These rules make use of typical sarcastic expressions and indicators, unexpected juxtaposition of positive and negative words, highly exaggerated emotions, and so on. Such rules, however, are hard to write, and also require that the system have access to a large amount of world knowledge (such as knowing that people typically like chocolate cake).

Finally, we also need to teach the machine what to do with sarcasm once it has found it. We use sarcasm in different ways to achieve different outcomes, so tools that automatically detect sarcasm need to understand its intended effect. This can range from simple switching of polarity (“The best feeling in the world is definitely being ignored. I love it #keepdoingit #bestthingever”) to more complex forms (“To get it to work, you just have to shut one eye, twist your head, stand on one leg, wear a yellow hat and sing the National Anthem simultaneously.”).

Recent deep-learning techniques—a method of creating parameters from which the machine can teach itself—can detect the presence of sarcasm with 87% accuracy, but along with other machine-learning techniques, they still struggle to deal with the nuances of sarcasm attribution and scope. Rule-based techniques have had some success with both tasks, but there’s still an upper limit to how far these can go.

So where does this all leave us? Will we ever teach machines to understand sarcasm properly? And can we teach them when it’s appropriate to be sarcastic in conversation? While AI has made huge strides in equalling or even beating human intelligence in some ways, before they can truly understand human conversation, they’ll need to learn sarcasm.

C’mon—it’s not that hard.