Open Viagounet opened 1 week ago
Same here. Even an example that llama.cpp gives doesn't work with it, so I don't think its your fault. llama.cpp's json GBNF example
running into this as well on a slightly more complicated gbnf on a line value ::= object_type_1 | object_type_2
"parse: error parsing grammar: expecting newline or end at object_type_1 | object_type_2"
This is a snippet of test GBNF that llama_cpp is offering in llama_grammar.py.
string ::=
"\"" (
[^"\\\x7F\x00-\x1F] |
"\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
)* "\"" ws
In this code, repetition is done by actually repeating (writing down) token as many as we want, which differs from what original JSON GBNF sample does.
So, my current understanding is that disabled {m}
is intended feature and not a bug of llama-cpp-python's GBNF unlike the original GBNF.
I'm still not sure the reason why llama-cpp-python choose this behavior tho.
RIght, thanks for your answers. I ended up writing a function to automatically convert the bracket syntax into a set of repeating tokens. Not very elegant, but works well enough.
Bracket support for grammars was added about 3 weeks ago in https://github.com/ggerganov/llama.cpp/pull/6640 -- is this Python library referencing a version that includes this newest change?
Hello, I tried checking for similar issues about this problem but couldn't find one. I've had an issue with not being able to use the repetition brackets symbol when working with grammars.
I'm using Ubuntu 20.04, Python 3.12 and
llama_cpp_python==0.2.79
.The following works fine:
But this doesn't:
It returns this error:
The llama.cpp GBNF Guide seems to say it should be possible to use this pattern?
Not sure if my understanding of GBNF is lacking or if it's a real bug. Thank you!