Why prompting alone isn't enough
A language model samples tokens from a probability distribution. Even a model that has seen your DSL can assign nonzero probability to a token that breaks it, and over enough generations that token eventually gets sampled. No amount of prompt wording removes the possibility, because the wrong tokens are still on the menu.
The structural fix is to take them off the menu. If the grammar says only certain tokens are legal next, mask the rest before sampling. Now invalid output isn't unlikely — it's unreachable.
Verify with a parser, not the model
Generation handles 'produce valid DSL'; you still want to confirm 'is this string valid DSL', and that's a parser's job, not a model's. dslai generates a deterministic validator from the same grammar, so checking is exact and reproducible: it returns valid, or invalid at a specific position with what it expected there.
That separation matters — an LLM asked to grade its own output can be confidently wrong, while a parser cannot. You get a compiler-style verdict you can act on.
how it works
- 01
bring your grammar
Paste your DSL's EBNF/GBNF-style grammar into dslai — no training set.
- 02
compile the constraint
dslai turns the grammar into a decoding mask that keeps output inside the language.
- 03
generate
Produce snippets that are syntactically valid by construction.
- 04
validate
Run any input through the deterministic parser to confirm it — and see exactly where it breaks if not.
frequently asked
- Will this work for my custom language specifically?
- If you can express it as a grammar — which you can if it has a parser or a spec — dslai can constrain generation to it and validate against it. The playground lets you paste your grammar and try it immediately.
- Does constraining hurt the model's quality?
- It only removes syntactically illegal options; the model still chooses freely among valid ones. For semantic quality on top, you can add retrieval over your docs or, for hard cases, fine-tune a small model.
- What if my grammar is ambiguous?
- Constrained generation still only produces strings in the language; dslai's validator handles ambiguity by exploring valid parses and accepts input if any parse consumes it.
- Is there an API I can call from my pipeline?
- A hosted API and a CI validation check are on the roadmap as paid tiers. The free playground today runs the same engine in your browser so you can prove the approach first.
Last updated June 7, 2026