best_params() returns the winning parameter values recorded by compile()
or optimize_grid(), such as the best temperature of a grid search or the
number of demonstrations chosen by LabeledFewShot(). It reads
optimization_result(module)$best_params.
Arguments
- module
A module returned by
compile()or modified byoptimize_grid().- flatten
If
TRUE(the default), length-one list elements are unwrapped to plain values. IfFALSE, the parameters are returned as stored.
See also
Other optimization results:
apply_best_config(),
best_demos(),
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)
best_params(compiled)
#> $k
#> [1] 2
#>