Open AI GPT 3
Open AI GPT 3
You're in luck! This E-book will teach you everything you need to know. It's perfect for
anyone who wants to get started with AI writing.
With this E-book, you'll be able to create AI models that write high-quality content which
outperforms anything other tools could produce. In addition, you'll be able to take your
business to the next level with AI-generated content.
I will keep this as short as possible and offer you as much information in images as
possible.
Tools we are going to need for this to work and train OpenAI.
To get started with OpenAI, the first thing you need to do is register for an account. You can do
this by visiting the OpenAI website and clicking on the "Sign Up" button. Once you have
registered, you can access the OpenAI platform and start using its various features.
Navigate to the “footer” section of the website and press “Login.” From there, you should be able
to log in with Google and follow the steps to complete your account creation.
Or you can just sign-up for a new account if you prefer that way.
I will teach you everything; however, it’s still good to look around and figure out some
things yourself. It will help in the long run!
The following tool we are going to need is Postman. You can sign-up for a free account
here: https://www.postman.com/postman-account/.
Postman allows us to send API requests to OpenAI and fine-tune files without having to
code(neat, isn’t it?).
It should look like that after accessing the link. But, do not worry, it’s free to use up to
certain limits!
We will need that to create the datasets for the fine-tuning, which can be used afterward
in OpenAI to produce our content.
This one is also free; just click the link and go to the “chain with…”.
JSON strings are easy for computers to read and understand, making them the perfect
choice for training an AI model. By converting our text data into JSON strings, we will be
able to teach our AI more effectively and help it learn more quickly. Ultimately, this will
help us create better AI models that can be used for various tasks.
We will get into this later on. But, first, let’s jump to the central part: creating our Postman
workspace and preparing for fine-tuning.
It’s good to have all the tools ready, so let’s download one more that will help us later.
That is https://code.visualstudio.com/, Visual Studio Code. Installing this will enable you
to write the JSON strings later, which are used to fine-tune.
Simply - press the download button, and the process is simple. You just need to install it,
and I will teach you later how to use it and what we need from it.
In the next section, we will learn about Postman and how to configure it for OpenAI
fine-tuning.
I will try to keep this as simple as possible. So, for example, you wouldn’t have to spend your
time reading. Images for the win!
After that, the page you are redirected to is the workspace creation, which will require
you to input a “name” and a “summary,” basically a description of your project.
Link: https://beta.openai.com/docs/api-reference/files
Our first job is how to upload a file to OpenAI using API(that file will contain our datasets
later on). For this example, we shall use dummy content.
Great!
Not a big deal. Then just press “enter,” and it should save the fine.
Now we want to add our first “request.”
If you read anything on the OpenAI documentation, you know the URL and the type of
request we need to make.
https://api.openai.com/v1/files
H e r e ’ s h o w i t s h o u l d l o o k :
As you can see, the link is added under the “POST.” So just copy/paste it in the free
space.
You can also rename the request, so we know what it does; I will use “Upload file to
OpenAI.”
The example below will suffice. I am positive you can do this without much hassle.
Getting our API key from OpenAI
We all of this to work, we will need the API key from the OpenAI account. Don’t worry.
OpenAI grants you 18$ of free credit, so the key is also available.
After clicking that, you should be able to create or use an existing Key provided by
OpenAI.
Afterward, it’s just a matter of copying/pasting the key.
We want to create our upload file request in Postman. Therefore, we need to set up the
environment for it first.
Under the “upload file to OpenAI.” request we’ve just created, go to > headers. Now, do not really
bother yourself with what Postman has as default; we will add our own entries.
Great. Now on the right side of it, we will add our API key from OpenAI.
Go to OpenAI and the API keys and copy or create a new secret key to use in our
process.
We are done with configuring the Headers. We now need to jump into the “body section”
and create a purpose + add the same API key.
This process will help us to complete the process - please check the image below for
reference and help.
Now that you’ve found it, the next step is to add some keys and values that will
correspond to OpenAI.
Firstly we want to add a “purpose,” then a “file,” which will be our dataset file as already
specified.
Please ensure that the “file” is set to “file” and not to text, as this will differ and will not
allow you to upload/select anything.
Remember that OpenAI takes only.JSONL type of files when it comes to fine-tuning, so I
will give you my dummy data for this purpose.
We will use the Visual Studio Code to open that file, so do not worry for now if you have
not installed it. However, I recommend installing it as we’ll need it soon!
If you’ve downloaded the file, all that is left is to upload it. Press “select files” and just
choose the paragraphs.jsonl -
That’s what our final result should look like. While we are at it, do not forget to save your
progress in Postman. Just use “CONTROL + S” on your keyboard. That will keep it.
Our last step is to send the request and see if the answer is positive.
Press the “send” button.
That is the result we are looking for. OpenAI documentation shows us what we need to
see to recognize success. However, sometimes the Postman glitches, and the requests
do not send. Worry not. Just restart the website and log in again.
Making the fine-tuning process in Postman
Now that we are done with the “file upload” and learned how to upload our file to OpenAI through
API request, things are becoming easier.
We will focus on creating the process that fine-tunes the file/dataset we make. So let’s jump right
into it!
Let’s go back a step and create a new request in Postman. We shall call this a “fine-tune
process.”
Just input the link in the POST request as we did with the “file upload.
The exact process of adding our API key from OpenAI again.
Now we are going to press on the “Body” section and go to > “raw.”
That is where you are going to add the settings for fine-tuning. Here are my current ones:
{
"training_file": " ",
"model": "davinci",
"suffix": "bgdtune"
}
Suffixes can be anything you want, from your name to your favorite pet :). So we will use that later on!
Hopefully, you have followed that correctly, and that’s the result.
Now you may be wondering where to get the “training_file” ID. That’s simple; let’s return to our
“upload file” request and get it!
If you did not find it, press the “send” button to forward the request to OpenAI. Finally, let’s press
CONTROL + S to save our current progress in Postman.
Now that we are almost done with this, while you are on the “fine tune process” request, go to the
“send” button and click it.
That will send the file to OpenAI and start training it.
If you see this, then you are set. The file has been successfully sent to OpenAI, and it’s being
trained.
Congrats, seriously!
You made it this far, pat yourself on the shoulder, and let’s move to the next big part!
Retrieve our fine-tuned info from OpenAI
This will not be as complicated as the others, I promise. All you need is the API key from the
OpenAI account.
You can get that from the “fine tune process” request.” Then, after pressing send and getting the
response, the ID is listed right at the beginning.
As in the picture above, that’s how it looks. Now replace the (File_ID) with the real one.
That’s our final desired output. With the “Authorization” and the API key added. DO NOT
FORGET THAT!
Result:
{
"object": "fine-tune",
"id": "ft-puPlI5XhwrzD0lvW0YfMH6Op",
"hyperparams": {
"n_epochs": 4,
"batch_size": 1,
"prompt_loss_weight": 0.1,
"learning_rate_multiplier": 0.1
},
"organization_id": "org-Ygwg5D3pYmJxnsfIU6OUTd8D",
"model": "davinci",
"training_files": [
{
"object": "file",
"id": "file-GnQokZYstWYTzjg0IOlmrKcG",
"purpose": "fine-tune",
"filename": "paragraphs.jsonl",
"bytes": 41901,
"created_at": 1658510960,
"status": "processed",
"status_details": null
}
],
"validation_files": [],
"result_files": [],
"created_at": 1658511065,
"updated_at": 1658511070,
"status": "pending",
"fine_tuned_model": null,
"events": [
{
"object": "fine-tune-event",
"level": "info",
"message": "Created fine-tune: ft-puPlI5XhwrzD0lvW0YfMH6Op",
"created_at": 1658511065
},
{
"object": "fine-tune-event",
"level": "info",
"message": "Fine-tune costs $1.05",
"created_at": 1658511069
},
{
"object": "fine-tune-event",
"level": "info",
"message": "Fine-tune enqueued. Queue number: 3",
"created_at": 1658511070
}
]
}
That’s what yours should be like as well. Which means? Yes, you’ve thought that right! Our file is
being fine-tuned and is almost ready!
I did not add an image as the response is too long to be visible. The desired fine-tuned file will be
available to us in the “Playground” of the OpenAI. That takes some time. Worry not will be there
:).
Getting a list of fine-tunes info from OpenAI
Let’s say you got more files being fine-tuned right now. What are you going to do? Checking
each of them at a time may be boring, so there’s an option to list them all.
In the “Headers,” add “Authorization” and the “API KEY.” - Then just press “send.”
Our final output should be a “200 OK,” and the response from the OpenAI shares details of your
fine-tuned data.
That will list all the fine tunes you have (If you have many).
This is it. Now you just wait for your file to be processed by OpenAI and appear in the
Playground.
Here is where you are going to install Visual Studio Code. If that’s too daunting, then here is a
video that you can follow: How to install Visual Studio Code on Windows 10/11 [ 2022 Upd…
After you’ve installed the visual studio code, we are ready to go forward and create our datasets.
Why? So we can submit them as we’ve learned to OpenAI and train our model.
Automated data entry can be inaccurate and lead to errors in your datasets.
By manually building your datasets, you can ensure that the data is accurate and reliable. In
addition, you have complete control over the prompts and completions, so you can customize
them to match your specific needs.
That is how Visual studio code looks like on the inside. If you successfully installed it, then this is
the output.
Now, do you remember I gave you a file paragraphs.JSONL to download while we were
uploading dummy data to OpenAI?
If you still have it, we are going to use it here. If not, just look for the link above at the beginning
of this E-book. The link is there!
That file contains some data from my “paragraph” generator. It’s just a tiny part to get you
accustomed to the datasets.
In the visual studio code -> go to -> File -> Open File - > Open paragraphs.JSONL
I assure you, it’s not super-duper-complicated once you get the hang of it.
What is completion? Completion is how you train the AI. For example, your desired output so
the AI will parse it and follow its pattern.
The program that converts text to string? The one above is in the “tools” section. That's your
lifesaver. Check it out, prepare it, because we have a storm coming.
As you can see, datasets are formed from a “prompt” and the “completion,” which means “ideal
text generated” - what you want the generated text to look like. So that’s what you are training
the AI on.
Let’s break it down in an example with my paragraph generator. For that, I have used Jasper.AI
to form our Prompt + Completion. Look at this ->
{"prompt": "How to make money online with YouTube\nKeywords: Make money
online, Youtube\nTone of voice:Informative\nParagraph:", "completion":"
Making money online is a great way to earn some extra cash, and there are
plenty of ways to do it. One popular option is to make money with YouTube.
You can make money on YouTube by creating and publishing videos that
generate advertising revenue, or by partnering with existing channels and
companies as an influencer or product promoter. To get started, you'll
need to create a channel and start building up a following. Once you have
a sizable audience, you can begin pursuing opportunities to make money.
There are a few different ways to make money on YouTube, so be sure to
research the options and find the one that best suits your needs. With a
little effort, you can start making money with YouTube in no time."}
What is your paragraph about: How to make money online with YouTube
Keywords: Make money online
The tone of voice: Informative
Paragraph: *Here is where the AI will generate your desired output after being trained*
So breaking that down would be us telling the AI what the paragraph is about, the keywords we
want it to follow, the tone of voice, and in the end, the desired output(completion).
I know this may be a little overwhelming, but trust me, it takes you a little time to get used to it.
However, once your brain has adjusted to the situation, it is just a matter of time until you create
insane things like “paragraph generator,” “AIDA Marketing,” “Article generator,” etc.
And since my model is done training, here is what it will look like in the OpenAI’s playground.
As you can see, your trained model will appear under the “Fine-Tunes”. So all you have to do is
to follow the instructive model you’ve used in the training file.
Now that you have an excellent idea of what it will be like, creating a dataset based on your use
case is not that complicated.
If you follow the patterns in the dummy file I’ve given you, nothing is stopping you. However, for
the sake of this guide, I will show you one example.
Let’s say you want an AIDA generator(Attention, Interest, Desire, Action) marketing tactic. Oh,
that’s how it is going to be.
Company: Jasper
Product Description: Jasper AI is an AI writing assistant that helps you write content faster,
better, and easier.
Tone of voice: engaging
AIDA Generated(Completion): “Attention: Feeling overwhelmed by the thought of writing a blog
post, article, or even an email?
Interest: Jasper AI is here to help! This AI assistant will take care of all the tedious work for you
so that you can focus on what’s important – creating content that engages your audience.
Desire: Writing doesn’t have to be complicated. With Jasper AI, you can write like a pro in no
time. Plus, our software is constantly learning and evolving so your content will always be fresh
and original.
Action: Sign up for a free trial today and see how Jasper AI can help you write better content
faster!”
That’s what Jasper generated when using its AIDA framework. All you have to do is develop with
it and reverse-engineer it by training your own AI with it. Simple enough?
All I did with the text was run it through the tool that converts text to JSON strings(see in the tools
above) and input it in the “completion.” BAM! A part of the fine-tuning is done. There are 499 to
come :).
Let’s say you want the AI to write product descriptions. Watch how I turn one of the above strings
into a prompt to train the AI.
So we always have the {“prompt”: “then the prompt text,” followed by a completion(your ideal text
to train the AI on),” completion”: “Here you input high-quality training content”}
Does this sound easy? I hope so, and it is when you’re getting into it. Let’s jump back to the
product description example.
{“prompt”: “Product: Google Ads \nDescription: Google Ads are the best way of advertising
online.\nFinal Output”, “completion”: “Introducing Google Ads. The right and the best way of
advertising your product online on autopilot.”}
This is how this would look in a prompt:
Product:
Write a short product description:
Final output(completion:
Then the AI would follow the “completion” given in the training to write a completely new and
high-quality one related to the product and product description input by the user.
-> that “\n” stands for “new line,” so basically, it helps the AI form an idea about the training
format we’re using.
->completion is the ideal text generated we are training the AI with. So you’re feeding one
example of a high-quality product description, and the AI will follow the pattern and formatting for
creating new ones.
->Product and Description represent precisely what they mean—teaching the AI how to format
this. First, we tell it that we need a product and a description. Then the user inputs a short
description of the product and gets to the “Completion,” which generates high-quality content.
Pay attention(Update!):
-> https://www.mediafire.com/file/kya7ns5bspmzasw/Blog_Introductions.jsonl/file
Here is a dataset to create an “article generator.” Just follow the given examples for this
one, and you should be fine!
-> https://www.mediafire.com/file/1buyu1ybn1zbx3u/Testsv2.jsonl/file
As long as you follow these examples + the one I’ve given above (paragraph generator),
you should be able to create anything!
You can use this formatting model to train the AI on literally anything. I hope that was clear
enough and easy enough because it is the best way you can do this.
OpenAI said, “For a high-quality fine-tuning session, 500 or more completions are required”.
Urgh, that will take your time. But is it worth it? Completely, yes.
What’s left? Create a dataset using Visual studio code and the examples I gave you. Then, feed
it real examples from Jasper or Google articles. Do not worry; it won’t copy/paste and create
plagiarised content. The AI will only follow the pattern.
You can have a tool of your own in no time with custom-trained models that generate better and
faster outputs at a fraction of the cost. :)
● First, keep your data training examples simple, and do not crowd your prompts.
● Always have the file in a . JSONL format(probably you know that already, just remember!)
● If the use cases are the same(can be any use case), you can train it in multiple niches.
However, if your project is too big and requires many data training examples, you should
lower it.
● 500 lines are enough for small frameworks. (Up to 100-150 words outputs).
● Anything that requires quality outputs should be fine-tuned with more than 1.000 lines.
● Creating things like "Article generators" requires a lot of training examples. A LOT.
● That's why I suggest creating a dataset and uploading it to AI21 Labs(another AI tech like
OpenAI); they do better with longer-form outputs.
When we say “fine-tuning,” we are not training or teaching the AI new things. Please remember
that it has already been given access to the internet itself!
When we fine-tune, we actually just do this: Hey, AI! So please take these instructions and
examples and write for me that way.
Here are two other use-cases JSONL files. The AIDA and PAS frameworks are waiting for you to
be filled and fine-tuned!
Download: https://www.mediafire.com/file/hjskdic99d0e6d0/AIDA.jsonl/file
Download: https://www.mediafire.com/file/ai3dfs02tpsri96/PAS.jsonl/file
These two files are also DIY(Do it yourself). So just follow the given instructions to fill the files
correctly and get your own frameworks!
Download: https://www.mediafire.com/file/c3zfzybzsk5270j/BHWgoo.jsonl/file
Download: https://www.mediafire.com/file/v6wmdj2g6gb6a3w/BHWout.jsonl/file
Blog Conclusion Paragraphs:
Download: https://www.mediafire.com/file/z5ztgjptbz9qy4b/BHWconc.jsonl/file
Product Descriptions:
Download: https://www.mediafire.com/file/hrzpcmaqocqcy8w/BHWprd.jsonl/file
Long story short: AI 21 Labs is another AI tech that competes with OpenAI
regarding text generation(completion). They have been in the market for a decent
amount of time, and I think their technology is really great.
We’ve run some tests. Some of them were great, but some of them just failed to
deliver.
They give you 90$ in free credits! Amazing. You actually get to test their stuff
correctly, even fine-tune some models.
I will now show you how it looks on the inside. Well, as you would imagine,
nothing is out of the ordinary. However, they do give you access to some
pre-made frameworks and get to play around.
You can even press the “new” button and create your own framework in no time at
all. Of course, that is not precisely fine-tuning, but it’s pretty cool to play around
until you get used to things.
How to fine-tune with AI21
Compared to OpenAI, which has an entire learning curve, AI21 comes in with a simple
design.
Let’s just look above and see what we find :D.
Yep, as simple as that. Just navigate to the “datasets” section and press the “upload”
button.
That will prompt you to ask for the .JSONL file(dataset) you want to upload.
Then you can see live how your fine-tuning is going by pressing “Models.”
Once everything is done, you will find a model similar to OpenAI in the Playground.
All that is left is to select the model you’ve fine-tuned. Since you will give it a name, it’s
very easy to find.
And use it in the playground or take the “code” out to make an application.
It’s that simple with AI 21. Thank you for taking the time to read and learn.
Do you know what’s worse than not being able to fine-tune? Yep, that’s right. It’s worse
not knowing how to find the correct information and how to place it within your dataset.
All the datasets I’ve shared contain a prompt and completion; however, they are made
for you to fill with information. Otherwise, you can’t exactly learn the proper process and
how to find that info.
Go to google.com (wow, complicated, thanks.), and let’s say you want to fill in the
Product description generator dataset with information that it’s only a little above this
section.
Yes? Ok.
And let’s search for “Best TVs 2022”. Of course, there are many results, and it’s
confusing what information you need to pull from there. Here is the situation where most
people get stuck.
Personally, I am picky. I hate taking information that I wouldn’t like on my website just
because I need to fine-tune something.
What I think: Do I want my website to have the product's pros and cons? Definitely! So
what happens? I take them with me.
Now below, you have the product description. Do I like that? Most certainly. Then what? I
also pull that with me.
Here is how I would format this in a dataset:
- You will have the AI write content similar to what ranks on the first page of Google.
- You can have the AI write the factual content in the OpenAI’s playground. (Oh, but
how?)
Here is how you can format that trained model in the Playground to keep it factual:
I am pretty sure this is easy to comprehend, and you already understood what this is and
how it works.
Short tip: You can add additional prompts in the playground after fine-tuning a model. I
know it’s mentioned above within the “Tips & tricks” section, but I will repeat it.
Keeping the dataset simple is very important. You can tweak everything afterward!
If you look closely, you will notice that I’ve included the “Pros and Cons” in that example,
so the AI will know exactly what I want and where I want.
Ok, I will give you another example. Let’s take the “Blog outline generator” dataset and
try to fill in the information.
How would I turn this into a ready-to-tune line? Go on Google and search for a random
blog topic/idea. In this case, I will take “How to book a plane ticket.”
Great! It does not precisely have an outline, but it has different points that look similar.
{"prompt": "Blog Topic: How to book a plane ticket\nBlog outline:", "completion": " Look
for flights in advance.\n\nCheck airfare deal websites.\n\nEnter your trip details on an
aggregator site.\n\nChoose how many stops you want to make.\n\nClick through to the
airline’s website.\n\nChoose your seat.\n\nChoose to make it a package deal or
not.\n\nRequest special accommodations."}
- We have a topic/idea.
- A section that separates the prompt from completion(“Blog outline”)
- Then we have the completion
Here is what I took:
Hopefully, this has been clear enough and did not confuse you!
# Now, here is what comes with the new update in the future and what you should
expect: