Workshop · Constrain
Guidance
Write the shape. Mix fixed text with generation holes. Restrict those holes with a grammar, an enum, or a regex. The model fills only what the decoder allows. Parse-and-retry is the fallback you should not need for constrained fields.
What a template cannot do
A library template that says “return JSON” still lets the model emit a poem. Structure after the fact is cleanup, not control.
- Not a persona library.
- Not live constrained decoding on this site.
- Not a guarantee if the grammar itself is wrong.
How it works
Conceptual workflow
Steppable map of Guidance. Evidence is taken from the spec on this page. Nothing here is a live compiler, eval, decoder, or optimizer run.
vcp · prompts/guidance
run@once
- template
- grammar
- decode
- emit
Stage 1 / 4 · receive
Write the template
Literals and holes. The literals will appear in the output. The holes are the only places the model may speak.
Artifact · template.guidance
User input
Need a ticket JSON with status and id.
Rule in force
Fix the keys; generate the values.
Visible reply
{"status": {{gen}}, "id": {{gen}}}
Illustration · not a live model run
Spec evidence
Guidance controls generation structurally. Instead of asking a model to “return JSON” and hoping, you interleave fixed text with constrained holes. A template mixes literals with generation sites: {{gen}}, {{#select}}, and grammar-backed captures. The literals are not suggestions. They are tokens that will appear. Constrained decoding restricts the next token to the legal set: an enum choice, a regex, a JSON grammar, or a context-free grammar. Illegal tokens are not sampled. The decoder fills only the holes. If the grammar says a field is a number, the model cannot emit a paragraph there. Structure is enforced at generation time, not cleaned up afterwards. The output is a valid object or a valid string in the declared language. Parse errors become impossible for the constrained fields — unless the grammar itself is wrong. Guidance is not running in this laboratory. The workflow shows where constraint happens: in the decoder, not in a later apology.
- This page is a conceptual map
- The compiler or eval runner is not executed here
Method
Constrain loop · not executed here
Library
A pasted persona belongs in the library
Conceptual workflow · 4.5s / stage · 1/4