arXiv:2608.13742cs.SEcs.AI2026-08中稿 · publication at the…

用ISO标准优化非功能需求描述,能提升代码质量但未必提高正确性。

Does ISO-Grounded NFR Specification Improve LLM Code Generation? A Comparison of Rich and Structured Interventions against a Natural-Language Baseline

  • 将NFR规范基于ISO/IEC 25010模型,用自然语言或结构化格式表达
  • 代码可读性密度下降(如性能项从0.88降至0.69),错误处理测试通过率反降
  • 内容比格式更重要,自然语言与JSON效果接近,适合注重质量的开发者

在大模型代码生成中,非功能需求(NFR)常以简短单行语句描述。本文研究将这些需求基于ISO/IEC 25010质量模型进行丰富化表达(自然语言版或结构化JSON版),相比传统的简洁描述(NL-simple)是否能提升代码质量。在HumanEval和HumanEval-ET数据集上,对性能、错误处理、代码异味、可读性四个NFR进行十种提示变体测试,固定模型版本并采用配对非参数分析。主要发现:基于ISO的丰富化描述显著降低静态质量指标中的不可读密度(如性能项由0.88降至0.69),减少对提示措辞的敏感性,但未稳定提升功能性正确性;错误处理任务的扩展测试通过率反而下降,表明防御性编程与精确输出评测存在矛盾。次要发现:当内容一致时,自然语言与结构化格式在正确性上差异极小(|delta| ≤ 0.023),说明语义内容比格式形式更关键。实践建议:应优先投入标准化内容构建,而非关注序列化形式。完整可复现代码包已提供。

原文摘要 · Abstract (English)

In LLM-based code generation, Non-Functional Requirements (NFRs) are often specified as terse one-line phrases. We ask whether grounding those specifications in ISO/IEC 25010 Quality Model, either as rich natural-language prose (NL-rich) or as structured JSON (Structured), improves code generated on HumanEval/HumanEval-ET compared to a RobuNFR-style one-line baseline (NL-simple). We evaluate four NFRs (performance, error handling, code smell, readability) with ten prompt variations per condition under a fixed model snapshot and paired non-parametric analysis. Primary finding: ISO-grounded enrichment improves static quality proxies (unreadability density falls across all four NFRs (e.g., Performance 0.88 -> 0.69 for NL-rich)) and reduces sensitivity to prompt wording, but does not reliably improve functional correctness; for error handling, extended-test pass rate decreases, suggesting tension between defensive coding patterns and exact-output benchmarks. Secondary finding: when ISO content is held constant, NL-rich and Structured differ negligibly in correctness (|delta| <= 0.023), indicating that semantic content matters more than JSON-vs-prose format. Practitioners should invest in standard-grounded NFR content rather than serialization form. A fully traceable replication package is provided.

代码生成非功能需求ISO标准LLM评估

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。