Gwern’s AI-Generated Poetry

By Scott Alexander

Gwern has answered my prayers and taught GPT-2 poetry.

GPT-2 is the language processing system that OpenAI announced a few weeks ago. They are keeping the full version secret, but have released a smaller prototype version. Gwern retrained it on the Gutenberg Poetry Corpus, a 117 MB collection of pre-1923 English poetry, to create a specialized poetry AI.

I previously tested the out-of-the-box version of GPT-2 and couldn’t make it understand rhyme and meter. I wrongly assumed this was a fundamental limitation: “obviously something that has never heard sound can’t derive these complex rhythms just from meaningless strings of letters.” I was wrong; it just didn’t have enough training data. Gwern’s retrained version gets both of these right, and more too. For example:

Thou know’st how Menoetiades the swift Was dragged, of Hector and the fierce compeers And Phrygian warriors. So, we will dispatch Your bodies, then, yourselves to burn the ships In sacrifice; with torches and with bells To burn them, and with oxen to replace Your gallant friends for ever. But I wish That no man living has so long endured The onset of his foes, as I have power To burn or storm; for mighty Hector erst

Was slain, and now returns his safe return

This is all perfect iambic pentameter. I know AP English students who can’t write iambic pentameter as competently as this.

(by the way, both “compeers” and “erst” are perfectly cromulent words from the period when people wrote poems like this; both show up in Shelley)

It has more trouble with rhymes – my guess is a lot of the poetry it was trained on was blank verse. But when it decides it should be rhyming, it can keep it up for a little while. From its Elegy Written in a Country Churchyard fanfic:

Methinks I see her in her blissful dreams: Or, fancy-like, in some mirage she lies, Majestic yet majestic, and of seems

The image of the unconquerable skies.

Methinks I see her in her blissful dreams: —Or, fancy-like, in some majestic cell, Where lordly seraphs strew their balmy dreams

On the still night, or in their golden shell.

There, in the calm of some Platonic dream, Sits she, and views the unclouded moon arise

Like a fair lady full of realms divine;

And, all at once, a stony face and bright
Glittering in moonlight, like the noon-tints of a night.

COME ON, IT’S A ROBOT. THAT’S BETTER THAN YOU COULD DO IF YOU WERE A ROBOT. GIVE IT A BREAK.

I think its problem is less ability to rhyme, and more a sort of…maintaning the will to rhyme. Gwern prompts it with several Alexander Pope pieces; Pope is a very formal poet who always rhymes in the exact same way. For each Pope piece, GPT-2 does the first couplet in perfect Pope style, then degenerates into increasingly confused gibberish. For example:

Pride even in numbers; wit’s a kind pretence To something foreign still, but ne’er to sense; A constant waste of words, the world produces, A lazy sap, that nothing that’s foreign to expels, ; that’s foreign still unknown to the soul; A young, like, but in the world in motion, Obscending not, which smells all our own the worse than our own our own the soul’s, and soul; Like sense; which is like, but in all our whole. Which thus far more like, but in all things that’s an excellence; and ne’er unchanged by which is folly’s the worse, they give the worse maintained by which If sick of sense;

Wholubil, or snug. ills, we know our own our first in sense the worse maintained between the worse, soon expired.

First two lines are perfect rhyme and rhythm, next four have no rhyme but are close to the right meter, next few have almost random length, and by the last one we’ve abandoned grammar and are making up nonsense words like “wholubil”. Every Pope test Gwern runs is like this:

They talk of constancy and faithless love, A seraph trembles at the specious glove; Nor in the rich confin’d relief of state, Find proud pretence, nor in the disdiscoveries of fate. For when misfortune makes choice remains the conduct’s the prize half known, Can we secret soul without due, they fear of sense of more known. Some rise where’ rights, they make it pays due. . . . Sense and judgment, as equal prize seem meanly, the reward the joy, as much possess the prize paid, as well reckon the prize we do not less dare not less keenly wise. We see; Of happy lovers ought, as well done, like a friend. Know they ought, ’tis ev’ is the other joy, as well worth a right; The joy, as well might, as well may, as well may all is great. Nor need of joys not as well maysters, as well as well may they give; but as little store; but as well as well as well may shewn, as much, as well we know, as well as well can be sure might prove, as well may well as well as well as well as well may view;

The mind: as well as well as well as well as much the fair as well as well as well as well as well as well as well may

Again, first two lines are great – “a seraph trembles at the specious glove” is both nonsense and exactly the sort of thing Alexander Pope would write, but by the fourth line we have nonsense words, by the fifth we lose the meter, the eighth and ninth are just periods, and finally it starts stuttering helplessly.

I tested this many more times on a public version (not poetry-trained) and found a similar effect – the first two lines are always the best, and it deteriorates from there. I’m interested in hearing from people who understand the model better than I do about why this should be.

Some other highlights:

My heart, why come you here alone? The wild thing of my heart is grown To be a thing,

Fairy, and wild, and fair, and whole

That last line, with its ABAB structure, is actually brilliant even by the standards of human poets. “Fairy and wild and fair and whole”. I could say that all day. This has to be a coincidence. It’s not that good anywhere else. But even having something generally okay enough that it can occasionally blunder into something that good is great.

From its Hindu phase:

