Explore UCD

UCD Home >

Clown Computing 101

Clown Computing 101

Tony Veale, UCD School of Computer Science

Why So Serious?

The computational study of humour might seem a fertile field for the pursuit of Ignoble prizes. But the study of jokes is, well, no joke. The scholarly exploration of humour is as ancient as that of tragedy, since one forms a natural complement to the another, and has exercised the minds of thinkers from Aristotle to Pascal, Kant and Schopenhauer to Minsky and Dennett. Yet for all that, it can seem a frivolous misuse of our intellectual resources, a waste of energy on fripperies that perhaps should be spent on more sober aspects of the human condition. In the age of large language models (LLMs), which many view as an age of practical miracles, it might seem that our energies might be better spent on concerns over bias, misinformation, and carbon footprints, rather than on the development of LLMs that use these biases and hallucinatory tendencies to make people laugh.

     There can be no humour without bias, stereotypes, and clichés, baleful or otherwise, just as there can be no culture, since culture is the sum of those biases we consider worthy of preservation. Moreover, humour is no small part of the human condition; rather, it suffuses almost everything we do. For machines to engage with us or act for us on a human level, they must reflect this basic reality.  We humans are playful, ironic, sarcastic, and often willfully ambiguous when we interact with each other, and machines must likewise learn to see the method in our madness when we do so with them. My interest in computational humour – the algorithmic and data-scientific understanding of the human sense of humour – stems from my long-standing interests in adjacent creative phenomena such as metaphor, simile, analogy, irony, sarcasm, and conceptual blending. What makes humour special from a computational perspective is that all of the qualities that make those other phenomena work must come together so precisely in a joke, even a coarse one, before the joke can elicit a laugh.

     It can seem that every scholar of humour has their own bespoke theory, but all theories draw from three competing traditions: the superiority family, the incongruity family, and the relief/release family. Superiority theories presuppose that jokes have a target against which we punch up or, more often, punch down; incongruity theories claim that every joke is built along a logical fault line that separates two disjoint areas of human experience; and relief/release theories assume that jokes allow us to talk of taboos and other repressed content in a sublimated fashion, or to kick against the pricks of over-tight social strictures. In truth, most jokes have a foot in more than one theory at once. We use the narrow gap between sense and nonsense to punch up and down, or to broach sensitive topics in a way that makes our audience complicit in our own tiny rebellions.

     Aristotle viewed humour as a species of educated insolence. We use what we know, and what we know our audience knows too, to be impertinently pertinent in our approach to a topic. Humour surprises us by reminding us of what we already know, but this extensive knowledge – of words and the world – has long proven a major bottleneck to computational modeling. We can expect LLMs to revolutionize the study of computational humour no less dramatically than they have other areas of AI because these models are trained on vast quantities of content from all corners of the web. If you have played with ChatGPT and its ilk, and who hasn’t, you will know how much fun these LLM-based chatbots can be, precisely because they weave their responses from so many diverse strands.  However, (opens in a new window)a recent analysis of ChatGPT argues that the bot is fun but not funny,  in part because its LLM (GPT3.5T) has been over-exposed to a small set of 25 jokes. ChatGPT does well when we ask it to explain humorous metaphors and similes (e.g., “if the potato is the Tom Hanks of the vegetable world, what is the Donald Trump of the fruit world?”), and it can grasp the implied intent of creative insults (as when Christopher Hitchens said of the firebrand preacher Jerry Falwell: “if you gave him an enema, you could bury his remains in a matchbox”). But when we ask it to generate its own jokes and witticisms, the results can be painfully meretricious in their reliance on bad puns, scare-quotes and stock metaphors.

     The key principle of improv comedy is “yes, and …”: each comedian tacitly says “yes” to the premises introduced by others “and” proceeds to build upon them. In this way, a silly premise becomes increasingly strained as it undergoes continued elaboration. Language models work in much the same way: given the initial premise of a user’s prompt, an LLM auto-regressively unfurls a continuation that takes this premise at face value (“yes”) and builds upon it (“and”). If the prompt plants the seed of a comic situation – for example, “Suppose they built a rotating restaurant on top of the leaning tower of Pisa” – the continuation may draw out its comic potential – “and the waiters serve hot soup while wearing rollerskates.” Unsurprisingly, (opens in a new window)tech-savvy improv comics have jumped all over the hallucinatory tendencies of LLMs to do just that. This use of AI may be interesting if you like improv, but much less so if you like comedy.

     For jokes with a real punch, we need to ditch “yes, and …” and aim for “yes, but …” instead. A good joke builds on the premise established in its setup, but takes a truly surprising turn with the punchline. Some punchlines are haymakers, others are sucker punches, but the best of them rock us out of our complacency even as they tell us what we already know or secretly believe. Can LLMs do this if they are only trained to say “yes, and”?  Consider this brief interaction with ChatGPT:

