You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following this issue (thanks @marcotcr for the quick reply !), would it be possible to add more gen arguments in the substring component ?
For instance name to save the result of the generation, regex to allow only substrings that respect a given pattern,max_tokens to limit the generation, stop to stop it etc.
This substring is really great because it limits hallucinations, thanks for it :)
Thanks,
Simon
The text was updated successfully, but these errors were encountered:
Hi there. We really need to document the features in the grammar library, but in the meantime he is an example where we:
Save the result of a generation in a variable, using capture, even when something is optional
Set max_tokens only on part of the grammar, using token_limit
fromguidanceimportcapture, substring, select, regex, token_limit# Either substring or a number with at most one tokengrammar=select(
[capture(substring('This is very cool.'), name='substring'),
token_limit(capture(regex('\d+'), name='number'), 1)])
lm=llama2+'Hi there, here is a sentence "'+ (grammar+'"')
lm=llama2+'Hi there, here is a sentence "'+ (grammar+'"')
lm['substring']
Hi there, here is a sentence "This is very cool."
lm=llama2+'Hi there, here is a number: '+grammarlm['number']
Hello,
Following this issue (thanks @marcotcr for the quick reply !), would it be possible to add more
gen
arguments in thesubstring
component ?For instance
name
to save the result of the generation,regex
to allow only substrings that respect a given pattern,max_tokens
to limit the generation,stop
to stop it etc.This
substring
is really great because it limits hallucinations, thanks for it :)Thanks,
Simon
The text was updated successfully, but these errors were encountered: