guidance

Constrain LLM outputs with regex and grammars for valid JSON, XML, or code.

Updated May 2, 2026
One-click install
npx skills add https://github.com/AlvaroBiano/hermes-agent --skill guidance-alvarobiano
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/AlvaroBiano/hermes-agent/tree/main/optional-skills/mlops/guidance
Command: npx skills add https://github.com/AlvaroBiano/hermes-agent --skill guidance-alvarobiano

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Guidance provides a framework to control LLM outputs using regex and grammars, ensuring JSON/XML/code generation is valid, and enabling multi-step workflows with Pythonic control flow.

Core Features & Use Cases

  • Regex and grammar-based constrained generation for valid outputs
  • Token healing and multi-step workflows with guidance decorators
  • Local model support (Transformers, llama.cpp) and backend integration across Anthropic and OpenAI
  • Use cases include data extraction, form validation, and structured document generation

Quick Start

Ask the AI to generate a constrained JSON object using a regex and grammar to guarantee valid syntax.

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 generate valid JSON using regex and grammars?

You can constrain LLM outputs to generate valid JSON by applying regex and grammar-based constrained generation. This guarantees syntactically valid structured outputs without needing post-processing validation.

What is token healing and how does it improve constrained generation workflows?

Token healing is a mechanism that fixes tokenization artifacts at pattern boundaries during constrained generation. It ensures smooth transitions between static text and generated content in multi-step workflows.

Does constrained generation work with local models using transformers and llama.cpp?

Yes, constrained generation works with local models using transformers and llama.cpp backends. This enables private, fast inference while maintaining valid JSON, XML, or code generation.

Can I use guidance for multi-step workflows with Pythonic control flow?

Yes, you can build multi-step workflows using Pythonic control flow and guidance decorators. This allows complex generation pipelines where each step's output feeds into the next constrained generation task.

What's the best way to guarantee valid syntax for data extraction and form validation?

The best way to guarantee valid syntax for data extraction and form validation is using grammar-based constrained generation. It enforces output formats like JSON or XML directly during inference, eliminating invalid outputs.

Do I need to install transformers to implement constrained generation pipelines?

Yes, you need the guidance and transformers dependencies installed to implement constrained generation pipelines. These backends provide the infrastructure for grammar-based output control and local model inference.