guidance

Constrain LLM generation with regex, grammars, and token healing.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill solves the challenge of unpredictable LLM output by enforcing strict syntactic and structural constraints, ensuring the model generates valid, usable data every time.

Core Features & Use Cases

  • Constrained Generation: Use regex, grammars, and selection lists to force the model to follow specific formats like JSON, XML, or custom patterns.
  • Token Healing: Automatically fixes awkward token boundaries to ensure natural text flow and perfect spacing.
  • Use Case: If you are building a data extraction pipeline, use this Skill to guarantee that the model outputs a perfectly formatted JSON object matching your Pydantic schema, eliminating the need for complex post-processing or retry loops.

Quick Start

Use the guidance skill to generate a valid JSON object containing a name and age field for a user profile.

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 output valid JSON matching my schema?

You can enforce valid JSON generation by applying constrained generation with regex and grammars, ensuring the LLM outputs structured data that perfectly matches your schema without post-processing.

What is token healing and how does it fix awkward text boundaries?

Token healing is a constrained generation mechanism that automatically fixes awkward token boundaries to ensure natural text flow and perfect spacing during LLM inference.

Can I use constrained generation with local model backends like transformers?

Yes, constrained generation supports integration with transformers or llama.cpp libraries to enable logit-level control over the generation process for local model backends.

What is the best way to guarantee structured output formats from an LLM?

The best way to guarantee structured output formats is using grammars and selection lists to force the model to follow specific patterns like JSON or XML, eliminating unpredictable LLM output.

Does constrained generation support multi-step workflows and ReAct agent patterns?

Yes, constrained generation supports multi-step workflows and ReAct agent patterns for high-performance inference, extending strict syntactic control beyond single-turn outputs.

Why does my LLM output invalid JSON and how do I stop it?

LLM output becomes invalid JSON due to unpredictable token generation; you can stop this by enforcing strict syntactic constraints using grammars and token healing to guarantee valid data.