TL;DR
While Large Language Models (LLMs) excel at generating code from pristine, textbook-style specifications, real-world software requirements are notoriously messy and ambiguous. This paper introduces Orchid, the first function-level code generation benchmark specifically designed with ambiguous requirements. The study reveals that requirement ambiguity severely degrades the performance of even state-of-the-art models like GPT-4, causing them to generate wildly inconsistent code without realizing they are guessing.
What Problem Does This Paper Address?
Existing code generation benchmarks (like HumanEval or MBPP) operate under a flawed assumption: that software requirements are always clear, precise, and unambiguous. In reality, natural language is inherently imprecise.
When an LLM is given an ambiguous prompt, it faces a conflict called forced determinism—it must collapse linguistic uncertainty into a single, executable piece of code without asking for clarification. Because current evaluation paradigms don't explicitly model or control for ambiguity, we haven't known whether an LLM's coding failures stem from poor programming ability or simply a misinterpretation of an unclear prompt. This paper fills that gap by systematically categorizing and evaluating how LLMs behave under uncertainty.
Methods
The authors first established a taxonomy of four ambiguity types relevant to function-level code generation:
- Lexical: A single word has multiple meanings (e.g., "pattern" meaning a literal substring vs. a regular expression).
- Syntactic: The grammatical structure allows multiple interpretations (e.g., unclear pronoun references).
- Semantic: A phrase can be understood in multiple ways within context (e.g., "remove duplicate occurrences").
- Vagueness: The requirement completely omits necessary details (e.g., "filter by threshold" without specifying if it means keeping items above or below it).
To build a benchmark around these types, they designed a semi-automated, human-in-the-loop pipeline:
- Requirement Extraction: Cleaned up existing benchmark tasks by removing code snippets and examples.
- Requirement Rewriting (Multi-Agent Framework): Powered by DeepSeek-V3, an Injection Agent introduced a specific type of ambiguity; a Judge Agent iteratively verified that the ambiguity was plausible and retained the original intent; and an Explain Agent detailed the possible interpretations.
- Human Curation: Authors spent over 246 person-hours manually validating the dataset to ensure high quality.
Datasets
The resulting benchmark, Orchid, contains 1,304 tasks and 5,216 ambiguous requirement variants. It is split into three subsets:
- Orchid-HEval: 164 tasks derived from HumanEval+ (simpler tasks).
- Orchid-BCB: 164 tasks derived from BigCodeBench (more complex, real-world tasks).
- Orchid-BCB-Expand: 976 tasks generated via the automated pipeline to increase coverage, though lacking the final rigorous human verification step.
Key Insights and Ideas
- The SOTA Paradox: Counterintuitively, the most advanced models suffer the steepest relative performance drops when faced with ambiguity. While they easily ace clear requirements, their reliance on making assumptions makes them fragile when the prompt is unclear.
- Functional Divergence: Ambiguity shatters model consistency. When given the exact same ambiguous prompt across multiple trials, LLMs frequently generate entirely different, mutually incompatible code implementations.
- The Detection vs. Resolution Gap: LLMs are actually quite good at flagging that a prompt might be ambiguous (high recall). However, they are terrible at localizing exactly where the ambiguity lies or proposing concrete ways to resolve it. Instead, they default to a conservative strategy of over-flagging almost everything as ambiguous.
Key Results
- Performance Drop: Ambiguity consistently degraded code generation quality across all six evaluated models, dropping Pass@1 accuracy by an average of 7.22 percentage points (a 16.25% relative decline).
- GPT-4 Vulnerability: GPT-4's accuracy plummeted by over 28 percentage points on the Orchid-BCB dataset when ambiguity was introduced.
- Doubled Conflict Rates: For capable models, the intra-model conflict rate (how often the same model generates functionally different code for the same prompt) nearly doubled. For instance, GPT-4's conflict rate jumped from 14.09% to 28.29%.
- Low Precision in Detection: While models like Claude-3.5 achieved near-100% recall in detecting semantic ambiguity, precision hovered around 50% across the board, meaning clear requirements were frequently misclassified as ambiguous. Localization rates rarely exceeded 23%.
Limitations and Future Work
The primary limitation is that the largest subset, Orchid-BCB-Expand (74.8% of the dataset), did not undergo manual expert validation, meaning it may have less consistent quality than the core subsets.
The authors conclude that simply scaling up LLMs will not solve the ambiguity problem. Instead, future automated software engineering tools must move away from autonomous generation and toward ambiguity-aware techniques—such as interactive multi-agent frameworks that actively ask developers for clarification when uncertainty is detected.
Summary updated