Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement text.generate.format constrained generation #358

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

rlouf
Copy link
Member

@rlouf rlouf commented Nov 12, 2023

text.generate.format takes a model, a Python type and returns a generator which, given a prompt, will output text in the format described by the Python type:

from datetime import datetime

from outlines import models
from outlines import text


model = models.transformers("gpt2")
result = text.generate.format(model, datetime.date)("Which day is today?")
# 2023-11-12

Closes #346.

TODO

  • int
  • float
  • datetime.datetime
  • datetime.date
  • datetime.time
  • bool
  • Add some documentation + README

outlines/text/format.py Outdated Show resolved Hide resolved
@rlouf rlouf force-pushed the add-format-generation-method branch 5 times, most recently from 1c35d70 to 79e0879 Compare November 13, 2023 17:57
@rlouf rlouf changed the title Implement "text.generate.format" constrained generation Implement text.generate.format constrained generation Nov 13, 2023
@rlouf rlouf force-pushed the add-format-generation-method branch 2 times, most recently from d0a45d2 to b480d39 Compare November 13, 2023 21:40
@rlouf rlouf marked this pull request as ready for review November 13, 2023 21:43
@rlouf rlouf force-pushed the add-format-generation-method branch from b480d39 to 9e05bd3 Compare November 13, 2023 21:49
@rlouf rlouf merged commit 4594704 into outlines-dev:main Nov 13, 2023
5 checks passed
@rlouf rlouf deleted the add-format-generation-method branch November 13, 2023 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type-guided generation
1 participant