---
title: "Hafez: an Interactive Poetry Generation System (2017)"
description: "The pipeline builds on the authors' earlier work. 2 references, cited by 68 papers here. Among them: 128."
authors: ["Marjan Ghazvininejad", "Xing Shi", "Jay Priyadarshi", "Kevin Knight"]
year: 2017
venue: "Proceedings of ACL 2017, System Demonstrations"
source: "https://aclanthology.org/P17-4008/"
licence: "CC BY 4.0 (ACL Anthology)"
licence_url: "https://creativecommons.org/licenses/by/4.0/"
summary_licence: "Elamur Cosmic License"
canonical: "https://research.elamur.ai/free/en/papers/ghazvininejad-2017-hafez-interactive-poetry-generation-system/"
---
[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/ghazvininejad-2017-hafez-interactive-poetry-generation-system/)

[home](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2017](https://md.research.elamur.ai/free/en/papers/2017/page/2/) / Hafez: an Interactive Poetry Generation System

# Hafez: an Interactive Poetry Generation System

**Authors:** [Marjan Ghazvininejad](https://md.research.elamur.ai/free/en/authors/marjan-ghazvininejad/), [Xing Shi](https://md.research.elamur.ai/free/en/authors/xing-shi/), Jay Priyadarshi and [Kevin Knight](https://md.research.elamur.ai/free/en/authors/kevin-knight/) · **Year:** 2017 · **Venue:** [Proceedings of ACL 2017, System Demonstrations](https://md.research.elamur.ai/free/en/venues/acl/) ([ACL 2017](https://md.research.elamur.ai/free/en/venues/acl/2017/)) · **Publisher:** [Association for Computational Linguistics](https://md.research.elamur.ai/free/en/publishers/association-for-computational-linguistics/) · **Licence:** [CC BY 4.0 (ACL Anthology)](https://creativecommons.org/licenses/by/4.0/)

**Links:** [Publisher's page](https://aclanthology.org/P17-4008/) · [PDF](https://aclanthology.org/P17-4008.pdf) · [OpenAlex](https://openalex.org/W2741986794)

**Citations:** 128 citations (OpenAlex, 2026-10-14) · [68](https://md.research.elamur.ai/free/en/papers/ghazvininejad-2017-hafez-interactive-poetry-generation-system/cited-by/) in our library, of the 141,840 papers whose bibliographies we read

## Summary
Hafez is a demo system that writes English sonnet-style poems on any topic a user supplies. It targets three weaknesses of earlier poetry generators: poem quality is hard to evaluate, users cannot steer a draft beyond changing the random seed, and generation is slow. The pipeline builds on the authors' earlier work. A word2vec model and a rhyme-type dictionary choose topic-related rhyme pairs. A Finite State Acceptor (FSA) then enforces meter and line-final rhymes, and an RNN decoder fills in the lines under the FSA's guidance. The new version adds eight weighted feature functions to the beam-search score, which are exposed as sliders for style control. A web interface lets users rate poems from 1 to 5 stars, and these logs are used to learn a better default style configuration. GPU porting and vocabulary pruning cut generation time from about 20 seconds to 2. In Mechanical Turk experiments, most users found an adjusted poem they preferred to the default one. This shows that interactive control plus crowd feedback can improve creative generation.

## Key points
- **Style features.** Eight features are added to the beam score:
  - encouraged or banned words, with fixed weights of +5 and −5;
  - curse words;
  - repetition;
  - alliteration;
  - word length;
  - topical words;
  - sentiment, based on SentiWordNet;
  - concreteness, based on Brysbaert et al. (2014) norms.

  The seven tunable weights form the "style configuration."
- **Speed.** A four-line poem takes about 2 seconds, versus roughly 20 seconds for the earlier CPU system. The gains come from:
  - preloading the 1.8M-entry word2vec vocabulary, which saves 3–4 seconds;
  - precomputing rhyme types;
  - restricting candidate rhyme words to the RNN vocabulary;
  - running scoring and top-k selection on the GPU.
- **Mechanical Turk study (62 HITs).**
  - In 71% of HITs, at least one adjusted poem was rated higher than the default poem.
  - Only 10% of reported best poems came from the default settings.
  - Best poems averaged +1.4 stars over the default.
  - A separate check with 18 users compared default and best poems, to control for creators being biased toward their own edits.
- **Other uses.** The system also runs as an Amazon Alexa Skill ("Custom Poetry"), which recites poems aloud. It was also used in a 15-minute poetry contest with 7 participants.

## Interesting ideas
- **Hard constraints in an automaton, fluency in a neural model.** An FSA guarantees form (meter, rhyme placement), while the RNN supplies fluent wording within those limits. This split could suit any generation task with strict structural rules, such as templates, metrical verse in other languages, or slot-constrained text.
- **Style as additive scoring terms.** Each controllable attribute is a simple per-word feature with a weight added to the beam-search score. This gives cheap, interpretable, user-facing knobs without retraining the model, and it carries over to any decoder.
- **"Same rhyme words, new style" comparisons.** Users regenerate while holding the rhyme set fixed, and each rating is recorded relative to the default poem. Every slider change therefore becomes a paired comparison, which reduces noise in subjective ratings.
- **Per-weight quadratic fits for tuning.** A quadratic curve is fitted between each weight's offset from the default and the change in star rating, and the peak of that curve becomes the new default. This lightweight way of tuning hyperparameters from crowd feedback could work wherever only noisy human scores are available.
- **Speed as a prerequisite for evaluation.** The authors treat speed not just as a convenience but as what makes large-scale feedback collection possible. One example is replacing a per-beam CPU heap with a single global GPU sort, which is asymptotically worse but faster in practice. The broader lesson is to optimize interactive systems so that human evaluation can scale.

*Our summary of the paper, in our own words — not its text. The work belongs to its authors; read it at the links above.*

## Institutions

- [University of Southern California](https://md.research.elamur.ai/free/en/universities/university-of-southern-california/) — University, Los Angeles, United States · 104 works · 33,876 citations

📚 Shelves (4): [🖥️ Computer Science](https://md.research.elamur.ai/free/en/shelves/computer-science/) · 9,086 works · [🤖 Artificial Intelligence](https://md.research.elamur.ai/free/en/shelves/computer-science/artificial-intelligence/) · 8,889 works · [🎭 Arts and Humanities](https://md.research.elamur.ai/free/en/shelves/arts-and-humanities/) · 9,296 works · [🗣️ Language and Linguistics](https://md.research.elamur.ai/free/en/shelves/arts-and-humanities/language-and-linguistics/) · 9,206 works

## Cite

Cite as: Marjan Ghazvininejad, Xing Shi, Jay Priyadarshi and Kevin Knight. 2017. Hafez: an Interactive Poetry Generation System. Proceedings of ACL 2017, System Demonstrations.

The paper itself, not this page. BibTeX from the library's record of the work.

```bibtex
@inproceedings{ghazvininejad2017hafez,
  title = {{Hafez: an Interactive Poetry Generation System}},
  author = {Marjan Ghazvininejad, Xing Shi, Jay Priyadarshi and Kevin Knight},
  booktitle = {Proceedings of ACL 2017, System Demonstrations},
  year = {2017},
  doi = {10.18653/v1/p17-4008},
  url = {https://doi.org/10.18653/v1/p17-4008}
}
```

- [← previous Instance Weighting for Neural Machine Translation Domain Adaptation](https://md.research.elamur.ai/free/en/papers/wang-2017-instance-weighting-neural-machine-translation/)
- [next → Image-Grounded Conversations: Multimodal Context for Natural Question and Response Generation](https://md.research.elamur.ai/free/en/papers/mostafazadeh-2017-image-grounded-conversations-multimodal-context/)
- [↑ back to papers of 2017](https://md.research.elamur.ai/free/en/papers/2017/page/2/)

## References

2 references, 1 of them with a card of ours. ↗ leads to the work, «find» searches for one we have no id for yet.

1. onded the original rankings in 72% of the cases. 3.2 [find](https://scholar.google.com/scholar?q=onded+the+original+rankings+in+72%25+of+the+cases%2E+3%2E2)
2. Stefano Baccianella, Andrea Esuli, and Fabrizio Sebastiani. 2010. [Sentiwordnet 3.0: An enhanced lexical resource for sentiment analysis and opinion mining](https://md.research.elamur.ai/free/en/papers/baccianella-2010-sentiwordnet-3-0-enhanced-lexical/). In LREC.

*Updated 24 October 2026*
