guidance

Enforces grammar-based output constraints for LLM-generated text and structured data.

1|Updated Apr 30, 2025
One-click install
npx skills add https://github.com/lucasfth/config --skill guidance-lucasfth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/lucasfth/config/tree/main/.hermes/skills/mlops/inference/guidance
Command: npx skills add https://github.com/lucasfth/config --skill guidance-lucasfth

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Guidance enables precise control over LLM outputs using regex and grammar constraints to enforce structured formats (JSON/XML/code) and faster, deterministic results across workflows.

Core Features & Use Cases

  • Regex and grammar constraints to enforce strict output formats
  • Token healing and grammar-based generation for reliable structured outputs
  • Build multi-step workflows with Pythonic control flow and local model support

Quick Start

To get started, install Guidance and run a minimal constrained-generation example in Python.

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 guarantee valid JSON and XML formats?

Token healing fixes tokenization boundaries during constrained generation, preventing malformed outputs when regex or grammar constraints interrupt token sequences. It ensures grammar-driven generation produces clean, structured JSON or XML without broken syntax artifacts.

Can I build multi-step prompt workflows with Pythonic control flow for local models?

Yes, you can orchestrate complex multi-step workflows using Pythonic control flow to manage prompts across both local and cloud backends. This allows you to chain constrained generation steps dynamically for intricate form processing and data extraction pipelines.

What is the best way to enforce regex patterns during language model generation?

The best way to enforce regex patterns is through grammar-driven generation, which intercepts the decoding process to only allow tokens matching your specified pattern. This guarantees outputs conform exactly to your regex constraints for reliable structured data.

Do I need the transformers library to apply grammar-based constraints to LLM outputs?

Yes, the transformers library is required alongside the guidance package to apply grammar-based constraints and orchestrate constrained generation workflows. These dependencies provide the necessary backend integration for running local and cloud model inference with regex enforcement.