Our future robot overlords might be a pretty artistic bunch if recent research is any indication. Scientists have recruited AI to craft semi-coherent piano melodies and accompanying lyrics and to create snippets of pithy (not to mention human-like) prose. In a new paper (“Autonomous Haiku Generation”)  published on the preprint server Arxiv.org, Stanford University students Rui Aguiar and Kevin Liao tasked a machine learning system with generating the last two lines of a haiku poem when given the first line.

“Poetry is a creative endeavor that is highly difficult to both grasp and achieve with any level of competence,” wrote Aguiar and Liao. “Our task was to generate high-quality haikus using artificial intelligence and deep learning.”

As one might well imagine, imbuing an AI model with creativity — or at least what might pass for creativity — wasn’t an easy task. The pair initially set out to tackle tanka poems, or Japanese poems consisting of five lines (the first and third of which have five syllables and the other seven), but the form’s lengthier nature and a lack of proper corpora forced them to switch course. (In contrast to tanka poems, haikus contain seventeen syllables instead of 31 and three short lines that don’t rhyme.)

The team’s work on haiku generation began with sample set sourcing, which entailed scraping and parsing “several hundred” poems from the electronic text archive Bartleby. But they soon realized that they’d need a larger data set, so they tapped an 8,000-work-strong open source collection of haikus scraped from popular poem websites.

When it came to model design, the researchers opted to use a long short term memory (LSTM) network — an AI architecture capable of learning long-term dependencies — that captured the context of prior word predictions to make subsequent predictions. Specifically, they took in a sliding window of words from the haiku’s first line and used it to obtain a probability distribution of the next word. After adding mathematical noise to their probabilities, they selected words with the highest probability and chose an end-of-line word before starting the next line.

To test the AI system’s chops, the researchers recruited eight human evaluators to score its poems alongside baseline poems in a single-blind trial. The results suggest that while the AI’s haikus probably won’t be in line for the next IAFOR Vladimir Devidé award, the model achieved greater coherency than might be expected:

Haiku AI

Above: Sample haikus generated by the AI system.

If nothing else, it lends credence to the notion that AI could someday supercharge the artistic process. Researchers at Adobe recently proposed an algorithm capable of reproducing handpainted canvases in the style of Leonardo da Vinci, Vincent van Gogh, and Johannes Vermeer. Other researchers are experimenting with systems that hallucinate foundational sketches of cats, fire trucks, mosquitos, and yoga poses. Companies like Promethean AI are employing machine learning to help human artists create art for video games. And some of the best machine-guided artwork came out of last year’s international RobotArt competition, which tasked contestants with designing artistically inclined AI and robotics systems.

“In summary, we found that for the most part, a [recurrent neural network] is the most effective approach for text generation,” wrote the researchers. “While we had some slight variation in the quality of poems produced, we were able to generate coherent and meaningful poems at a much higher and more consistent level using the RNN than … other [approaches].”