If you've ever fought with an LLM to produce valid JSON only to get malformed output, this is the fix. Guidance is Microsoft Research's framework that uses grammars and regex to constrain generation at the token level, so you get guaranteed valid JSON, XML, or any structured format you define. It backs up one token before generating to avoid awkward spacing issues, supports multi-step workflows with Python control flow, and works with Claude, GPT-4, or local models. The regex constraint approach is clever: it filters invalid tokens during generation rather than hoping the model gets it right. Most useful when you're building agents or data pipelines where parsing failures break everything downstream.

skills.sh installs
1K
GitHub stars
14.4K
last updated
Aug 21, 2026

Install

$ npx -y skills add orchestra-research/ai-research-skills --skill guidance --agent claude-code

Installs into .claude/skills of the current project.

Files

Guidance: Constrained LLM Generation

When to Use This Skill

Use Guidance when you need to:

  • Control LLM output syntax with regex or grammars
  • Guarantee valid JSON/XML/code generation
  • Reduce latency vs traditional prompting approaches
  • Enforce structured formats (dates, emails, IDs, etc.)
  • Build multi-step workflows with Pythonic control flow
  • Prevent invalid outputs through grammatical constraints

GitHub Stars: 18,000+ | From: Microsoft Research

Installation

# Base installation
pip install guidance

# With specific backends
pip install guidance[transformers]  # Hugging Face models
pip install guidance[llama_cpp]     # llama.cpp models

Quick Start

Basic Example: Structured Generation

from guidance import models, gen

# Load model (supports OpenAI, Transformers, llama.cpp)
lm = models.OpenAI("gpt-4")

# Generate with constraints
result = lm + "The capital of France is " + gen("capital", max_tokens=5)

print(result["capital"])  # "Paris"

With Anthropic Claude

from guidance import models, gen, system, user, assistant

Sponsors

Details

Repository
github.com/orchestra-research/ai-research-skills
Categories
DevOps & CI/CD, AI & Agent Building, Data Science & ML
First seen
Jun 3, 2026

More from orchestra-research/ai-research-skills

All 95
1orchestra-research avatarllamaguardorchestra-research/ai-research-skillsMeta's 7-8B specialized moderation model for LLM input/output filtering. 6 safety categories - violence/hate, sexual content, weapons, substances, self-harm, cr1Kskills.sh installs
2orchestra-research avatartorchforge-rl-trainingorchestra-research/ai-research-skillsProvides guidance for PyTorch-native agentic RL using torchforge, Meta's library separating infra from algorithms. Use when you want clean RL abstractions, easy1Kskills.sh installs
3orchestra-research avatarnemo-evaluator-sdkorchestra-research/ai-research-skillsEvaluates LLMs across 100+ benchmarks from 18+ harnesses (MMLU, HumanEval, GSM8K, safety, VLM) with multi-backend execution. Use when needing scalable evaluatio1Kskills.sh installs
4databricks avatardatabricks-jobsdatabricks/databricks-agent-skillsDevelop and deploy Lakeflow Jobs on Databricks via DABs, Python SDK, or the CLI. Use when creating data engineering jobs with notebooks, Python wheels, SQL, dbt1Kskills.sh installs
5cursor avatarcreate-learning-pathcursor/pluginsBuild a personalized learning roadmap with milestones and practice checkpoints1Kskills.sh installs
6secondsky avatarsap-btp-connectivitysecondsky/sap-skillsSAP BTP Connectivity skill covering Destination Service, Connectivity Service, Cloud Connector, Connectivity Proxy, and Transparent Proxy for Kubernetes. Use wh1Kskills.sh installs