How To Quickly Generate Full Articles Using OpenAI’s GPT-2

Chad Bennett
HEROIC.com
Published in
4 min readFeb 26, 2019

Since hearing the recent news about OpenAI’s super text generator called GPT-2, I have been dying to dig into the research and test out the software. Although it is my opinion the decision to hold back the full implementation of GPT-2 is hype, ingeniously planned to generate more interest in OpenAI, there is a realistic expectation that this tool will be used for spammy and malicious purposes.

To my pleasant surprise, the initial work to get a limited implementation of GPT-2 running has already been developed and takes roughly 15 minutes to get working.

Use the following steps below to start generating your own AI modeled articles.

  1. Create or fire up your favorite Linux server. (For this test, I am using an AWS EC2 t2.medium instance using the Deep Learning AMI (Ubuntu) Version 21.2.)
  2. Log into your Linux box
  3. Update Linux box so it doesn’t get pwned.
$ sudo apt update
$ sudo apt upgrade

4. Install Dependencies that aren't already installed(Git, Python, PIP, Pytorch 0.41+, tqdm, regex)

# Upgrade Pip (Not necessary but beneficial)
$ pip install — upgrade pip
# Install Dependencies
$ pip3 install torch torchvision tqdm regex==2017.4.5

5. Install Software

# Download and cd into GPT2-Pytorch with Text-Generator script
$ git clone https://github.com/graykode/gpt-2-Pytorch && cd gpt-2-Pytorch
# Download huggingface's pretrained pytorch model
$ curl --output gpt2-pytorch_model.bin https://s3.amazonaws.com/models.huggingface.co/bert/gpt2-pytorch_model.bin

6. Run Software

$ python main.py --text "It was a bright cold day in April, and the clocks were striking thirteen. Winston Smith, his chin nuzzled into his breast in an effort to escape the vile wind, slipped quickly through the glass doors of Victory Mansions, though not quickly enough to prevent a swirl of gritty dust from entering along with him."

7. Have Fun!

As a test, I loaded the initial paragraph of this post into the text-generator to see what it would spit out. You can see the results at the bottom of this article.

If you are interested in using artificial intelligence to help build the next generation of cybersecurity, we could use your help at HEROIC.com. HEROIC Cybersecurity, was founded with a mission to protect humanity from the future of advanced cyber threats. Utilizing big data, artificial intelligence, and the blockchain, HEROIC is laying the framework necessary to protect against AI-based cyber threats and to build the next generation of cybersecurity.

SYSTEM PROMPT (HUMAN-WRITTEN): Since hearing the recent news about OpenAI’s super text generator called GPT-2, I have been dying to dig into the research and test out the software. Although it is my opinion the decision to hold back the full implementation of GPT-2 is hype, ingeniously planned to generate more interest in OpenAI, there is a realistic expectation that this tool will be used for spammy and malicious purposes.

SOFTWARE OUTPUT (AI MACHINE-WRITTEN): The main thing to know about GPT-2 is that it will become more useful as the time comes for real-time data sharing and analytics. It will make it easier to track users and the time is limited in comparison with regular speech analysis. The data will be stored in a secure location and the process will be as simple as typing the message from a phone.

While the software makes use of the OAuth 2.0, it does not support an OAuth 3.0, it does support a simple form of authentication. While the OAuth 3.0 is not as secure as the OAuth 2.0, it does not have the security issues of OAuth 3.0. You must use a valid OAuth 3.0 and use a secure connection from your computer, to get access to the data you need.

The system is also not designed to replace speech analysis, but rather to give you a better grasp of the content of your messages. There is no need to be so precise about what you are saying, but we will assume that the user is going to be using one of the most popular OAuth 1.0 protocols.

Once you are able to read the message in real time, the user can view it using the chat window. I would not recommend this to anyone, but it can be useful to share your messages with other users.

The chat window displays the content of messages. The user can click on the message to view it or press the chat button. When the message is viewed, it will show the user a list of all the messages they have read.

If the user clicks on the message that he or she wants to read, he or she can also read it. If they click on the message that the user wants to read, they can either fill in the blank message, or the user can click the message that the user wants to read.

OpenAI has already started to test out the code and is ready to deploy it.

The project has been completely tested on OpenAI VPS platform. It now has over 7 million registered users. OpenAI VPS is the platform that can store and manage OpenAI data.

In order to get your hands on OpenAI VPS, you will need to purchase an OpenAI VPS for your Linux, Mac OS X, or Windows PC.

The OpenAI VPS is available for free download from https://openai.openai.org/

Works Cited

AI Generated Text. Screenshot from https://blog.openai.com/better-language-models/

--

--

Chad Bennett
HEROIC.com

CEO at HEROIC Cybersecurity(@heroiccyber), 3x Inc 500, Ironman Finisher, Father of 6. Artificial Intelligence + Big Data + Blockchain = Nextgen Cybersecurity.