Open JasperDekoninck opened 1 year ago
Is anyone working on this atm? If not I think I could do this
Go ahead :) Currently noone is actively working on this.
Marking this as a good first issue to work on.
The place to start implementation is https://github.com/eth-sri/lmql/blob/main/src/lmql/ops/ops.py#L825. Relevant methods to override are:
stop
to indicate the decoder whether to stop at the current tokenpostprocess_var
/postprocess
to indicate to the decoder when postprocessing is required (e.g. to truncate a token, in the middle of which a stopping expression triggered)postprocess_order
to make sure multiple stopping phrases on the same variable are resolved to the highest-priority one.I'm working on this
It would be very helpful to be able to have more advanced stopping conditions in STOPS_AT/STOPS_BEFORE. One use case for stopping conditions with lists instead of strings, is that:
is a lot easier than:
For more advanced conditions based on regexes, one could look at the "calculator" example from the "tool-augmented queries". Using regexes, it would be possible to do this without few-shot examples (note that my regexes might not be exactly correct):