What problem does it solve?
Guidance helps you prevent malformed model outputs by constraining generation to regex patterns, grammars, and selectable options, so downstream systems can reliably consume JSON, XML, and code-like structures.
Core Features & Use Cases
- Constrained generation with regex: Force fields to match required formats such as emails, dates, IDs, and numeric patterns.
- Grammar-based structured output: Use context-free grammars to generate nested JSON/XML/code with guaranteed structural validity.
- Multi-step workflow building: Compose deterministic, multi-round pipelines using Guidance’s Pythonic control flow and reusable functions.
- Token healing: Automatically fix awkward token-boundary artifacts to improve correctness for structured continuations (e.g., spacing and identifiers).
- Selection constraints: Restrict outputs to a fixed set of categories for classification and routing.
Quick Start
Ask your AI to generate a valid JSON object containing fields that must follow a specified regex and grammar, such as a user profile with name, age, and email, using Guidance constraints to ensure the output is always parseable.