When Prompt Under-Specification Improves Code Correctness: An Exploratory Study of Prompt Wording and Structure Effects on LLM-Based Code Generation

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

TL;DR

Prompt under-specification doesn't always degrade LLM code generation; in structurally rich prompts, removing constraints or using vaguer language can actually improve code correctness. This happens because simplifying a prompt can disrupt misleading "retrieval cues" that inadvertently anchor the model to incorrect, memorized solution patterns.

What Problem Does This Paper Address?

A common assumption in prompt engineering is that more precise, highly detailed prompts lead to better LLM-generated code. Prior studies have shown that minor wording changes or missing requirements (under-specification) can tank model performance.

However, the authors point out a major flaw in this conventional wisdom: it relies almost entirely on minimal-specification benchmarks like HumanEval or MBPP. These benchmarks use short, single-docstring descriptions that lack the structural redundancy found in real-world programming tasks. This paper investigates a fundamental question: How do prompt wording, structural richness, and task complexity interact to affect code correctness across different LLMs?

Methods

The authors systematically introduced three types of prompt mutations to evaluate model robustness:

  1. Lexical Vagueness (LV): Replacing precise, task-relevant terms with broader synonyms and renaming identifiers to be less informative (e.g., changing sort to arrange).
  2. Under-Specification (US): Removing a single explicit constraint, such as value bounds or edge-case descriptions.
  3. Syntax and Formatting (SF): Introducing surface-level noise like typos or formatting irregularities without altering semantic content.

Mutations were generated using an LLM and validated via an independent automated judge alongside manual human inspection. The authors evaluated 10 different code-generation models (ranging from 6B open-source models to state-of-the-art proprietary reasoning models) using two primary metrics: Pass@1 and a fine-grained transition-based analysis tracking solutions that flipped from passing to failing ($Pass \rightarrow Fail$) and vice versa ($Fail \rightarrow Pass$). They also analyzed the models' internal attention distributions to see which parts of the prompt mattered most.

Datasets

The study compared two structurally contrastive benchmarks:

  • HumanEval (HE): 164 simple, hand-written Python problems characterized by minimal specifications (just a function signature and a short docstring).
  • LiveCodeBench (LCB): 1,055 complex, contamination-free competitive programming problems featuring multi-layered specifications, including full prose descriptions, explicit constraint sections, input/output format specifications, and multiple sample I/O pairs with explanations.

Key Insights and Ideas

  • Robustness is an Artifact of Prompt Structure, Not Model Scale: Larger models aren't inherently more robust to prompt changes. Instead, the structure of the prompt dictates robustness. Multi-layered prompts provide redundant information channels; if the description is degraded, the model can fall back on intact I/O formats or examples.
  • The "Less is More" Phenomenon: Surprisingly, under-specification and vagueness frequently helped models generate correct code. Original prompts often contain domain-specific vocabulary or strict constraint formulations that act as "spurious retrieval cues." These cues trick the model into pulling an overfitted, memorized algorithm from its training data that doesn't quite fit the current problem.
Figure 1: A LiveCodeBench example where removing a constraint improves generated code: the constraint primed the model toward an incorrect algorithm; its removal forced reasoning from problem structure.
  • Attention Redistribution: Attention mapping revealed that when prompts are structurally rich (like LCB), models distribute 30–50% of their attention to the I/O format and sample regions. In contrast, HumanEval forces models to concentrate 60–86% of their attention purely on the short description, making it highly fragile.
Figure 3: Normalized last-layer last-token attention distributed across prompt regions for HumanEval (Signature, Description, Examples) and LiveCodeBench (Description, I/O Format, Sample I/O), averaged over all attention heads.

Key Results

  • Asymmetric Benchmark Performance: On HumanEval, mutations uniformly degraded performance. Under-specification (US) caused an average Pass@1 drop of 11.8%, and lexical vagueness (LV) caused a 7.1% drop. On LiveCodeBench, however, the net effect was near-zero (US dropped by only 0.9%, and LV dropped by 0.2%).
  • Opposing Forces Cancel Out: The near-zero net effect on LiveCodeBench wasn't due to insensitivity; rather, it was caused by two opposing forces balancing each other out. For LV mutations on LCB, the ratio of $Fail \rightarrow Pass$ to $Pass \rightarrow Fail$ transitions was 0.99 (nearly perfect balance), whereas on HumanEval it was a heavily skewed 0.40.
  • Consistent Improvements: The authors identified 47 "clean" tasks in LiveCodeBench where introducing vagueness or under-specification consistently and exclusively improved the pass rate across multiple models. Manual analysis showed that 74% of these improvements under under-specification occurred because removing a constraint either fixed a LeetCode-style input parsing assumption or disrupted a constraint-anchored wrong algorithm.

Limitations and Future Work

The authors acknowledge several limitations:

  • Python-Only: The study was conducted exclusively on Python code generation; results might differ for languages with different type systems or library dependencies.
  • Greedy Decoding: The evaluation relied on Pass@1 with greedy decoding to ensure reproducibility, which masks the variance inherent in multi-sample generation ($Pass@k$).
  • Exploratory Nature: As an exploratory study, the findings are primarily hypothesis-generating. Future work will require tightly controlled causal experiments to isolate specific linguistic triggers.

Summary updated

Abstract

Large language models are increasingly used for code generation, yet the correctness of their outputs depends not only on model capability but also on how tasks are specified. Prior studies demonstrate that small changes in natural language prompts, particularly under-specification can substantially reduce code correctness; however, these findings are largely based on minimal-specification benchmarks such as HumanEval and MBPP, where limited structural redundancy may exaggerate sensitivity. In this exploratory study, we investigate how prompt structure, task complexity, and specification richness interact with LLM robustness to prompt mutations. We evaluate 10 different models across HumanEval and the structurally richer LiveCodeBench. Our results reveal that robustness is not a fixed property of LLMs but is highly dependent on prompt structure: the same under-specification mutations that degrade performance on HumanEval have near-zero net effect on LiveCodeBench due to redundancy across descriptions, constraints, examples, and I/O conventions. Surprisingly, we also find that prompt mutations can improve correctness. In LiveCodeBench, under-specification often breaks misleading lexical or structural cues that trigger incorrect retrieval-based solution strategies, leading to correctness improvements that counterbalance degradations. Manual analysis identifies consistent mechanisms behind these improvements, including the disruption of over-fitted terminology, removal of misleading constraints, and elimination of spurious identifier triggers. Overall, our study shows that structurally rich task descriptions can substantially mitigate the negative effects of under-specification and, in some cases, even enhance correctness. We outline categories of prompt modifications that positively influence the behavior of LLM code-generation, offering practical insights for writing robust prompts.
BibTeX
@misc{akli2026when,
  author = {Amal AKLI and Mike PAPADAKIS and Maxime CORDY and Yves Le TRAON},
  title = {{When Prompt Under-Specification Improves Code Correctness: An Exploratory Study of Prompt Wording and Structure Effects on LLM-Based Code Generation}},
  year = {2026},
  eprint = {2604.24712},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.24712},
}

Loading related content...

Figure