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:
- Lexical Vagueness (LV): Replacing precise, task-relevant vocabulary with broader, ambiguous synonyms (e.g., changing "sort" to "arrange").
- Under-Specification (US): Omitting an explicit constraint, such as an edge-case behavior or a numeric bound.
- 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.
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.
- 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