arXiv cs.CL· Amit Verma·· 15 小时前AI 评分34
为什么结构化输出会失败?九款 LLM 上提示词强制 Pydantic Schema 的实证研究
Why Does Structured Output Fail? An Empirical Study of Prompt-Enforced Pydantic Schemas Across Nine LLMs
AI 导读
一项实证研究对九种 OpenAI 与 Anthropic 模型/API 配置的 3,997 次生成尝试做了细粒度失败分类,发现相近的校验通过率可能掩盖不同的失败模式。
正文 · 原文
Abstract:Pipelines that require structured outputs from hosted language models often specify a Pydantic schema in the prompt, validate the response, and retry when validation fails. Although native structured-output modes provide an alternative, application-side validation remains important for enforcing custom constraints. Yet pipeline reliability is often summarized by a single validity rate, which obscures why outputs fail and which interventions may help. We introduce a fine-grained taxonomy of schema-conformance failures and a deterministic classifier that assigns failure categories from model responses and Pydantic validation errors. We apply this framework to 3,997 generation attempts across nine OpenAI and Anthropic model/API configurations, using questions from HotpotQA and FinanceBench. Our results show that similar validity rates can mask different failure patterns, and that dominant failure categories vary with schema constraints and task. Markdown-fenced JSON is the most common failure: among 681 fenced failures, only 48.0% pass validation after fence removal, while the remainder conceal additional violations, predominantly field-length violations. In an exploratory prompt ablation, variants that suppress fences appear to shift failures toward length violations, but the shift is consistent with exposing violations that were already present, illustrating how aggregate validity rates can obscure changes in failure composition. We derive four engineering practices for validator, schema, retry and evaluation design, three supported by our data and one, on retry feedback, proposed but not tested, and release the classifier, completions, and annotations.
| Comments: | 36 pages, 2 figures, 16 tables. Under review at Empirical Software Engineering. Artifact: this https URL |
| Subjects: | Software Engineering (cs.SE); Computation and Language (cs.CL); Machine Learning (cs.LG) |
| Cite as: | arXiv:2610.33949 [cs.SE] |
| (or arXiv:2610.33949v1 [cs.SE] for this version) | |
| https://doi.org/10.48550/arXiv.2610.33949 arXiv-issued DOI via DataCite (pending registration) |
Submission history
From: Amit Verma [view email]
[v1]
Sat, 24 Oct 2026 23:30:38 UTC (99 KB)
来源:arXiv cs.CL · arxiv.org