⚙️Fine-tuning
Create tuned model
To create a tuned model, you need to pass your dataset to the model in the genai.create_tuned_model
method. You can do this by directly defining the input and output values in the call or importing from a file into a dataframe to pass to the method.
For this example, you will tune a model to generate the next number in the sequence. For example, if the input is 1
, the model should output 2
. If the input is one hundred
, the output should be one hundred one
.
Your tuned model is immediately added to the list of tuned models, but its status is set to "creating" while the model is tuned.
Evaluate your model
You can use the GenerativeAI.DefaultInstance.TunedModels.GenerateText
method and specify the name of your model to test your model performance.
It really seems to have picked up the task despite the limited examples, but "next" is a relatively simple concept, see the tuning guide for more guidance on improving performance.
Update the description
You can update the description of your tuned model any time using the GenerativeAI.DefaultInstance.TunedModels.Patch
method.
Delete the model
You can clean up your tuned model list by deleting models you no longer need. Use the GenerativeAI.DefaultInstance.TunedModels.Delete
method to delete a model. If you canceled any tuning jobs, you may want to delete those as their performance may be unpredictable.
If the model no longer exists, it will return an error:
<class 'google.api_core.exceptions.NotFound'>: 404 Tuned model tunedModels/generate-num-2946 does not exist.
Last updated