guidance

Control LLM output with regex and grammars for structured JSON/XML/code generation.

6|3|Updated Jan 29, 2026
One-click install
npx skills add https://github.com/jonnabio/ace-framework --skill guidance-jonnabio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/jonnabio/ace-framework/tree/main/.ace/packs/ai-research/guidance
Command: npx skills add https://github.com/jonnabio/ace-framework --skill guidance-jonnabio

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires guidance, transformers, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill helps control LLM output with regex and grammars, ensuring valid JSON/XML/code generation and structured formats.

Core Features & Use Cases

  • Regex Constraints: Control output syntax with regex or grammars.
  • Constrained Generation: Guarantee valid JSON/XML/code generation and enforce structured formats.
  • Multi-Step Workflows: Build complex workflows with Pythonic control flow.
  • Use Case: Imagine you need to generate structured JSON from unstructured text. Use this Skill to define the desired output format and let it automatically generate the JSON for you.

Quick Start

Install guidance using pip install guidance. Then, to generate a person object with name and age, use from guidance import models, gen; person = models.Anthropic("gpt-4"); person += gen("person", grammar=json_grammar).

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I enforce valid JSON generation from an LLM?

You can enforce valid JSON generation from an LLM by applying regex constraints and grammars during the generation process. This approach guarantees structured data output and format validation directly within the generation workflow.

What is the best way to control LLM output syntax with regex?

Controlling LLM output syntax with regex involves using constrained generation frameworks to define allowed patterns. This mechanism guarantees valid JSON, XML, or code generation by enforcing structured formats throughout the multi-step workflow.

How do I build multi-step workflows for structured LLM output?

You can build multi-step workflows for structured LLM output by utilizing Pythonic control flow within constrained generation frameworks. This allows you to define complex sequences that enforce regex and grammar constraints across multiple generation steps.

Does Guidance work with Python and Hugging Face transformers?

Guidance works with Python and requires specific LLM models to function. It integrates constrained generation techniques using dependencies like transformers, allowing you to control output syntax and enforce structured formats within your Python environment.

Can I generate structured data from unstructured text using constrained generation?

You can generate structured data from unstructured text by defining the desired output format with grammars and regex. Constrained generation automatically enforces these rules to produce valid JSON or XML from the unstructured input text.