[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EFR5MH32TPWZ2F4TRFHMG1":3,"skill-same:01M6EFR5MH32TPWZ2F4TRFHMG1":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":17,"categories":18,"keywords":29,"publishedAt":31,"linkOnly":32,"markdownContent":33,"markdownBody":33,"frontMatter":34,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":38,"repositoryHtmlUrl":39,"repositoryHomepageUrl":40,"ownerHtmlUrl":41,"ownerBlogUrl":7,"ownerDescription":42,"updatedAt":43,"install":44,"resources":57},"01M6EFR5MH32TPWZ2F4TRFHMG1","outlines","LLM 结构化输出生成",null,"","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FTerminalSkills\u002Fskills\u002Foutlines\u002FSKILL.md",[19,24],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BRZZF9D7PVFN5MXSPWWD61","AI 工程师","PROFESSION","适用职业",{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8CFBYS6KNR8FXE26HTAY17Y","大模型应用开发","SCENARIO","使用场景",[30],"Outlines","2026-11-10 10:12:30",false,"# Outlines — Structured Text Generation\n\nYou are an expert in Outlines, the Python library for reliable structured text generation with LLMs. You help developers generate guaranteed-valid JSON, regex-matching text, and grammar-constrained output from open-source models — using finite state machine guided generation that constrains the token sampling process to produce only valid output on the first try.\n\n## Core Capabilities\n\n### Structured Generation\n\n```python\nimport outlines\nfrom pydantic import BaseModel, Field\nfrom enum import Enum\n\n# Load model\nmodel = outlines.models.transformers(\"meta-llama\u002FLlama-3.1-8B-Instruct\")\n\n# JSON generation with Pydantic schema\nclass Sentiment(str, Enum):\n    positive = \"positive\"\n    negative = \"negative\"\n    neutral = \"neutral\"\n\nclass ReviewAnalysis(BaseModel):\n    sentiment: Sentiment\n    score: float = Field(ge=0, le=1)\n    topics: list[str] = Field(min_length=1, max_length=5)\n    summary: str = Field(max_length=200)\n\ngenerator = outlines.generate.json(model, ReviewAnalysis)\n\nresult = generator(\n    \"Analyze this review: 'Great product, fast shipping, but packaging could be better'\"\n)\n# result is a validated ReviewAnalysis instance — guaranteed to match schema\nprint(result.sentiment)    # Sentiment.positive\nprint(result.score)        # 0.85\nprint(result.topics)       # [\"product quality\", \"shipping\", \"packaging\"]\n\n# Regex-constrained generation\nphone_gen = outlines.generate.regex(model, r\"\\(\\d{3}\\) \\d{3}-\\d{4}\")\nphone = phone_gen(\"Generate a US phone number:\")\n# phone = \"(415) 555-0123\" — always matches the regex\n\n# Choice (classification)\nclassifier = outlines.generate.choice(model, [\"spam\", \"ham\", \"uncertain\"])\nresult = classifier(\"Is this spam? 'You won $1000000!!!'\")\n# result = \"spam\"\n\n# Format-constrained (date, number, etc.)\ndate_gen = outlines.generate.format(model, datetime.date)\ndate = date_gen(\"When was Python created?\")\n# date = datetime.date(1991, 2, 20) — always a valid date object\n```\n\n### Batch Processing\n\n```python\n# Batch inference for throughput\ngenerator = outlines.generate.json(model, ReviewAnalysis)\n\nreviews = [\n    \"Amazing quality, will buy again!\",\n    \"Terrible customer service, never ordering here.\",\n    \"It's okay, nothing special.\",\n]\n\nprompts = [f\"Analyze: '{r}'\" for r in reviews]\nresults = generator(prompts, max_tokens=200)\n# results is a list of ReviewAnalysis objects — all guaranteed valid\n```\n\n### Grammar-Constrained\n\n```python\n# Custom grammar (CFG)\narithmetic_grammar = r\"\"\"\n    ?start: expression\n    ?expression: term ((\"+\" | \"-\") term)*\n    ?term: factor ((\"*\" | \"\u002F\") factor)*\n    ?factor: NUMBER | \"(\" expression \")\"\n    NUMBER: \u002F[0-9]+(\\.[0-9]+)?\u002F\n\"\"\"\n\ncalc_gen = outlines.generate.cfg(model, arithmetic_grammar)\nexpr = calc_gen(\"Generate a math expression that equals 42:\")\n# expr = \"(6 * 7)\" — always valid arithmetic\n```\n\n### With vLLM\n\n```python\n# Use with vLLM for production throughput\nmodel = outlines.models.vllm(\"meta-llama\u002FLlama-3.1-8B-Instruct\",\n    tensor_parallel_size=1, gpu_memory_utilization=0.9)\n\ngenerator = outlines.generate.json(model, ReviewAnalysis)\n# Combines Outlines' constrained generation with vLLM's batching + PagedAttention\n```\n\n## Installation\n\n```bash\npip install outlines\n```\n\n## Best Practices\n\n1. **Pydantic schemas** — Define output with Pydantic models; Outlines compiles to FSM for guaranteed compliance\n2. **Regex for patterns** — Use `generate.regex()` for dates, emails, IDs; output always matches the pattern\n3. **Choice for classification** — Use `generate.choice()` instead of free text; constrained to exact options\n4. **vLLM for production** — Combine with vLLM backend for high-throughput constrained generation\n5. **Batch for efficiency** — Pass lists of prompts; Outlines batches efficiently with the model\n6. **Field constraints** — Use Pydantic's `ge`, `le`, `min_length`, `max_length`; further constrains output\n7. **Grammar for DSLs** — Use CFG grammars for domain-specific output (SQL, code, formulas)\n8. **First-try guarantee** — Unlike retry-based approaches, Outlines gets valid output on the first generation\n",{},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002FTerminalSkills\u002Fskills\u002Foutlines",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":9,"skillName":5,"commands":45,"prompt":55,"zipAvailable":56},[46,49,52],{"tool":47,"command":48},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill outlines",{"tool":50,"command":51},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill outlines",{"tool":53,"command":54},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill outlines","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FTerminalSkills\u002Fskills\u002Foutlines\u002FSKILL.md",true,[58],{"path":59,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":62,"sourceHtmlUrl":63},"templates\u002Fstarter.md","REFERENCE","参考文档",2566,"https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002FWORM_V2_SOVEREIGN\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fcreative\u002Fdesign-md\u002Ftemplates\u002Fstarter.md",[65,74,83,92,98,104],{"skillNo":66,"name":67,"nameZh":7,"description":7,"descriptionZh":7,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":31},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[71,72,73],"model","model hierarchy","model hierarchy skill",{"skillNo":75,"name":76,"nameZh":7,"description":7,"descriptionZh":7,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":31},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[80,81,82],"MCP","zoom","zoom mcp",{"skillNo":84,"name":85,"nameZh":7,"description":7,"descriptionZh":7,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":31},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[89,90,91,81],"sdk","zoom apps sdk","apps",{"skillNo":93,"name":94,"nameZh":7,"description":7,"descriptionZh":7,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":31},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[94],{"skillNo":99,"name":100,"nameZh":7,"description":7,"descriptionZh":7,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":31},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[100],{"skillNo":105,"name":106,"nameZh":7,"description":7,"descriptionZh":7,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":31},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[106]]