This seems extremely similar to https://github.com/newhouseb/clownfish
A regex is a better fit for a different class of problems. You might implement a JSONformer/clownfish with this instead.
fn complete(input, masker):
completion = input
while (not done yet):
mask = masker(completion)
completion = complete(complete, mask)
end
return completion
end
is that accurate?You have to go one token at a time, otherwise the masking becomes combinatoric rather than linear (two tokens at a time -- need to generate all two token pairs, etc.).
But otherwise, that's what the code does! https://github.com/r2d4/rellm/blob/main/rellm/rellm.py#L21