How to use deep learning to write Shakespeare

LSTM recurrent neural networks can be trained to generate free text. Let’s see how well AI can imitate the Bard

How to use deep learning to write Shakespeare
Getty Images

“Many a true word hath been spoken in jest.”
― William Shakespeare, King Lear

“O, beware, my lord, of jealousy;
It is the green-ey’d monster, which doth mock
The meat it feeds on.”
― William Shakespeare, Othello

“There was a star danced, and under that was I born.”
― William Shakespeare, Much Ado About Nothing

Who can write like Shakespeare? Or even just spell like Shakespeare? Could we teach AI to write like Shakespeare? Or is this a hopeless task? Can an AI neural network describe despair like King Lear, feel jealousy like Othello, or use humor like Benedick? In theory, there is no reason why not if we can just teach it to.

From MIT’s The Complete Works of William Shakespeare website, I downloaded the texts of three well-known Shakespeare masterpieces: “King Lear,” “Othello,” and “Much Ado About Nothing.” I then trained a deep learning recurrent neural network (RNN) with a hidden layer of long short-term memory (LSTM) units on this corpus to produce free text.

To continue reading this article register now

How to choose a low-code development platform