How to create grammars? #2560
Replies: 5 comments
-
Huh, well I finally got it work with
I'm not sure which part was the issue, but it would be helpful if it were more clear. |
Beta Was this translation helpful? Give feedback.
-
I would like to know, when provided with the grammar is it a strong recommendation for the LLM, or does it have to follow it? Just trying to figure out if my grammar is wrong or if I just need to prompt it better.
should evaluate to something like
but it will sometimes output
instead, which I think is wrong, at least with my current understanding of BNF. It's certainly not what I want. |
Beta Was this translation helpful? Give feedback.
-
What's before that? Is it something that could match |
Beta Was this translation helpful? Give feedback.
-
No it will literally reply just that, nothing before it. It shouldn’t start with a quote, but it is. |
Beta Was this translation helpful? Give feedback.
-
I'm not an expert on BNF but for what it's worth I don't see a reason for the behavior you're describing. It also looks like the sampler assigns -INF to the tokens it rejects: https://github.com/ggerganov/llama.cpp/blob/25d43e0eb578b6e73046d9d6644a3a14d460600d/llama.cpp#L2671-L2675 It also doesn't seem like it ever boosts the probability for tokens, only penalizes the ones it "rejects". Quoting "rejects" here because I don't know definitively what that means. One would presume everything that doesn't match a token the grammar can accept should be rejected but using a list for that seems a little weird to me. A lot of the time, it's going to be a list of nearly every token the model supports. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've looked at the basic BNF syntax and examples in the repo, but when trying to create my own it just crashes with LLAMA_ASSERT(false) on line 2203.
It's got something to do with the 'argument' part, it isn't a problem when I comment out the declaration and usage.
Beta Was this translation helpful? Give feedback.
All reactions