Class: Google::Apis::AiplatformV1::GoogleCloudAiplatformV1CustomCodeExecutionSpec

Inherits:
Object
  • Object
show all
Includes:
Core::Hashable, Core::JsonObjectSupport
Defined in:
lib/google/apis/aiplatform_v1/classes.rb,
lib/google/apis/aiplatform_v1/representations.rb,
lib/google/apis/aiplatform_v1/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) ⇒ GoogleCloudAiplatformV1CustomCodeExecutionSpec

Returns a new instance of GoogleCloudAiplatformV1CustomCodeExecutionSpec.



5641
5642
5643
# File 'lib/google/apis/aiplatform_v1/classes.rb', line 5641

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

Instance Attribute Details

#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)


5639
5640
5641
# File 'lib/google/apis/aiplatform_v1/classes.rb', line 5639

def evaluation_function
  @evaluation_function
end

Instance Method Details

#update!(**args) ⇒ Object

Update properties of this object



5646
5647
5648
# File 'lib/google/apis/aiplatform_v1/classes.rb', line 5646

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