bench/grammar_check.sh results

  • Date: 2026-11-28
  • Code: pg_grammar_guard 0.5.0 (commit b8b93e1, loaded from the checkout through extension_control_path).
  • PostgreSQL 19.0, built from REL_19_STABLE 8efc01ba3ec, CFLAGS=-O2, no assertions.
  • GBNF parser: llama.cpp test-gbnf-validator (build_vulkan, source tree at c46758d).
  • Machine: AMD Ryzen AI 9 HX 370, Fedora, Linux 7.3.3. Sizes do not depend on the machine.
  • Commands: GBNF_VALIDATOR=<llama.cpp>/build_vulkan/bin/test-gbnf-validator bash bench/grammar_check.sh and TABLES=200 bash bench/grammar_check.sh, each against a throwaway server.

Size

Each generated table has id, created_at and four columns of its own (EXTRA=4).

tables distinct columns (table, column) pairs flat gbnf correlated gbnf flat json_schema
81 326 486 7,958 B 18,156 B 12,618 B
200 802 1,200 19,382 B 44,655 B 30,587 B

Each GBNF grammar is 16 bytes longer than with 0.4.10: its one ws rule is now bounded.

GBNF acceptance (81 tables)

13 of 13 inputs answered as expected:

grammar input expected and got
flat a column of the chosen table accepted
correlated a column of the chosen table accepted
flat a column of another table accepted
correlated a column of another table refused
flat a column that exists nowhere refused
correlated a column that exists nowhere refused
correlated a table that exists nowhere refused
README quickstart tax_id of readme.customers accepted
README quickstart email of readme.customers refused
README quickstart 10,000 spaces before the first key refused
README nested spec the JSON line shown in the README accepted
README nested spec "action":"drop" refused
README nested spec four items in columns (max_items 3) refused

These replace figures the README carried without a script or record behind them: sizes of 10.9 KB / 22.2 KB over a private 81-relation catalog, an extrapolated 55 KB at 200 relations, “5/5” under XGrammar, and the answers of a local 35B model (8/8 against 0/8, and a table of three prompts). No language model was run for this file.