Nodes/Kinburg-Nodes/Grammar Presets
ComfyUI Node

Grammar Presets

Force your local LLM into a shape it can't talk its way out of

By Kinburg·Created 3 months ago·Updated 6 days ago· 1
Grammar Presets
    • grammar
    presetCharacter Card (JSON)

    Ask a chat LLM for JSON and you'll get JSON - eventually, after a preamble, maybe a closing flourish, and a whole lot of praying that your parser tolerates prose. The grown-up fix is a GBNF grammar: it constrains decoding so the model physically cannot emit anything outside the shape you declared. Grammar Presets is a dropdown of those grammars.

    It ships with templates that force an LLM's output into a fixed structure: Character Card (JSON), Entity Card (JSON), plus two music-related ones (Siren Song Config (text), Siren Voice Plan (table)). Pick one, and the grammar output carries the GBNF template as a string. Wire it into a Local LLM (GGUF) node's grammar_override input, and that node's structured output comes back in exactly that shape.

    The input that matters:

    • preset - the grammar template. Add your own with the ➕ Add grammar button (persisted on disk, and it survives a git pull because user grammars live separately from the shipped ones).

    The output:

    • grammar - the GBNF string. This is what you wire into Local LLM (GGUF)'s grammar_override.

    The canonical flow: Grammar PresetsLocal LLM (GGUF) (grammar_override) + a photo + a short prompt like "fill the card from this image" → Card Save. The vision model returns exactly the card structure, straight from the picture, no JSON-extraction dance. The grammar's JSON keys already mirror the card fields 1:1, which is what makes Card Save so frictionless.

    The music grammars are the same trick pointed at a different target, and the pack's docs include the classic grammar gotcha worth remembering: with grammar-constrained generation, open-ended repetition can trap the model. The Voice Plan grammar bounds its rows and requires a closing END line for exactly that reason - and when you run a grammar-constrained pass you should turn the truncation samplers off (top_p 1.0, top_k 0, min_p 0) and repeat_penalty with them, because a table format mandates repeated tokens and penalizing them fights the grammar. That's the kind of footgun detail the pack's docs actually warn you about, which is rare.

    Install via ComfyUI Manager (search "Kinburg-Nodes") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Kinburg/Kinburg-Nodes
    

    then restart. The node itself is just a string store - no dependencies - but it only does something once the pack's Local LLM (GGUF) node is working, which means llama-cpp-python (auto-installed by install.py, CUDA-matched to your torch) and a GGUF model of your own. One-author personal pack, 95 nodes, per-package docs, and a 1395-check test suite that keeps the docs honest with the real schema.

    CategoryKinburg-Nodes/LLM/presets

    Inputs (1)

    NameTypeDefaultDescription
    presetCOMBOCharacter Card (JSON)The GBNF grammar template. Add your own with '➕ Add grammar'. Wire the 'grammar' output into a Local LLM (GGUF) node's grammar_override.

    Outputs (1)

    NameTypeDescription
    grammarSTRING