airflow.providers.google.cloud.operators.vertex_ai.generative_model

This module contains Google Vertex AI Generative AI operators.

Classes

RunEvaluationOperator

Use the Rapid Evaluation API to evaluate a model.

Module Contents

class airflow.providers.google.cloud.operators.vertex_ai.generative_model.RunEvaluationOperator(*, project_id, location, pretrained_model, eval_dataset, metrics, experiment_name, experiment_run_name, prompt_template, generation_config=None, safety_settings=None, system_instruction=None, tools=None, gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Use the Rapid Evaluation API to evaluate a model.

Parameters:
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • location (str) – Required. The ID of the Google Cloud location that the service belongs to.

  • pretrained_model (str) – Required. A pre-trained model optimized for performing natural language tasks such as classification, summarization, extraction, content creation, and ideation.

  • eval_dataset (dict) – Required. A fixed dataset for evaluating a model against. Adheres to Rapid Evaluation API.

  • metrics (list) – Required. A list of evaluation metrics to be used in the experiment. Adheres to Rapid Evaluation API.

  • experiment_name (str) – Required. The name of the evaluation experiment.

  • experiment_run_name (str) – Required. The specific run name or ID for this experiment.

  • prompt_template (str) – Required. The template used to format the model’s prompts during evaluation. Adheres to Rapid Evaluation API.

  • generation_config (dict | None) – Optional. A dictionary containing generation parameters for the model.

  • safety_settings (dict | None) – Optional. A dictionary specifying harm category thresholds for blocking model outputs.

  • system_instruction (str | None) – Optional. An instruction given to the model to guide its behavior.

  • tools (list | None) – Optional. A list of tools available to the model during evaluation, such as a data store.

  • gcp_conn_id (str) – The connection ID to use connecting to Google Cloud.

  • impersonation_chain (str | collections.abc.Sequence[str] | None) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

template_fields = ('location', 'project_id', 'impersonation_chain', 'pretrained_model', 'eval_dataset',...[source]
project_id[source]
location[source]
pretrained_model[source]
eval_dataset[source]
metrics[source]
experiment_name[source]
experiment_run_name[source]
prompt_template[source]
generation_config = None[source]
safety_settings = None[source]
system_instruction = None[source]
tools = None[source]
gcp_conn_id = 'google_cloud_default'[source]
impersonation_chain = None[source]
execute(context)[source]

Derive when creating an operator.

The main method to execute the task. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

Was this entry helpful?