In Which a Neural Network Learns to Tell Knock-Knock Jokes
2 min read

In Which a Neural Network Learns to Tell Knock-Knock Jokes

In Which a Neural Network Learns to Tell Knock-Knock Jokes

The neural network can be trained to write recipes, invent Pokemon, and invent superhero names. But can it learn to tell a joke?

@researchbuzz generously provided me with a list of 200 knock-knock jokes - brief and highly formulaic, they seemed to be the form of joke best-suited for a neural network to reproduce. I figured it would quickly learn the formula, but would never, never manage to tell an actual joke.

It proved me wrong.

Very early on, the network figured out that question marks were important somehow, as were the words “Knock” and “who” in some mysterious way:

Koo k
ano?
?
Khnck
Knock oae?t
rA noc?
Knock
Woock
Whecr
lwhot
h o nwoe
hio

In very short order, it learned to begin a knock-knock joke, and almost never got that part wrong again. But the rest of the formula took quite a while to figure out, and the algorithm frequently devolved into playing a game of telephone with itself:

Knock Knock
Who’s There?
Iane
Aatar who?
Aaane who?
Aan who?
Anac who?
Iobe who?
Irata who?

Next it figured out the formula, but no actual, you know, words:

Knock Knock
Who’s There?
Bool
Hane who?
Scheres are then the there

Then it learned the joke about the cow with no lips which became its Favorite Thing Ever, even if it didn’t know how to properly tell it. The punchline to Every Single Joke was ooo ooooo ooo…

Knock Knock
Who’s There?
Alec
Anic who?
Wow co poo the tho tho door to the soout oo ooo oooo ooo oo oo oo oo ooo oo oo oo ooo ooo oooo ooo ooo oo oo ooo ooo ooo ooo ooo oo oo ooo ooo ooo ooo oo oo oo ooo ooo ooo ooo…

It made it past this stage, but still had problems that were remarkably similar to two people telling knock-knock jokes over a very bad phone connection, and maybe forgetting who was telling the actual joke:

Knock Knock
Who’s There?
Alther
Water who?
Water who who?
Who who?
Arton and out on the moor?

At last it figured out the basic formula and proceeded to make jokes that, while technically correct, didn’t make all that much sense. Many of them were partially plagiarized from jokes in the training dataset.

Knock Knock
Who’s There?
Hiwl
Howlowwhowhow

Knock Knock
Who’s There?
Ireland
Ireland who?
Ireland you money, butt.

And then.

It produced. An actual joke. I checked, and this one most definitely wasn’t in the dataset. There was one about Alec, but the pun was “Alec-tricity”. There was one about knock-knock jokes themselves, but it was “Irish I knew more knock-knock jokes”. And it didn’t produce this just once, but over and over again. I give you possibly the freakiest thing the neural network has done to date:

Knock Knock
Who’s There?
Alec
Alec who?
Alec- Knock Knock jokes.