Abstract
Marjan Ghazvininejad, Xing Shi, Jay Priyadarshi, Kevin Knight. Proceedings of ACL 2017, System Demonstrations.
2017.
Introduction
Automated poetry generation has historically struggled with three primary bottlenecks: the difficulty of objective evaluation, a lack of user agency, and high computational latency. Traditional NLP metrics like BLEU are often ineffective for poetry, which requires specific rhythm, meter, and emotional resonance. Furthermore, most systems operate as "black boxes," providing a prompt and receiving a static result without the ability to iterate or polish. Finally, the complex search procedures required to satisfy poetic constraints often make generation frustratingly slow for real-time use.
Hafez addresses these challenges by providing an interactive system that generates sonnets based on arbitrary user topics. By combining the creative fluency of Recurrent Neural Networks (RNNs) with the structural constraints of Finite State Acceptors (FSAs), the system enables a collaborative human-AI creative process that is 10x faster than previous iterations.
System Architecture
The Hafez system employs a hybrid architecture designed to balance creative semantic generation with rigid poetic structure. The generation pipeline consists of several distinct stages:
- Topic Association: Using
word2vec, the system identifies rhyme words related to the user's input topic. - Constraint Enforcement: A Finite State Acceptor (FSA) is constructed to define "legal" paths for the poem, ensuring adherence to specific meter and placing rhymes at the ends of lines.
- Neural Decoding: An RNN decoder generates the text, traversing the paths permitted by the FSA.
To achieve the interactivity required for a "live" system, the authors moved scoring and sorting operations to the GPU and optimized the vocabulary. These improvements resulted in a 10x speedup, reducing generation time for a four-line stanza from 20 seconds to under 2 seconds.
Interactive Style Polishing
A key innovation of Hafez is the "Polish" loop. Rather than aiming for a single perfect output, the system provides users with eight tunable stylistic features—such as alliteration, sentiment, word length, and "concreteness"—via a web interface. Users can adjust these sliders to re-generate the poem using the same rhyme pairs but with different stylistic "flavors."
This approach treats AI poetry as a sandbox for human-AI synergy. In user studies, 71% of participants were able to generate a poem they preferred over the initial default by utilizing these interactive controls.
Learning from Feedback
Hafez includes a logging system that records user ratings (1–5 stars) alongside the chosen style configurations. The system applies quadratic regression to this data to correlate stylistic weights with user satisfaction. This allows the system to autonomously learn and update its "default" settings based on the aggregate preferences of its user base. Experiments showed that these learned defaults were preferred by users in 59% of cases compared to the original, manually-tuned settings.
Conclusion
Hafez demonstrates that the most effective AI poetry systems may not be those that act autonomously, but those that serve as sophisticated tools for human expression. While challenges remain in maintaining long-range semantic coherence across full sonnets, the system represents a significant step forward in collaborative AI creativity, successfully deploying as both a web interface and an Amazon Alexa skill.
Summary updated