GBNF, a rebranding of Backus-Naur Form is a kind of Regex if you somehow made Regex more obtuse and clunky and also way less powerful. It's like going to the dentist in text form. It is bad, and should feel bad.
HOWEVER, if you tame this vile beast of a language you can make AI respond to you in pretty much any way you like. And you should.
You can use it by pasting GBNF into SillyTavern, Oobabooga, or probably something else you might be using. First, click on the
then scroll down and paste it like so:
In Ooba, you can go to
And then
Note that not all loaders support it, I think it's limited to llama.cpp, transformers, and _HF variants.
Then, your next messages will be formatted like you wanted. In this case, every message will be "quoted text"
, *action text*
or multiple instances. It should be simple to understand.
Here's that one in case you want it, I just wrote it and tested it:
root ::= (actions | quotes) (whitespace (actions | quotes))*
actions ::= "*" content "*"
quotes ::= "\"" content "\""
content ::= [^*"]+
whitespace ::= space | tab | newline
space ::= " "
tab ::= "\t"
newline ::= "\n"
Even if you don't know Regex this language should be easy to pick up, and will allow you to make LLMs always respond in a particular format (very useful in some cases!)
You can also look at the examples.
There are websites to test BNF like this one but since it's a badly designed, badly implemented language from hell, none of them will work and you will have to look at the console to find out why this ugly duckling of a language didn't want to work this time. Imagine if Batch files had regular expressions, it'd probably look like this. All of that said, this is pretty fucking useful! So thanks to whoever did the heavy lifting to implement this.
I won't stand for this slander for GBNF, there's a reason why programming language grammar is defined in GBNF and not regexes.
Actually GBNF is this re-branding, BNF is the proper name (the G is Georgi Gerganov's). There's also a reason why languages compile to assembly but that doesn't mean it's user-friendly. Or Abstract Syntax Trees. There's stuff that pretty much only applies to compilers, doesn't mean it's a good general-purpose solution.
Though I must imagine implementing BNF is orders of magnitude easier than implementing the monster that is extended regular expressions.