Defective Task Descriptions in LLM-Based Code Generation: Detection and Analysis

Amal Akli, Mike Papadakis, Maxime Cordy, Yves Le TraonarXiv 2026 · arXiv

TL;DR

While Large Language Models (LLMs) excel at code generation, they are highly sensitive to "defective" prompts containing vague or incomplete instructions. This paper introduces SpecValidator, a lightweight, parameter-efficiently fine-tuned 1.5B model that automatically detects task description defects, significantly outperforming frontier models like GPT-5-mini and Claude Sonnet 4 while revealing hidden flaws in standard evaluation benchmarks.

What Problem Does This Paper Address?

Standard code-generation benchmarks evaluate LLMs using perfectly curated, well-formed task descriptions. In the real world, however, human developers write messy prompts. They omit edge cases, use ambiguous language, or introduce typos.

When an LLM encounters a defective prompt, it often confidently generates syntactically correct but semantically flawed code. The authors address two major gaps: understanding how different types of prompt defects impact code correctness across various model scales, and building an automated, lightweight gatekeeper to flag these defects before an LLM attempts to generate faulty code.

Methods

The authors categorize prompt defects into three distinct classes:

  1. Lexical Vagueness (LV): Replacing precise, task-relevant vocabulary with broader, ambiguous synonyms (e.g., changing "sort" to "arrange").
  2. Under-Specification (US): Omitting an explicit constraint, such as an edge-case behavior or a numeric bound.
  3. Syntax and Formatting (SF): Introducing surface-level noise like typos, bad indentation, or bracket corruption.

To study these, they build a pipeline to systematically inject these defects into existing benchmarks using GPT-5-mini, validating quality using Qwen2.5-Coder-32B as an automated judge alongside human verification.

Figure 1: Dataset construction. Defects are generated with GPT-5-mini with defect quality being scored by a Qwen-32B evaluator. Defective descriptions are then manually verified by 3 human reviewers.

To solve the detection problem, they develop SpecValidator, a sequence classifier built on top of the Qwen2.5-Coder-1.5B backbone. They experiment with three training regimes: linear probing, full fine-tuning, and Low-Rank Adaptation (LoRA). LoRA fine-tuning yielded the best balance, updating only 0.14% of the parameters.

Datasets

The study leverages three widely used Python code-generation benchmarks representing different styles and complexities:

  • HumanEval: Structured docstrings with typed function signatures.
  • MBPP: Short, informal natural language descriptions of basic programs.
  • LiveCodeBench (LCB): Complex competitive programming problems with explicit numerical bounds and formal input/output contracts.

Through their mutation framework, they generate a new, publicly available dataset consisting of 6,573 defective task description instances.

Key Insights and Ideas

  • Under-Specification is the Ultimate LLM Killer: Omitting a single constraint or edge case (US) causes catastrophic drops in code correctness. Because the prompt remains grammatically correct, models confidently generate code for the wrong problem.
  • Contextual Grounding is a Shield: LiveCodeBench proved remarkably resilient to all defect types. Why? Because it includes explicit sample input/output blocks. Even if the natural language description becomes vague or loses a constraint, the LLM can reconstruct the missing logic purely from the example I/O contracts.
  • Scale Won't Save You: Larger models or advanced reasoning models (like GPT-5-mini) do not inherently possess better robustness against defective prompts than smaller models. Sensitivity is description-dependent, not capacity-dependent.
  • Generation Power $\neq$ Meta-Reasoning Power: Frontier models excel at writing code but perform poorly at identifying why a prompt is bad in a zero-shot or few-shot setting. A specialized, tiny model (1.5B) fine-tuned for the task easily beats them.

Key Results

  • Impact on Code Generation: Under-specification caused Pass@1 drops of up to 15.3% on HumanEval and 10.8% on MBPP. Conversely, surface-level formatting noise (SF) had a negligible impact (under 3.7%), showing that modern code LLMs are highly robust to simple typos.
Figure 2: Pass@1 drop (%) with all defect types in all models and benchmarks, computed as (Orig −Mutated)/Orig × 100. Red cells indicate performance degradation; blue cells indicate a slight gain. Column labels: US = Under-Specification; LV = Lexical Vagueness; SF = Syntax and Formatting.
  • Defect Detection Performance: SpecValidator (LoRA) achieved an F1-score of 0.804 and a Matthews Correlation Coefficient (MCC) of 0.745. It significantly outperformed few-shot GPT-5-mini (F1 = 0.462, MCC = 0.276) and few-shot Claude Sonnet 4 (F1 = 0.557, MCC = 0.412).
  • Generalization to Real Flaws: When evaluated on the original, supposedly "clean" benchmark datasets, SpecValidator flagged 83 descriptions as under-specified. Manual and empirical verification showed that 72.7% of the flagged MBPP prompts were genuinely defective, leading to near-zero Pass@1 rates across all 10 evaluated LLMs.

Limitations and Future Work

The authors note several limitations and areas for future exploration:

  • Generalization to Complex Tasks: The finding regarding LiveCodeBench's immunity might not generalize to more complex, library-intensive tasks (e.g., BigCodeBench) where prompt precision and external API interactions differ.
  • Instruction-Tuned vs. Base Models: The study primarily evaluates instruction-tuned variants of models; base models might exhibit different sensitivities.
  • Coarse Metrics: The Pass@1 metric treats all failures equally, failing to distinguish between "near misses" and complete code failures.
  • Future Directions: Promising future work includes extending this framework to compound/mixed defects and developing automated prompt-repair mechanisms to fix under-specified descriptions dynamically before code generation.

Summary updated

Abstract

Large language models are widely used for code generation, yet they rely on an implicit assumption that the task descriptions are sufficiently detailed and well-formed. However, in practice, users may provide defective descriptions, which can have a strong effect on code correctness. To address this issue, we develop SpecValidator, a lightweight classifier based on a small model that has been parameter-efficiently finetuned, to automatically detect task description defects. We evaluate SpecValidator on three types of defects, Lexical Vagueness, Under-Specification and Syntax-Formatting on 3 benchmarks with task descriptions of varying structure and complexity. Our results show that SpecValidator achieves defect detection of F1 = 0.804 and MCC = 0.745, significantly outperforming GPT-5-mini (F1 = 0.469 and MCC = 0.281) and Claude Sonnet 4 (F1 = 0.518 and MCC = 0.359). Perhaps more importantly, our analysis indicates that SpecValidator can generalize to unseen issues and detect unknown Under-Specification defects in the original (real) descriptions of the benchmarks used. Our results also show that the robustness of LLMs in task description defects depends primarily on the type of defect and the characteristics of the task description, rather than the capacity of the model, with Under-Specification defects being the most severe. We further found that benchmarks with richer contextual grounding, such as LiveCodeBench, exhibit substantially greater resilience, highlighting the importance of structured task descriptions for reliable LLM-based code generation.
BibTeX
@misc{akli2026defective,
  author = {Amal Akli and Mike Papadakis and Maxime Cordy and Yves Le Traon},
  title = {{Defective Task Descriptions in LLM-Based Code Generation: Detection and Analysis}},
  year = {2026},
  eprint = {2604.24703},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.24703},
}

Loading related content...

Figure