Cette page est affichée en anglais. Une traduction française est en cours.
SkillsMay 11, 2026·2 min de lecture

Guidance — Constrained Generation in Python

Guidance gives you constrained generation (regex, select lists, grammars) in Python. `pip install guidance`, then run with Transformers or other backends.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Asset
Commande d'installation directe
npx -y tokrepo@latest install dc8ec1af-aae5-4af4-b355-dffcad6efaf7 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

Guidance gives you constrained generation (regex, select lists, grammars) in Python. pip install guidance, then run with Transformers or other backends.

  • Best for: teams who need controllable formats (IDs, enums, templates) and want stronger guarantees than best-effort prompting
  • Works with: Python, Guidance primitives (gen, select), model backends like Transformers/LlamaCpp/OpenAI (per repo)
  • Setup time: 10 minutes

Quantitative Notes

  • Install command: pip install guidance (repo)
  • Setup time ~10 minutes
  • GitHub stars (verified): see Source & Thanks

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.


🙏

Source et remerciements

GitHub: https://github.com/guidance-ai/guidance Owner avatar: https://avatars.githubusercontent.com/u/142035062?v=4 License (SPDX): MIT GitHub stars (verified via api.github.com/repos/guidance-ai/guidance): 21,453

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires