Torch is a scientific computing framework with wide support for machine learning algorithms. Andrej Karpathy has an excellent blog post explaining recurrent neural networks (RNNs) and character level models. With his sample code for Torch it is very easy to get started creating your own RNN by using text from a specific domain. This model learns to predict the next character in a sequence. The model can be used to generate text character by character that looks similar to the original training data.

I used training data from the Wikipedia list of Harlequin romantic novel titles. It is too short to get proper spelling for all output but below are some of the generated titles predicted by the model. Some are pretty good:

  • Nurse Christmas Havin’s Love
  • Nurse Nanny
  • His Secret Surgning
  • Bring Doctor Gleg
  • The Marriage
  • The Peach Dark’s Wife
  • Love And The Ring
  • Be One Mother
  • The Girl From The Wind
  • Man In The Spring
  • Her Secret Cares
  • Levenkicted Engagement
  • The Girl Cawllay
  • A Deap For The Love
  • Her Promes and So Love
  • No The Blue Sweet
  • One Her Nurse Marriage Acking Blondes
  • The Gurld Of Heartss
  • House Of Jancher
  • Aan Flone Comes Marriage
  • The Man In Woothboul Doctor
  • To Lusban For Life
  • Married At Promas
  • The Princess
  • Decoth’s Bride And Yount Wife
  • Wild Of My Me
  • Love Fither For

Bonus material

I reused the same code but trained it on christmas carols and death metal lyrics (~50/50). Now it makes awful songs: