Practical Notes
Use Guidance as a safety layer when you can't afford invalid formats. Start with simple constraints (regex for numbers/IDs, select() for enums), then graduate to richer grammars. In agent pipelines, put constraints right before boundaries: DB writes, API calls, tool arguments, and routing decisions.
Safety note: Constraints can increase compute; budget latency by keeping grammars small and prompts focused.
FAQ
Q: What is constrained generation? A: You restrict the model to outputs that match a pattern (regex), belong to a list, or follow a grammar—reducing invalid responses.
Q: Do I need a specific model? A: No. The repo mentions multiple backends; you pick one that fits your environment (local Transformers, llama.cpp, hosted APIs).
Q: Where does it help most? A: Any step that must be parseable: routing labels, IDs, enums, JSON-like fields, or template-bound strings.