Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Update code snippets in cheatsheet

Herumb Shandilyab2816c4a35e3
diff --git a/docs/docs/cheatsheet.md b/docs/docs/cheatsheet.md
index 31ed316d0..c5f11e0c4 100644
--- a/docs/docs/cheatsheet.md
+++ b/docs/docs/cheatsheet.md
@@ -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")
)
```
@@ -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