I Programmed an AI Bot to Help Me Run for President

Automating the perfect campaign speech with GPT-2: OpenAI’s Machine Learning Model

Ben Wallace
LineByLine
8 min readMar 11, 2020

--

Candidate images cred: FiveThirtyEight.com, Bot cred: CGP Grey

2020 is already a crazy year for America. So, why not throw AI at all of it and see if it can solve some problems? In this article, I will introduce to you GPT-2, how I used it to write a speech, and what the output was.

Project Inspiration and Initiation

GPT-2 is a predictive text model that was created to show off the future impact that Natural Language Processing could have on our culture. OpenAI, the non-profit that developed this technology, said in its official blog post:

GPT-2 is a large transformer-based language model with 1.5 billion parameters, trained on a dataset of 8 million web pages. GPT-2 is trained with a simple objective: predict the next word, given all of the previous words within some text.

I first heard about GPT-2 on a podcast. I can’t remember which one, but I’ll drop it here if I remember! In a nutshell, an author developed a text editor that used GPT-2 to recommend sentences based on what she wrote and training data from her past novel. Not only were these sentence recommendations well-structured, but the model seemed to have an admirable understanding of the novel’s characters and lore. Incredible! What a tremendous way of conceptualizing how AI can benefit our lives.

A visualization of words generated from GPT-2 (source: OpenAI)

But of course, there are two sides to every coin. OpenAI developed this to warn us about the malicious use cases of this tool. More specifically, OpenAI predicts that tools like could generate misleading news articles, impersonate others online, and automate abusive social media content or phishing emails. This is why OpenAI’s open-source release of GPT-2 is much smaller in size. This will result in less-quality outputs than what OpenAI claims its fully-fledged version can accomplish.

With all these potential dangers, my mind went to politics. Many of us know of that deepfake video of Barack Obama. Imagine what that technology can do with GPT-2. How can a particular interest group use a tool like this to sway voters, suppress opponents, and concoct the perfect speech? Luckily, institutions like OpenAI and Center for Humane Technology are trying to answer these questions.

In my project, I aimed to set aside the issues and focus on the fun: using GPT-2 to curate the perfect campaign speech! Conveniently enough, I’m already running for President (only because Wallace2020.org was an available domain). So, with the help of GPT-2 and my fellow Presidential Hopefuls, I curated the most perfect Presidential Campaign Kickoff Speech of all time.

Development

In order to build with GPT-2, I basically followed the step-by-step guide of Ng Wai Foong’s article, Beginner’s Guide to Retrain GPT-2 (117M) to Generate Custom Text Content. This article will walk you through the bare minimum of what GPT-2 has to offer.

The first unique thing one must do is collect, organize, and standardize training data. Since I wish to create the perfect campaign speech, I decided to steal the speeches of every prominent candidate in the Democratic 2020 Race. So, I gathered the transcripts of every kickoff speech from Pete Buttigieg, Bernie Sanders, Kamala Harris, Corey Booker, Andrew Yang, Elizabeth Warren, Joe Biden, Amy Klobuchar, Beto O’Rourke, Julián Castro, Jay Inslee, and Marianne Williamson. My logic is that by collecting all their speeches, GPT-2 can find repetitions in policy items, word choice, and syntax.

A cool GIF I found from WRCBtv

I had to write a little bit of cleanup code that places each sentence on its own line (that was my choice) and encodes everything in UTF-8. After securing the training data, I placed it in my code directory. Again, follow the steps in this Medium article for more details. Section 4 of the article, “Generating samples”, is where your work comes together. When creating an
output, GPT-2 gives you two options; generating an unconditional sample or an interactive conditional sample. I chose the latter, because I wanted my output to be based on user input. In this project, my input was simple: “Hi! My name is Ben Wallace, and I am proud to announce that I am running for President of the United States.” I wanted GPT-2 to take that and run with it!

The Results

Here it is! The perfect campaign speech. I decided to generate a few samples/speeches and placed them in text files. You can find them at the root of my Github repository here. The one that I have published on the Meet Ben section of my website is labeled wallace_2020_final.txt. Here is the final product:

