# `Tune.Optimizers.InferRules`
[🔗](https://github.com/mikehostetler/tune/blob/v0.5.0/lib/tune/optimizers/infer_rules.ex#L1)

Derives natural-language rules from bootstrapped examples.

The program is bootstrapped with the teacher role. The original program and
the bootstrapped program are evaluated on the validation set and both stay
selectable. Then `num_candidates` rule candidates are built: for each
predictor, the proposal role derives up to `num_rules` rules from a shuffled
view of that predictor's bootstrapped demonstrations, and the rules are
appended to its instruction. Each candidate keeps the bootstrapped
demonstrations and is evaluated on validation; the best complete eligible
candidate is returned, so a worse rule set is never chosen.

Options: `:num_candidates` (default 2), `:num_rules` (default 5), and
BootstrapFewShot options (`:accept_score` required).

# `with_rules`

```elixir
@spec with_rules(String.t(), [String.t()]) :: String.t()
```

Appends rules to an instruction in the inspectable format used by InferRules.

---

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