Skip to contents

Teleprompter() is the parent class of every optimizer in dsprrr ("teleprompter" is DSPy's original name for an optimizer). You never compile with it directly: create one of the optimizers below and pass it to compile(). This page documents the three arguments that every optimizer accepts.

Usage

Teleprompter(metric = NULL, metric_threshold = NULL, max_errors = 5L)

Arguments

metric

A metric function called as metric(prediction, expected), such as metric_exact_match(field = "answer"), or NULL. Optimizers that score candidates require one.

metric_threshold

A score between 0 and 1, or NULL (the default). Only some optimizers use it, and each optimizer's page says how.

max_errors

Integer error budget (default 5L). The optimizers that run under optimizer_control() (the two bootstrap optimizers, COPRO, MIPROv2, SIMBA, GEPA, AutoResearch and MetaHarness) stop after this many consecutive failed evaluations when compile() is not given a control object.

Value

A Teleprompter object.

Details

Most optimizers store counts as S7 integer properties, so write 5L rather than 5. A double fails with an error such as @max_errors must be <integer>, not <double>.

Optimizers at a glance

OptimizerWhat it changes
LabeledFewShot()Demos: k training rows. No model calls.
KNNFewShot()Demos: the training rows most similar to each input, chosen at run time.
BootstrapFewShot()Demos: training rows plus the program's own outputs that pass the metric.
BootstrapFewShotWithRandomSearch()Demos: the best of several bootstrap candidates on a validation set.
GridSearchTeleprompter()Instructions, template or settings, from a table of variants.
COPRO()Instructions, rewritten by a model over several rounds.
MIPROv2()Instructions and demos, searched together.
SIMBA()Instruction rules and demos taken from hard examples.
GEPA()Instructions (and Flex source) evolved by reflecting on failures.
ReAnchor()Thresholds, cuts and weights of decision outputs.
BetterTogether(), Omni()Run other optimizers in sequence or in competition.
AutoResearch(), MetaHarness()An agent proposes and tests program edits.

To sweep runtime settings such as reasoning_effort on a module in place, use optimize_grid() instead.

Examples

Teleprompter()
#> <dsprrr::Teleprompter>
#>  @ metric          : NULL
#>  @ metric_threshold: NULL
#>  @ max_errors      : int 5

# Counts must be integers
try(Teleprompter(max_errors = 5))
#> Error : <dsprrr::Teleprompter> object properties are invalid:
#> - @max_errors must be <integer>, not <double>