guidance

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

Updated May 3, 2026
One-click install
npx skills add https://github.com/80portisfound/vibe-learning --skill guidance-80portisfound
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/80portisfound/vibe-learning/tree/main/packages/hermes/optional-skills/mlops/guidance
Command: npx skills add https://github.com/80portisfound/vibe-learning --skill guidance-80portisfound

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? LLMs frequently produce malformed JSON, invalid formats, or off-spec outputs that break downstream parsing and require costly 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 token generation. - Token Healing: Automatically repairs token boundaries between prompts and generations to avoid spacing artifacts. - Multi-Step Workflows and Agents: Build ReAct agents, chain-of-thought pipelines, and classification systems with Pythonic control flow via the @guidance decorator. - Use Case: You need an API that always returns valid JSON user profiles. Define regex constraints for each field, and Guidance guarantees the model output parses cleanly on the first attempt. ## Quick Start 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. The framework filters invalid tokens during generation, so the output always matches the specified structure without retry loops.

What is token healing in Guidance?▼

Token healing backs up one token at the prompt-generation boundary and regenerates it together with new tokens. This prevents artifacts like double spaces or broken words caused by unnatural tokenization boundaries, and it is enabled by default.

Guidance vs Instructor vs Outlines for structured output?▼

Guidance supports regex constraints, context-free grammars, and token healing with both API and local models. Instructor adds Pydantic validation with automatic retrying, while Outlines offers JSON schema validation. Choose Guidance for grammar constraints and local model workflows.

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

Yes, Guidance supports local models through the Transformers and LlamaCpp backends, including quantized GGUF models with GPU offloading. It also works with Anthropic, OpenAI, and Azure OpenAI API-based models.

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 outputs are valid on the first attempt without retries.

How do I build a ReAct agent with tool use in Guidance?▼

Use the @guidance decorator with stateless=False, then loop through thought generation, action selection via select(), and tool execution. The select function constrains action choices to your defined tool set, preventing invalid tool calls.