I would like to create an NLP autoencoder that happens to only generate text that conforms to a poetic meter, for example 'iambic pentameter'. That is, the output should be a series of clauses which are 10 syllables long and are read aloud with the verbal stresses as 'duh-DUH duh-DUH duh-DUH duh-DUH duh-DUH'. Shakespeare and his contemporaries used this format for much of their poetry.

The only method I can think of is to collect lines of text which are in this format, and then train an autoencoder on these. Since the network only emits iambic pentameter while training, it should also emit iambic pentameter while predicting. Given a large enough corpus, this seems like it should work.

One problem is that this training only accepts iambic pentameter. To rewrite other text into IP, the training needs to include variations of text in IP and train (not IP sentence) to emit (IP sentence). Generating these variations is straightforward. This crosses the line from training "sentence embeddings" to training "thought embeddings".

Are there other ways to solve this problem? Is there a way to directly alter the sentence embedding space? For example, variational sampling works by applying a nonlinear transformation on the embedding space.

Note: the CMU Pronouncing Dictionary supplies pronunciation stresses for over 100k words, usable for classifying meter: http://www.speech.cs.cmu.edu/cgi-bin/cmudict

Note: this is a personal hobby project to teach myself deep learning & NLP- I really do not know whether it is achievable with current NLP technology.


1 Answer 1


A starting point that comes to mind is creating a cost function for a sentence being in IP. Now, while normally this is a binary affair (either a sentence is in IP or not - or so I would assume), this does not lend itself readily to the task. You should devise a cost function that measures how close your sentence is to IP (so I assume that sentence with 11 syllables would have a lower cost than one with 12. Verbal stresses and their associated costs are left to you to figure out ;) ).

After you have a cost function, you should take some sort of pretrained deep neural network that can translate from one language to another, such as those that use Word2Vec, set it to translate from English to English, and train it with two costs - one for keeping the meaning of the text (probably with another instance of word2vec or something to that effect), the other for being in IP. The relative weights of the two costs should be determined experimentally (you may even want to change them while training).

This is of course a shot in the dark. More research and experimentation will be required, but I hope this may serve you as a starting point in your endeavor.

Be advised that while this is an intriguing project, in my opinion it might not be the best choice for beginners.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.