Do you think that building an NLP based AI application such as a chatbot or a Translator requires a lot of data science skills and would take a lot of time? It is not always true, this article will help you better understand. I am going to show how to use GPT-3 to build some amazing NLP based AI applications with minimal development effort. Before getting into the build let’s first understand what GPT-3 is and what are all the features of GPT-3 that make it so special.
What is GPT-3?
GPT-3 is Generative Pre-trained Transformer 3, it is a language model trained on a vast number of datasets from the internet and developed by a company called OpenAI. GPT-3 is being offered via API, currently, the API is in a controlled beta and there is a waitlist for one to gain access to this amazing API.
Below are some reasons why the GPT-3 model has been most talked about for
- GPT-3 model consists of 175 billion parameters, the previous version, GPT-2 model had only 1.5 billion parameters. Parameters are weights in a neural network model that transforms the inputs to output
- It is a generative model which means that it has the ability to generate a long sequence of words that is coherent as an output
- This state-of-the-art language model can respond to almost any question passed on to it and that too in a more humane way
- Billions of words, text, and code snippets used in model training hence make it capable of auto code in a wide range of programming languages
- Its Multilingual text processing help to work on languages other than English as well
- The best part is GPT-3 model can perform a specific task, such as being a translator or a chatbot or code builder without any customization or any special tuning, all it needs is a few training examples
To learn more about the technical details of this amazing model check out here. Here in this article, I am going to show you how this amazing API can be used to solve different NLP based AI use-cases.
Getting Access to the GPT-3 Beta API
To build the use-cases covered in this article, you need to have access to the GPT-3 beta API. It is currently available only on an invite, you can apply for access using the below link. It will take you to a form where a couple of questions will be asked about your organization and the project you are planning to implement.

Implementation Background
To interface with the GPT-3 API, I am going to use a script from the following gpt3-sandbox repository. The script I am using from this repository is gpt.py available at the API folder that enables me to access the GPT-3 API hence making it possible to show different use-cases that can be solved. The scripts used in this article can be found here
Use-case 1 – Chatbot
Here we are not going to pass any training examples but just directly access the API and use it as a chatbot.
In the below example, I am importing the required packages as well as the script we have downloaded from the "gpt3-sandbox" repository. We will be passing three arguments to the model they are,
- Engine – There are four options for us to choose from, they are Davinci, ADA, Babbage, and Curie. We will be using Davinci as it is the most powerful engine trained using 175 billion parameters
- Temperature – This is usually between the range 0 and 1, it is used to control the randomness of the generated output. A value of 0 makes the model deterministic that is, the output will be the same every time we execute whereas on the other hand with 1 there will be high randomness in the output generated.
- max_tokens – maximum completion length
In the below script the question that needs to be asked is passed on to the variable "prompt1" and then passed to the model using the submit_request function. The result is stored in the ‘output1’ variable as shown below,
In the above example, as you see the model can come up with a really good response for the question asked with no tweaking or tuning. Since here we are not providing any training examples the model output need not always be a response it could come up with a similar set of questions or with content related to the input passed. The performance can be improved by supplying some training examples
Use-case 2 – LaTex – Text to Equation
In the below example we are going to see the implementation of text to equation conversion with very minimal training which is not possible with other pre-trained models.
In the below example the temperature value has been increased to bring some randomness to the response and we are also passing some predefined examples to the model as a training dataset. With just 5 examples we could train the model to convert the text to an equation. After training the model with the known examples we pass the following as input "x squared plus 2 times " and the model converts it into an equation.
Use-case 3 -Translator (English to French)
Like above use-case with a few examples, we could train the model to behave like a translator. Below is the code for the translator module where we train the model to translate the text in English to French with just three examples.
This ability of the model to perform a specific task like "foreign language translator" or "text to equation converter" with very minimal development effort makes it very special.
Below is a tutorial video where I provide a walk-through of the use-case implementation.
Some cool applications created using GPT-3
To learn more about interesting applications built using GPT3 check this page here.
About Me
I am a Data Science professional with over 10 years of experience and I have authored 2 books in data science. I write data science-related content intending to make it simple and accessible. Follow me up at Medium. I have a YouTube channel as well where I teach and talk about various data science concepts. If interested, subscribe to my channel below.