Back to blog
Articles
May 9, 2023
·
7 MIN READ

How To Create A Custom Fine-Tuned Prediction Model Using Base GPT-3 models

May 9, 2023
|
7 MIN READ

Latest content

Tutorials
5 min read

Optimizing RAG with Knowledge Base Maintenance

How to find gaps between knowledge base content and real user questions.
April 23, 2024
Tutorials
4 min read

Scaling Quality Assurance with HumanFirst and Google Cloud

How to use HumanFirst with Vertex AI to test, improve, and trust agent performance.
March 14, 2024
Announcements
2 min read

Full Circle: HumanFirst Welcomes Maeghan Smulders as COO

Personal and professional history might not repeat, but it certainly rhymes. I’m thrilled to join the team at HumanFirst, and reconnect with a team of founders I not only trust, but deeply admire.
February 13, 2024
Tutorials
4 min read

Accelerating Data Analysis with HumanFirst and Google Cloud

How to use HumanFirst with CCAI-generated data to accelerate data analysis.
January 24, 2024
Tutorials
4 min read

Exploring Contact Center Data with HumanFirst and Google Cloud

How to use HumanFirst with CCAI-generated data to streamline topic modeling.
January 11, 2024
Articles
5 min

Building In Alignment: The Role of Observability in LLM-Led Conversational Design

Building In Alignment: The Role of Observability in LLM-Led Conversational Design
December 6, 2023
Articles
5 min read

Rivet Is An Open-Source Visual AI Programming Environment

Rivet is suited for building complex agents with LLM Prompts, and it was Open Sourced recently.
September 27, 2023
Articles
6 min read

What Is The Future Of Prompt Engineering?

The skill of Prompt Engineering has been touted as the ultimate skill of the future. But, will prompt engineering be around in the near future? In this article I attempt to decompose how the future LLM interface might look like…considering it will be conversational.
September 26, 2023
Articles
4 min read

LLM Drift

A recent study coined the term LLM Drift. LLM Drift is definite changes in LLM responses and behaviour, over a relatively short period of time.
September 25, 2023
Tutorials
5 min read

Optimizing RAG with Knowledge Base Maintenance

How to find gaps between knowledge base content and real user questions.
April 23, 2024
Tutorials
4 min read

Scaling Quality Assurance with HumanFirst and Google Cloud

How to use HumanFirst with Vertex AI to test, improve, and trust agent performance.
March 14, 2024
Announcements
2 min read

Full Circle: HumanFirst Welcomes Maeghan Smulders as COO

Personal and professional history might not repeat, but it certainly rhymes. I’m thrilled to join the team at HumanFirst, and reconnect with a team of founders I not only trust, but deeply admire.
February 13, 2024

Let your data drive.

How To Create A Custom Fine-Tuned Prediction Model Using Base GPT-3 models

COBUS GREYLING
May 9, 2023
.
7 MIN READ

LLMs can be divided into two categories: generative & predictive. The generative capabilities of LLMs have been the subject of much attention and discussion, and rightly so – they are incredibly impressive

The generative capabilities of LLMs have been the subject of much attention and discussion, and rightly so – they are incredibly impressive and often only require zero or few-shot learning.

The increasing popularity of Prompt Engineering has further highlighted the importance of generative tasks.

The image below shows the most common generative tasks from a Conversational AI Development Framework perspective, along with the predictive tasks.

The importance of correctly predicting an intent with a Large Language Model (LLM) is paramount, as the actions taken by a chatbot are based on this result.

To achieve this, both generative and predictive LLMs can be fine-tuned to create a custom model. OpenAI GPT-3, Ada is an example of a LLM that can be fine-tuned for classifying text into one of two classes, as seen in the image below.

As fine-tuning of LLMs becomes more commonplace, it will become the norm for mass adoption of LLMs in more formal and enterprise settings.

We are ready to begin!

The code below will allow us to access the training data from Sklearn . The command listed displays the various categories of data that have been archived from the original 20 newsgroups website.

These are the 20 categories available, from these we will make use of rec.autos and rec.motorcycles.

The code to fetch the two categories we are interested in, also assign the data to vehicles_dataset .

Below a record is printed of dataset:

The result shows that the data is disorganised and each entry has a high possibility of containing ambiguity or inaccuracy.

We can now determine how many records and examples we have for autos and motorcycles.

The printed result:

The next step is converting the data into JSON format defined by OpenAI here. Below is an example of the format.

The code to convert that data…

lastly, converting the data frame to a JSONL file named vehicles.jsonl:

Now the OpenAI utility can be used to analyse the JSONL file.

With the result of the analysis displayed below…

Now we can start the training process and from this point an OpenAI api key is required.

The command to start the fine-tuning is a single line, with the foundation GPT-3 model defined at the end. In this case it is ada. I wanted to make use of davinci, but the cost is extremely high as opposed to ada, which is one of the original base GPT-3 models.

The output from the training process.

And lastly, the model is queried with an arbitrary sentence: So how do I steer when my hands aren't on the bars?

The correct answer is given in motorcycles .

Another example with the sentence: Is countersteering like benchracing only with a taller seat, so your feet aren't on the floor?

And again the correct result is given as motorcycles .

As production implementations of LLMs become more widespread, more emphasis will be placed on fine-tuning them to maximise performance.

Nevertheless, the importance of fine-tuning LLMs is currently not being fully recognised.

I’m currently the Chief Evangelist @ HumanFirst. I explore and write about all things at the intersection of AI and language; ranging from LLMs, Chatbots, Voicebots, Development Frameworks, Data-Centric latent spaces and more.

Subscribe to HumanFirst Blog

Get the latest posts delivered right to your inbox