An arm is one way of answering the items of a reference: a prompt, a
model, a reading recipe, a baseline that calls no model at all. It is a
function run(item, ctx) that returns the arm's output for one item,
which the benchmark's scorer then compares with the item's label.
Usage
hr_arm(name, run, params = list(), derived_from = NULL, version = "0.0.1")Arguments
- name
The arm's name: one non-blank string, unique within a benchmark.
- run
A function of
(item, ctx)returning the arm's output for one item: what the scorer is given (seehr_scorer()).itemis the item's payload fromhr_reference().- params
A named list of the settings that make this arm what it is. They are recorded with the benchmark and reach
runasctx$params.- derived_from
The name of the arm this one is built from (for an arm that reuses another's draws offline), or
NULL.- version
The arm's version, one string. Change it when the arm's behaviour changes, so results from before and after can be told apart.
Value
An object of class hr_arm: a list of name, run, params,
derived_from, version and hash, a SHA-256 hash of the other five
that changes when the arm's code, settings or version do. The code is
hashed as text, with the values it names from the environment it was
made in: the workspace for an arm written at top level, or the function
of yours that built it. So an arm that reads a global prompt has a new
hash when that prompt changes, and the same arm has the same hash in
every session and after saveRDS(). A function from a package is hashed
by its code and the package's name.
Details
ctx is a list with
clientThe client given to
hr_benchmark().traceA
gr_trace()of this run alone. Every request the arm makes must be recorded into it (gr_call(..., trace = ctx$trace)): it is how the benchmark counts the run's tokens, dollars and refusals, and how it holds the run to the benchmark's limits.governorThe
hr_governor()the run is held to: the benchmark's limits less what earlier runs used. It is already attached totrace.draw_indexThe run number, 1 to
runs. Pass it togr_call()asdraw_indexso each run is its own draw: under agr_cache()or agr_replay_client()a request sent without it answers every run with the same stored reply, and the benchmark refuses such an arm.callA shortcut,
ctx$call(messages, ...), forgr_call(ctx$client, messages, ..., trace = ctx$trace, draw_index = ctx$draw_index).item_id,arm,run,paramsThe item's id, the arm's name, the run number and the arm's
params.