guidance

Constrain LLM outputs with regex and grammar constraints.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Constrain LLM outputs with regex and grammars to ensure structured and valid results.

Core Features & Use Cases

  • Regex-based constraints for validated formats (emails, dates, numbers)
  • Grammar-based generation for JSON/XML and domain-specific languages
  • Token healing and multi-step workflows to build robust, end-to-end prompts

Quick Start

Configure Guidance with a grammar or regex constraint and run a simple example to generate a structured output.

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 ensure valid JSON and XML generation?

You can constrain LLM outputs for valid JSON and XML generation by applying grammar-based constraints during inference. This ensures the generated text strictly adheres to your specified schema, preventing formatting errors.

What is the best way to validate structured formats like emails and dates from LLM responses?

The best way to validate structured formats like emails and dates is by applying regex-based constraints. This directly restricts the LLM token generation to match your defined regular expressions, guaranteeing valid format output.

Does constrained generation work with local LLM backends like Transformers and llama.cpp?

Yes, constrained generation works with local LLM backends like Transformers and llama.cpp. The Guidance library supports applying regex and grammar constraints across API-backed and local backend environments for structured generation.

How do I build multi-step workflows for reliable data extraction?

You can build multi-step workflows for reliable data extraction by combining grammar constraints with token healing. This approach repairs broken tokens at boundaries and structures sequential prompts to ensure robust end-to-end extraction.

When should I use token healing in structured LLM generation?

Use token healing in structured LLM generation when prompt boundaries break tokens, causing invalid syntax. It repairs these boundaries before generation, ensuring regex and grammar constraints apply cleanly without tokenization errors.