i love reading and trying to write poems. A form of poem writing i find particularly fun is acrostic poems. i’ve even made my own style of it where the first letters of each line and first letters of the last word of each line spell out something. This is an example of such an acrostic i wrote- ‘The Eternal Wait‘ and here’s the traditional acrostic form- ‘Bird and Birda‘ (this was written together with a friend on a train journey). I went on to make a 3D sculpture of such a poem- a 3D acrostic if you may, that follows the above 2D rule, but also reads a phrase as you go around the four phases of the cuboid. Please refer to my ‘Kshann Rachna‘ piece for more information.
There have been some very nice projects done around using machine learning algorithms for poetry generation. In particular, a lot of these works use Long Short Term Memory (LSTMs), a kind of neural network to generate poems. It is done by training the LSTM on a collection of poems and then the network is able to produce new poems. I was particularly interested in generating acrostics. I began by hacking a popular recurrent neural network repository (char-rnn) to take a word or phrase as input and generate an acrostic with that.
Here’s a couple of examples of computer generated acrostics from that-
Happy New Year
HERE into life expand their gifts,
And mournfully cease, that lead, divine,
Pride of the liven presses of Christinage,
Pour the blush’d painters was eternal bloom,
Yet vow’d delightand pass his fate of day,
No sharp foremosop in strife,that lift wise,
Even to dividing ills to balm?
What sorrow, there, thy hand whom blaze each snowy shore.
Yet thro’ again of heather with mountains forth,
Enamoured, all turn, tears was die,
And all thee did you visit hear,
Rage, he were giving on his head of injuring sigh.
poetry is fun
pour no our day so dealer hills,
once him he wisdom
enath a thrush of leaping thench,
the blushing I lives, in green monarch’s light;
riseit shall scarce before it finds to heal.
yes have his name we say not in those all of macry.”
in fires where the suffering bances! shaken free the Morning stines.
said the hand, reared, and seeing to this bed
from the heavens that whirled it takes
unstills a brittle vale, we see his hand,
nor the burns that flown affections blest.
I thought these were pretty fun outputs. One aspect lacking definitely was the acrostic word or phrase had no actual influence on what the poem was about, apart from forming the first letters. One way i began to tackle that was using word embeddings. The overall idea was to use the word or phrase and try and find similar words to that using a word embedding. I used the ConceptNet5 API for that. Once i got a list of words close to the given word or phrase, i searched words among it starting with a letter matching with the input phrase or word (which forms the acrostic). Then these matching words became the first word of the corresponding line in the acrostic. If no matching word is found, then the letter itself is used. I also hooked it up with an image recognition network using Tensorflow to take an image as input- classify it- take the classification word and run the above process on it.
Here’s an output of an acrostic poem generated with an input image:
I’m currently running this as a local web app to upload images and generate poems. Will look to make it public soon. Another thought is to classify images into emotion(s) and use a word embedding on the emotion to get more poetic feel. Haven’t found a good emotion classifying image dataset yet. Anyone?
Also, the current dataset of poems used for training the LSTM is just a random scraping off the web for poems. Looking to collect better datasets. Anyone got some hints for places to look at?