Hi! My name is Ben Wallace, and I am proud to announce that I am running for President of the United States.
I get it.
You guys think you know everything about me, but you don’t.
I am running for president because I believe in American greatness, and I believe that you all, one by one, will join me on this journey.
And I am running for president because, like so many Americans, you know we like to turn things back.
So if in the future you think the United States of America is a distant memory, well, I want to be perfectly clear: I’m not going to tell you what to think.
I won’t.
I can’t.
You’ll just know that this is a difficult race and I believe we can only win it by the power of the people.
So, if you don’t believe in a Trump presidency, get out the vote, and if you don’t believe in a Trump-Russia investigation, then get out the vote!
I’ll tell you a little bit more about myself.
In 1980 I was just 29 years old and living in a small apartment in Midland, New Jersey.
Nothing really happened in that area until I was arrested for trying to buy marijuana from a guy who was also in possession of two handguns.
That arrest brought a whole new meaning to the phrase, ‘Oh, we know what happened in Indiana.’
And that is why I stand here today, standing before you in a red jail jumpsuit, my true face, facing a crowd of people who say we have to change our politics from scratch because of the mess we made in our history by trying to turn it into a political issue.
And that is why I founded The Young America my saying, don’t compromise, and when I say I am from Jamaica, you say I’m from California, I say I’m from New York, I’m from Philadelphia, I’m sure there are thousands more here who agree with them than the Jamaicans.
So, if you don’t believe me, get out the vote, and if you don’t believe me, get out the vote today.
I have this great question, Joe Biden, who is up for re-election in 2018.
He is the son of a United States senator from the state of Delaware, and I was elected as his deputy.
He is the son of a United States senator from the state of Delaware, and he is running for president as a Republican.
So, this is a logical question that asks, what is the appeal of a president who claims to be from Jamaica?
If we’re going to understand what we’re doing here, we have to ask ourselves what the hell we’re doing.
Why are we here, and how can we engage with this country?
Why are we spending this much money on politics and money, and no one is asking what is at stake for us if we don’t start from the ground up?
Why should health care be just a political issue?
The greatest killers in the world are not people who once killed and raped and doused everyone they know with chemicals.
They are barbarians intent on ripping us off.
They seek to divide us up, to kill us, to divide us children, to rape us, to mutilate us and to pollute our air, water and soil.
They seek to murder our children, their children.
They seek wars that harm us all.
They threaten our futures.
They threaten hell for our children.
They threaten war.
They threaten mass murder.
But we have democracy, we have freedom, we have terror.
We have it down pat.
We have laws that protect us, that protect us.
We have proportional representation, we have proportional representation.
We have no more mass incarceration.
We have pre-crime, we have post-crime.
We treat everyone with dignity.
We treat our veterans with dignity, we treat our African-Americans with dignity, we treat Native Americans with dignity and we treat them.
We treat them.
We treat them not just with equal justice of the law, but with equal justice of the decision.
We treat them the way we treated our privacy.
We treat them the way we treat our lives.
We treat them the way we treat our children.
We treat them the way we treat our love.
Thank you Barack Obama.

Not bad, huh? I particularly enjoyed the Obama salutation at the end! If you follow the Presidential race, it’s truly fascinating to read this and guess which parts were inspired by which candidates. But the gestalt of the Democratic Party is still there; inside this speech lies tales of social justice, economic reform, and Jamaican-citizenship fraud: the big three on the Democrats’ platform. 😄

Final Thoughts

Was this the perfect speech? Certainly, not. In fact, this speech seemed to be more of an SNL satire than an attempt to manipulate voters. This likely has to do with GPT-2’s open-source limitations (remember, GPT-2 released a lighter
version by design) and my minuscule training data. If I had GPT-2’s full usability along with hours of transcripts from these candidates’ rallies, interviews, and filibusters, this speech would be a lot more convincing!

If you think Marco Rubio and Pete Buttigieg sound robotic, just wait until you hear BenBot in 2024.

👍,
Ben

For my full Github repository on this project, click here.
Also, visit Wallace2020.org to see what else I created to run for President!

Have any comments or recommendations for the LineByLine Team? Please reach out to us at linebyline.team@gmail.com.

--

--