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 eval method and chain function to compile outlines graphs #42

Merged
merged 4 commits into from
Apr 5, 2023
Merged

Conversation

rlouf
Copy link
Member

@rlouf rlouf commented Apr 5, 2023

We first provide a chain function which allow to compile outlines graph to an executable function:

import outlines
from outlines.text import string

s = string()
t = string()
o = s + " " + t
chain = outlines.chain([s, t], o)
print(chain("one", "two"))
# one two

We also add an eval method to Variables to make it easier to evaluate variables during debugging:

import outlines
from outlines.text import string

s = string()
t = string()
o = s + " " + t

print(o.eval({s: "one", t: "two"}))
# one two

In a future iteration we may want to rename chain to function and implement chain a decorator around a function instead:

import outlines

@outlines.chain
def add(s: str, t: str):
    return s + t

print(add("one", "two"))
# one two
import outlines

def add(s: str, t: str):
    return s + t

print(outlines.chain(add)("one", "two"))
# one two

We also add meta-prompting examples in the examples folder. Closes #1.

@rlouf rlouf merged commit 1645a4e into main Apr 5, 2023
@rlouf rlouf deleted the eval branch April 5, 2023 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement LMQL Fig.4
1 participant