Let’s Generate Paper Titles

Inspired by this toot and using this tutorial -- both by Allison Parrish, who gives the greatest talks on computer-generated poetry -- I trained a recurrent neural network and had it generate some paper titles based on entries in my bibliographic database (available from here). Fun times!

In [1]:
from pybtex.database import parse_file
from textgenrnn import textgenrnn
In [2]:
bib = parse_file('Everything.bib')
In [3]:
english_entries = [entry for _, entry in bib.entries.items()
                   if not 'hyphenation' in entry.fields.keys()
                   and 'title' in entry.fields.keys()]
In [4]:
all_titles = set()

for entry in english_entries:
    if 'subtitle' in entry.fields.keys():
        all_titles.add(': '.join([entry.fields['title'],
                                  entry.fields['subtitle']]))
    else:
        all_titles.add(entry.fields['title'])
In [5]:
len(all_titles)
Out[5]:
812
In [6]:
textgen = textgenrnn()
In [7]:
textgen.train_on_texts(all_titles, num_epochs=3)
Epoch 1/3
45313/45313 [==============================] - 131s 3ms/step - loss: 1.6268
Epoch 2/3
45313/45313 [==============================] - 130s 3ms/step - loss: 1.2783
Epoch 3/3
45313/45313 [==============================] - 132s 3ms/step - loss: 1.1202

And here they are -- generated paper titles in increasing order of craziness (the higher the temperature, the more the generative algorithm deviates from the learned probability distribution)!

In [8]:
textgen.generate(10, temperature=0.7, return_as_list=True)
Out[8]:
['The Action in Religion and the Secular Thomass: The New Gender and the Community of Program',
 'Data and the Sociology of Man and Personalism',
 'Smartian Historical Section',
 'The Daily Reflect',
 'The Homeless for Secular Historical Age',
 'The Verrees of Exports: The Planting of Modern Instendence and Nethernatization',
 'The Material Follower on the Sociology of Church',
 'The Modern Protestant',
 'The Disadert, Protestant in Mag and the Usage of Ninternation of That Its Mediations',
 'A Public American Christianity in the Emerging Power Contextic Posts']
In [9]:
textgen.generate(10, temperature=0.8, return_as_list=True)
Out[9]:
['Studies and Modern Emerging Hebey',
 'The Nabits of the Signamentality and West',
 'The Poststellitar Man in Europe',
 'Recypt Wyospher: What is Sociology is our Sociology',
 'The Nethernal Seat of the Philosophy',
 'Mediations',
 'Civil in Prance',
 'The Exit City, and Sociology of World: Evangelical Theory',
 'The Imperial Bourge in the Christendom',
 'The Political Camy Colonial History']
In [10]:
textgen.generate(10, temperature=0.9, return_as_list=True)
Out[10]:
["The Splitural Religious Affective: Let's Haul Turn of Institution",
 'The Contemporary Mediation',
 'The Weber in Urban Jaccula',
 'Franch of World Changing New Sociology: A Harvect in the Durklbow of Europe and Mission',
 "Common's Whore and Axistents",
 'The Nations of World: The Storing of Mediatization on American America, into the great in the Knowledge of Multicultural',
 'Historications Necession: Tool in Post-sentity',
 'Literatical Gritalist Religion',
 'Massing Nazi World essays',
 'Help user the matt has deletic']
fun