guidance

Generate constrained LLM outputs using regex, grammars, and token healing with Guidance.

1|Updated Mar 12, 2026
One-click install
npx skills add https://github.com/kaminocorp/hermes-alpha-hunter --skill guidance-kaminocorp
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/kaminocorp/hermes-alpha-hunter/tree/main/skills/mlops/inference/guidance
Command: npx skills add https://github.com/kaminocorp/hermes-alpha-hunter --skill guidance-kaminocorp

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? LLMs frequently produce malformed JSON, invalid emails, or off-format text that breaks downstream parsing and forces retry loops. This Skill uses Microsoft Research's Guidance framework to constrain generation at the token level so outputs always match the required structure. ## Core Features & Use Cases - Regex and Grammar Constraints: Enforce formats like emails, dates, phone numbers, JSON, XML, and CSV directly during generation. - Token Healing: Automatically fixes unnatural token boundaries between prompts and generated text for clean continuations. - Multi-Backend Support: Works with Anthropic Claude, OpenAI, Azure OpenAI, Hugging Face Transformers, and llama.cpp local models. - Use Case: Build a ReAct agent that extracts structured entities (names, dates, organizations) from unstructured text with guaranteed-valid formats, or generate schema-conformant JSON for API payloads without validation retries. ## Quick Start Ask the agent to use the guidance skill to generate a JSON object with name, age, and email fields where each value is constrained by a regex pattern.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I guarantee valid JSON output from an LLM?▼

Use Guidance's gen function with regex constraints for each JSON field, or define a grammar-based template with the @guidance decorator. The framework filters invalid tokens during generation so the output always matches the required structure.

Guidance vs Instructor vs Outlines for structured output?▼

Guidance supports regex constraints, context-free grammars, and token healing with a Pythonic syntax. Instructor is better when you need Pydantic validation with automatic retrying, while Outlines fits JSON schema validation use cases.

Does Guidance work with local models like llama.cpp?▼

Yes, Guidance supports local models through the Transformers backend for Hugging Face models and the LlamaCpp backend for GGUF quantized models. Both support GPU offloading, quantization, and full constrained generation features.

What is token healing in Guidance?▼

Token healing fixes unnatural token boundaries between a prompt and generated text by backing up one token and regenerating. It prevents issues like double spaces or broken words, and it is enabled by default.

Why is constrained generation slower than free generation?▼

Regex constraints add roughly 1.2-1.5x overhead and grammars about 2x because tokens must be filtered against the pattern. However, end-to-end latency is often lower since valid outputs eliminate retry loops and post-validation.