guidance

Constrain language model generation with regex and grammar rules for valid structured outputs.

Updated Jun 25, 2026
One-click install
npx skills add https://github.com/davpatel605-beep/hermusagent --skill guidance-davpatel605-beep
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/davpatel605-beep/hermusagent/tree/main/backend/vendor/hermes/optional-skills/mlops/guidance
Command: npx skills add https://github.com/davpatel605-beep/hermusagent --skill guidance-davpatel605-beep

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill solves unreliable language model outputs by enforcing structured formats, syntax rules, and constrained generation patterns so applications can receive valid responses without repeated validation and repair.

Core Features & Use Cases

  • Constrained Generation: Control LLM responses with regex, grammars, and selection constraints to guarantee valid JSON, XML, code, and other structured outputs.
  • Workflow Orchestration: Build multi-step LLM workflows, agents, and extraction pipelines using Pythonic Guidance functions with support for multiple model backends.
  • Use Case: A developer building an AI data extraction service can use this Skill to generate validated records from unstructured text while preventing malformed fields and invalid formats.

Quick Start

Use the guidance skill to create a structured JSON generator that extracts user information with validated fields from text input.

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?

Constrained generation enforces valid JSON output from an LLM by applying regex patterns and grammar rules during decoding, preventing malformed fields and syntax errors without repeated validation.

What is constrained generation for AI agents?

Constrained generation for AI agents restricts language model outputs to predefined formats and syntax, ensuring multi-step workflows and extraction pipelines reliably receive valid structured data.

How do I build a multi-step LLM workflow for data extraction?

Build a multi-step LLM data extraction workflow by using Pythonic orchestration functions to chain models, applying grammar constraints to extract validated records from unstructured text inputs.

Can I use regex constraints to validate LLM responses locally?

Yes, you can apply regex constraints to validate and control LLM responses across both API and local model backends, ensuring generated text strictly matches required patterns.

Does this approach work with local model backends or only APIs?

This approach works with both API and local model backends, allowing you to enforce structured outputs and apply grammar constraints regardless of your deployment environment.

Why does my LLM output malformed structured data despite prompt instructions?

LLMs output malformed structured data because prompt instructions alone cannot guarantee syntax compliance; applying grammar-based generation and token healing directly constrains the decoding process.