guidance

Constrain language model outputs with regex and grammars for valid JSON or XML.

Updated May 9, 2026
One-click install
npx skills add https://github.com/robertbr123/Linket-Agent --skill guidance-robertbr123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guidance
Source: https://github.com/robertbr123/Linket-Agent/tree/main/optional-skills/mlops/guidance
Command: npx skills add https://github.com/robertbr123/Linket-Agent --skill guidance-robertbr123

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill enables precise control over language model outputs, ensuring structured and valid JSON/XML/code generation, and facilitates the creation of complex multi-step workflows.

Core Features & Use Cases

  • Constrained Generation: Utilize regex and grammars to control syntax, enforce structured formats, and build multi-step workflows.
  • Structured Output: Generate valid JSON, XML, or code with guaranteed syntax correctness.
  • Use Case: When you need to automate the generation of structured data from unstructured text, such as converting customer feedback into structured feedback entries, or extracting information from legal documents into structured JSON format.

Quick Start

Run the guidance generate_user_info script with the provided input file 'user_info.jsonl'.

Frequently Asked Questions about guidance

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

FAQPage Schema
How do I enforce valid JSON generation from an LLM?

To enforce valid JSON generation, this Skill applies regex matching and grammar parsing to constrain the language model output. It guarantees syntax correctness for structured data generation tasks like converting unstructured text into JSON.

What is constrained generation and how does it control LLM output syntax?

Constrained generation controls LLM output syntax by using regex and grammars to restrict the model's token selection. This ensures the generated text strictly adheres to predefined structural formats like XML or JSON.

How do I extract structured data from unstructured text using LLMs?

You can extract structured data from unstructured text by running the provided scripts to apply constrained generation. This automates converting inputs like customer feedback or legal documents into structured JSON entries.

Does this Skill require the transformers library for grammar parsing?

Yes, this Skill requires both the guidance and transformers dependencies to execute its constrained generation workflows. These libraries provide the foundational environment for regex matching and grammar parsing.

Can I build multi-step LLM workflows with guaranteed valid XML output?

Yes, you can build multi-step workflows with guaranteed valid XML output by utilizing the grammar-based constrained generation features. This ensures precise control over syntax across every step of the automated text processing pipeline.

What is the best way to prevent syntax errors in automated LLM text processing?

The best way to prevent syntax errors in automated LLM text processing is to apply grammar parsing and regex constraints during generation. This approach forces the model to produce structurally valid code or data formats directly.