<!-- llms-explorer concept facts · https://llms-explorer.com/tree/grammar-aware-draft-filtering-for-ngram-and-draf/ · pack 2026-10-05 · ~504 tokens -->

# Grammar-aware draft filtering for ngram and draft-model drafters

> speculative-decoding-with-structured-output-gram.md already holds verifier-side grammar handling and its asserted statement that no grammar-aware draft filtering exists; this file adds the drafter-side evidence for that statement.

Parent: [Mac local LLMs: Speculative decoding and MTP](https://llms-explorer.com/tree/mac-local-llms-speculative-decoding-and-mtp/) · 1 facets · 5 facts · page: https://llms-explorer.com/tree/grammar-aware-draft-filtering-for-ngram-and-draf/

## Facts

- speculative-decoding-with-structured-output-gram.md already holds verifier-side grammar handling and its asserted statement that no grammar-aware draft filtering exists; this file adds the drafter-side evidence for that statement. — source: `asserted`
- In `common/speculative.cpp` the draft-model drafter builds its per-sequence samplers with `top_k = 10` and `samplers = { TOP_K }` only, with no grammar field set, so the drafter proposes tokens without any grammar mask. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/speculative.cpp)
- The draft sampler rebuild for rejection-style verification uses `samplers = { TOP_K, TEMPERATURE }` with top_k 10 at the target's temperature and a seed XORed with 0x85ebca6b, and again sets no grammar. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/speculative.cpp)
- `common/speculative.cpp` registers five n-gram drafter types by name: ngram-simple, ngram-map-k, ngram-map-k4v, ngram-mod and ngram-cache; the file includes ngram-cache.h, ngram-map.h and ngram-mod.h. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/speculative.cpp)
- A grep of the file for grammar or GBNF finds no match, so neither the n-gram drafters nor the draft-model drafter filter proposals against a grammar; filtering happens only at target verification. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/speculative.cpp)
