Package com.google.genai.types
Class ReinforcementTuningCodeExecutionRewardScorer
java.lang.Object
com.google.genai.JsonSerializable
com.google.genai.types.ReinforcementTuningCodeExecutionRewardScorer
ReinforcementTuningCodeExecutionRewardScorer allows users to implement a function to evaluate
rewards for the sample response. The function signature is as follows: ``` def evaluate(example:
dict[str, Any], response: dict[str, Any]) -> float: ... ``` `example` is a
ReinforcementTuningExample in ProtoJSON format, (i.e., the format is the same as as one line in
the training/validation dataset except that the keys must be in camel case). System instructions
(i.e., `example.get("systemInstruction")`) and references (i.e., `example.get("references")`) are
also included in the `example` provided that they are set in the training/validation dataset.
`response` is a Content in ProtoJSON format (i.e., keys must be in camel case), which is the same
as the Online Prediction response for Gemini models. Note: Reward output by the `evaluate`
function is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`. This
data type is not supported in Gemini API.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for ReinforcementTuningCodeExecutionRewardScorer. -
Field Summary
Fields inherited from class com.google.genai.JsonSerializable
MAX_READ_LENGTH_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Instantiates a builder for ReinforcementTuningCodeExecutionRewardScorer.Deserializes a JSON string to a ReinforcementTuningCodeExecutionRewardScorer object.The python code snippet as a string for evaluating rewards.Creates a builder with the same values as this instance.Methods inherited from class com.google.genai.JsonSerializable
fromJsonNode, fromJsonString, objectMapper, setMaxReadLength, stringToJsonNode, toJson, toJsonNode, toJsonString
-
Constructor Details
-
ReinforcementTuningCodeExecutionRewardScorer
public ReinforcementTuningCodeExecutionRewardScorer()
-
-
Method Details
-
pythonCodeSnippet
The python code snippet as a string for evaluating rewards. The following is an example python code snippet that returns a reward `1.0` for a parsed response matching the user-provided reference answer in per prompt references map. ``` def evaluate(example, response) -> float: response_str = response.get("parts", [])0 references = example.get("references", {}) if response_str == references.get("concise_answer"): return 1.0 return -1.0 ``` Note: Reward output by the evaluate function is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`. -
builder
Instantiates a builder for ReinforcementTuningCodeExecutionRewardScorer. -
toBuilder
Creates a builder with the same values as this instance. -
fromJson
Deserializes a JSON string to a ReinforcementTuningCodeExecutionRewardScorer object.
-