Skip to content

Commit

Permalink
docs(choice): update README
Browse files Browse the repository at this point in the history
  • Loading branch information
g-prz committed Nov 22, 2024
1 parent 01bb18d commit 5e78c7b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,29 @@ generator = outlines.generate.choice(model, ["Positive", "Negative"])
answer = generator(prompt)
```

You can also pass these choices through en enum:

````python
from enum import Enum

import outlines

class Sentiment(str, Enum):
positive = "Positive"
negative = "Negative"

model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")

prompt = """You are a sentiment-labelling assistant.
Is the following review positive or negative?
Review: This restaurant is just awesome!
"""

generator = outlines.generate.choice(model, Sentiment)
answer = generator(prompt)
````

### Type constraint

You can instruct the model to only return integers or floats:
Expand Down

0 comments on commit 5e78c7b

Please sign in to comment.