guidance

Constrain LLM output syntax with regex, grammars, and token-level filtering.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill solves the issue of unpredictable LLM output by enforcing strict syntactic constraints, ensuring that generated text always adheres to required formats like JSON, XML, or specific regex patterns.

Core Features & Use Cases

  • Constrained Generation: Use regex, grammars, and selection lists to force the model to output valid data structures.
  • Token Healing: Automatically fixes unnatural token boundaries between prompts and generated text to ensure perfect formatting.
  • Multi-Step Workflows: Build complex, stateful agentic workflows using Pythonic control flow and context managers.
  • Use Case: If you need to generate a JSON user profile, this Skill guarantees the output will be valid JSON matching your Pydantic schema, eliminating the need for error-prone retry loops.

Quick Start

Use the guidance skill to generate a JSON object representing a person with a name and age using the provided Pydantic schema.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I force an LLM to generate valid JSON output matching a specific schema?

You can enforce valid JSON generation by applying regex, grammars, and token-level filtering to constrain the LLM output. This guarantees the generated text strictly adheres to your required format, eliminating the need for error-prone retry loops.

What is token healing and how does it fix unnatural token boundaries in LLM generation?

Token healing automatically fixes unnatural token boundaries between prompts and generated text during inference. This mechanism ensures perfect formatting and prevents structural errors in the constrained generation output.

Can I use guidance and transformers libraries to build multi-step agentic workflows?

Yes, you can build complex, stateful multi-step agentic workflows using guidance and transformers. This approach leverages Pythonic control flow and context managers to orchestrate deterministic, multi-step text generation.

Do I need local model integration for high-performance constrained text generation?

Local model integration is supported to achieve high-performance deterministic text generation. However, the strict requirement is having the guidance and transformers libraries installed to enforce format compliance and token healing during inference.

What is the best way to guarantee structured data generation from an LLM without retry loops?

The best way to guarantee structured data generation without retry loops is enforcing strict syntactic constraints using grammars and token-level filtering. This proactively ensures valid JSON or XML output deterministically during the inference process.

Why does my LLM output fail Pydantic schema validation despite using prompt engineering?

LLM output fails Pydantic validation because prompt engineering alone cannot guarantee strict syntactic compliance. Applying constrained generation with token-level filtering and grammars deterministically enforces valid JSON structures that perfectly match your schema.