Skip to content

Conversation

HanClinto
Copy link
Contributor

Resolves #3878 by ensuring the existence of a "root" symbol before returning a valid grammar.

NOTE: There are two possible locations to put this fix -- the alternate location is to put it in sampling.cpp->llama_sampling_init(), which is the only place where the "root" node is named as required. That fix would look like this.

@ggerganov Do you have preference on the two versions of this fix? I think this main difference is -- philosophically -- do we want all grammars to require a "root" node (if so, then put it in grammar-parser), or if it's possible to have a grammar without a "root" node (that's technically a syntactically correct grammar, but it's missing our expected entry point), then we should put the fix in sampling.cpp.

@ggerganov
Copy link
Member

The fix should be in sampling.cpp - no need to require root node in the grammars

…urning valid grammar structure. This is an alternate fix location to put the required root node in sampling.cpp instead of grammar-parser.cpp.
@HanClinto HanClinto force-pushed the fix_gbnf_root_required branch from bfcf545 to 10ac60b Compare March 12, 2024 15:14
@HanClinto
Copy link
Contributor Author

The fix should be in sampling.cpp - no need to require root node in the grammars

Excellent, thank you!

This branch is now updated.

@ggerganov ggerganov merged commit 4636283 into ggml-org:master Mar 13, 2024
NeoZhangJianyu pushed a commit to NeoZhangJianyu/llama.cpp that referenced this pull request Mar 15, 2024
hodlen pushed a commit to hodlen/llama.cpp that referenced this pull request Apr 1, 2024
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.

Malformed grammar crashes the server

2 participants