Skip to content

Commit b2816c4

Browse files
committed
Update code snippets in cheatsheet
1 parent 929213e commit b2816c4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/docs/cheatsheet.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ You can choose only selected columns from the csv by specifying them in the argu
101101
```python
102102
dolly_100_dataset = dl.from_csv(
103103
"dolly_subset_100_rows.csv",
104-
fields=["instruction", "context", "response"],
104+
fields=("instruction", "context", "response"),
105105
input_keys=("instruction", "context")
106106
)
107107
```
@@ -301,13 +301,15 @@ Other custom configurations are similar to customizing the `dspy.BootstrapFewSho
301301
### dspy.Ensemble
302302

303303
```python
304-
from dspy.teleprompt import BootstrapFewShotWithRandomSearch, Ensemble
304+
from dspy.teleprompt import BootstrapFewShotWithRandomSearch
305+
from dspy.teleprompt.ensemble import Ensemble
305306

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

309-
ensemble_optimizer = dspy.Ensemble(reduce_fn=dspy.majority)
310-
your_dspy_program_compiled_ensemble = ensemble_optimizer.compile(your_dspy_program_compiled.programs[:3])
310+
ensemble_optimizer = Ensemble(reduce_fn=dspy.majority)
311+
programs = [x[-1] for x in your_dspy_program_compiled.candidate_programs]
312+
your_dspy_program_compiled_ensemble = ensemble_optimizer.compile(programs[:3])
311313
```
312314

313315
### dspy.BootstrapFinetune

0 commit comments

Comments
 (0)