hr_set() builds a step or a chain again with some settings changed and
the rest as they were. In a chain each setting is named by its path,
"step.setting" (split at the first dot), as hr_settings() lists them:
hr_set(chain, retrieve.top_k = 8). For a single step, the setting's
own name is enough: hr_set(step, top_k = 8).
Arguments
- x
A step from
hr_step(),gr_step()orgr_step_retrieve(), or an arm built byhr_chain().- ...
The settings to change, each named:
"step.setting" = valuefor a chain,setting = valuefor a single step.
Value
x built again with the settings changed: a step of the same
class, or an arm from hr_chain() with the same name and version. With
no settings given, x as it is.
Details
Only settings of a step's schema can be changed. A path whose step is
not in the chain, or whose setting is not in that step's schema, is an
error of class hr_unknown_setting (also hr_unknown_param and
gr_bad_setting) that lists the settings of the step it names, or the
steps of the chain. A setting the schema
does not name, which a step built with build keeps as a fixed extra, is
refused the same way.
The new values are checked by hr_validate() as when the step was built,
so a number outside its range is moved to the nearest bound with a
warning of class hr_param_clamped (also gr_clamped), and a value the
step's constructor refuses, such as an unknown reader, is an error. Each step that changed is built again from its
settings, through its build function when it has one, so a setting its
constructor checks is checked here, and keeps its class: a gr_step()
stays a gr_step.
The chain is then built again by hr_chain() under its own name and
version, with the changed steps in place, so its hash and configuration
are those of the new settings. A setting changed to its default gives the
configuration of the chain with that setting left out. hr_sweep()
calls hr_set() for each row of its grid when given a chain, which is
how a chain is swept by name.
See also
hr_settings(), hr_sweep(), hr_chain(), hr_validate()
Other harness:
gr_arm(),
gr_condensation_check(),
gr_qa_reference(),
gr_reverse_text(),
gr_scorer_answer(),
hr_arm(),
hr_benchmark(),
hr_chain(),
hr_contrast(),
hr_drift_check(),
hr_effort_check(),
hr_effort_escalate(),
hr_effort_event(),
hr_effort_log(),
hr_mdd(),
hr_modules(),
hr_reference(),
hr_register(),
hr_report(),
hr_scorer(),
hr_settings(),
hr_skill(),
hr_step(),
hr_step_command(),
hr_sweep(),
hr_sweep_check()
Examples
chain <- hr_chain(segment = gr_step("segment"),
retrieve = gr_step_retrieve(top_k = 4),
read = gr_step("read", reader = "stuff"), name = "checked")
wider <- hr_set(chain, retrieve.top_k = 8, segment.max_tokens = 300)
wider$params
#> $segment.max_tokens
#> [1] 300
#>
#> $retrieve.top_k
#> [1] 8
#>
#> $read.reader
#> [1] "stuff"
#>
hr_settings(wider)[hr_settings(wider)$set, c("step", "param", "value")]
#> step param value
#> 2 segment max_tokens 300
#> 21 retrieve top_k 8
#> 35 read reader stuff
# A setting at its default is the chain without it.
six <- hr_set(chain, retrieve.top_k = 6)
plain <- hr_chain(chain, retrieve = gr_step_retrieve(), name = "checked")
identical(attr(six, "hr_config"), attr(plain, "hr_config"))
#> [1] TRUE
# A single step takes the setting's own name.
attr(hr_set(gr_step_retrieve(), top_k = 2), "resolved")$top_k
#> [1] 2