[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6MANC9YAG145X8MT0EVP22W":3,"skill-same:01M6MANC9YAG145X8MT0EVP22W":96},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":50,"commitSha":51,"skillDirectory":52,"forksCount":53,"repositoryHtmlUrl":54,"repositoryHomepageUrl":55,"ownerHtmlUrl":56,"ownerBlogUrl":57,"ownerDescription":58,"updatedAt":59,"install":60,"resources":73},"01M6MANC9YAG145X8MT0EVP22W","outlines",null,"Generates guaranteed-valid structured output from LLMs with Outlines (dottxt.ai), constraining token sampling via finite state machines for JSON schemas, Pydantic models, regex, choice lists, and integer\u002Ffloat types, on Transformers, llama.cpp, vLLM, and limited OpenAI backends. Use when you need output that always parses as valid JSON or matches a regex. Use when extracting typed data into Pydantic models from a local model. Use when classifying text into a fixed set of categories. Use when running batch structured generation on vLLM or Transformers. Use when controlling token sampling at the grammar level. Not for API models needing automatic retries (use Instructor).","hashgraph-online\u002Fawesome-codex-plugins","hashgraph-online","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F160371962?v=4","01M6CNB6NRJVNNGN14TR01Q6D3","HOL (Hashgraph Online)","01M6JT1HSKKG9V68KQAQGBA7XP",1575,"MIT","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Foutlines\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"Outlines","as","automatic","for","float","at","categories","you","retries","state machines","structured output","valid","regex","local","sampling","use","text","applications","Safety","batch","2026-11-10 10:12:30",false,"---\nname: outlines\ndescription: Generates guaranteed-valid structured output from LLMs with Outlines (dottxt.ai), constraining token sampling via finite state machines for JSON schemas, Pydantic models, regex, choice lists, and integer\u002Ffloat types, on Transformers, llama.cpp, vLLM, and limited OpenAI backends. Use when you need output that always parses as valid JSON or matches a regex. Use when extracting typed data into Pydantic models from a local model. Use when classifying text into a fixed set of categories. Use when running batch structured generation on vLLM or Transformers. Use when controlling token sampling at the grammar level. Not for API models needing automatic retries (use Instructor).\nlicense: MIT\nmetadata:\n  version: 1.0.0\n  category: llm-applications\n  maintainer: Kalaris Labs\n  tags: Prompt Engineering, Outlines, Structured Generation, JSON Schema, Pydantic, Local Models, Grammar-Based Generation, vLLM, Transformers, Type Safety\n  dependencies: outlines, transformers, vllm, pydantic\n---\n\n# Outlines: Structured Text Generation\n\n## When to Use This Skill\n\nUse Outlines when you need to:\n- **Guarantee valid JSON\u002FXML\u002Fcode** structure during generation\n- **Use Pydantic models** for type-safe outputs\n- **Support local models** (Transformers, llama.cpp, vLLM)\n- **Maximize inference speed** with zero-overhead structured generation\n- **Generate against JSON schemas** automatically\n- **Control token sampling** at the grammar level\n\n\n## Installation\n\n```bash\n# Base installation\npip install outlines\n\n# With specific backends\npip install outlines transformers  # Hugging Face models\npip install outlines llama-cpp-python  # llama.cpp\npip install outlines vllm  # vLLM for high-throughput\n```\n\n## Quick Start\n\n### Basic Example: Classification\n\n```python\nimport outlines\nfrom typing import Literal\n\n# Load model\nmodel = outlines.models.transformers(\"microsoft\u002FPhi-3-mini-4k-instruct\")\n\n# Generate with type constraint\nprompt = \"Sentiment of 'This product is amazing!': \"\ngenerator = outlines.generate.choice(model, [\"positive\", \"negative\", \"neutral\"])\nsentiment = generator(prompt)\n\nprint(sentiment)  # \"positive\" (guaranteed one of these)\n```\n\n### With Pydantic Models\n\n```python\nfrom pydantic import BaseModel\nimport outlines\n\nclass User(BaseModel):\n    name: str\n    age: int\n    email: str\n\nmodel = outlines.models.transformers(\"microsoft\u002FPhi-3-mini-4k-instruct\")\n\n# Generate structured output\nprompt = \"Extract user: John Doe, 30 years old, john@example.com\"\ngenerator = outlines.generate.json(model, User)\nuser = generator(prompt)\n\nprint(user.name)   # \"John Doe\"\nprint(user.age)    # 30\nprint(user.email)  # \"john@example.com\"\n```\n\n## Core Concepts\n\n### 1. Constrained Token Sampling\n\nOutlines uses Finite State Machines (FSM) to constrain token generation at the logit level.\n\n**How it works:**\n1. Convert schema (JSON\u002FPydantic\u002Fregex) to context-free grammar (CFG)\n2. Transform CFG into Finite State Machine (FSM)\n3. Filter invalid tokens at each step during generation\n4. Fast-forward when only one valid token exists\n\n**Benefits:**\n- **Zero overhead**: Filtering happens at token level\n- **Speed improvement**: Fast-forward through deterministic paths\n- **Guaranteed validity**: Invalid outputs impossible\n\n```python\nimport outlines\n\n# Pydantic model -> JSON schema -> CFG -> FSM\nclass Person(BaseModel):\n    name: str\n    age: int\n\nmodel = outlines.models.transformers(\"microsoft\u002FPhi-3-mini-4k-instruct\")\n\n# Behind the scenes:\n# 1. Person -> JSON schema\n# 2. JSON schema -> CFG\n# 3. CFG -> FSM\n# 4. FSM filters tokens during generation\n\ngenerator = outlines.generate.json(model, Person)\nresult = generator(\"Generate person: Alice, 25\")\n```\n\n### 2. Structured Generators\n\nOutlines provides specialized generators for different output types.\n\n#### Choice Generator\n\n```python\n# Multiple choice selection\ngenerator = outlines.generate.choice(\n    model,\n    [\"positive\", \"negative\", \"neutral\"]\n)\n\nsentiment = generator(\"Review: This is great!\")\n# Result: One of the three choices\n```\n\n#### JSON Generator\n\n```python\nfrom pydantic import BaseModel\n\nclass Product(BaseModel):\n    name: str\n    price: float\n    in_stock: bool\n\n# Generate valid JSON matching schema\ngenerator = outlines.generate.json(model, Product)\nproduct = generator(\"Extract: iPhone 15, $999, available\")\n\n# Guaranteed valid Product instance\nprint(type(product))  # \u003Cclass '__main__.Product'>\n```\n\n#### Regex Generator\n\n```python\n# Generate text matching regex\ngenerator = outlines.generate.regex(\n    model,\n    r\"[0-9]{3}-[0-9]{3}-[0-9]{4}\"  # Phone number pattern\n)\n\nphone = generator(\"Generate phone number:\")\n# Result: \"555-123-4567\" (guaranteed to match pattern)\n```\n\n#### Integer\u002FFloat Generators\n\n```python\n# Generate specific numeric types\nint_generator = outlines.generate.integer(model)\nage = int_generator(\"Person's age:\")  # Guaranteed integer\n\nfloat_generator = outlines.generate.float(model)\nprice = float_generator(\"Product price:\")  # Guaranteed float\n```\n\n### 3. Model Backends\n\nOutlines supports multiple local and API-based backends.\n\n#### Transformers (Hugging Face)\n\n```python\nimport outlines\n\n# Load from Hugging Face\nmodel = outlines.models.transformers(\n    \"microsoft\u002FPhi-3-mini-4k-instruct\",\n    device=\"cuda\"  # Or \"cpu\"\n)\n\n# Use with any generator\ngenerator = outlines.generate.json(model, YourModel)\n```\n\n#### llama.cpp\n\n```python\n# Load GGUF model\nmodel = outlines.models.llamacpp(\n    \".\u002Fmodels\u002Fllama-3.1-8b-instruct.Q4_K_M.gguf\",\n    n_gpu_layers=35\n)\n\ngenerator = outlines.generate.json(model, YourModel)\n```\n\n#### vLLM (High Throughput)\n\n```python\n# For production deployments\nmodel = outlines.models.vllm(\n    \"meta-llama\u002FLlama-3.1-8B-Instruct\",\n    tensor_parallel_size=2  # Multi-GPU\n)\n\ngenerator = outlines.generate.json(model, YourModel)\n```\n\n#### OpenAI (Limited Support)\n\n```python\n# Basic OpenAI support\nmodel = outlines.models.openai(\n    \"gpt-4o-mini\",\n    api_key=\"your-api-key\"\n)\n\n# Note: Some features limited with API models\ngenerator = outlines.generate.json(model, YourModel)\n```\n\n### 4. Pydantic Integration\n\nOutlines has first-class Pydantic support with automatic schema translation.\n\n#### Basic Models\n\n```python\nfrom pydantic import BaseModel, Field\n\nclass Article(BaseModel):\n    title: str = Field(description=\"Article title\")\n    author: str = Field(description=\"Author name\")\n    word_count: int = Field(description=\"Number of words\", gt=0)\n    tags: list[str] = Field(description=\"List of tags\")\n\nmodel = outlines.models.transformers(\"microsoft\u002FPhi-3-mini-4k-instruct\")\ngenerator = outlines.generate.json(model, Article)\n\narticle = generator(\"Generate article about AI\")\nprint(article.title)\nprint(article.word_count)  # Guaranteed > 0\n```\n\n#### Nested Models\n\n```python\nclass Address(BaseModel):\n    street: str\n    city: str\n    country: str\n\nclass Person(BaseModel):\n    name: str\n    age: int\n    address: Address  # Nested model\n\ngenerator = outlines.generate.json(model, Person)\nperson = generator(\"Generate person in New York\")\n\nprint(person.address.city)  # \"New York\"\n```\n\n#### Enums and Literals\n\n```python\nfrom enum import Enum\nfrom typing import Literal\n\nclass Status(str, Enum):\n    PENDING = \"pending\"\n    APPROVED = \"approved\"\n    REJECTED = \"rejected\"\n\nclass Application(BaseModel):\n    applicant: str\n    status: Status  # Must be one of enum values\n    priority: Literal[\"low\", \"medium\", \"high\"]  # Must be one of literals\n\ngenerator = outlines.generate.json(model, Application)\napp = generator(\"Generate application\")\n\nprint(app.status)  # Status.PENDING (or APPROVED\u002FREJECTED)\n```\n\n## Common Patterns\n\nDetails, code examples and parameter tables: [references\u002Fcommon-patterns.md](references\u002Fcommon-patterns.md). Read it when this step applies.\n\n## Backend Configuration\n\nDetails, code examples and parameter tables: [references\u002Fbackend-configuration.md](references\u002Fbackend-configuration.md). Read it when this step applies.\n\n## Best Practices\n\n### 1. Use Specific Types\n\n```python\n# ✅ Good: Specific types\nclass Product(BaseModel):\n    name: str\n    price: float  # Not str\n    quantity: int  # Not str\n    in_stock: bool  # Not str\n\n# ❌ Bad: Everything as string\nclass Product(BaseModel):\n    name: str\n    price: str  # Should be float\n    quantity: str  # Should be int\n```\n\n### 2. Add Constraints\n\n```python\nfrom pydantic import Field\n\n# ✅ Good: With constraints\nclass User(BaseModel):\n    name: str = Field(min_length=1, max_length=100)\n    age: int = Field(ge=0, le=120)\n    email: str = Field(pattern=r\"^[\\w\\.-]+@[\\w\\.-]+\\.\\w+$\")\n\n# ❌ Bad: No constraints\nclass User(BaseModel):\n    name: str\n    age: int\n    email: str\n```\n\n### 3. Use Enums for Categories\n\n```python\n# ✅ Good: Enum for fixed set\nclass Priority(str, Enum):\n    LOW = \"low\"\n    MEDIUM = \"medium\"\n    HIGH = \"high\"\n\nclass Task(BaseModel):\n    title: str\n    priority: Priority\n\n# ❌ Bad: Free-form string\nclass Task(BaseModel):\n    title: str\n    priority: str  # Can be anything\n```\n\n### 4. Provide Context in Prompts\n\n```python\n# ✅ Good: Clear context\nprompt = \"\"\"\nExtract product information from the following text.\nText: iPhone 15 Pro costs $999 and is currently in stock.\nProduct:\n\"\"\"\n\n# ❌ Bad: Minimal context\nprompt = \"iPhone 15 Pro costs $999 and is currently in stock.\"\n```\n\n### 5. Handle Optional Fields\n\n```python\nfrom typing import Optional\n\n# ✅ Good: Optional fields for incomplete data\nclass Article(BaseModel):\n    title: str  # Required\n    author: Optional[str] = None  # Optional\n    date: Optional[str] = None  # Optional\n    tags: list[str] = []  # Default empty list\n\n# Can succeed even if author\u002Fdate missing\n```\n\n## Comparison to Alternatives\n\n| Feature | Outlines | Instructor | Guidance | LMQL |\n|---------|----------|------------|----------|------|\n| Pydantic Support | ✅ Native | ✅ Native | ❌ No | ❌ No |\n| JSON Schema | ✅ Yes | ✅ Yes | ⚠️ Limited | ✅ Yes |\n| Regex Constraints | ✅ Yes | ❌ No | ✅ Yes | ✅ Yes |\n| Local Models | ✅ Full | ⚠️ Limited | ✅ Full | ✅ Full |\n| API Models | ⚠️ Limited | ✅ Full | ✅ Full | ✅ Full |\n| Zero Overhead | ✅ Yes | ❌ No | ⚠️ Partial | ✅ Yes |\n| Automatic Retrying | ❌ No | ✅ Yes | ❌ No | ❌ No |\n| Learning Curve | Low | Low | Low | High |\n\n**When to choose Outlines:**\n- Using local models (Transformers, llama.cpp, vLLM)\n- Need maximum inference speed\n- Want Pydantic model support\n- Require zero-overhead structured generation\n- Control token sampling process\n\n**When to choose alternatives:**\n- Instructor: Need API models with automatic retrying\n- Guidance: Need token healing and complex workflows\n- LMQL: Prefer declarative query syntax\n\n## Performance Characteristics\n\n**Speed:**\n- **Zero overhead**: Structured generation as fast as unconstrained\n- **Fast-forward optimization**: Skips deterministic tokens\n- **1.2-2x faster** than post-generation validation approaches\n\n**Memory:**\n- FSM compiled once per schema (cached)\n- Minimal runtime overhead\n- Efficient with vLLM for high throughput\n\n**Accuracy:**\n- **100% valid outputs** (guaranteed by FSM)\n- No retry loops needed\n- Deterministic token filtering\n\n## Resources\n\n- **Documentation**: https:\u002F\u002Foutlines-dev.github.io\u002Foutlines\n- **GitHub**: https:\u002F\u002Fgithub.com\u002Foutlines-dev\u002Foutlines\n- **Discord**: https:\u002F\u002Fdiscord.gg\u002FR9DSu34mGd\n- **Blog**: https:\u002F\u002Fblog.dottxt.co\n\n## See Also\n\n- `references\u002Fjson_generation.md` - Comprehensive JSON and Pydantic patterns\n- `references\u002Fbackends.md` - Backend-specific configuration\n- `references\u002Fexamples.md` - Production-ready examples\n\n## Agent operating procedure\n\n1. **Check the environment.** Confirm the framework version, model provider, API keys and rate limits.\n2. **Pin down the inputs.** Confirm formats, identifiers and parameters from the data or the user. Ask rather than guess any value that changes the result.\n3. **Run a small version first.** Test a single call or chain with a known input and inspect raw outputs.\n4. **Execute the full task** using the instructions and references above.\n5. **Validate the result.** Evaluate on a small labeled set; check structured outputs against their schema; log prompts and responses.\n6. **Report.** State what was run (versions, commands, parameters), what was checked, and what is still uncertain.\n\n| If this happens | Do this |\n|---|---|\n| Outputs do not match the expected schema | Add validation and retries, tighten the schema, or simplify the prompt. |\n| A function, flag or endpoint in these instructions is missing in the installed version | Check the installed version's own documentation (`help()`, `--help`, official docs), adapt, and tell the user. Never invent an API. |\n| A required input, identifier or parameter is ambiguous | Ask the user, or state the assumption explicitly before running. |\n\n**Integrity rules**\n\n- Never fabricate results, parameters, identifiers, citations or statistics. If something cannot be run or verified, say so plainly.\n- Never send private or sensitive data to external APIs without the user's consent.\n- Treat version-specific details here as possibly outdated: confirm them against the official documentation for the installed version.\n- Ask before actions that cost money, consume shared GPUs or cloud quota, touch personal or patient data, or cannot be undone.\n","# Outlines: Structured Text Generation\n\n## When to Use This Skill\n\nUse Outlines when you need to:\n- **Guarantee valid JSON\u002FXML\u002Fcode** structure during generation\n- **Use Pydantic models** for type-safe outputs\n- **Support local models** (Transformers, llama.cpp, vLLM)\n- **Maximize inference speed** with zero-overhead structured generation\n- **Generate against JSON schemas** automatically\n- **Control token sampling** at the grammar level\n\n\n## Installation\n\n```bash\n# Base installation\npip install outlines\n\n# With specific backends\npip install outlines transformers  # Hugging Face models\npip install outlines llama-cpp-python  # llama.cpp\npip install outlines vllm  # vLLM for high-throughput\n```\n\n## Quick Start\n\n### Basic Example: Classification\n\n```python\nimport outlines\nfrom typing import Literal\n\n# Load model\nmodel = outlines.models.transformers(\"microsoft\u002FPhi-3-mini-4k-instruct\")\n\n# Generate with type constraint\nprompt = \"Sentiment of 'This product is amazing!': \"\ngenerator = outlines.generate.choice(model, [\"positive\", \"negative\", \"neutral\"])\nsentiment = generator(prompt)\n\nprint(sentiment)  # \"positive\" (guaranteed one of these)\n```\n\n### With Pydantic Models\n\n```python\nfrom pydantic import BaseModel\nimport outlines\n\nclass User(BaseModel):\n    name: str\n    age: int\n    email: str\n\nmodel = outlines.models.transformers(\"microsoft\u002FPhi-3-mini-4k-instruct\")\n\n# Generate structured output\nprompt = \"Extract user: John Doe, 30 years old, john@example.com\"\ngenerator = outlines.generate.json(model, User)\nuser = generator(prompt)\n\nprint(user.name)   # \"John Doe\"\nprint(user.age)    # 30\nprint(user.email)  # \"john@example.com\"\n```\n\n## Core Concepts\n\n### 1. Constrained Token Sampling\n\nOutlines uses Finite State Machines (FSM) to constrain token generation at the logit level.\n\n**How it works:**\n1. Convert schema (JSON\u002FPydantic\u002Fregex) to context-free grammar (CFG)\n2. Transform CFG into Finite State Machine (FSM)\n3. Filter invalid tokens at each step during generation\n4. Fast-forward when only one valid token exists\n\n**Benefits:**\n- **Zero overhead**: Filtering happens at token level\n- **Speed improvement**: Fast-forward through deterministic paths\n- **Guaranteed validity**: Invalid outputs impossible\n\n```python\nimport outlines\n\n# Pydantic model -> JSON schema -> CFG -> FSM\nclass Person(BaseModel):\n    name: str\n    age: int\n\nmodel = outlines.models.transformers(\"microsoft\u002FPhi-3-mini-4k-instruct\")\n\n# Behind the scenes:\n# 1. Person -> JSON schema\n# 2. JSON schema -> CFG\n# 3. CFG -> FSM\n# 4. FSM filters tokens during generation\n\ngenerator = outlines.generate.json(model, Person)\nresult = generator(\"Generate person: Alice, 25\")\n```\n\n### 2. Structured Generators\n\nOutlines provides specialized generators for different output types.\n\n#### Choice Generator\n\n```python\n# Multiple choice selection\ngenerator = outlines.generate.choice(\n    model,\n    [\"positive\", \"negative\", \"neutral\"]\n)\n\nsentiment = generator(\"Review: This is great!\")\n# Result: One of the three choices\n```\n\n#### JSON Generator\n\n```python\nfrom pydantic import BaseModel\n\nclass Product(BaseModel):\n    name: str\n    price: float\n    in_stock: bool\n\n# Generate valid JSON matching schema\ngenerator = outlines.generate.json(model, Product)\nproduct = generator(\"Extract: iPhone 15, $999, available\")\n\n# Guaranteed valid Product instance\nprint(type(product))  # \u003Cclass '__main__.Product'>\n```\n\n#### Regex Generator\n\n```python\n# Generate text matching regex\ngenerator = outlines.generate.regex(\n    model,\n    r\"[0-9]{3}-[0-9]{3}-[0-9]{4}\"  # Phone number pattern\n)\n\nphone = generator(\"Generate phone number:\")\n# Result: \"555-123-4567\" (guaranteed to match pattern)\n```\n\n#### Integer\u002FFloat Generators\n\n```python\n# Generate specific numeric types\nint_generator = outlines.generate.integer(model)\nage = int_generator(\"Person's age:\")  # Guaranteed integer\n\nfloat_generator = outlines.generate.float(model)\nprice = float_generator(\"Product price:\")  # Guaranteed float\n```\n\n### 3. Model Backends\n\nOutlines supports multiple local and API-based backends.\n\n#### Transformers (Hugging Face)\n\n```python\nimport outlines\n\n# Load from Hugging Face\nmodel = outlines.models.transformers(\n    \"microsoft\u002FPhi-3-mini-4k-instruct\",\n    device=\"cuda\"  # Or \"cpu\"\n)\n\n# Use with any generator\ngenerator = outlines.generate.json(model, YourModel)\n```\n\n#### llama.cpp\n\n```python\n# Load GGUF model\nmodel = outlines.models.llamacpp(\n    \".\u002Fmodels\u002Fllama-3.1-8b-instruct.Q4_K_M.gguf\",\n    n_gpu_layers=35\n)\n\ngenerator = outlines.generate.json(model, YourModel)\n```\n\n#### vLLM (High Throughput)\n\n```python\n# For production deployments\nmodel = outlines.models.vllm(\n    \"meta-llama\u002FLlama-3.1-8B-Instruct\",\n    tensor_parallel_size=2  # Multi-GPU\n)\n\ngenerator = outlines.generate.json(model, YourModel)\n```\n\n#### OpenAI (Limited Support)\n\n```python\n# Basic OpenAI support\nmodel = outlines.models.openai(\n    \"gpt-4o-mini\",\n    api_key=\"your-api-key\"\n)\n\n# Note: Some features limited with API models\ngenerator = outlines.generate.json(model, YourModel)\n```\n\n### 4. Pydantic Integration\n\nOutlines has first-class Pydantic support with automatic schema translation.\n\n#### Basic Models\n\n```python\nfrom pydantic import BaseModel, Field\n\nclass Article(BaseModel):\n    title: str = Field(description=\"Article title\")\n    author: str = Field(description=\"Author name\")\n    word_count: int = Field(description=\"Number of words\", gt=0)\n    tags: list[str] = Field(description=\"List of tags\")\n\nmodel = outlines.models.transformers(\"microsoft\u002FPhi-3-mini-4k-instruct\")\ngenerator = outlines.generate.json(model, Article)\n\narticle = generator(\"Generate article about AI\")\nprint(article.title)\nprint(article.word_count)  # Guaranteed > 0\n```\n\n#### Nested Models\n\n```python\nclass Address(BaseModel):\n    street: str\n    city: str\n    country: str\n\nclass Person(BaseModel):\n    name: str\n    age: int\n    address: Address  # Nested model\n\ngenerator = outlines.generate.json(model, Person)\nperson = generator(\"Generate person in New York\")\n\nprint(person.address.city)  # \"New York\"\n```\n\n#### Enums and Literals\n\n```python\nfrom enum import Enum\nfrom typing import Literal\n\nclass Status(str, Enum):\n    PENDING = \"pending\"\n    APPROVED = \"approved\"\n    REJECTED = \"rejected\"\n\nclass Application(BaseModel):\n    applicant: str\n    status: Status  # Must be one of enum values\n    priority: Literal[\"low\", \"medium\", \"high\"]  # Must be one of literals\n\ngenerator = outlines.generate.json(model, Application)\napp = generator(\"Generate application\")\n\nprint(app.status)  # Status.PENDING (or APPROVED\u002FREJECTED)\n```\n\n## Common Patterns\n\nDetails, code examples and parameter tables: [references\u002Fcommon-patterns.md](references\u002Fcommon-patterns.md). Read it when this step applies.\n\n## Backend Configuration\n\nDetails, code examples and parameter tables: [references\u002Fbackend-configuration.md](references\u002Fbackend-configuration.md). Read it when this step applies.\n\n## Best Practices\n\n### 1. Use Specific Types\n\n```python\n# ✅ Good: Specific types\nclass Product(BaseModel):\n    name: str\n    price: float  # Not str\n    quantity: int  # Not str\n    in_stock: bool  # Not str\n\n# ❌ Bad: Everything as string\nclass Product(BaseModel):\n    name: str\n    price: str  # Should be float\n    quantity: str  # Should be int\n```\n\n### 2. Add Constraints\n\n```python\nfrom pydantic import Field\n\n# ✅ Good: With constraints\nclass User(BaseModel):\n    name: str = Field(min_length=1, max_length=100)\n    age: int = Field(ge=0, le=120)\n    email: str = Field(pattern=r\"^[\\w\\.-]+@[\\w\\.-]+\\.\\w+$\")\n\n# ❌ Bad: No constraints\nclass User(BaseModel):\n    name: str\n    age: int\n    email: str\n```\n\n### 3. Use Enums for Categories\n\n```python\n# ✅ Good: Enum for fixed set\nclass Priority(str, Enum):\n    LOW = \"low\"\n    MEDIUM = \"medium\"\n    HIGH = \"high\"\n\nclass Task(BaseModel):\n    title: str\n    priority: Priority\n\n# ❌ Bad: Free-form string\nclass Task(BaseModel):\n    title: str\n    priority: str  # Can be anything\n```\n\n### 4. Provide Context in Prompts\n\n```python\n# ✅ Good: Clear context\nprompt = \"\"\"\nExtract product information from the following text.\nText: iPhone 15 Pro costs $999 and is currently in stock.\nProduct:\n\"\"\"\n\n# ❌ Bad: Minimal context\nprompt = \"iPhone 15 Pro costs $999 and is currently in stock.\"\n```\n\n### 5. Handle Optional Fields\n\n```python\nfrom typing import Optional\n\n# ✅ Good: Optional fields for incomplete data\nclass Article(BaseModel):\n    title: str  # Required\n    author: Optional[str] = None  # Optional\n    date: Optional[str] = None  # Optional\n    tags: list[str] = []  # Default empty list\n\n# Can succeed even if author\u002Fdate missing\n```\n\n## Comparison to Alternatives\n\n| Feature | Outlines | Instructor | Guidance | LMQL |\n|---------|----------|------------|----------|------|\n| Pydantic Support | ✅ Native | ✅ Native | ❌ No | ❌ No |\n| JSON Schema | ✅ Yes | ✅ Yes | ⚠️ Limited | ✅ Yes |\n| Regex Constraints | ✅ Yes | ❌ No | ✅ Yes | ✅ Yes |\n| Local Models | ✅ Full | ⚠️ Limited | ✅ Full | ✅ Full |\n| API Models | ⚠️ Limited | ✅ Full | ✅ Full | ✅ Full |\n| Zero Overhead | ✅ Yes | ❌ No | ⚠️ Partial | ✅ Yes |\n| Automatic Retrying | ❌ No | ✅ Yes | ❌ No | ❌ No |\n| Learning Curve | Low | Low | Low | High |\n\n**When to choose Outlines:**\n- Using local models (Transformers, llama.cpp, vLLM)\n- Need maximum inference speed\n- Want Pydantic model support\n- Require zero-overhead structured generation\n- Control token sampling process\n\n**When to choose alternatives:**\n- Instructor: Need API models with automatic retrying\n- Guidance: Need token healing and complex workflows\n- LMQL: Prefer declarative query syntax\n\n## Performance Characteristics\n\n**Speed:**\n- **Zero overhead**: Structured generation as fast as unconstrained\n- **Fast-forward optimization**: Skips deterministic tokens\n- **1.2-2x faster** than post-generation validation approaches\n\n**Memory:**\n- FSM compiled once per schema (cached)\n- Minimal runtime overhead\n- Efficient with vLLM for high throughput\n\n**Accuracy:**\n- **100% valid outputs** (guaranteed by FSM)\n- No retry loops needed\n- Deterministic token filtering\n\n## Resources\n\n- **Documentation**: https:\u002F\u002Foutlines-dev.github.io\u002Foutlines\n- **GitHub**: https:\u002F\u002Fgithub.com\u002Foutlines-dev\u002Foutlines\n- **Discord**: https:\u002F\u002Fdiscord.gg\u002FR9DSu34mGd\n- **Blog**: https:\u002F\u002Fblog.dottxt.co\n\n## See Also\n\n- `references\u002Fjson_generation.md` - Comprehensive JSON and Pydantic patterns\n- `references\u002Fbackends.md` - Backend-specific configuration\n- `references\u002Fexamples.md` - Production-ready examples\n\n## Agent operating procedure\n\n1. **Check the environment.** Confirm the framework version, model provider, API keys and rate limits.\n2. **Pin down the inputs.** Confirm formats, identifiers and parameters from the data or the user. Ask rather than guess any value that changes the result.\n3. **Run a small version first.** Test a single call or chain with a known input and inspect raw outputs.\n4. **Execute the full task** using the instructions and references above.\n5. **Validate the result.** Evaluate on a small labeled set; check structured outputs against their schema; log prompts and responses.\n6. **Report.** State what was run (versions, commands, parameters), what was checked, and what is still uncertain.\n\n| If this happens | Do this |\n|---|---|\n| Outputs do not match the expected schema | Add validation and retries, tighten the schema, or simplify the prompt. |\n| A function, flag or endpoint in these instructions is missing in the installed version | Check the installed version's own documentation (`help()`, `--help`, official docs), adapt, and tell the user. Never invent an API. |\n| A required input, identifier or parameter is ambiguous | Ask the user, or state the assumption explicitly before running. |\n\n**Integrity rules**\n\n- Never fabricate results, parameters, identifiers, citations or statistics. If something cannot be run or verified, say so plainly.\n- Never send private or sensitive data to external APIs without the user's consent.\n- Treat version-specific details here as possibly outdated: confirm them against the official documentation for the installed version.\n- Ask before actions that cost money, consume shared GPUs or cloud quota, touch personal or patient data, or cannot be undone.\n",{"name":5,"license":15,"metadata":44,"description":7},{"tags":45,"version":46,"category":47,"maintainer":48,"dependencies":49},"Prompt Engineering, Outlines, Structured Generation, JSON Schema, Pydantic, Local Models, Grammar-Based Generation, vLLM, Transformers, Type Safety","1.0.0","llm-applications","Kalaris Labs","outlines, transformers, vllm, pydantic","main","2b63f856ce19c2a797929cacabd9e0fc936812fa","plugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Foutlines",491,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins","https:\u002F\u002Fhol.org\u002Fplugins\u002Fbest-codex-plugins","https:\u002F\u002Fgithub.com\u002Fhashgraph-online","https:\u002F\u002Fhol.org","Open-source standards and developer tools for interoperable AI agents: discovery, identity, communication, payments, privacy and security.","2026-11-14 14:06:13",{"source":8,"skillName":5,"commands":61,"prompt":71,"zipAvailable":72},[62,65,68],{"tool":63,"command":64},"npx","npx skills add hashgraph-online\u002Fawesome-codex-plugins --skill outlines",{"tool":66,"command":67},"bunx","bunx skills add hashgraph-online\u002Fawesome-codex-plugins --skill outlines",{"tool":69,"command":70},"pnpm","pnpm dlx skills add hashgraph-online\u002Fawesome-codex-plugins --skill outlines","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Foutlines\u002FSKILL.md",true,[74,80,84,88,92],{"path":75,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":78,"sourceHtmlUrl":79},"references\u002Fbackend-configuration.md","REFERENCE","参考文档",1289,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Foutlines\u002Freferences\u002Fbackend-configuration.md",{"path":81,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":82,"sourceHtmlUrl":83},"references\u002Fbackends.md",14407,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Foutlines\u002Freferences\u002Fbackends.md",{"path":85,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":86,"sourceHtmlUrl":87},"references\u002Fcommon-patterns.md",3876,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Foutlines\u002Freferences\u002Fcommon-patterns.md",{"path":89,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":90,"sourceHtmlUrl":91},"references\u002Fexamples.md",21231,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Foutlines\u002Freferences\u002Fexamples.md",{"path":93,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":94,"sourceHtmlUrl":95},"references\u002Fjson_generation.md",14927,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Foutlines\u002Freferences\u002Fjson_generation.md",[97,106,114,122,130,138],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":101,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":105},"01M7DV332YQMGD8WTRJ9DZQXTB","worktable-review-with-annotations","Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-review-with-annotations\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-review-with-annotations\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":110,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":105},"01M7DV2YGHCZVBEB1AHYB6CGHE","worktable-find-and-synthesize-context","Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-find-and-synthesize-context\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-find-and-synthesize-context\u002FSKILL.md",[],[],{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":118,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":105},"01M7DV2TQN1H11ME2SAF9MXN7V","worktable-create-or-update-docs","Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-update-docs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-update-docs\u002FSKILL.md",[],[],{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":126,"sourceHtmlUrl":127,"categories":128,"keywords":129,"publishedAt":105},"01M7DV2NE452NEA8TXATKSNAJH","worktable-create-or-manage-records","Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-records\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-records\u002FSKILL.md",[],[],{"skillNo":131,"name":132,"nameZh":6,"description":133,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":134,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":105},"01M7DV2HENRBR2KSCVM064WH0Y","worktable-create-or-manage-interactive-html","Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-interactive-html\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-interactive-html\u002FSKILL.md",[],[],{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":142,"sourceHtmlUrl":143,"categories":144,"keywords":145,"publishedAt":105},"01M7DV2CADR5R7RQFFYPNAGR9Y","worktable-collaborate-threads","Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-collaborate-threads\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-collaborate-threads\u002FSKILL.md",[],[]]