Wrapper for Python class BootstrapFewShot.
Summary
Functions
Python method BootstrapFewShot._bootstrap.
Python method BootstrapFewShot._bootstrap_one_example.
Python method BootstrapFewShot._prepare_predictor_mappings.
Python method BootstrapFewShot._prepare_student_and_teacher.
Python method BootstrapFewShot._train.
Optimize the student program.
Get the parameters of the teleprompter.
A Teleprompter class that composes a set of demos/examples to go into a predictor's prompt.
Types
Functions
@spec _bootstrap( SnakeBridge.Ref.t(), keyword() ) :: {:ok, term()} | {:error, Snakepit.Error.t()}
Python method BootstrapFewShot._bootstrap.
Parameters
max_bootstraps(term() keyword-only default: None)
Returns
term()
@spec _bootstrap_one_example(SnakeBridge.Ref.t(), term(), [term()], keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
Python method BootstrapFewShot._bootstrap_one_example.
Parameters
example(term())round_idx(term() default: 0)
Returns
term()
@spec _prepare_predictor_mappings( SnakeBridge.Ref.t(), keyword() ) :: {:ok, term()} | {:error, Snakepit.Error.t()}
Python method BootstrapFewShot._prepare_predictor_mappings.
Returns
term()
@spec _prepare_student_and_teacher(SnakeBridge.Ref.t(), term(), term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
Python method BootstrapFewShot._prepare_student_and_teacher.
Parameters
student(term())teacher(term())
Returns
term()
@spec _train( SnakeBridge.Ref.t(), keyword() ) :: {:ok, term()} | {:error, Snakepit.Error.t()}
Python method BootstrapFewShot._train.
Returns
term()
@spec compile(SnakeBridge.Ref.t(), term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
Optimize the student program.
Parameters
student- The student program to optimize.trainset- The training set to use for optimization.teacher- The teacher program to use for optimization.valset- The validation set to use for optimization.
Returns
term()
@spec get_params( SnakeBridge.Ref.t(), keyword() ) :: {:ok, %{optional(String.t()) => term()}} | {:error, Snakepit.Error.t()}
Get the parameters of the teleprompter.
Returns
%{optional(String.t()) => term()}
@spec new( [term()], keyword() ) :: {:ok, SnakeBridge.Ref.t()} | {:error, Snakepit.Error.t()}
A Teleprompter class that composes a set of demos/examples to go into a predictor's prompt.
These demos come from a combination of labeled examples in the training set, and bootstrapped demos.
Each bootstrap round copies the LM with a new rollout_id at temperature=1.0 to
bypass caches and gather diverse traces.
Parameters
metric- A function that compares an expected value and predicted value, outputting the result of that comparison. (type:Callable)metric_threshold- If the metric yields a numerical value, then check it against this threshold when deciding whether or not to accept a bootstrap example. Defaults to None. (type:float())teacher_settings- Settings for theteachermodel. Defaults to None. (type:map())max_bootstrapped_demos- Maximum number of bootstrapped demonstrations to include. Defaults to 4. (type:integer())max_labeled_demos- Maximum number of labeled demonstrations to include. Defaults to 16. (type:integer())max_rounds- Number of iterations to attempt generating the required bootstrap examples. If unsuccessful aftermax_rounds, the program ends. Defaults to 1. (type:integer())max_errors- Maximum number of errors until program ends. IfNone, inherits fromdspy.settings.max_errors. (type:integer() | nil)