Skip to content

Commit

Permalink
Update code snippets in cheatsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
krypticmouse committed Mar 5, 2024
1 parent 929213e commit b2816c4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/docs/cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ You can choose only selected columns from the csv by specifying them in the argu
```python
dolly_100_dataset = dl.from_csv(
"dolly_subset_100_rows.csv",
fields=["instruction", "context", "response"],
fields=("instruction", "context", "response"),
input_keys=("instruction", "context")
)
```
Expand Down Expand Up @@ -301,13 +301,15 @@ Other custom configurations are similar to customizing the `dspy.BootstrapFewSho
### dspy.Ensemble

```python
from dspy.teleprompt import BootstrapFewShotWithRandomSearch, Ensemble
from dspy.teleprompt import BootstrapFewShotWithRandomSearch
from dspy.teleprompt.ensemble import Ensemble

fewshot_optimizer = BootstrapFewShotWithRandomSearch(metric=your_defined_metric, max_bootstrapped_demos=2, num_candidate_programs=8, num_threads=NUM_THREADS)
your_dspy_program_compiled = fewshot_optimizer.compile(student = your_dspy_program, trainset=trainset, valset=devset)

ensemble_optimizer = dspy.Ensemble(reduce_fn=dspy.majority)
your_dspy_program_compiled_ensemble = ensemble_optimizer.compile(your_dspy_program_compiled.programs[:3])
ensemble_optimizer = Ensemble(reduce_fn=dspy.majority)
programs = [x[-1] for x in your_dspy_program_compiled.candidate_programs]
your_dspy_program_compiled_ensemble = ensemble_optimizer.compile(programs[:3])
```

### dspy.BootstrapFinetune
Expand Down

0 comments on commit b2816c4

Please sign in to comment.