Skip to content

Commit

Permalink
Fix samplers documentation (#980)
Browse files Browse the repository at this point in the history
This fixes issue #978. Specifically for the classification example in
the outlines cookbook section
[here](https://outlines-dev.github.io/outlines/cookbook/classification/),
it fixes the piece of code in
outlines.generate.api.SequenceGeneratorAdapter that keeps returning the
wrong result (i.e. returning False even if a specific sampler is passed
(greedy, multinomial, or beam search).
  • Loading branch information
jrinder42 committed Jun 18, 2024
1 parent 26142d5 commit 63ac124
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/cookbook/classification.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Outlines provides a shortcut to do multi-label classification, using the `outlin
```python
from outlines.samplers import greedy

generator = outlines.generate.choice(model, ["URGENT", "STANDARD"], sampler=greedy)
generator = outlines.generate.choice(model, ["URGENT", "STANDARD"], sampler=greedy())
```
Outlines supports batched requests, so we will pass two requests to the model:

Expand Down Expand Up @@ -96,7 +96,7 @@ class Classification(BaseModel):
and we can use `generate.json` by passing this Pydantic model we just defined, and call the generator:

```python
generator = outlines.generate.json(model, Classification, sampler=greedy)
generator = outlines.generate.json(model, Classification, sampler=greedy())
labels = generator(prompts)
print(labels)
# [Classification(label=<Label.urgent: 'URGENT'>), Classification(label=<Label.standard: 'STANDARD'>)]
Expand Down

0 comments on commit 63ac124

Please sign in to comment.