Structured output
Inferlets that constrain the model's output to a grammar, a JSON Schema, or a templated form. The same idea in three languages.
Running on the dummy driver?
The dummy driver honors constraint masks, so these inferlets emit in-grammar / schema-valid output — but the content inside the structure (string field values, numbers) is uniform random. The structural assertions hold; semantic ones don't.
| Inferlet | What it shows |
|---|---|
constrained-decoding | Grammar-constrained decoding with a Lark grammar. |
json-schema-validation | JSON generation constrained against a runtime-string JSON schema. |
template-generation | Grammar-constrained JSON merged with a Jinja2 template. |
python-constrained-decoding | Same idea in Python. |
js-constrained-decoding | Same idea in JavaScript. |
Related guide
- Constrained generation: the
SchemaandConstrainAPI these inferlets use. - Generator:
collect_jsonand theconstrainbuilder method.