Skip to content

Commit 9b26700

Browse files
authored
Update minimal-example.mdx
1 parent 88c0a16 commit 9b26700

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

docs/quick-start/minimal-example.mdx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,15 @@ Before we delve into the example, let's ensure our environment is properly confi
1616

1717
```python
1818
import dspy
19-
# from dspy.datasets import DataLoader
20-
from dspy.datasets.gsm8k import gsm8k_metric
19+
from dspy.datasets.gsm8k import GSM8K, gsm8k_metric
2120

2221
# Set up the LM
2322
turbo = dspy.OpenAI(model='gpt-3.5-turbo-instruct', max_tokens=250)
2423
dspy.settings.configure(lm=turbo)
2524

2625
# Load math questions from the GSM8K dataset
27-
dl = DataLoader()
28-
29-
gms8k = dl.from_huggingface('gsm8k', "main", input_keys=('question'))
30-
31-
gsm8k_train = dl.sample(gms8k['train'], 10)
32-
gsm8k_valid = dl.sample(gms8k['test'], 10)
33-
34-
# Split into test and dev sets
35-
split = dl.train_test_split(gsm8k_valid, train_size=0.5)
36-
gsm8k_valid = split['train']
37-
gsm8k_test = split['test']
26+
gms8k = GSM8K()
27+
gsm8k_trainset, gsm8k_devset = gms8k.train[:10], gms8k.dev[:10]
3828
```
3929

4030
## Define the Module
@@ -63,7 +53,7 @@ config = dict(max_bootstrapped_demos=4, max_labeled_demos=4)
6353

6454
# Optimize! Use the `gms8k_metric` here. In general, the metric is going to tell the optimizer how well it's doing.
6555
teleprompter = BootstrapFewShot(metric=gsm8k_metric, **config)
66-
optimized_cot = teleprompter.compile(CoT(), trainset=gsm8k_train, valset=gsm8k_valid)
56+
optimized_cot = teleprompter.compile(CoT(), trainset=gsm8k_trainset, valset=gsm8k_devset)
6757
```
6858

6959
## Evaluate
@@ -97,4 +87,4 @@ Feel free to adapt and expand upon this example to suit your specific use case w
9787

9888
***
9989

100-
<AuthorDetails name="Herumb Shandilya"/>
90+
<AuthorDetails name="Herumb Shandilya"/>

0 commit comments

Comments
 (0)