Skip to contents

A setting a reader does not use (top_k under a reader that sends every chunk, mmr with top_k at or above the number of chunks) leaves the requests as they were, and a sweep over it compares an arm with itself. hr_sweep_check() finds such pairs in a benchmark: two arms that sent byte-identical requests (the same model, prompts and request settings, in the same order) on every item and run they share.

Usage

hr_sweep_check(bench)

Arguments

bench

An hr_bench from hr_benchmark().

Value

A data frame with one row per arm whose requests were identical to an earlier arm's: arm and same_as (the first earlier arm, in the benchmark's order, that sent the same requests), runs (the item and run pairs compared), requests (the requests arm sent over them), and settings, the recorded settings (param.* columns) that differ between the two, as "top_k: 2 vs 8", which are the settings that changed nothing. No rows when every pair of arms sent different requests.

Details

An arm is reported once, against the first arm before it with the same requests, so three arms that sent the same requests give two rows. Pairs in which neither arm sent a request are left out, since requests cannot tell them apart. A request answered from a cache counts as sent: its prompt is recorded as it would have gone out.

Examples

cl <- hr_mock_client(function(m, p) "Revenue was 45.2 million dollars.")
ref <- gr_qa_reference(
  questions = c(revenue = "What was revenue in 2024?"),
  documents = gr_example(), answers = list("45.2 million"), split = "test")
old <- hr_options(verbose = FALSE)
# `stuff` sends the whole document, so top_k changes nothing.
arms <- hr_sweep(gr_arm("fast"), list(top_k = c(2, 8)))
bench <- hr_benchmark(arms, ref, runs = 5, client = cl,
                      scorer = gr_scorer_answer())
hr_sweep_check(bench)
#>            arm      same_as runs requests      settings
#> 1 fast:top_k=8 fast:top_k=2    5        5 top_k: 2 vs 8
hr_options(old)