outlines

Generate grammar-constrained structured outputs validated against Pydantic models and JSON Schema.

1|Updated Apr 10, 2026
One-click install
npx skills add https://github.com/zerwiz/wayofpi --skill outlines-zerwiz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: outlines
Source: https://github.com/zerwiz/wayofpi/tree/main/.hermes/hermes-agent/skills/mlops/inference/outlines
Command: npx skills add https://github.com/zerwiz/wayofpi --skill outlines-zerwiz

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Outlines removes the risk of malformed AI output when you need strict structure such as JSON, XML, regex-matched text, or typed Python objects.

Core Features & Use Cases

  • Validates generations against Pydantic models and JSON Schema.
  • Constrains token sampling so outputs stay structurally correct without retry loops.
  • Works with local backends like Transformers, llama.cpp, and vLLM, with limited OpenAI support.
  • Use it for data extraction, classification, form parsing, entity extraction, and code scaffolding in production workflows.

Quick Start

Use the outlines skill to generate a valid JSON object that matches a Pydantic schema from your prompt.

Frequently Asked Questions about outlines

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I guarantee valid JSON schema or Pydantic outputs from LLM generation?

To guarantee valid structured LLM outputs, you can constrain token sampling during generation. This schema-driven validation ensures model outputs match your Pydantic models or JSON Schema without retry loops.

What is grammar-constrained decoding for language model outputs?

Grammar-constrained decoding restricts the token sampling space so language model outputs stay structurally correct. This mechanism validates generations against defined schemas, preventing malformed AI output for strict structures like JSON or typed Python objects.

How do I parse forms and extract data using structured LLM outputs?

You can parse forms and extract data by constraining the language model generation to match a specific schema. This guarantees structurally correct outputs for classification, entity extraction, and form parsing in production workflows.

Does structured generation work with vLLM and local Transformers backends?

Yes, structured generation works with local backends like Transformers, llama.cpp, and vLLM. Backend adapters adapt the schema-driven validation to each platform, with limited support for hosted OpenAI models.

What is the best way to prevent malformed JSON from LLMs in production?

The best way to prevent malformed JSON is applying grammar-constrained decoding during generation. This removes the risk of invalid structures and eliminates retry loops by validating outputs against schemas before completion.

When should I not use constrained decoding for LLM outputs?

You should not use constrained decoding when using unsupported hosted backends beyond limited OpenAI support, or when your task requires unconstrained creative text generation rather than strict schema-driven validation or typed object extraction.