The happy dress came now would my thy gait Love thou have black heaven love hair was standīeauteous the large least in the building seatĬhild be numbers to fair fearless men brand The large numbers must due did be you sweet But poems contain mostly only valid phrases. In this case, I generated poems that follow the Shakespearean rhyme scheme and syllable count. That eyes can see! take heed (dear heart) of this large privilege,Īnd she with meek heart doth please all seeing,īut when i plead, she bids me play my part,įor HMMs, I trained my models using word-based tokenization and line-based sequencing.
![sonnet generator sonnet generator](https://www.coursehero.com/thumb/a8/93/a89350977b5e0fd0f90aca731a23348cc4e6729f_180.jpg)
Her wratk doth bind the heartost simple fair, The worst of worth the words of weather ere:Īnd with the crow of well of thine to make thy large will more. But they do not follow the specific syllable count, rhyme scheme or iambic pentameter. And we see recurring themes/keywords throughout. In this case, we can see that the poems are not too bad! In terms of sentence structures and phrases. The model is trained to minimize categorical cross-entropy loss with the ‘adam’ optimizer.īelow is one example generated sonnet. The output is a fully-connected dense layer with a softmax nonlinearity. My best RNN consists of 3 LSTM hidden layers of 600 units, each accompanied by 20% dropout. And each line has 10 syllables in total (mostly).įor RNNs, I trained my models using character-based tokenization and sonnet-based sequencing.
![sonnet generator sonnet generator](https://64.media.tumblr.com/a81a5b65818daa5ac710ba4548b8525e/tumblr_o4720uzO811txw7lto1_500.png)
Meter-wise, they follow iambic pentameter, where a stressed syllable is followed by an unstressed syllable. Shakespearean sonnets also have a particular rhyme scheme, "ABAB CDCD EFEF GG". Format-wise, a sonnet is 14 lines long, splitting into 3 quatrains, each with 4 lines, ended by a couplet of 2 lines. Shakespeare's sonnets follow very specific patterns and are great for generative models. Models were trained on all 154 Shakespearean sonnets and an additional dataset, Amoretti written by Edmund Spenser, a contemporary Shakespearean poet. In this project, I built and trained Recurrent Neural Networks (RNNs) and Hidden Markov Models (HMMs) to generate sonnets of Shakespeare's writing style.
![sonnet generator sonnet generator](https://64.media.tumblr.com/0af2aa48730992b7a0e370bc120cdc0d/tumblr_o21363YlOK1txw7lto1_500.png)
One fun project in NLP is to build a model that generates machine-written sonnets in the style of William Shakespeare. Natural Language Processing (NLP) is a vast field that has applications in language translation, speech recognition, sentiment analysis, text understanding, text classification, text generation, etc.