OpenAI Models Fine-Tuning
In this example we are going to teach an OpenAI model, how to write MindsDB AI SQL queries :)
All OpenAI models belong to the group of Large Language Models (LLMs). By definition, these are pre-trained on large amounts of data. However, it is possible to fine-tune these models with a task-specific dataset for a defined use case.
OpenAI supports fine-tuning of some of its models, including davinci
, curie
, babbage
, and ada
(more details here). And with MindsDB, you can easily fine-tune an OpenAI model making it more applicable to your specific use case.
Let’s create a model to answer questions about MindsDB’s custom SQL syntax.
First, create an OpenAI engine, passing your OpenAI API key:
Then, create a model using this engine:
You can check model status with this command:
Once the status is complete, we can query for predictions:
On execution, we get:
If you followed one of the MindsDB tutorials before, you’ll see that the syntax provided by the model is not exactly as expected.
Now, we’ll fine-tune our model using a table that stores details about MindsDB’s custom SQL syntax.
Here is a table we’ll use to fine-tune our model:
And here is its content:
This is how you can fine-tune an OpenAI model:
The FINETUNE
command creates a new version of the openai_davinci
model. You can query all available versions as below:
Once the new version status is complete and active, we can query the model again, expecting a more accurate output.
On execution, we get: