guidance

Constrain LLM outputs with regex and grammar rules for JSON, XML, and code.

Updated Apr 30, 2026
One-click install
npx skills add https://github.com/photonics-dhl/Hermes --skill guidance-photonics-dhl
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/photonics-dhl/Hermes/tree/main/hermes-home/skills/mlops/inference/guidance
Command: npx skills add https://github.com/photonics-dhl/Hermes --skill guidance-photonics-dhl

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Constrained generation of outputs ensures that LLM responses are structured, validated, and machine-friendly, reducing errors and post-processing.

Core Features & Use Cases

  • Regex- and grammar-driven constraints: enforce JSON/XML/code formats and valid tokens in generation.
  • Multi-step workflows: implement pipelines with Pythonic control flow to build complex tasks.
  • Local and cloud backends: work with Guidance on transformers, llama.cpp, or API models via Guidance.
  • Real-world example: generate a user profile as a strict JSON object with fields name, age, and email, guaranteed to follow the schema.

Quick Start

Use Guidance to generate a JSON object that adheres to a strict schema.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I enforce structured LLM outputs with regex and grammars?▼

To enforce structured LLM outputs, you apply regex and grammar constraints during generation, guaranteeing responses follow valid JSON, XML, or code formats. This approach eliminates invalid syntax and reduces post-processing.

Can I use constrained generation for JSON with local and cloud backends?▼

Yes, constrained generation supports local and cloud backends. You can apply grammar-based generation features across transformers, llama.cpp, or API models to guarantee strict JSON schema adherence.

How do I build multi-step workflows for prompt engineering?▼

Multi-step workflows for prompt engineering are built using Pythonic control flow. You coordinate multi-step generation with validation to create complex pipelines that enforce structured outputs.

What is the best way to guarantee valid JSON generation from an LLM?▼

The best way to guarantee valid JSON generation is using grammar-driven constraints. By enforcing a strict schema during generation rather than post-processing, you ensure the output is always machine-friendly and validated.

Do I need Python to use the Guidance framework for constrained generation?▼

Yes, you need Python to use the Guidance framework. It requires Python-based workflows to coordinate multi-step generation with validation and implement grammar-driven constraints across your models.