AIFeed

Sieve-df: a Rust fuzzer for LLM structured-output engines (llguidance, outlines)

Original text(via HN AI)

sieve-df

题图
题图

Coverage-guided differential fuzzer for LLM structured-output engines

sieve-df

At every decoding step sieve-df checks whether an engine's token mask allows exactly the right tokens for a JSON Schema. It needs no model weights: it loads an ungated tokenizer.json (for example a Qwen tokenizer from Hugging Face) and does random token walks over the mask, weighted toward boundary tokens such as ":, "},{" and leading-space tokens.

EngineHow it is driven
llguidanceRust crate, linked directly
outlines-coreRust crate, linked directly
XGrammarPython, through a JSON-lines subprocess bridge
llama.cpp grammar sampler (optional)via llama-cpp-python and a vocab-only GGUF generated from tokenizer.json ; scripts/setup_llamacpp.sh ; needs a real tokenizer

Everything is free and open source; nothing needs an account, API key or card.

What it finds

  • Contradictions – the mask allows a token, but the engine rejects it when it is fed.
  • Dead ends – an allowed token leads to a state with an empty mask that cannot finish.
  • Disagreements – two engines differ on one token. To decide who is right sieve-df tries to finish the output and validates it with jsonschema-rs: a valid finish means the blocking engine is too strict; if none can be produced, the allowing engine is too loose.
  • Invalid outputs (EOS allowed for a document that violates the schema), crashes (engine panics, isolated) and hangs (compile blow-ups).

Each bug is shrunk to a minimal schema plus token path, written as a markdown issue draft, and counted in an engine x JSON Schema feature x tokenizer table.

Quick start


        cargo build --release
examples/quickstart.sh            # built-in vocabulary, bundled schemas, no downloads
      

With a real tokenizer and the other engines:


        scripts/fetch_tokenizer.sh        # Qwen2.5 tokenizer.json -> data/tokenizers/qwen2.5.json
scripts/setup_xgrammar.sh         # optional: .venv with XGrammar (no torch needed)
scripts/fetch_corpora.sh          # optional: JSON Schema Test Suite + JSONSchemaBench

target/release/sieve-df run \
  --tokenizer data/tokenizers/qwen2.5.json \
  --engines llguidance,outlines-core,xgrammar \
  --builtin --mcp examples/mcp \
  --suite data/corpora/json-schema-test-suite \
  --bench data/corpora/jsonschemabench --bench-subsets Handwritten,Kubernetes \
  --mutants 3 --walks 20 --out out/run
      

Commands

CommandPurpose
sieve-df runfuzz: random walks ( --mode single│differential│both ) over the selected schemas; writes findings.jsonl , findings/*.json , stats.json
sieve-df replay <findings>re-run saved findings and report whether they still reproduce
sieve-df shrink <findings>reduce findings to a minimal schema + token path, deduplicated into unique bugs ( minimized.jsonl )
sieve-df report --minimized …write one markdown issue draft per bug, results.md/csv and index.md
sieve-df benchcompile and mask-computation latency per engine

Schema sources for run and bench: --schemas (files/dirs), --mcp (MCP tool definitions), --suite (JSON Schema Test Suite), --bench (JSONSchemaBench), --builtin, plus --mutants N to add mutated variants (nested anyOf, $ref recursion, pattern, unicode enums, escaped keys, bounds), --filter, --limit, --shuffle.

Coverage-guided fuzzing

fuzz/ holds cargo-fuzz targets that feed mutated schemas and walks to the linked engines with libFuzzer's coverage feedback; see fuzz/README.md.

Documentation

  • docs/findings.md – bugs found so far, each pinned by a test
  • docs/architecture.md – design, oracles, bridge protocol
  • CONTRIBUTING.md – setup, rules, adding engines and mutations

License

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