llm_predict() creates a parsnip model specification whose "dsprrr"
engine predicts with a dsprrr module, for classification or regression on
text columns. temperature and top_p can be marked for tuning with
tune(); see temperature() and top_p().
Arguments
- mode
"classification"(the default) or"regression".- signature
Optional signature string or
signature()object for the module.NULLderives one from the data when fitting.- temperature
Sampling temperature for the module, or
tune().- top_p
Nucleus sampling parameter for the module, or
tune().
Details
The engine is registered automatically when parsnip is loaded (see
register_dsprrr_engine()). Fitting builds a Predict module from the
predictor columns and the outcome: an enum output with the outcome's levels
for classification, or a number for regression, unless you give a
signature. Prediction runs the module on the new data with the default
chat (see dsp_configure()); a fitted model makes no model calls until
it predicts.
Known issue: the engine is registered without parsnip's encoding
information, so parsnip::fit() and parsnip::fit_xy() currently fail
with "no applicable method for 'filter'". Until that is fixed, the
specification cannot be fitted through parsnip, workflows or tune.
See also
Other integrations:
as_dsprrr_metric(),
as_dsprrr_traces(),
as_ellmer_tool(),
as_vitals_cost(),
as_vitals_samples(),
as_vitals_solver(),
as_vitals_task(),
create_search_tool(),
ragnar_tool(),
reasoning_effort(),
register_dsprrr_engine(),
summarize_traces_df(),
temperature(),
top_p(),
use_dsprrr_template(),
validate_workflow(),
vitals_metrics
Examples
spec <- llm_predict(
mode = "classification",
signature = "text -> sentiment: enum('positive', 'negative', 'neutral')"
) |>
parsnip::set_engine("dsprrr")
spec
#>
#> ── LLM Predict Model Specification
#> Mode: classification
#> Engine: dsprrr
# Mark a parameter for tuning
llm_predict(signature = "text -> sentiment", temperature = parsnip::tune())
#>
#> ── LLM Predict Model Specification
#> Mode: classification