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
Using SMC sampling we can generate sequences that follow arbitrary constraints. All we need is a function that takes previously-generated tokens, a possible completion and returns a boolean. For instance this example from LlamPPL to constrain the sequence generated to not have longer that are more than 5 letters long:
defcan_follow(str_so_far, s):
ifisinstance(s, llp.Token):
s=str(s)
iflen(s.strip()) >5:
returnFalseiflen(s.strip()) ==0:
returnTrueifnots[0].isalpha():
returnTrueiflen(str_so_far) ==0:
returnTrue# First token, can be alphanumericwords=str_so_far.split()
iflen(words) >=1andlen(words[-1]) +len(s) <=5:
returnTrueelse:
returnFalse
I propose to add a Constrained subclass to Sequence :
Using SMC sampling we can generate sequences that follow arbitrary constraints. All we need is a function that takes previously-generated tokens, a possible completion and returns a boolean. For instance this example from LlamPPL to constrain the sequence generated to not have longer that are more than 5 letters long:
I propose to add a
Constrained
subclass toSequence
:We will need to add a
create_proposal
and areweigh
method toSequence
.The text was updated successfully, but these errors were encountered: