apply_best_config() copies the best parameters, the demonstrations and
the optimization result from an optimized module to another module, for
example to reuse a compiled configuration on a module with a different
chat.
Usage
apply_best_config(source, target = NULL, include = c("all", "params", "demos"))Arguments
- source
An optimized module, returned by
compile()or modified byoptimize_grid().- target
The module to update. It is modified in place. If
NULL, a fresh copy ofsourceis created and updated.- include
What to copy:
"all"(the default),"params"(the best parameters, such astemperature) or"demos"(the demonstrations).
See also
Other optimization results:
best_demos(),
best_params(),
config_diff(),
export_module_code(),
optimization_result(),
optimization_summary(),
top_trials()
Examples
classifier <- module(signature("text -> sentiment"))
trainset <- data.frame(
text = c("I love it!", "Terrible experience", "It's okay"),
sentiment = c("positive", "negative", "neutral")
)
compiled <- compile(classifier, LabeledFewShot(k = 2L), trainset)
fresh <- module(signature("text -> sentiment"))
apply_best_config(compiled, fresh, include = "demos")
length(fresh$demos)
#> [1] 2