guidance

Constrains LLM outputs with regex and grammars for JSON, XML, and code.

1|1|Updated Apr 26, 2026
One-click install
npx skills add https://github.com/BermudaLocals/hermes-agent-lite --skill guidance-bermudalocals
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/BermudaLocals/hermes-agent-lite/tree/main/optional-skills/mlops/guidance
Command: npx skills add https://github.com/BermudaLocals/hermes-agent-lite --skill guidance-bermudalocals

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guidance provides a robust framework to constrain LLM outputs, ensuring they adhere to formats like JSON, XML, or code, reducing errors and the need for post-generation validation.

Core Features & Use Cases

  • Constrained generation via regex and grammars to produce valid structured outputs.
  • Token healing, multi-step workflows, and local model support for reproducible results.
  • Use Case: Build data extraction pipelines that produce validated JSON payloads from unstructured text.

Quick Start

Install Guidance, import its APIs, and start generating constrained outputs with a few lines of Python.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I constrain LLM outputs to valid JSON using regex and grammars?

You can constrain LLM outputs to valid JSON by applying regex and grammars, which ensures structured output adherence and reduces the need for post-generation validation. This framework applies to JSON, XML, and code generation.

How does constrained generation work for multi-step LLM workflows?

Constrained generation for multi-step workflows works by applying grammars and token healing across local and API backends, ensuring reproducible results. This enables building data extraction pipelines that produce validated payloads from unstructured text.

Do I need to install transformers to use constrained generation with local models?

Yes, you need transformers available in your runtime to use constrained generation with local models. You must install Guidance and its dependencies, including transformers, before importing its APIs to start generating constrained outputs.

What's the best way to generate validated JSON payloads from unstructured text?

The best way to generate validated JSON payloads from unstructured text is using constrained generation via regex and grammars. This approach applies format constraints directly during generation, eliminating post-generation validation errors.

Why does my LLM output fail JSON validation after generation?

LLM outputs fail JSON validation because standard generation lacks format constraints. Applying regex and grammars during generation constrains the output to valid JSON, XML, or code, preventing structural errors before they occur.

Can I use constrained generation with both local models and API backends?

Yes, constrained generation supports both local models and API backends for multi-step workflows. This framework enables reproducible results across different environments while maintaining structured output adherence.