-
Notifications
You must be signed in to change notification settings - Fork 585
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
Capturing and referencing variable in output #1516
Comments
Full code
Output:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sometimes outside of getting a structured output for the final answer, you might want to get the intermediate output by LLM and reference them in a later stage. Together with #1407 (and related #1434 #1480) here a interface of doing is is proposed.
Using a named variable it could be possible to pass value forward, e.g. for a simple example to count number of r in the word 'strawberry':
Then each letters in
Capture
can be parsed into a listAnd then create pattern using a loop so to emulate the effect of a for loop without LLM output
Alternatively one can also capture a value e.g.
String("Integer: ") + capture(integer, "integer_value")
, then parse it usingint_val = parse_value("integer_value", int)
to cast into python type withHere is my prototype of the implementation: https://github.com/903124/outlines/tree/capture
Looking forward to any suggestion or enhancement!
The text was updated successfully, but these errors were encountered: