Class: Google::Apis::AiplatformV1beta1::GoogleCloudAiplatformV1beta1CustomCodeExecutionSpec

Inherits:
Object
  • Object
show all
Includes:
Core::Hashable, Core::JsonObjectSupport
Defined in:
lib/google/apis/aiplatform_v1beta1/classes.rb,
lib/google/apis/aiplatform_v1beta1/representations.rb,
lib/google/apis/aiplatform_v1beta1/representations.rb

Overview

Specificies a metric that is populated by evaluating user-defined Python code.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ GoogleCloudAiplatformV1beta1CustomCodeExecutionSpec

Returns a new instance of GoogleCloudAiplatformV1beta1CustomCodeExecutionSpec.



14408
14409
14410
# File 'lib/google/apis/aiplatform_v1beta1/classes.rb', line 14408

def initialize(**args)
   update!(**args)
end

Instance Attribute Details

#code_execution_regionString

Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: us-central1, us-east1, us-east4, us-west1, us- west4, southamerica-east1, europe-west2, europe-west3, asia-east1, asia-south1, asia-southeast1. If unset, the request's originating region is used; requests from regions where the sandbox is unavailable will fail with UNIMPLEMENTED. Corresponds to the JSON property codeExecutionRegion

Returns:

  • (String)


14389
14390
14391
# File 'lib/google/apis/aiplatform_v1beta1/classes.rb', line 14389

def code_execution_region
  @code_execution_region
end

#evaluation_functionString

Required. Python function. Expected user to define the following function, e.g. : def evaluate(instance: dict[str, Any]) -> float: Please include this function signature in the code snippet. Instance is the evaluation instance, any fields populated in the instance are available to the function as instance[ field_name]. Example: Example input: instance= EvaluationInstance( response=EvaluationInstance.InstanceData(text="The answer is 4."), reference= EvaluationInstance.InstanceData(text="4") ) Example converted input: ` 'response': `'text': 'The answer is 4.'`, 'reference': `'text': '4'` ` Example python function: def evaluate(instance: dict[str, Any]) -> float: if instance'response' == instance'reference': return 1.0 return 0.0 CustomCodeExecutionSpec is also supported in Batch Evaluation (EvalDataset RPC) and Tuning Evaluation. Each line in the input jsonl file will be converted to dict[str, Any] and passed to the evaluation function. Corresponds to the JSON property evaluationFunction

Returns:

  • (String)


14406
14407
14408
# File 'lib/google/apis/aiplatform_v1beta1/classes.rb', line 14406

def evaluation_function
  @evaluation_function
end

Instance Method Details

#update!(**args) ⇒ Object

Update properties of this object



14413
14414
14415
14416
# File 'lib/google/apis/aiplatform_v1beta1/classes.rb', line 14413

def update!(**args)
  @code_execution_region = args[:code_execution_region] if args.key?(:code_execution_region)
  @evaluation_function = args[:evaluation_function] if args.key?(:evaluation_function)
end