Perform model tuning with client.Tunings
mainThe client.Tunings module allows you to fine-tune models. This is primarily available for the Gemini Enterprise Agent Platform (enterprise: true).
Supported tuning methods include:
- Standard Tuning: Training on a dataset using
TuneAsync. - Preference Tuning: Set
Method = TuningMethod.PREFERENCE_TUNINGinCreateTuningJobConfig. - Distillation: Set
Method = TuningMethod.DISTILLATIONand provide aBaseTeacherModelto train a student model. - Continuous Tuning: Pass the resource name of a previously tuned model as the
baseModelparameter to continue training.
// Example: Preference Tuning
var config = new CreateTuningJobConfig {
TunedModelDisplayName = "Tuned Model",
Method = TuningMethod.PREFERENCE_TUNING,
EpochCount = 1,
};
var tuningJob = await client.Tunings.TuneAsync(
baseModel: "gemini-flash-latest",
trainingDataset: trainingDataset,
config: config
);