Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve precision of grammar_strict #94

Merged
merged 1 commit into from
Aug 4, 2024
Merged

Improve precision of grammar_strict #94

merged 1 commit into from
Aug 4, 2024

Conversation

shubhamugare
Copy link
Collaborator

In some cases, we are underapproximating the next token set, the model may behave weirdly. This is mainly because the grammar-constrained decoding forces the model to generate whitespace " " and the next word separately. The current LLMs are not trained to generate words after whitespace, and the model's quality can degrade.

Hence, in this PR we improve the precision of this approach by using accept sequences of length 3 in certain cases. Mainly, when %ignore tokens such as whitespace are present, this would enable SynCode to have a further lookahead.

Consider a case, input = "I" and the model's next choice is to choose " have" as the next token. SynCode with single lookahead and underapproximating grammar_strict mode, would force the model to generate " ". Typically, during the model's actual training, the model is not trained on inputs ending with whitespace. Thus, in the next step, when input="I ", the model's behavior seems to be poorer.

To fix this, in this PR we allow a longer lookahead accept sequences in some cases.

@shubhamugare shubhamugare merged commit b26b19e into main Aug 4, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant