Cards Against Humanity Card Generation (Slightly NSFW)

Source: Deep Learning on Medium


Go to the profile of Spencer Kelly

(WARNING: Cards Against Humanity is an adult themed game, and includes lots of rude language. Nothing graphic will be shown in this post, only words, but it could still get you some weird looks in the workplace)

What is Humor? Can an AI understand what makes something funny? Can writing a Medium post validate the time you spent training a computer to say dirty words?

I won’t be answering any of those questions today. But hopefully we can all have a bit of fun looking at “AI” generated CAH cards, and getting more insight into what makes this task especially hard.


Let me start out by saying that I’m not breaking any new ground here. Text generation has been done for a while, and by people much smarter than me. So I’m not going to try to explain in detail deep learning methods I used here. If you’re a deep learning nerd like me, I’ll just say the model structure is Embedding->LSTM->Dropout->Dense (length of char list).

There are some challenging parts of this task though, so i’ll give a short explanation of those below. Feel free to skip further down if you just want to see the cards I generated.

Data Problems and Why I Cheated

The first step to any deep learning project is finding the data. Thankfully, a group of crazy people had already put in the time to create a spreadsheet of every CAH card, including custom expansions created by third parties. This meant I could either train the model with just the ~2k official white cards, or an additional ~19k third party white cards. I’m using the white cards because there are more examples to train on, but I promise to give you a taste of what it looks like when the model tries to create black cards as well.

The problem with all this beautiful data, is that it’s extremely diverse. At it’s core, deep learning is training a program to recognize patterns, and in this case, replicate them. It’s easy to create a model that generates Shakespeare scripts because Shakespeare has a consistent voice, talking about relatively similar content. And while CAH does have a distinct voice, it doesn’t have consistent content. And the distinct voice is blurred when bringing in third party cards.

Think of it this way, you’re learning a new language and I give you two paragraphs to read. One of them is a short movie review, and the other is a list of unrelated short sentences that are meant to make people of that culture laugh when paired with other unseen sentences. If I ask you to translate both, which do you think will be easier? I’d put my money on the former because when you don’t know what a word means, you can rely on the context around it to help you.


Because of this challenge with diverse data, I had to cheat a bit. I’m not directly just taking the output of the Neural Network and adding it to the list of generated cards. There’s a bit of post processing done on the cards, and human selection to eliminate cards that are just clearly nonsense. I realise this is cheating, but just consider the system more of a “Card Ideas Generator”. I’ll make sure to show you some of the raw output as well though.

After the network produces potential cards, I run them through a text processor that checks them for similarities with cards in my dataset. Similar cards are inevitable, but I’m trying to eliminate cards that don’t significantly differ in meaning from cards in the database. A bit of necessary overfitting also means that occasionally the network will just produce an exact copy of a card it’s seen.

Then I run the cards through an automatic spelling corrector. This fixes minor spelling errors that the network made and is still completely automatic, so it’s fair game in my opinion. After this is done, I select the best cards and add them to my list of generated cards.

SHOW ME THE CARDS!

Below is a list 50 white cards I picked out:

  • a horny forever
  • a hardworking pile of colon stained shit
  • an unintentional science at feelings
  • big bathrooms
  • low branches
  • being too late
  • coat hair
  • white pudding
  • secretly tickled meat
  • a big fat dead hooker
  • a gay
  • trying to sex with a large poopy finger
  • unicorn sticks
  • not flaws
  • military decisions
  • forgetting the supremacy ideas.
  • bully bumpers
  • a pile of surprise sex tape.
  • that dried medical lube
  • borderline inappropriately hanging out.
  • your mom’s crush.
  • a man in a sippy cup
  • good box
  • horny white justice.
  • a burping ballerina
  • making bread red children.
  • trump-feeling websites.
  • clown cock.
  • going to the monkey bar
  • not weapons.
  • a 6-year-old babysitter.
  • my choke hole in my basement
  • a range of worn cards
  • sad penis.
  • dad’s funny bitch.
  • my post-travel condoms.
  • suffer school
  • holding mom
  • the sexual vagina that just wanted to communicate
  • a couple of boards with booze brains
  • the size of a bulge.
  • grandma training.
  • singing “o tannenbaanana.”
  • the 69%
  • just a love bag
  • m’finger bitch
  • sad standards
  • buying a virgin on top of the world
  • something fried
  • sorry.

