DEV Community

Danyaal
Danyaal

Posted on

GPT2 Article Generator

My Final Project

I built an application to allow for generating news articles using OpenAI's GPT-2 text generator. The headline is provided by the user and they can optionally provide the start of the article, then it generates the rest of the article. The program has both a command line interface and a GUI, making it easy to use but also making it easier to integrate into other tools.

Link to Code

https://github.com/DanTm99/gpt2-article-generator

GitHub logo DanTm99 / gpt2-article-generator

An application that uses GPT-2 to generate news articles from user given prompts

GPT2 Article Generator

An application to allow for generating news articles using OpenAI's GPT-2 text generator. The model used for this was further trained on All The News, a dataset of over 200,000 news articles by components.one.

Setup

The repository can be cloned as normal:

git clone https://github.com/DanTm99/gpt2-article-generator.git

The model this program uses is hosted on Google Drive and can be downloaded from here. The contents of this archive should be extracted to the gpt2-article-generator folder so that the checkpoint is in the gpt2-article-generator folder.

Navigate into the folder:

cd gpt2-article-generator

To use this with your GPU you must have and NVIDIA GPU with a CUDA Compute Capability 3.5 or higher.

If you have the required hardware you must install the required software on your system as shown here.

Install the required packages as normal to use this with GPU support:

pip3 install -r
…

How I built it (what's the stack? did I run into issues or discover something new along the way?)

I coded the project in Python and used TensorFlow as the models that were the focus on this project were TensorFlow models. In making this I learned how to interact with GPT-2, including further training it and using it to generate text in various ways.

Top comments (0)