Creative Applications › Poetry Generation

Michael BrenndoerferJanuary 14, 20267 min read
Language AI HandbookAll chapters
Part 63 of 67LLM Applications
Chapter 484Creative Applications › Poetry Generation
Reading section 5 of 12 · Poetry Generation · 7 minSection 5 of 12 · 7 min

Book contents

Section 5 of 12 · 7 min read

Creative Applications › Poetry GenerationOne section · Sections in this chapter5 / 12 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Poetry is the form of writing most compressed in meaning. Where prose uses many words to construct context and connection, poetry uses few words with maximum resonance. This compression makes poetry both a fascinating challenge and a revealing stress test for language models.

What Is a Poem, Technically?

Poems are characterized by formal constraints that prose does not share. These constraints operate at multiple levels:

  • Phonological: Rhyme (end rhyme, internal rhyme), alliteration, assonance, consonance.
  • Metrical: Patterns of stressed and unstressed syllables (iambic pentameter, trochaic tetrameter, free verse).
  • Structural: Stanza organization, line breaks, fixed forms like sonnet, haiku, villanelle.
  • Semantic: Compression of meaning through metaphor, imagery, ambiguity, and resonance.

Language models trained on large corpora have absorbed these patterns extensively. They can reproduce metrically correct iambic pentameter, maintain ABAB rhyme schemes, and generate haiku-like structures. What they do less reliably is generate poetry where the formal constraints serve the meaning: where a specific word choice is correct both because it rhymes and because it carries precisely the right connotation.

This gap reveals something important about what poetic craft requires. A skilled poet does not choose a rhyming word by looking up which words sound like the previous line's last word. The poet considers the full semantic field of every candidate rhyme, the connotations it carries, the rhythm it introduces, the way it resolves or extends the poem's central tension. A language model, sampling from a probability distribution, may find a rhyme that sounds correct but introduces a semantic register that undermines the poem's unity. The gap between formal correctness and semantic fitness is where human craft and machine generation most visibly differ.

Metrical Analysis and Generation

Meter in English poetry is based on alternating stressed and unstressed syllables. The fundamental unit is the foot: iambic (unstressed-stressed, as in "a-BOVE"), trochaic (stressed-unstressed, as in "TI-ger"), anapestic (unstressed-unstressed-stressed, as in "un-der-STAND"), and dactylic (stressed-unstressed-unstressed, as in "MER-ri-ly").

A line of iambic pentameter has five iambic feet. Each foot is an unstressed syllable followed by a stressed syllable, notated here as "da-DUM":

da-DUM⏟1da-DUM⏟2da-DUM⏟3da-DUM⏟4da-DUM⏟5\underbrace{da\text{-}DUM}_{1} \quad \underbrace{da\text{-}DUM}_{2} \quad \underbrace{da\text{-}DUM}_{3} \quad \underbrace{da\text{-}DUM}_{4} \quad \underbrace{da\text{-}DUM}_{5}

where the subscript numbers 1 through 5 label the five feet in the line, and "DUM" marks the stressed syllable in each pair. "Penta" means five; "meter" means measure; so iambic pentameter is a line measured by five iambic feet.

Shakespeare's sonnets are written in iambic pentameter. "Shall I compare thee to a summer's day?" breaks down as: "shall-I" (iamb), "com-PARE" (iamb), "thee-TO" (iamb), "a-SUM-" (iamb), "-mer's-DAY" (iamb).

When prompting a language model to write in a specific meter, it helps to include a metrical analysis of an example line and ask the model to follow the same stress pattern. However, language models often sacrifice strict meter for semantic coherence, which is arguably the right tradeoff: a metrically perfect but meaningless line serves no one.

The relationship between metrical regularity and expressive power in poetry is subtle. Strict metrical regularity can produce a lulling, incantatory effect, as in many folk ballads. Deliberate metrical variation, a line that breaks the established pattern at a moment of emotional intensity, can create powerful emphasis. The technical term for a stress that falls where the meter does not expect it is "syncopation." A poet chooses when to be regular and when to deviate; a model trained to produce metrically correct lines will tend toward regularity at the expense of expressive deviation.

Fixed Forms: Sonnet, Haiku, Villanelle

Fixed poetic forms provide explicit structural constraints that make evaluation more tractable. Three commonly generated forms are:

Sonnet: 14 lines, typically in iambic pentameter. The Petrarchan sonnet divides into an octave (8 lines, ABBAABBA rhyme scheme) and a sestet (6 lines, variable rhyme). The Shakespearean sonnet divides into three quatrains (ABAB CDCD EFEF) and a couplet (GG). The volta, or "turn," is a shift in tone, perspective, or argument that typically occurs between the octave and sestet in the Petrarchan form, or in the final couplet of the Shakespearean form. Language models frequently generate lines that scan correctly and rhyme in the right places but miss the volta, producing technically compliant sonnets that feel flat because the argumentative arc is absent. Sonnets are ideal for language model generation because the constraints are well-defined and the form is so extensively represented in training data.

Haiku: Three lines of 5, 7, and 5 syllables. Traditionally includes a kigo (seasonal word) and a kireji (cutting word) that creates a juxtaposition between two images. Haiku generation is a common benchmark because syllable counting is easily verified. Language models frequently miscounting syllables is one of the most reliably documented failure modes. The deeper challenge is generating the imagistic juxtaposition that gives haiku their characteristic resonance: two images placed side by side so that their relationship creates meaning without being stated.

Villanelle: 19 lines organized as five tercets followed by a quatrain. The first and third lines of the opening tercet alternate as the last lines of subsequent stanzas and both appear as the final couplet. Dylan Thomas's "Do Not Go Gentle into That Good Night" is the most famous example. Villanelles are difficult for language models because they require two specific lines to be repeated verbatim in precise positions, which challenges models that tend to paraphrase rather than copy. The constraint also creates a compositional challenge: the two refrain lines must be meaningful in different contexts as the poem develops around them, so they need to be crafted with enough semantic richness to sustain multiple readings.

Syllable Counting in LLMs

Language models process text as tokens, not phonemes. A token might correspond to multiple syllables ("butterfly" is one token, three syllables) or multiple tokens might form one syllable (rare words sometimes split at the character level). This tokenization/syllable mismatch means models cannot directly "count syllables" by counting tokens. Models that successfully count syllables in poems are likely doing so by pattern-matching to training examples rather than phonological computation. This is why haiku syllable counts are unreliable without explicit verification.

The Lyric Mode and Emotional Compression

Beyond the technical constraints of fixed forms, poetry operates through a mode of expression that differs fundamentally from narrative or expository prose. The lyric mode, which covers most short poetry, is characterized by the presentation of a moment of perception or feeling in a way that makes it available to the reader as an experience rather than as information.

A poem about grief does not explain grief. It embodies grief through specific images, rhythms, and sounds that create a felt experience of grief in the reader. This is why "I am very sad" is not a poem, while "After great pain, a formal feeling comes" (Dickinson) might be. The abstraction disappears; the specific, unexpected image makes the abstract emotional state concrete and surprising.

Language models have absorbed enormous amounts of poetry and critical discussion of poetry, so they have learned to deploy images and avoid direct statement. They produce similes, they end on sensory details, they vary line length for rhythm. What they produce less reliably is the image that feels inevitable and surprising at once: the image that, once read, you cannot imagine the poem without. Generating that kind of image requires the kind of semantic reach that draws from lived experience in a way that training-data recombination rarely achieves. Knowing this, you can use models best in poetry generation by supplying the central insight or image yourself and asking the model to build a formal structure around it.