返回提示词库
文本 · 通用大模型LLM 输出结构化验证与自动修复框架设计师PW
创作者Prompt2 编辑部PromptWhisper 收录
文本通用大模型开发与工程

LLM 输出结构化验证与自动修复框架设计师

为LLM应用设计输出结构化验证管道,自动检测格式错误并触发重试修复策略,支持JSON Schema、Pydantic等验证方案

12浏览
完整提示词可替换花括号中的变量后直接使用

You are an expert in designing structured output validation and auto-repair pipelines for LLM applications. Given the following context: - **Application type**: [e.g., chatbot, data extraction, code generation] - **Expected output format**: [e.g., JSON, XML, Markdown, code] - **Validation schema**: [paste JSON Schema, Pydantic model, or describe constraints] - **LLM provider**: [e.g., OpenAI, Anthropic, local model] - **Error tolerance**: [strict / lenient / best-effort] Design a complete structured output validation and auto-repair framework: 1. **Validation Layer Design** - Schema definition strategy (JSON Schema, Pydantic, Zod, etc.) - Multi-level validation: syntax > schema > semantic > business rules - Streaming vs batch validation tradeoffs 2. **Error Detection & Classification** - Common failure modes (truncation, hallucinated fields, type mismatches) - Error severity scoring (recoverable vs fatal) - Confidence-based output filtering 3. **Auto-Repair Strategies** - Prompt-based retry with error context injection - Partial parse + targeted re-generation - Fallback chain: constrained decoding > regex extraction > re-prompt - Token budget management across retries 4. **Implementation Blueprint** - Middleware/interceptor architecture - Integration with existing frameworks (Instructor, Outlines, Guardrails) - Monitoring: success rate, retry count, latency overhead 5. **Testing & Hardening** - Adversarial test cases for edge cases - Regression suite for schema evolution - Performance benchmarks Provide concrete code examples and architecture diagrams (as Mermaid) for the recommended approach.

2026/4/26

如何使用这条提示词

  1. 1复制上方完整提示词。
  2. 2在对应模型中替换主题、人物或风格变量。
  3. 3生成后记录有效调整,形成自己的版本。