outlines

Generate structured JSON, regex, and Pydantic-validated outputs from local LLMs.

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/vivekgoquest/hermes-agent-stable --skill outlines-vivekgoquest
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: outlines
Source: https://github.com/vivekgoquest/hermes-agent-stable/tree/main/optional-skills/mlops/inference/outlines
Command: npx skills add https://github.com/vivekgoquest/hermes-agent-stable --skill outlines-vivekgoquest

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires outlines, transformers, vllm, pydantic, and includes references (resource) components.

What problem does it solve? LLMs often produce malformed JSON or free-form text that breaks downstream parsing. This Skill constrains token generation at the logit level so outputs always match a JSON schema, Pydantic model, regex, or fixed set of choices, eliminating retry loops and validation failures. ## Core Features & Use Cases - Guaranteed structured output: Compile Pydantic models, JSON schemas, regex patterns, or Literal choices into token-level automata that filter invalid tokens during generation. - Multiple local backends: Works with Transformers, llama.cpp, and vLLM via outlines.from_transformers, from_llamacpp, and from_vllm, plus OpenAI for server-side constrained JSON. - Use Case: Extract structured company information (name, founded year, industry, employees) from unstructured text by defining a Pydantic model, calling model(prompt, CompanyInfo), and validating the returned JSON string with CompanyInfo.model_validate_json(result). ## Quick Start Use the outlines skill to extract a user's name, age, and email from this text into a validated Pydantic model using a local Transformers model.

Frequently Asked Questions about outlines

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

FAQPage Schema
How do I generate structured JSON from an LLM with Outlines?▼

Define a Pydantic model for your target structure, wrap a model with outlines.from_transformers (or from_vllm/from_llamacpp), then call model(prompt, YourModel). The result is a JSON string you parse with YourModel.model_validate_json(result).

Outlines vs Instructor for structured LLM outputs?▼

Outlines constrains generation at the token level with zero overhead and full local model support, guaranteeing valid outputs without retries. Instructor focuses on API models with automatic retrying, making it better when you rely on hosted APIs and want retry logic.

Does Outlines work with vLLM and llama.cpp?▼

Yes. Use outlines.from_vllm(LLM(...)) for high-throughput serving with tensor parallelism and quantization, or outlines.from_llamacpp(Llama(...)) for GGUF models on CPU or Apple Silicon. Both support the same output_type constrained generation.

Why did outlines.generate.json stop working after upgrading?▼

The pre-1.0 helpers like outlines.generate.json and outlines.models.transformers were removed in Outlines v1. Create a model with outlines.from_transformers and call it directly with an output type: model(prompt, YourModel).

Can Outlines enforce regex patterns and multiple-choice outputs?▼

Yes. Pass a regex string like r"[0-9]{3}-[0-9]{4}" as the output type to force pattern-matching text, or pass a Literal["a", "b", "c"] for guaranteed multiple-choice selection. Numeric types like int and float also work directly.

What are the limitations of Outlines structured generation?▼

Outlines has no automatic retrying since validity is guaranteed by the automaton, and OpenAI backend support is limited compared to local models. Deeply nested schemas increase automaton complexity, so flatter structures generate faster.