The cards that make sense represent about a third of the results the network produced. Admittedly, some of the cards above don’t make sense, but some of the cards that make sense were boring, and part of the fun is creating some nonsensical cards.

Here’s an idea of what the raw (slightly formatted but unmodified) output of my network looks like:

penis.
a shit-to-fie
the contraction of a burrito.
the ring my slowl sorr that tells you with the chinese dogs. public motherwease.
female social suberious with forgetting to parol into a petrodomined body show.
an erection that lasts for hours.
aming down on a game of minivan
the poor
a female orgasm
subway shaving a single panties.
a keyback horse with a tremendous dingus.
an 80-year-old girlfriend
a burger silence
recaulation
zego for one
magic human remains for your secret school. inappropriate labor.
having sex with a dead baby fetus.
(rangta butt pullting people.
being kernels for domester of the mongrey.
a flamboyant man that fires a smiling prince.
a valladian memo baby.
idiots
a somen sort of this with the color off the side to. spending the nuit as every day
smelling sex lives of sexual charases.
getting tape on it.
a doctor with a sopping wet vagina.
a fairy food.
making up for your home.
incurable some sexy tantrum.
buffalo big destroying pop

If you play CAH you might recognize a few of these. “penis”, “idiots”, and “the poor” are all direct copies of cards. And “a female orgasm” is only a slight modification on the card “the female orgasm”. This is the network memorizing some cards, and just spitting them back out. That’s why I analyze the cards for their similarity to other cards in the database before accepting them.

Average number of words in a card was 4.94

You’ll also note that the list of white cards I posted above hardly has any longer cards in it. And the raw output should show you why. The network couldn’t learn to string together longer sentences that made sense. I blame this mainly on low number of long cards in the dataset.

Black Cards (prepare for some garbage)

  • every successful man is _________.
  • nobody people think i am a powerful wishing with ___.
  • the humpty dance is your chance of getting killed by a refugee terrorist.
  • the new morning, there was _______ and ______.
  • what do with the sound of ______.
  • wake up when my husband would say _______
  • I knew we would be right!
  • the next people invented ______.
  • our notorious face of my last position was ________.
  • _______ is a sure sign of my life.

I could keep going but it’s clear that even the cherry picked best examples of black cards make very little sense. They also tend to be more clearly derived from cards the network has tried to memorize.

Once again, here’s an example of the raw output of the network:

nothing is better the good of death? 
check out my new podcast about ______ and ______.
ted cruz caused a still want of ______.
the red room for eating ____ for a kirld and gentler ______. the probilew recommend a trip was completely ruined by ______. ___________. a wedding is a the face.
on cheeristed ______ for his/her dont combrate your signessant-class impressed the only acceptable to have ____ in public.
g go goage ______.
______ is a sure sign of my life.
snatch and ______.
what's the biggest source of tenish in the charge of ______. what do you were a parent when i never have to be a proctive in raid of ______.
momes, my imanager compaint for ______.
i wonder if ______ was all over the poil.
immers is now explore the honors using lose in the country black, ive had a horrible vision, father. i saw mountains crumbling, stars falling from _____.
there can a parent that did you have a moment to talk to my kids and do with ______.
i got have ______.

Conclusion time

Overall, I’d call this project a somewhat interesting/amusing failure. The white cards were often funny but kind of reminded me of one of those quizzes where you use the first letter of your last and first name to create your “hooker name” or whatever. It just shoved words together and hoped it was funny. And let’s not even talk about the black cards. Clearly more examples were needed there.

I’m guessing a closer to “state of the art” network could have done better (no shit), but I’m not sure it would have been THAT much better. I think it would have yielded results that made sense more consistently and copied less, but it’s jokes probably wouldn’t have been better. The problem is that in order to make good original cards, you have to be aware of the culture and things around you. And a network like this one only knows cards that are already created.

The only way I can see of solving this is by training a more advanced network on a broader database of text on many topics, then specializing it for the task of generating cards. But how to do that is currently beyond me.

If you have any ideas of how to do that, or simply better ways to make this task work, please let me know. I’d love to hear your feedback. I’d also love feedback on the post if you have it. I’m still just learning to write these articles and I could use some constructive criticism.

link to deck (whitecards only)