Add anything
and until
method in the DSL for reasoning models
#1480
Labels
anything
and until
method in the DSL for reasoning models
#1480
This was triggered by trying to make structured generation with DeepSeek, where we want to let the model generate anything (unstructured) between the
think
tags, and start structured generation after</think>
has been generated. It would thus make sense to have ananything
construct that corresponds to.*
, the unstructured case. Intuitively, we could adduntil
method so that users could write the following for a classification taskThe implementation is trickier than it looks,
anything.until("<think>")
is best expressed with a negative lookahead:but the regex engine that
outlines-core
uses does not support lookaheads. However, it is equivalent to the following regular expression:The idea would thus be to have
anything.until
generate aRegex
node with an "expanded lookahead". Computing the expansion shouldn't be too hard.Note: we could also decide that "until" keeps the "" token. We should discuss.
Regexes
It is tempting to also implement
until_regex
this way. It is very simple for simple patterns like[0-9]
:however it can get complicated quite quickly, for instance
anything.until_regex("(abc|def)")
which we would need to translate to:so we will not implement this in the first iteration.
The text was updated successfully, but these errors were encountered: