Clinton Slogans: Text Generation using Recurrent Neural Networks

In the Fall of 2016, a month before the election, a list of tried and rejected slogans for the Hillary Clinton campaign were leaked via email to the press. I thought these slogans were super interesting, with some of my favorites being "Fairness worth the fight" or "New Solutions Real Results." Naturally, twitter had a field day and we all had a bit of fun.
I, about a year later, wanted to have an excuse to try out text generating RNNs and decided to go back to this dataset and check it out.
So below, over the course of about an hour, I built a RNN using @minimaxir's textgenrnn for this exact purpose. Turns out, this library is aggressively easy to use, making this a great intro to textgen RNNs.

In [ ]:
from textgenrnn import textgenrnn
textgen = textgenrnn()
textgen.generate()

Now let's take a look at the first 5 of our list of slogans, compiled into a txt file from an NYT article using the pandas library.

In [21]:
import pandas as pd
pd.read_fwf('Hilary_slogans.txt', sep = "").head()
Out[21]:
Title
0 A fair shot and a fair deal
1 Hillary - For Fairness. For Families.
2 Building a fairer future today
3 Fairness worth the fight
4 Fairness First.

And now we'll train the rnn from the text file.

In [7]:
textgen.train_from_file('Hilary_slogans.txt', num_epochs=5)
94 texts collected.
Training on 2,162 character sequences.
Epoch 1/5
16/16 [==============================] - 5s 300ms/step - loss: 0.6964
####################
Temperature: 0.2
####################
A fair chance for you

A stronger tomorrows our fair chance

A fair chance for you.

####################
Temperature: 0.5
####################
Stronger together

New Strength for the future

A fair chance for your families.

####################
Temperature: 1.0
####################


Builting Americas America at us

Your families

Epoch 2/5
16/16 [==============================] - 5s 300ms/step - loss: 0.5797
####################
Temperature: 0.2
####################
A better bargain for a better bargain

A better bargain for a fair chance

A better bargain for a fair chance for families

####################
Temperature: 0.5
####################
Making America for families

Stronger together



####################
Temperature: 1.0
####################
Moving Ahead.

A nev figgh for your family. the fight.

A stronger tomorrowing the work

Epoch 3/5
16/16 [==============================] - 5s 301ms/step - loss: 0.4914
####################
Temperature: 0.2
####################
A fair chance for families

A fair chance for families

A fair chance for families

####################
Temperature: 0.5
####################


Fairness for you

A fair fight

####################
Temperature: 1.0
####################
Its about you.

A new bargain for a better better tomorrow

Building move future

Epoch 4/5
16/16 [==============================] - 5s 304ms/step - loss: 0.4321
####################
Temperature: 0.2
####################
A fair chance for families

A stronger America working for you

A fair chance for families

####################
Temperature: 0.5
####################
Fairness for all



A better bargain

####################
Temperature: 1.0
####################
A new get chance

Your future and that it

Putting Fairness First

Epoch 5/5
16/16 [==============================] - 5s 302ms/step - loss: 0.3864
####################
Temperature: 0.2
####################
A fair chance for families

A stronger America working for you

A stronger America to fair chance for you.

####################
Temperature: 0.5
####################
A stronger America working for you.

Fairness for all our families

Strength for families

####################
Temperature: 1.0
####################
A new build her future

Building a fairer to fight

Move we povely. Am strong when you can

The last thing we want to do is simply make 10 generations using our model. The last one is my favorite!

In [18]:
for i in range(0,10):
    textgen.generate()
A fair chance for families

A stronger America working for you

A new bargain for a fair chance

Renewing our basic for a stronger together

A new better bargain for a stronger America

Your family at a fair chance

Getting ahead together

Your family at a stronger time

Progress for families

Get ahead. Together.