Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsMay 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

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Stage only · 29/100Stage only
Surface agent
Tout agent MCP/CLI
Type
Script
Installation
Single
Confiance
Confiance : Established
Point d'entrée
README.md
Commande CLI universelle
npx tokrepo install dc8ec1af-aae5-4af4-b355-dffcad6efaf7
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