# `Dspy.BootstrapFewShot`
[🔗](https://github.com/nshkrdotcom/dspex/blob/v0.11.0/lib/snakebridge_generated/dspy/bootstrap_few_shot.ex#L7)

Wrapper for Python class BootstrapFewShot.

# `t`

```elixir
@opaque t()
```

# `_bootstrap`

```elixir
@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()`

# `_bootstrap_one_example`

```elixir
@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()`

# `_prepare_predictor_mappings`

```elixir
@spec _prepare_predictor_mappings(
  SnakeBridge.Ref.t(),
  keyword()
) :: {:ok, term()} | {:error, Snakepit.Error.t()}
```

Python method `BootstrapFewShot._prepare_predictor_mappings`.

## Returns

- `term()`

# `_prepare_student_and_teacher`

```elixir
@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()`

# `_train`

```elixir
@spec _train(
  SnakeBridge.Ref.t(),
  keyword()
) :: {:ok, term()} | {:error, Snakepit.Error.t()}
```

Python method `BootstrapFewShot._train`.

## Returns

- `term()`

# `compile`

```elixir
@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()`

# `get_params`

```elixir
@spec get_params(
  SnakeBridge.Ref.t(),
  keyword()
) :: {:ok, %{optional(String.t()) =&gt; term()}} | {:error, Snakepit.Error.t()}
```

Get the parameters of the teleprompter.

## Returns

- `%{optional(String.t()) => term()}`

# `new`

```elixir
@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 the `teacher` model. 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 after `max_rounds`, the program ends. Defaults to 1. (type: `integer()`)
- `max_errors` - Maximum number of errors until program ends. If ``None``, inherits from ``dspy.settings.max_errors``. (type: `integer() | nil`)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
