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

Sequential generation #305

Open
freckletonj opened this issue Sep 30, 2023 · 3 comments
Open

Sequential generation #305

freckletonj opened this issue Sep 30, 2023 · 3 comments
Labels
enhancement transformers Linked to the `transformers` integration

Comments

@freckletonj
Copy link

freckletonj commented Sep 30, 2023

Per @brandonwillard 's suggestion, I'm adding a feature request to allow generated text to be tied to a variable for easy access; useful in the case where one prompt has multiple pieces being generated, and you want access to each.

guidance offers a feature that looks like this:

prompt = '''
Here's one sentence: {{gen "SENTENCE_1"}}
Now, another sentence: {{gen "SENTENCE_2"}}
'''
out = guidance(prompt)()

print(out['SENTENCE_1'])
# <prints what the LLM generated>

print(out['SENTENCE_2'])
# <prints the other sentence>

Already, outlines allows this from the generation side:

prompt = '''
Here's one sentence: [a-z]{0,50}
Now, another sentence: [a-z]{0,50}
'''

But the user would have to parse each sentence out themselves.

Python has a syntax that allows this for instance, perhaps we copy that?

pattern = r"(?P<day>\d{2})-(?P<month>\d{2})-(?P<year>\d{4})"
text = "The date is 25-12-2021"
match = re.search(pattern, text)

edit: upon experiment, that date pattern already works great with outlines and generates a valid(ish) date. Our regex parser already respects the naming syntax then, apparently!

@freckletonj freckletonj changed the title Feature Req: Tie Generated text to Variables Feature Req: Tie Generated text to Keys Sep 30, 2023
@rlouf
Copy link
Member

rlouf commented Oct 6, 2023

@freckletonj thank you for opening an issue! Would you mind moving your message to #305 so we can consolidate requirements there?

@freckletonj
Copy link
Author

This is #305, do you mean add it to #182? I've left a comment over there: #182 (comment)

@rlouf
Copy link
Member

rlouf commented Oct 6, 2023

Yes sorry 😅

@rlouf rlouf changed the title Feature Req: Tie Generated text to Keys Sequential generation Jan 26, 2024
@rlouf rlouf added the transformers Linked to the `transformers` integration label Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement transformers Linked to the `transformers` integration
Projects
None yet
Development

No branches or pull requests

2 participants