.

Technology

GBNF grammars

GBNF (GGML Backus-Naur Form) is a grammar definition language used to strictly constrain Large Language Model (LLM) output, ensuring predictable, structured formats like JSON.

GBNF (GGML Backus-Naur Form) is an extension of the classic Backus-Naur Form (BNF), engineered specifically for Large Language Models (LLMs) to enforce structured output. Developed within the `llama.cpp` framework, it uses production rules to define the exact syntax a model must follow, moving beyond simple prompt engineering. This capability is critical for applications demanding predictable data: a GBNF grammar can compel an LLM to generate perfectly valid JSON, a specific XML schema, or even formal structures like chess notation (e.g., `1. e4 e5`). The format incorporates modern regex-like features, including repetition symbols (`*`, `+`) and optional elements (`?`), providing a precise and powerful mechanism for output steering.

https://github.com/ggerganov/llama.cpp/blob/master/grammars/README.md
1 project · 1 city

Related technologies

Recent Talks & Demos

Showing 1-1 of 1

Members-Only

Sign in to see who built these projects