I built a GBNF grammar compiler that makes 8B models reliably call tools - here's how it works (deep dive)
Summary
A developer built a GBNF grammar compiler in Rust for llama.cpp that enforces tool-calling JSON schemas, making small models (like 8B parameters) reliably call tools. The system narrows grammar to only matched tools per turn, improving reliability.
Similar Articles
How I made small local AI models stop breaking JSON - a grammar-based approach
The author presents a method using GBNF grammars in llama.cpp to constrain local AI model outputs, ensuring valid JSON. A compiler is built to convert tool schemas into grammar rules, with per-turn narrowing for relevant tools.
Building a Rust Inference Engine That Matches Llama.cpp
Ferrox is a pure-Rust inference engine that loads GGUF models and runs local LLMs on CPU, Metal, or CUDA, with a CLI and an OpenAI-compatible server. It aims to match llama.cpp's performance while being written from scratch with no bindings.
Little Brains, Big Feats: Exploring Compact Language Models
This paper benchmarks 17 compact language models (1B-8B parameters) as generators in Russian-language RAG systems under CPU-only inference, finding that Qwen-family models offer strong quality-latency tradeoffs for private, GPU-free deployment.
I benchmarked PrismML's 1-bit Bonsai-8B against IBM's Granite on CPU tool calling. The 1-bit model won, but only with grammar-constrained decoding
An independent benchmark of PrismML's 1-bit Bonsai-8B against IBM's Granite and other models on CPU tool calling shows that with grammar-constrained decoding, Bonsai-8B achieves a 92% pass rate, outperforming larger models, but fails without constraints. Granite is the best raw model at 72%.
10,000 Lines Later: When a Tool Became a Compiler - Rob Durst - Gleam Gathering 2026
At Gleam Gathering 2026, Rob Durst shared how he rewrote a YAML-to-Terraform configuration tool as a compiler using Gleam, and how he came to appreciate the power of type-driven design and the decoder pattern.