…which Indra, King of all the Blest, Had thrown by Rávan’s mighty breast, The monstrous coil, the brawny hand, The monstrous mouth, the jaw, the jaw, The jaw, the jaw and bleeding jaw, The ungovernable host, the jaw, And the great bow which never bends, The arm, the fist, the knee, the ends, The body laid with mighty stroke, And the great bow which never bends. So, when the giants fought, and fell With murderous strokes, the giant fell,— So falls the tree with all his trunks Terrific in its death, that shoots Wild volley at the mighty trunk,— So fell the tree with all its boughs While all the vipers dug and sowed— So fell the tree with all its boughs. But Ráma’s heart was sad within

He wept and mourned his captive’s sin

The first two lines are great (and the program must have invented the epithet “King of All The Blest” for Indra, because I can’t find it anywhere else). The description of Ravan’s jaw is, uh, quite memorable. “So falls the tree with all his trunks” is a good deployment of a metaphor which is frankly overused in old poetry. I’m ambivalent between interpreting the repetition as an AI getting stuck in a loop vs. as good use of repetition as a poetic device.

The next few are from this list of a thousand randomly generated samples:

And they have seen the last light fail; By day they kneel and pray; But, still they turn and gaze upon

The face of God to-day.

And God is touched and weeps anew For the lost souls around; And sorrow turns their pale and blue,

And comfort is not found.

They have not mourned in the world of men, But their hearts beat fast and sore, And their eyes are filled with grief again,

And they cease to shed no tear.

And the old men stand at the bridge in tears, And the old men stand and groan, And the gaunt grey keepers by the cross

And the spent men hold the crown.

And their eyes are filled with tears, And their staves are full of woe. And no light brings them any cheer,

For the Lord of all is dead

And:

There are several kinds of people in America; There are several kinds of people, I mean their number. There’s a girl growing up in the house by the light, There’s a youth upon the road, or a girl somewhere in New York;

There’s a prettier girl, and a man more congenial,

But none of the likes of the likes of the fellows are equal. There’s one who has never been married and married, There’s one who don’t want to be treated with kindness; A fair youth is never employed nor neglected; There’s one who has never yet come to a neighbor,

And one who resides in New York from the start;

But none of the likes of the likes of the fellows Are equal to him, and wherever he goes, The heart somehow breaks under the hand that is steering;

And so it is with me

And this quatrain just worked out really well:

Fair is the Lake, and bright the wood, With many a flower-full glamour hung: Fair are the banks; and soft the flood

With golden laughter of our tongue

This one is notable for competent metaphor:

How the clouds Seem to me birds, birds in God’s garden! I dare not! The clouds are as a breath, the leaves are flakes of fire,

That clash i’ the wind and lift themselves from higher!

And this one is obviously a failure on one level, but on another level is some kind of great experimental modern political poetry:

The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), rapacious, The Emperor Wu (the great Wu), majestical, The Emperor Wu (the great Wu), rapacious, The Emperor Wu (the great Wu), rapacious, The Emperor Wu (the great Wu), rapacious, The Emperor Wu (the great Wu), rapacious, The Emperor Wu (the great Wu), rapacious, The Emperor Wu (the great Wu), rapacious, The Emperor Wu (the great Wu), rapacious, The Emperor Wu (the great Wu), rapacious, The Emperor Wu (the great Wu), rapacious,

The Emperor Wu (the great Wu), rapacious

This one displays an interesting combination of world-knowledge and lack-of-world-knowledge:

In the dark the sun doth gleam, And in the dark the moon doth seem But now the evening is begun– Gone is the sun upon the earth! The silver moon doth like a cup Of blood-red wine, and as that cup Is drained of life, doth quench no drop. What man will drink such wine? There is no soul of earth or birth Which man hath never known of earth. There is no soul who doth not sit And sing to it, and cry, “Drink!” There is no soul whose feet are set On youth’s eternal paradise; For all is a solemn harmony, And all is a perpetual chant, And all the world is a song of God.

There is no soul so wholly free

And here’s another:

There gloom the dark, broad seas. My mariners, Souls that have toiled, and wrought, and thought with me That ever with a frolic welcome took The thunder and the sunshine, and opposed Free hearts, free foreheads – you and I are old; Old age hath yet his honour and his toil; Death closes all: but something ere the end, Some work of noble note, may yet be done,

Not unbecoming men that strove with Gods.

Except this last time I’m cheating: this is an excerpt of Tennyson’s Ulysses, one of the most famous English poems. I included it as a placebo, ie a test to see whether real poems sound fake if you think they’re by an AI when you read them. I’ll be honest: if I didn’t know this was Great Poetry, I would skim it over and assume it made several mistakes. Like: is “gloom” really a verb (it is if you’re Alfred, Lord Tennyson). Is the last line grammatical? (yes: it’s an adjective phrase modifying “work”, ie “some work which is fitting for the sort of men who fought gods to do”). Are the mariners’ souls opposing their foreheads? (I’m still confused on this one). These are all the sorts of things that would make me go “Haha, AIs are still pretty dumb” if I were reading it blindly.

If you liked these poems, you might also appreciate Gwern’s work making AI-generated anime waifus.

(and you can also donate to Gwern’s Patreon here)