Adapts a metric function (with signature function(prediction, expected))
to a reward function (with signature function(prediction, inputs)).
Value
A reward function suitable for best_of_n() and refine()
Examples
# Convert exact match metric to reward function
reward <- as_reward_fn(metric_exact_match(), expected_field = "answer")
# With field extraction
reward <- as_reward_fn(
metric_exact_match(field = "sentiment"),
expected_field = "expected_sentiment"
)
