10.02.2023 Update: If you are looking for a quick way to customize your chat widget with your own products and contents, you can watch this video tutorial here and head over to Embeddings section in the plugin.
I Know Kung-Fu
You can think of fine-tuning a model as “plugging in a chip” like Neo in The Matrix, where after he is plugged in and completed his training, he is able to instantly access new knowledge and skills.
When he woke up from his training, his first word was “I know Kung-Fu”.
Similarly, fine-tuning a model using your own data allows the model to quickly access and understand information specific to your company, product, or website content.
Ley say you would like to train your AI to answer specific questions about your website content, company, product etc..
You can achieve this by fine-tuning a model using your own data.
Please note, this process requires a lot of efforts.. Preparing a high quality data is the key here..
And you need to do a lot of tests to achieve best results.
My aim is to build a bridge between WordPress and OpenAI. So users without technical or coding knowledge can easily use OpenAI’s API.
All you need to do is prepare your data and upload it to the plugin.
If you need a consultant to help you with this process, please hire me. You can get in touch with me here.
You can watch a short demo video here:
How to Train your AI
So.. Let’s get started..
Fine-tuning a model in OpenAI involves a few steps.
Here is a detailed explanation of how to fine-tune a model using our plugin.
There are 3 different ways of uploading your data to OpenAI and starting a fine-tuning process:
- Upload data directly from your computer: You can use this tool if you already have your data in the required format.
- Manual data entry: Manually enter your data. You can use this tool if you want to enter your data manually.
- Data converter: This tool is one of the most popular one because it allows you to convert your database to the required format with one click.
1. Upload data directly from your computer
-
- First, navigate to the Datasets tab.
- In the Datasets tab, you will be able to upload your datasets. Please note that OpenAI only accepts
*.jsonl
files and the maximum upload size is 100MB per file.
To upload larger datasets, your WordPress maximum file upload size setting should be set to at least 100mb. You can follow this guide here. - Here is an example of a
*.jsonl
file: - As you can see, the file contains prompt and completion pairs. The prompt is the question and the completion is the answer. You can find some examples here.
- There are 4 fields in the Datasets tab that you need to fill in.
- File: Click on the “Choose File” button to select the file you wish to upload. As I mentioned earlier, OpenAI only accepts
*.jsonl
files and the maximum upload size is 100MB per file. Learn about file format here. - Purpose: Select the purpose. Currently there is only one option which is “Fine-tune”.
- Model Base: Select the model base you wish to fine-tune your model. You can select from the dropdown list. Options are: ada, babbage, curie and davinci.
- Custom Model Name: Enter the custom model name for the fine-tuned model. This is optional. If you leave it blank, the fine-tuned model will be named after the model base you selected. I suggest you to use a custom model name so you can easily identify the fine-tuned model.
- File: Click on the “Choose File” button to select the file you wish to upload. As I mentioned earlier, OpenAI only accepts
- Once the file is uploaded, it will be displayed on the same tab. You can view information such as the file’s ID, size, creation date, filename, and purpose. There is also an “Actions” column where you can perform various actions on the uploaded files, such as creating a fine-tune request, retrieving content, and deleting the file.It will look something like this:
- If you wish to view the content of the file, you can click on the “Retrieve Content” button. For security reasons, OpenAI does not allow free plan users to view the content of the uploaded files. If you wish to view the content of the file, you will need to upgrade your account to a paid plan.
- To delete the file, click on the “Delete” button.
- If you did not receive any error messages up to this point, congratulations, you have succeeded! Now, let’s move on to creating a fine-tune request.
2. Manual Data Entry
- First, navigate to the Manual Entry tab.
- In the Manual Entry tab, you will be able to manually enter your data.
- Let say you want to enter your product data.Here is an example of a product data:
{"prompt":"Item is a handbag. Colour is army green. Price is midrange. Size is small.->", "completion":" This stylish small green handbag will add a unique touch to your look, without costing you a fortune."}
It will look something like this:
- Click on “Add more” to add more data.
- Once you have entered all your data, select a model base, give a custom name (optional), and click on “Upload”.
- If you did not receive any error messages up to this point, congratulations, you have succeeded! You can start creating fine-tunes.
3. Data Converter
-
- First, navigate to the Data Converter tab.
- In the Data Converter tab, you will be able to convert your entire Database to a JSONL file.
- This is how it looks like:
- There are 3 different options here.
- Convert Your Posts: This will convert all your posts in your DB to a JSONL file. Please note that this process will take a while depending on the number of posts you have. If you have huge DB it will split the datasets in small pieces.
- Convert Your Pages: This will convert all your pages in your DB to a JSONL file. Please note that this process will take a while depending on the number of pages you have. If you have huge DB it will split the datasets in small pieces.
- Convert Your WooCommerce Products: You will see this feature only if you have WooCommerce installed. This will convert all your WooCommerce products in your DB to a JSONL file. Please note that this process will take a while depending on the number of products you have. If you have huge DB it will split the datasets in small pieces.
- Important note: If you have huge DB, conversion might take longer and your website might become unresponsive if resources are not enough.
Creating Fine-Tunes
-
- To create a fine-tune request, click on the “Create Fine-Tune” button. This will create a fine-tune request on the OpenAI API based on the uploaded dataset.
- There is an important step here before creating your fine-tune request. You need to either create a new model or select an existing model from the dropdown list. If you select an existing model, the fine-tuned model will be created based on the selected model. If you create a new model, the fine-tuned model will be created based on the model base you selected when you uploaded the dataset.
Here is an example of a fine-tune request:
So why this step is important? Because you can create multiple fine-tune requests for the same dataset. For example, you can create a fine-tune request for the same dataset using different model bases. Or you can create a fine-tune request for the same dataset using different models. This way, you can compare the results and choose the best model for your use case.
A possible scenario is that you have huge dataset that is not possible to upload to OpenAI because of the 100MB limit. In this case, you can split your dataset into multiple files and upload them to OpenAI. Then, you can create a fine-tune request for each file using the same model base. This way, you can create a fine-tuned model based on the same model base but with different datasets.
-
- If you wish to upload a file for the same model, you will need to select the model from the dropdown list when you hit the “Create Fine-Tune” button.
- If you did not receive any error messages up to this point, congratulations, you have succeeded! Now, let’s move on to viewing the fine-tune requests.
Viewing Fine-Tune Status
-
- To view the fine-tune requests, click on the “View Fine-Tunes” button. This will display all the fine-tune requests you have created.
- Here is an example of a fine-tune requests:
- You can view information such as the fine-tune request’s ID, creation date, model, and status. There is also an “Training” column where you can perform various actions on the fine-tune requests, such as viewing the fine-tune request’s details, viewing the fine-tuned model, and deleting the fine-tune request.
- There are 4 buttons in the “Training” column: Events, Hyper-params, Result files and Training files. Let’s take a look at each one of them.
- Events: This button will display the fine-tune request’s events. You can view information such as the event’s ID, creation date, and status.
It’s important to note that fine-tuning a model can take some time, depending on the size of the dataset and the complexity of the model.Here is an example of a fine-tune request’s events:If the last message says “Fine-tuning succeeded”, then the fine-tune request is complete and your model is ready to be used.
- Hyper-params: This button will display the fine-tune request’s hyper-parameters. You can view information such as Epochs, batch size, Learning rate, and prompt loss weight.Here is an example of a fine-tune request’s hyper-parameters:
- Result files: This button will display the fine-tune request’s result files. You can download the result file from training the model.Here is an example of a fine-tune request’s result files:
And here is how a result file looks like:
- Training files: This button will display the fine-tune request’s training files. It is basically the file you uploaded to OpenAI.
- Events: This button will display the fine-tune request’s events. You can view information such as the event’s ID, creation date, and status.
- If you made it this far, congratulations, you have succeeded! Now, let’s move on to viewing the fine-tuned models.
Using Fine-Tuned Models
- Let say you already have a fine-tune request that is complete. Now, you want to use the fine-tuned model to with ChatBox in your website. To do that, please proceed to the plugins settings page and click ChatGPT tab.
- Here is an example of the ChatGPT tab:
- You will see that your fine-tuned model is now available in the dropdown list. You can select it and click on the “Save Changes” button.
This means from now on your ChatBox will use the fine-tuned model you selected. - If you don’t see your fine-tuned model in the dropdown list, please make sure that the fine-tune request is complete. You can also click on “Sync Models” link to get latest models.
- Now head over to the ChatGPT and ask your ChatBox a question. You should see that the ChatBox is now using the fine-tuned model.
- Please note, I can not guarantee that the fine-tuned model will work for your use case. It is up to you to test it and see if it works for you.As I mentioned before, dataset quality is very important. If you have a small dataset, you might not get good results. If you have a huge dataset with really well-defined prompt and completions, you might get good results. It all depends on your use case.