Guidance
FreeA handy looking Python library from Microsoft that uses Handlebars templating to interleave generation, prompting, and logical control.
About Guidance
Guidance is an efficient open-source Python library for steering large language models. It provides a Pythonic interface using common idioms like context managers (system, user, assistant) and functions (gen, select) to interleave control flow (conditionals, loops, tool use) with text generation. Guidance allows constrained generation with regular expressions and context-free grammars (CFGs), ensuring structured and high-quality output while reducing latency and cost compared to conventional prompting or fine-tuning. It supports multiple backends including Transformers, llama.cpp, and OpenAI, and is installable via pip. Originally developed by Microsoft, it is now maintained under the guidance-ai organization on GitHub.
Key Features
Pros & Cons
- Reduces latency and cost through constrained generation
- Familiar Python syntax lowers learning curve for developers
- Supports powerful constraints like regex and select for precise output control
- Works with popular LLM backends (Transformers, llama.cpp, OpenAI)
- Active open-source community with 21.7k stars and 1.2k forks on GitHub
- Primarily designed for Python users, limiting cross-language adoption
- May require understanding of regex and grammar concepts for advanced constraints
- As an open-source library, lacks official enterprise support or SLAs