outlines
Operate the Outlines structured-output library across output types, local models, provider integrations, and prompt workflows.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- outlines
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Operate the Outlines structured-output library across output types, local models, provider integrations, and prompt workflows.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/api-overview.md3.1 KB
- 参考文档references/compatibility.md3.5 KB
- 参考文档references/repo-provenance.md1.9 KB
- 参考文档references/repo-routing-metadata.json325 B
- 参考文档references/troubleshooting.md3.0 KB
- 脚本scripts/inspect_outlines_api.py3.8 KB
03 SKILL.md 正文
Outlines Repo Skill
Use this repo skill when a task involves Outlines as a Python package for structured outputs from large language models: defining schemas or regex/CFG constraints, wrapping local or hosted models, rendering prompt templates, composing chat/multimodal inputs, and troubleshooting package/provider/runtime behavior.
This skill is self-contained. Do not reopen the source checkout to use it. The source repository was used only as evidence for these bundled routes, references, and scripts.
Install and Import Check
Base install:
pip install outlines
Optional integrations are installed separately; choose only the backend/provider you need. Examples:
pip install transformers torch # local Transformers path
pip install llama-cpp-python # llama.cpp path
pip install vllm # vLLM offline/server client path as appropriate
pip install openai # OpenAI, SGLang, vLLM server SDK clients
pip install huggingface_hub # TGI client
Minimal import check:
import outlines
from outlines import Generator, Template
from outlines.inputs import Chat, Image
from outlines.types import JsonSchema, Regex, CFG, Choice
Important: in this source revision, Chat is imported from outlines.inputs, not from the top-level outlines namespace.
Route by Task
| Task signal | Read |
|---|---|
JSON/Pydantic/dataclass/TypedDict/GenSON output, Literal/Enum/Choice, regex, CFG, Generator, backend selection, custom logits processor, parsing generated JSON |
sub-skills/structured-generation/SKILL.md |
| Local/offline model setup with Transformers, Transformers multimodal, llama.cpp, MLX-LM, vLLM offline, tokenizers, device dtype, CUDA/MPS/VRAM, local batch/stream behavior | sub-skills/local-models/SKILL.md |
| Hosted or server-based providers: OpenAI/Azure, Anthropic, Gemini, Mistral, Ollama, LM Studio, SGLang, TGI, vLLM server, Dottxt; credentials/endpoints; provider exceptions | sub-skills/remote-providers/SKILL.md |
Prompt templates, Application, Chat, Image/Audio/Video, Jinja filters, cache controls, safe self-consistency/task-loop recipes |
sub-skills/prompt-workflows/SKILL.md |
Repo-Level References
references/api-overview.md: package map, public imports, model categories, and high-level call contracts.references/compatibility.md: optional dependencies, backend/provider/hardware boundaries, and what is or is not verified by CPU inspection.references/troubleshooting.md: cross-cutting install/import, optional dependency, provider, schema, cache, and safety failures.references/repo-provenance.md: source version and evidence baseline.references/repo-routing-metadata.json: structured router metadata for managed imports.
Safe Helper Scripts
scripts/inspect_outlines_api.py: read-only import/signature smoke for a local Python environment.sub-skills/structured-generation/scripts/validate_structure.py: local JSON Schema or regex validator.sub-skills/local-models/scripts/check_local_model_prereqs.py: no-network optional module/device probe.sub-skills/remote-providers/scripts/check_provider_prereqs.py: no-network provider SDK/env-var probe with secrets redacted.sub-skills/prompt-workflows/scripts/render_template.py: localTemplaterenderer.
Operating Rules
- Keep output-type design separate from model/provider selection. First define the structure, then pick a compatible execution route.
- Treat Outlines generation outputs as raw strings unless a provider wrapper explicitly returns something else; parse or validate after generation.
- Do not install broad extras or GPU stacks unless the task explicitly needs that runtime.
- Do not call provider services, download models, or start long-running servers during planning or static troubleshooting.
- Never execute model-generated code (
eval,exec, shell) while using this skill. Validate with schemas, regex, parsers, and bounded tests. - For remote errors, catch
outlines.exceptions.APIErrorsubclasses and useretryable,provider,status_code,request_id, andhintto decide recovery. - For local hardware, verify the actual framework/backend runtime before claiming CUDA, MPS, vLLM, or llama.cpp acceleration works.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).