diff --git a/google/genai/tunings.py b/google/genai/tunings.py index 3138f1c2..e0f1239f 100644 --- a/google/genai/tunings.py +++ b/google/genai/tunings.py @@ -585,13 +585,6 @@ def _TuningJob_from_mldev( to_object, ['custom_base_model'], getv(from_object, ['customBaseModel']) ) - if getv(from_object, ['distillationSpec']) is not None: - setv( - to_object, - ['distillation_spec'], - getv(from_object, ['distillationSpec']), - ) - if getv(from_object, ['experiment']) is not None: setv(to_object, ['experiment'], getv(from_object, ['experiment'])) @@ -604,19 +597,6 @@ def _TuningJob_from_mldev( if getv(from_object, ['pipelineJob']) is not None: setv(to_object, ['pipeline_job'], getv(from_object, ['pipelineJob'])) - if getv(from_object, ['preferenceOptimizationSpec']) is not None: - setv( - to_object, - ['preference_optimization_spec'], - getv(from_object, ['preferenceOptimizationSpec']), - ) - - if getv(from_object, ['satisfiesPzi']) is not None: - setv(to_object, ['satisfies_pzi'], getv(from_object, ['satisfiesPzi'])) - - if getv(from_object, ['satisfiesPzs']) is not None: - setv(to_object, ['satisfies_pzs'], getv(from_object, ['satisfiesPzs'])) - if getv(from_object, ['serviceAccount']) is not None: setv(to_object, ['service_account'], getv(from_object, ['serviceAccount'])) @@ -627,9 +607,6 @@ def _TuningJob_from_mldev( getv(from_object, ['tunedModelDisplayName']), ) - if getv(from_object, ['veoTuningSpec']) is not None: - setv(to_object, ['veo_tuning_spec'], getv(from_object, ['veoTuningSpec'])) - return to_object @@ -891,13 +868,6 @@ def _TuningJob_from_vertex( to_object, ['custom_base_model'], getv(from_object, ['customBaseModel']) ) - if getv(from_object, ['distillationSpec']) is not None: - setv( - to_object, - ['distillation_spec'], - getv(from_object, ['distillationSpec']), - ) - if getv(from_object, ['experiment']) is not None: setv(to_object, ['experiment'], getv(from_object, ['experiment'])) @@ -910,19 +880,6 @@ def _TuningJob_from_vertex( if getv(from_object, ['pipelineJob']) is not None: setv(to_object, ['pipeline_job'], getv(from_object, ['pipelineJob'])) - if getv(from_object, ['preferenceOptimizationSpec']) is not None: - setv( - to_object, - ['preference_optimization_spec'], - getv(from_object, ['preferenceOptimizationSpec']), - ) - - if getv(from_object, ['satisfiesPzi']) is not None: - setv(to_object, ['satisfies_pzi'], getv(from_object, ['satisfiesPzi'])) - - if getv(from_object, ['satisfiesPzs']) is not None: - setv(to_object, ['satisfies_pzs'], getv(from_object, ['satisfiesPzs'])) - if getv(from_object, ['serviceAccount']) is not None: setv(to_object, ['service_account'], getv(from_object, ['serviceAccount'])) @@ -933,9 +890,6 @@ def _TuningJob_from_vertex( getv(from_object, ['tunedModelDisplayName']), ) - if getv(from_object, ['veoTuningSpec']) is not None: - setv(to_object, ['veo_tuning_spec'], getv(from_object, ['veoTuningSpec'])) - return to_object diff --git a/google/genai/types.py b/google/genai/types.py index 88ad0a79..c2d7cf67 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -429,17 +429,6 @@ class AdapterSize(_common.CaseInSensitiveEnum): """Adapter size 32.""" -class TuningTask(_common.CaseInSensitiveEnum): - """Optional. The tuning task. Either I2V or T2V.""" - - TUNING_TASK_UNSPECIFIED = 'TUNING_TASK_UNSPECIFIED' - """Default value. This value is unused.""" - TUNING_TASK_I2V = 'TUNING_TASK_I2V' - """Tuning task for image to video.""" - TUNING_TASK_T2V = 'TUNING_TASK_T2V' - """Tuning task for text to video.""" - - class FeatureSelectionPreference(_common.CaseInSensitiveEnum): """Options for feature selection preference.""" @@ -9705,244 +9694,6 @@ class PartnerModelTuningSpecDict(TypedDict, total=False): ] -class DistillationHyperParameters(_common.BaseModel): - """Hyperparameters for Distillation.""" - - adapter_size: Optional[AdapterSize] = Field( - default=None, description="""Optional. Adapter size for distillation.""" - ) - epoch_count: Optional[int] = Field( - default=None, - description="""Optional. Number of complete passes the model makes over the entire training dataset during training.""", - ) - learning_rate_multiplier: Optional[float] = Field( - default=None, - description="""Optional. Multiplier for adjusting the default learning rate.""", - ) - - -class DistillationHyperParametersDict(TypedDict, total=False): - """Hyperparameters for Distillation.""" - - adapter_size: Optional[AdapterSize] - """Optional. Adapter size for distillation.""" - - epoch_count: Optional[int] - """Optional. Number of complete passes the model makes over the entire training dataset during training.""" - - learning_rate_multiplier: Optional[float] - """Optional. Multiplier for adjusting the default learning rate.""" - - -DistillationHyperParametersOrDict = Union[ - DistillationHyperParameters, DistillationHyperParametersDict -] - - -class DistillationSpec(_common.BaseModel): - """Tuning Spec for Distillation.""" - - base_teacher_model: Optional[str] = Field( - default=None, - description="""The base teacher model that is being distilled. See [Supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).""", - ) - hyper_parameters: Optional[DistillationHyperParameters] = Field( - default=None, - description="""Optional. Hyperparameters for Distillation.""", - ) - pipeline_root_directory: Optional[str] = Field( - default=None, - description="""Deprecated. A path in a Cloud Storage bucket, which will be treated as the root output directory of the distillation pipeline. It is used by the system to generate the paths of output artifacts.""", - ) - student_model: Optional[str] = Field( - default=None, - description="""The student model that is being tuned, e.g., "google/gemma-2b-1.1-it". Deprecated. Use base_model instead.""", - ) - training_dataset_uri: Optional[str] = Field( - default=None, - description="""Deprecated. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""", - ) - tuned_teacher_model_source: Optional[str] = Field( - default=None, - description="""The resource name of the Tuned teacher model. Format: `projects/{project}/locations/{location}/models/{model}`.""", - ) - validation_dataset_uri: Optional[str] = Field( - default=None, - description="""Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""", - ) - - -class DistillationSpecDict(TypedDict, total=False): - """Tuning Spec for Distillation.""" - - base_teacher_model: Optional[str] - """The base teacher model that is being distilled. See [Supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).""" - - hyper_parameters: Optional[DistillationHyperParametersDict] - """Optional. Hyperparameters for Distillation.""" - - pipeline_root_directory: Optional[str] - """Deprecated. A path in a Cloud Storage bucket, which will be treated as the root output directory of the distillation pipeline. It is used by the system to generate the paths of output artifacts.""" - - student_model: Optional[str] - """The student model that is being tuned, e.g., "google/gemma-2b-1.1-it". Deprecated. Use base_model instead.""" - - training_dataset_uri: Optional[str] - """Deprecated. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""" - - tuned_teacher_model_source: Optional[str] - """The resource name of the Tuned teacher model. Format: `projects/{project}/locations/{location}/models/{model}`.""" - - validation_dataset_uri: Optional[str] - """Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""" - - -DistillationSpecOrDict = Union[DistillationSpec, DistillationSpecDict] - - -class PreferenceOptimizationHyperParameters(_common.BaseModel): - """Hyperparameters for Preference Optimization.""" - - adapter_size: Optional[AdapterSize] = Field( - default=None, - description="""Optional. Adapter size for preference optimization.""", - ) - beta: Optional[float] = Field( - default=None, - description="""Optional. Weight for KL Divergence regularization.""", - ) - epoch_count: Optional[int] = Field( - default=None, - description="""Optional. Number of complete passes the model makes over the entire training dataset during training.""", - ) - learning_rate_multiplier: Optional[float] = Field( - default=None, - description="""Optional. Multiplier for adjusting the default learning rate.""", - ) - - -class PreferenceOptimizationHyperParametersDict(TypedDict, total=False): - """Hyperparameters for Preference Optimization.""" - - adapter_size: Optional[AdapterSize] - """Optional. Adapter size for preference optimization.""" - - beta: Optional[float] - """Optional. Weight for KL Divergence regularization.""" - - epoch_count: Optional[int] - """Optional. Number of complete passes the model makes over the entire training dataset during training.""" - - learning_rate_multiplier: Optional[float] - """Optional. Multiplier for adjusting the default learning rate.""" - - -PreferenceOptimizationHyperParametersOrDict = Union[ - PreferenceOptimizationHyperParameters, - PreferenceOptimizationHyperParametersDict, -] - - -class PreferenceOptimizationSpec(_common.BaseModel): - """Tuning Spec for Preference Optimization.""" - - hyper_parameters: Optional[PreferenceOptimizationHyperParameters] = Field( - default=None, - description="""Optional. Hyperparameters for Preference Optimization.""", - ) - training_dataset_uri: Optional[str] = Field( - default=None, - description="""Required. Cloud Storage path to file containing training dataset for preference optimization tuning. The dataset must be formatted as a JSONL file.""", - ) - validation_dataset_uri: Optional[str] = Field( - default=None, - description="""Optional. Cloud Storage path to file containing validation dataset for preference optimization tuning. The dataset must be formatted as a JSONL file.""", - ) - - -class PreferenceOptimizationSpecDict(TypedDict, total=False): - """Tuning Spec for Preference Optimization.""" - - hyper_parameters: Optional[PreferenceOptimizationHyperParametersDict] - """Optional. Hyperparameters for Preference Optimization.""" - - training_dataset_uri: Optional[str] - """Required. Cloud Storage path to file containing training dataset for preference optimization tuning. The dataset must be formatted as a JSONL file.""" - - validation_dataset_uri: Optional[str] - """Optional. Cloud Storage path to file containing validation dataset for preference optimization tuning. The dataset must be formatted as a JSONL file.""" - - -PreferenceOptimizationSpecOrDict = Union[ - PreferenceOptimizationSpec, PreferenceOptimizationSpecDict -] - - -class VeoHyperParameters(_common.BaseModel): - """Hyperparameters for Veo.""" - - epoch_count: Optional[int] = Field( - default=None, - description="""Optional. Number of complete passes the model makes over the entire training dataset during training.""", - ) - learning_rate_multiplier: Optional[float] = Field( - default=None, - description="""Optional. Multiplier for adjusting the default learning rate.""", - ) - tuning_task: Optional[TuningTask] = Field( - default=None, - description="""Optional. The tuning task. Either I2V or T2V.""", - ) - - -class VeoHyperParametersDict(TypedDict, total=False): - """Hyperparameters for Veo.""" - - epoch_count: Optional[int] - """Optional. Number of complete passes the model makes over the entire training dataset during training.""" - - learning_rate_multiplier: Optional[float] - """Optional. Multiplier for adjusting the default learning rate.""" - - tuning_task: Optional[TuningTask] - """Optional. The tuning task. Either I2V or T2V.""" - - -VeoHyperParametersOrDict = Union[VeoHyperParameters, VeoHyperParametersDict] - - -class VeoTuningSpec(_common.BaseModel): - """Tuning Spec for Veo Model Tuning.""" - - hyper_parameters: Optional[VeoHyperParameters] = Field( - default=None, description="""Optional. Hyperparameters for Veo.""" - ) - training_dataset_uri: Optional[str] = Field( - default=None, - description="""Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""", - ) - validation_dataset_uri: Optional[str] = Field( - default=None, - description="""Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""", - ) - - -class VeoTuningSpecDict(TypedDict, total=False): - """Tuning Spec for Veo Model Tuning.""" - - hyper_parameters: Optional[VeoHyperParametersDict] - """Optional. Hyperparameters for Veo.""" - - training_dataset_uri: Optional[str] - """Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""" - - validation_dataset_uri: Optional[str] - """Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""" - - -VeoTuningSpecOrDict = Union[VeoTuningSpec, VeoTuningSpecDict] - - class TuningJob(_common.BaseModel): """A tuning job.""" @@ -10014,9 +9765,6 @@ class TuningJob(_common.BaseModel): default=None, description="""Optional. The user-provided path to custom model weights. Set this field to tune a custom model. The path must be a Cloud Storage directory that contains the model weights in .safetensors format along with associated model metadata files. If this field is set, the base_model field must still be set to indicate which base model the custom model is derived from. This feature is only available for open source models.""", ) - distillation_spec: Optional[DistillationSpec] = Field( - default=None, description="""Tuning Spec for Distillation.""" - ) experiment: Optional[str] = Field( default=None, description="""Output only. The Experiment associated with this TuningJob.""", @@ -10033,15 +9781,6 @@ class TuningJob(_common.BaseModel): default=None, description="""Output only. The resource name of the PipelineJob associated with the TuningJob. Format: `projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}`.""", ) - preference_optimization_spec: Optional[PreferenceOptimizationSpec] = Field( - default=None, description="""Tuning Spec for Preference Optimization.""" - ) - satisfies_pzi: Optional[bool] = Field( - default=None, description="""Output only. Reserved for future use.""" - ) - satisfies_pzs: Optional[bool] = Field( - default=None, description="""Output only. Reserved for future use.""" - ) service_account: Optional[str] = Field( default=None, description="""The service account that the tuningJob workload runs as. If not specified, the Vertex AI Secure Fine-Tuned Service Agent in the project will be used. See https://cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent Users starting the pipeline must have the `iam.serviceAccounts.actAs` permission on this service account.""", @@ -10050,9 +9789,6 @@ class TuningJob(_common.BaseModel): default=None, description="""Optional. The display name of the TunedModel. The name can be up to 128 characters long and can consist of any UTF-8 characters.""", ) - veo_tuning_spec: Optional[VeoTuningSpec] = Field( - default=None, description="""Tuning Spec for Veo Tuning.""" - ) @property def has_ended(self) -> bool: @@ -10122,9 +9858,6 @@ class TuningJobDict(TypedDict, total=False): custom_base_model: Optional[str] """Optional. The user-provided path to custom model weights. Set this field to tune a custom model. The path must be a Cloud Storage directory that contains the model weights in .safetensors format along with associated model metadata files. If this field is set, the base_model field must still be set to indicate which base model the custom model is derived from. This feature is only available for open source models.""" - distillation_spec: Optional[DistillationSpecDict] - """Tuning Spec for Distillation.""" - experiment: Optional[str] """Output only. The Experiment associated with this TuningJob.""" @@ -10137,24 +9870,12 @@ class TuningJobDict(TypedDict, total=False): pipeline_job: Optional[str] """Output only. The resource name of the PipelineJob associated with the TuningJob. Format: `projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}`.""" - preference_optimization_spec: Optional[PreferenceOptimizationSpecDict] - """Tuning Spec for Preference Optimization.""" - - satisfies_pzi: Optional[bool] - """Output only. Reserved for future use.""" - - satisfies_pzs: Optional[bool] - """Output only. Reserved for future use.""" - service_account: Optional[str] """The service account that the tuningJob workload runs as. If not specified, the Vertex AI Secure Fine-Tuned Service Agent in the project will be used. See https://cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent Users starting the pipeline must have the `iam.serviceAccounts.actAs` permission on this service account.""" tuned_model_display_name: Optional[str] """Optional. The display name of the TunedModel. The name can be up to 128 characters long and can consist of any UTF-8 characters.""" - veo_tuning_spec: Optional[VeoTuningSpecDict] - """Tuning Spec for Veo Tuning.""" - TuningJobOrDict = Union[TuningJob, TuningJobDict]