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

Add Outlines #1346

Open
rlouf opened this issue Dec 19, 2024 · 2 comments
Open

Add Outlines #1346

rlouf opened this issue Dec 19, 2024 · 2 comments
Milestone

Comments

@rlouf
Copy link
Member

rlouf commented Dec 19, 2024

(name to be defined)

Following #1226 and #1220 we will be able to implement the following interface:

from outlines import Outline, models

model = models.transformers("gpt2")

def template(a: int) -> str:
    return f"What is 2 times {a}?"

fn = Outline(model, template, int)

where fn is a callable object whose arguments are the arguments to the prompt template:

fn(1)
# 2

fn(3)
# 6
@rlouf rlouf added this to the 1.0 milestone Dec 19, 2024
@yvan-sraka
Copy link

yvan-sraka commented Dec 20, 2024

Why, in your example, is the interface name_to_be_defined(model, template, int) instead of just name_to_be_defined(model, template)? (and, since models is provided by outlines too, wouldn't it make sense to directly provide model.name_to_be_defined(template)?)

Here, template is just any lambda or function that return an str, right? The arguments of the function could likely be inferred (since, iirc, Python is offers a lot of reflexivity) at runtime from the function pointer.

@rlouf
Copy link
Member Author

rlouf commented Dec 20, 2024

The third argument to name_to_be_defined is the output type. Here we're telling the model we want it to return an integer, which is enforced by structured generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants