⚙️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.
var baseModel = (await GenerativeAI.DefaultInstance.Models.List())
.FirstOrDefault(m => m.SupportedGenerationMethods.Contains("createTunedModel"));
Debug.Log(baseModel.ToString());
/* log
Model(name='models/gemini-1.0-pro-001',
base_model_id='',
version='001',
display_name='Gemini 1.0 Pro',
description=('The best model for scaling across a wide range of tasks. This is a stable '
'model that supports tuning.'),
input_token_limit=30720,
output_token_limit=2048,
supported_generation_methods=['generateContent', 'countTokens', 'createTunedModel'],
temperature=0.9,
top_p=1.0,
top_k=1)
*/base_model = [
m for m in genai.list_models()
if "createTunedModel" in m.supported_generation_methods][0]
base_modelYour 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.
Last updated
