CMU Students Train AI To Write Book of Limericks

Byron SpiceTuesday, February 2, 2021

Last semester, CMU students used AI to generate limericks that they collected in the volume "For You, Humans."

CMU students all get their kicks
By building apps that attract mass clicks
So they teamed up in class
Built an AI with sass
That wrote them a book full of lim'ricks.

Pardon the doggerel, but what else would be appropriate when Carnegie Mellon University students create an artificial intelligence for writing poetry?

Their digital Shakespeare was a project last semester in the School of Computer Science's Introduction to Deep Learning course. The instructor, Rita Singh, associate research professor in the Language Technologies Institute, said she suggested the project as a way for students to explore how AI might capture elements of artistic expression that are hard to quantify.

"What makes a few lines of English written by Tennyson 'poetry' and a 'masterpiece' while the same number of lines written by someone else following the same pattern/rule/rhyme turn out to be perfectly mundane and mediocre?" she said.

Mitch Fogelson, a Ph.D. student in mechanical engineering, said he and his fellow students ā€” Xinkai Chen, Qifei Dong, Christopher Dare and Tony Qin ā€” opted to focus their AI on limericks because the form has a fixed AABBA rhyming structure. They also had access to a database of 90,000 limericks that they could use to train their AI.

The team used an open-source language model called GPT-2, which was developed by OpenAI and had previously been used to produce poetry.

"It generated a virtually endless stream of poetry, thousands of poems," Fogelson recalled. "The quality overall wasn't amazing." In fact, the early efforts included some really weird stuff ā€” sort of limerick conversations. The AI also didn't always produce neat, five-line limericks. Some were just single lines.

The bulk of the project for the students was developing a computational method for wading through this sea of poetry and plucking out the relative few samples worth reading, Fogelson said. They created an algorithm that included constraints for rhyme and rhythm and, by monitoring whether words occurred in the vicinity of related words, looked for poems that made some sense.

Among those selected by the algorithm:

As a kid, I would know without thinking
That the limericks were just about drinking
But Iā€™d guess it's a sin
To be somewhat akin
To the innocent beverage, I'm thinking...


When an orchestra plays a soft part
The accord of each music is smart
But the music is slow
And they never can know
All the music is only a start

The students then manually selected the 100 to 200 limericks that merited publication. The result is the first AI-generated book of limericks, "For You, Humans," now available for sale on Amazon.

Fogelson said it was a useful exercise, demonstrating how data-driven models might support creative efforts in the future.

"The AI does not, to our knowledge, impart meaning whilst generating poems, but the neurons in our brains were nevertheless able to draw connections between the words," he added.

Singh said the book is just a beginning.

"The project will continue this semester with other student teams, and go on until what the AI produces rivals human creativity in poetry," she said. "We want to see how far we can go."

For now, she said, even the AI seems to know that more work is needed:

I'm not guilty, am I? On reflection?
That my knowledge, of meter negition
Is that writing is shoddy
I'll build on a noddy...
My brain barely works in perfection.

For More Information

Byron Spice | 412-268-9068 |