Projects

Automatic Joke Generation

My master's thesis about "Automatic joke generation: learning humor from examples"

View Automatic Joke Generation Code Cite

Automatic Joke Generation cover

GOOFER, GAG and JokeJudger are three systems I created for my master’s thesis about learning to automatically generate jokes from examples.

GOOFER: Generator Of One-liners From Examples with Ratings

GOOFER is a framework that models a general pipeline for learning to generate jokes from example jokes. It is an extension of the generate-and-test principle by generalizing the typical template-and-schema approach used in other computational humor generators. With classic machine learning methods, it learns to recognize good patterns in jokes within particular templates and then produces similar jokes using this learned pattern.

1Training: learn from rated jokes

Jokes with their ratings

  • I like my relations like I like my source: open. 5★4★5★
  • I like my coffee like I like my war: cold. 4★4★3★
  • I like my girlfriend like I like my estate: real. 2★1★3★

Template extractor: the template and its values

I like my X like I like my Y: Z.

XYZStars
relationssourceopen 5 4 5
coffeewarcold 4 4 3
girlfriendestatereal 2 1 3

Metric-based rater: measures every set of values

  • How common each word is
  • How often they occur together
  • How many meanings Z has
  • How related they are
  • Whether they sound alike
  • …

Classifier: learns which values make a good joke

A model that rates new X, Y, Z

2Generating: jokes about a word

Seed wordmen

Values generator: an adjective used with the seed for Z, then a noun used after Z for Y

XYZ
mengravesnameless
mencountrycold
menturkeyroast
menraingentle
menlaughsilly

The model keeps the values on the sun and drops the rest.

Apply the template

  • I like my men like I like my graves: nameless.
  • I like my men like I like my rain: gentle.

GOOFER worked through on analogy jokes, the template GAG uses below (from my talk at ICCC 2019). It learns from people’s ratings which words make a good joke in a template, then generates sets of words for a new seed word and keeps only the ones its classifier rates as good.

JokeJudger: Platform for collecting jokes and ratings

Since there was no large enough dataset of jokes rated for humor, I created a platform to collect jokes and ratings and called it JokeJudger. Because GOOFER works with templates, we collected rated jokes for one template only: analogy jokes. These jokes all fit the template “I like my X like I like my Y: Z”. On the site, users were prompted with jokes and asked to rate them using 1 to 5 stars. They could also submit their own jokes and view the ratings they received.

Later in the research, generated jokes were uploaded alongside human-created jokes so they could be rated without users realizing they weren’t created by hand. The collected jokes and ratings are on GitHub. In total, 203 users gave 9,034 ratings, to 424 jokes written by people and 100 generated ones.

The main screen: rating jokes.
The main screen: rating jokes.
The create joke menu. A user could press "Challenge me" to already fill in some blanks.
The create joke menu. A user could press "Challenge me" to already fill in some blanks.
Users could also allow suggestions to be given when creating jokes. The platform would use Datamuse to find suitable words for that position.
Users could also allow suggestions to be given when creating jokes. The platform would use Datamuse to find suitable words for that position.
Users could see how their jokes did, from the distribution of the ratings they received.
Users could see how their jokes did, from the distribution of the ratings they received.
Users could see all new ratings of their jokes on the notification screen.
Users could see all new ratings of their jokes on the notification screen.
Users had a profile showing their rank (how many jokes they rated and created), where they could also filter out jokes labeled as offensive.
Users had a profile showing their rank (how many jokes they rated and created), where they could also filter out jokes labeled as offensive.
The best rated jokes of the week, month and all time were presented in the Hall of Fame.
The best rated jokes of the week, month and all time were presented in the Hall of Fame.

GAG: Generalized Analogy Generator

GAG (Generalized Analogy Generator) is an analogy joke generator. It uses the GOOFER framework without its template extraction, as it only handles one template.

The system uses the analogy jokes collected on JokeJudger to learn to distinguish the relations between words in a good analogy joke from a bad analogy joke. Afterwards, it generates millions of jokes and tries to identify the jokes that its test algorithm considers good.

In our evaluation (on JokeJudger), we showed that it was able to generate funny jokes half as frequently as humans did.

Share of the ratings, per kind of joke
4 or 5 stars
GAG, classifier 11.4%
GAG, regression 10.1%
People, on JokeJudger 22.6%
People, one word per slot 21.1%
1 star
GAG, classifier 35.7%
GAG, regression 40.4%
People, on JokeJudger 23.4%
People, one word per slot 26.0%

How the jokes were rated on JokeJudger during the evaluation (from my talk at DAPI 2018). GAG’s jokes got 4 or 5 stars half as often as jokes people wrote with the same constraint, one word per slot, and GAG did better with a classifier than with regression.

Generated jokes

Here is a selection of jokes generated by the algorithm:

  • I like my coffee like I like my myself: hot.
  • I like my coffee like I like my sleep: strong.
  • I like my men like I like my graves: nameless.
  • I like my coffee like I like my country: cold.
  • I like my men like I like my society: heartless.
  • I like my women like I like my buildings: tall.
  • I like my women like I like my tests: independent.
  • I like my women like I like my questions: silly.
  • I like my men like I like my rain: gentle.
  • I like my women like I like my laughter: silly.
  • I like my computer like I like my affection: personal.
  • I like my computer like I like my argument: personal.

View Automatic Joke Generation

Talks about Automatic Joke Generation

In the press

Papers

Citation

 

What people say about Automatic Joke Generation

How to cite

Automatic Joke Generation: Learning Humor from Examples

@inproceedings{winters2018gag,
    issn = {0302-9743},
    abstract = {Computational humor systems often employ explicit rules encoding assumptions about what constitutes a funny joke. This paper explores how a program can teach itself to generate jokes based on a corpus of rated example jokes. We implement a system called Generalized Analogy Generator (GAG) capable of generating jokes using the "I like my X like I like my Y, Z" template. We use established humor theory and extend computational humor concepts to allow the system to learn the structures of the given jokes and estimate how funny people might find specific instantiations of joke structures. We also implement a platform for the collection of jokes and their ratings, which are used for the training data and evaluation of the system. Since GAG uses generalized components and learns its own schemas, this program successfully generalizes the most well-known analogy generator in the computational humor field.},
    journal = {Distributed, Ambient and Pervasive Interactions: Technologies and Contexts},
    booktitle = {Distributed, Ambient and Pervasive Interactions: Technologies and Contexts},
    pages = {360--377},
    volume = {10922 LNCS},
    publisher = {Springer International Publishing},
    isbn = {9783319911304},
    year = {2018},
    title = {Automatic Joke Generation: Learning Humor from Examples},
    language = {eng},
    author = {Winters, Thomas and Nys, Vincent and De Schreye, Danny},
    keywords = {Computational humor},
    organization = {Streitz, Norbert}
}

All projects