"Her frown lies betwixt two fickle eyes" - Teaching an AI to write Shakespearean Sonnets

By on   2 comments 550 words, read ~134 times.

For a domain based on Shakespeare - this blog doesn't talk about The Bard much. Sorry!

I forced a bot to read 154 Shakespearean Sonnets. This is what it came up with...

  Be where thou art, thou art the sea,
  Till all that belongs to it turn aside,
  And make another land into thy heart's plot.
  Let those elements that should guide thy march,
  Make thee thy ward against the sea's cruel gale!
  The deep shall not hold thee afloat,
  The deep shall hold thee afloat,  
  The fair thou in her holds her turns are unlimited.
    If she have any, none hold her so,
    She hath all the gilds of all men's eyes,
    But her fair hath no eyes, no heart,
    That shape to me most dear should like:
    Her eyesight no heart can make more black,
    Than those of a fool's wife, whose quality I do know,
    Her frown lies betwixt two fickle eyes.

OK. It isn't a work of genius. I only let the AI train for 5 minutes before I got bored. But here are some interesting things that it "learned":

  • Sonnets start with a number
  • Each line is fairly short
  • The last few lines are indented
  • They're usually about women
  • Eyes! And hearts! And cruelty! It's all so dramatic

If you were at a pub quiz, and the question was "Which of Shakespeare's characters is described as 'Her frown lies betwixt two fickle eyes'?" - what would you guess?

(Helena from A Midsummer Night's Dream, obvs.)

The words "frown", "fickle", and "betwixt" are rare in sonnets - although eyes are common - and yet OpenAI's GPT-2 has come up with a coherent sentence which sounds a bit Shakespeary!

Cherry Picked Evidence

That first sonnet was a bit of a fluke. Its next attempt was this piece of Vogon drivel:

Looking back at the first sonnet, it's easy to see what it hasn't got right:

  • No notion of Iambic Pentameter yet
  • Rhyming couplets are missing
  • A lack of ambiguous sexuality

Better poetry through technology

This was a quick and dirty demo, using some unstructured text, a few minutes of GPU resources, and a bout of insomnia.

It's utterly tempting to think that real AI is just around the corner. The results are superficially attractive. To someone unfamiliar with Shakespeare, they look convincing. The occasional little flashes of "genius" help fool even sceptics into thinking there's really an intelligence at work.

I'm a cynic. I think it's like the Barnum effect - people want to believe, so they dismiss the inconvenient.


Google offers a free Colab worksheet for training a GPT-2 AI. Basically, click next a bunch of times, upload a text file, click next some more, wait for *AI Magic*, and you can auto-generate text.

It doesn't have the best documentation in the world. But after a few false starts, I was able to get it working. It was certainly easier than buying a new laptop and trying to get everything running on that!

Share this post on…

2 thoughts on “"Her frown lies betwixt two fickle eyes" - Teaching an AI to write Shakespearean Sonnets

  1. Thank you! This looks like it has really clear instructions. I'm sure I'll need to (re)learn a few things along the way, but I reckon I can handle this. You're a star!


What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.