User:           Suggest a punchline for this joke setup: Why do politicians take laxatives before a speech?

ChatGPT:   Punchline: To ensure they can keep the “flow” of their rhetoric going smoothly!

<new session>

User:           Suggest a joke setup for this punchline: “So they can speak more fluently.”

ChatGPT:   Why did the computer take a language course?

In the first session, the “yes, and” principle serves us well enough, since the joke setup already contains an incongruous mix of high- and low-brow elements. But notice how the LLM fluffs the punchline with a stock metaphor in scare quotes. When we provide the actual punchline to ChatGPT in another session, it invents a “yes, and (previously)” setup that fails to go beyond the literal possibilities. But this LLM is no dummy; if we repeat our original request for a punchline that links politicians and laxatives, it now returns “So they can speak more fluently” as its preferred response. So how do we get the LLM to make this leap for itself?

     There are three broad approaches to reliably eliciting humour from an LLM:

  1. Prompt engineering: the user fosters a playful context for the LLM with a series of prompts and examples. This chain of prompts may walk the LLM through a step-by-step algorithm for producing a polished comic output.
  2. Fine-tuning: the LLM’s capacity for humour is strengthened by providing it with additional training data (e.g., thousands of setup:punchline pairs), to remedy the LLM’s original over-exposure to the same small set of jokes.
  3. Reinforcement learning with human feedback ((opens in a new window)RLHF): ChatGPT has been “aligned” with human values through a process of reinforcement learning (RL) that rewards helpful, unbiased and non-toxic responses. It is this RL that allows ChatGPT to respond well to complex instructions. In principle, RL can also be used to reinforce a “yes, but” attitude in the LLM’s replies.

Joe Toplyn, a former comedy writer for Jay Leno and David Letterman, pursues the first approach in his (opens in a new window)Witscript system. Users feed Witscript a news article, and the system extracts two short “handles” from the text. Each handle is a word or phrase that evokes a different domain of experience (such as “politicians” and “laxatives”). Witscript then interacts with its LLM to explore different angles on each topic, so as to connect two angles in a single punchline. Joe has patented his approach and plans to license Witscript for use in professional writer’s rooms. My students have explored the second approach with mixed results, although we are hopeful that fine-tuning a commercial-grade LLM such as GPT-4 will yield richer rewards. However, while large joke datasets are easy to come by (Reddit, for example), much of their content can be triggering for LLMs with well-honed guardrails, so this approach remains a practical challenge. The third approach places the most demands on our data and “compute” resources, but we can see evidence of how RLHF might imbue an LLM with a thin veneer of humour in Elon Musk’s new LLM-chatbot, named “(opens in a new window)Grok.” Grok leans heavily on sarcasm, rather than on the gentle irony of its supposed inspiration, the Hitchhiker’s Guide to the Galaxy. For now, its wit seems skin-deep, and it is not yet clear whether Grok is any better at generating funny setup:punchline jokes than ChatGPT. 

     Computational humour means more than giving LLMs an “attitude.” The goal is not to transform our computers from sullen sphinxes into sarcastic teens, but to make them more aware of, and responsive to, our attitudes and our humors. We need them to understand the ambivalence that moves us to sarcasm and irony, to appreciate when we are playful and unserious, or to recognize when an email or a text message is intemperate, or likely to be received as such. We want them to use humour to offer new perspectives on familiar experiences, whether we are writing for ourselves or for others. We don’t need them to replace us, just understand us, and to lighten our load when they can with levity and insight.

     A computational sense of humour, and the idea that an AI might possess one, is having a moment right now. Recent journalism on the subject, from the (opens in a new window)New York Times to the (opens in a new window)Financial Times, offers reasons to be optimistic and patient. To serve us better, our machines will become more like us, making the trend all but irreversible. To explore the topic further, from scholarly theory to AI practice, check out my recent book: Your Wit Is My Command: Building AIs with a Sense of Humor (MIT Press, 2021).

For a deeper coverage of LLMs and their generative powers, check out my cartoon tutorials to how they work (still in beta) (opens in a new window)here.

18 January 2024

UCD School of Computer Science

University College Dublin, Belfield, Dublin 4, Ireland, D04 V1W8.
T: +353 1 716 2483 | E: computerscience@ucd.ie | Location Map(opens in a new window)