Skip to main content

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.

InferletWhat it shows
constrained-decodingGrammar-constrained decoding with a Lark grammar.
json-schema-validationJSON generation constrained against a runtime-string JSON schema.
template-generationGrammar-constrained JSON merged with a Jinja2 template.
python-constrained-decodingSame idea in Python.
js-constrained-decodingSame idea in JavaScript.