Which Programs Does an Instruction Allow? Scoring Underspecification in Synthetic Code Data

Synthetic instruction–code pairs are usually filtered for one property: is the code a correct answer to the instruction? A second, quieter failure gets through these filters. Many instructions are correct but underspecified. "Normalize the column" is true of min-max scaling and of z-scoring alike. A student model trained on thousands of such pairs learns to settle the missing detail silently, and in whatever direction the synthetic generator happened to pick. This matters because agents fail on exactly this behavior: in repository-level issue resolution, requirement clarification accounts for 24.5% to 46.0% of agent failures (SWE-RPG).

We propose measuring underspecification directly. For each training instruction we ask a language model, one yes/no question at a time, whether each of several behaviorally different programs satisfies it. We run the programs to find out which ones actually behave differently. If the model says "yes" with high probability to a program whose outputs differ from the paired target, then the instruction does not pin down that difference. The pair is then either repaired, by inserting a clarification that rules the alternative out and re-checking, or turned into a training example of asking a clarifying question. In two sentences: execution tells us which programs genuinely differ, and a generative model's probability of "Yes" tells us which of those the instruction still permits. Instructions that permit behaviorally distinct programs are underspecified, and we fix or relabel them before training.

Core Claim

Correctness filters and ambiguity detectors in code today answer different questions with different tools, and neither measures the quantity that matters for training data: how many distinct behaviors an instruction admits. We make three claims.

First, an "admissibility" score, taken from the probability a model assigns to "Yes" when asked whether a program satisfies an instruction, can be computed over execution-defined behavior classes. That score separates underspecified instructions from well-specified ones better than asking an LLM whether the prompt is ambiguous, and better than checking whether sampled solutions disagree.

Second, the sampling check has a characteristic blind spot. When a model has a strong default interpretation, all its samples agree even though the instruction is ambiguous. Scoring admissibility of programs we construct ourselves does not depend on the model's own generation preferences, so it avoids this blind spot.

Third, training on data that has been repaired or relabeled according to this score produces models that ask for clarification or abstain on ambiguous requests, and it does so without losing pass rate on well-specified benchmarks.

Let $s(x,c) = P(\text{Yes}) / (P(\text{Yes}) + P(\text{No}))$ be the normalized answer probability a scoring model gives to the question "Does this code correctly implement the instruction $x$? Answer yes or no" for program $c$. We average $s$ over a few paraphrases of the question to reduce sensitivity to phrasing. Let $B_0$ be the set of candidate programs whose execution outputs match the target program $c^*$ on a shared input set. The underspecification score is

$$U(x) = \max_{c \notin B_0} s(x, c),$$

the highest admissibility the model grants to any program that behaves differently from the target. A pair is kept as-is when $s(x,c^*)$ is high and $U(x)$ is low. It is flagged as wrong when $s(x,c^*)$ is low. It is flagged as underspecified when both $s(x,c^*)$ and $U(x)$ are high.

Grounding in Prior Work

The scoring mechanism comes from text-to-image evaluation. VQAScore defines alignment as the probability of "Yes" to "Does this figure show {text}?". It argues that this beats embedding similarity because both inputs attend to each other at every layer, which lets the model check fine-grained bindings such as negations and counts. LLaVA-score extracts log-probabilities in a similar way. TIFA breaks long prompts into atomic questions, but it reports degradation beyond about five entities. We borrow the single-token yes/no probability and move it to instruction–code pairs. The new element is that we score a set of contrasting programs rather than one artifact: a well-specified instruction should reject nearby programs, and a single alignment score cannot express that.

Three papers motivate the gap. Hidden Positives shows that 44% to 87% of relevant code snippets are missing from retrieval benchmark labels, because one description often matches many implementations. That is the same one-to-many structure we exploit, seen from the evaluation side. Its MegaCode pipeline filters 300 million comment–code pairs down to 193 million with an LLM-supervised cross-encoder, but it judges only whether a comment matches its code, not whether the comment would also match different code. Caco builds 1.3 million reasoning pairs by executing code, back-translating it into natural-language problems, and keeping pairs whose answers match. It explicitly relies on unambiguous templates, and its back-translation step is a likely source of underspecified problems that no current check catches. CAPA injects ambiguity into HumanEval problems whose valid readings map to distinct code. This gives us controlled ground truth, but CAPA detects ambiguity by prompting an LLM.

Other work supplies parts of the method or constrains it. Li et al.'s CodeClarQA flags missing API operations using Sentence-BERT similarity between the description and operations extracted from code. It covers only missing top-level calls; arguments, types, and branch logic are out of scope, and a behavior-level score reaches exactly those. ICT (dataset) removes needed parameters from tool-use prompts and asks models to abstain through a verbalized five-step check. SYNTACT clarifies procedures before compiling them into workflows, filtering candidate questions by clustering. None of these three uses answer probabilities or execution to decide whether a clarification is needed.

Scoring Verifiers constrains our design. It finds that verifiers which see candidate code before writing tests become biased toward that code, which it calls "adherence bias". For this reason our distinguishing inputs come from differential execution across programs, never from tests written after inspecting $c^*$. The yes/no scorer sees each candidate separately and is never shown which one is the target.

The SemEval-2022 clarification-plausibility results pose an apparent contradiction. In the task, discriminative replaced-token-detection models beat masked-language-model scoring, and the winning X-PuDu system fine-tuned DeBERTa-v3. That result concerns filling masked tokens, whose representations cluster related words regardless of fit. A yes/no judgment made after full cross-attention over instruction and program is a different operation. We do not assume it wins, and we include a fine-tuned DeBERTa-v3 cross-encoder as a baseline.

Research Program

The pipeline has four stages.

Building alternatives. For each synthetic pair $(x, c^*)$ we build alternative programs from two sources. The first is programs sampled from several model families given only $x$, following the diversity argument of Ensemble-Instruct. The second is targeted edits to $c^*$ at the places where underspecification tends to live: default arguments, boundary conditions, sort stability, type handling, and choice among library functions. The edits matter because they do not depend on what any model prefers to generate.

Grouping by behavior. We execute all candidates on inputs from the original tests plus randomly generated type-conforming inputs, and group them into behavior classes by output. Programs that crash or time out are discarded.

Scoring. Every surviving candidate is scored with $s(x,c)$ using an open code model, which gives us access to answer probabilities. We compute $U(x)$ and also record which alternative attains the maximum, together with the input on which it disagrees with $c^*$.

Repair and relabeling. For flagged pairs, an LLM is shown $x$ and the disagreeing input–output pair and asked to insert the smallest clarification that rules out the alternative. This is the same insertion operation SemEval Task 7 evaluates, now checked automatically. A repair is accepted only if $s(x',c^*)$ stays high and $U(x')$ falls below threshold, a round-trip check in the spirit of Promptagator. Flagged pairs can alternatively be converted into dialogues: the original $x$, a clarifying question derived from the disagreement, the answer, and then $c^*$.

We will analyze calibration across scorer sizes. We will also study how $U$ depends on the number and source of alternatives, since too few alternatives underestimates ambiguity. Finally, we will check whether flagged pairs concentrate in particular CAPA ambiguity mechanisms.

Baselines

The naive reference point is the unfiltered synthetic corpus, together with a corpus filtered only on target correctness, keeping pairs with high $s(x,c^*)$. The correctness-only filter is the key ablation: it uses the same scorer and the same compute, and it differs from our method only in ignoring alternatives. Any gain from $U$ over it is attributable to contrastive scoring.

The strongest competitor for detection is sampling disagreement. We draw $k$ programs from $x$ alone, execute them, and flag $x$ when they fall into more than one behavior class. It is the natural execution-based way to spot ambiguity, and it needs no scorer. We run it with the same generator models and the same total number of generated programs as our alternative set, on the same inputs. Beating it means higher AUROC for separating CAPA's ambiguity-injected prompts from their originals, and especially higher recall on the subset where all samples agree.

The second competitor is an LLM judge prompted to decide whether clarification is needed, in the style of CAPA's gate and ICT's Structured Verification. This is the method those benchmarks actually use. We give it the same scorer model, or a stronger one for a conservative comparison, and tune the prompt on the same development split.

The third competitor is a discriminative cross-encoder. Following X-PuDu, we fine-tune DeBERTa-v3 on the same labeled development data to classify ambiguous versus clear, and a MegaCode-style reranker judging pair quality. Both get the same labeled budget.

We found no reported result on Lacuna for any of these baselines on CAPA ambiguity detection, ICT abstention, or CodeClarQA clarification-need prediction with figures we could quote, so we will run all of them ourselves. The only directly reported number close to our setting is X-PuDu's 68.90% classification accuracy on SemEval-2022 Task 7, against an estimated human ceiling of 77.1% to 79.4%. We will report our scorer's accuracy on that task as a side check of whether yes/no probabilities capture clarification plausibility at all.

The ablations cover alternatives from sampling only versus edits only versus both; behavior grouping by execution versus none, where we treat every textually distinct program as an alternative; and a single question prompt versus paraphrase-averaged prompts.

Why not just…?

Why not just sample several solutions and check whether they disagree? This is the most serious threat. If sampled programs already disagree whenever an instruction is ambiguous, the scorer adds cost without adding information. Our argument is that sampling measures what the model tends to write, not what the instruction permits. A model with a strong habit, such as always using z-scoring for "normalize", will produce unanimous samples for an ambiguous prompt. The decisive test is recall on CAPA items where samples agree. If sampling disagreement matches $U(x)$ there, we will adopt it as the cheaper method and report the scorer as unnecessary.

Why not just ask an LLM whether the instruction is ambiguous? CAPA and ICT do this, and it is cheap. However, a verbal judgment of ambiguity is not tied to any concrete behavioral difference. It cannot tell us which detail is missing, so it cannot drive a repair that can be checked. We also expect it to over-flag, calling harmless vagueness ambiguous; SemEval's NEUTRAL class shows how hard graded plausibility is for categorical judgments. We will measure precision and recall against CAPA labels, and the downstream effect of each flagging method on training.

Why not just fine-tune a discriminative classifier, as the SemEval winners did? That approach wins when labeled data matches the test distribution. Synthetic corpora, however, span libraries and task types with no ambiguity labels. We will train the classifier on CAPA's development split and test it both in-distribution and on ICT and CodeClarQA. If it matches $U(x)$ across domains, the generative scorer is not needed for detection, although it would remain useful for verifying repairs.

Why not just keep the correctness filter, since the pairs are correct? Correct but underspecified pairs are exactly what teaches silent guessing. The correctness-only ablation, evaluated on CAPA and ICT after training, shows whether the problem is real enough to matter.

Proposed Experiments

Detection. On CAPA we compute AUROC for separating ambiguity-injected from original prompts, broken down by CAPA's six ambiguity mechanisms, and we report the unanimous-samples subset separately. On ICT we measure abstention accuracy on utterance-removal cases. On CodeClarQA we measure clarification-need prediction, focusing on whether our score catches missing arguments that its API-level labels do not cover.

Training. We build a Caco-style corpus by back-translating execution-verified Python from HumanEval- and MBPP-like seeds, then produce four versions: unfiltered, correctness-filtered, $U$-filtered with repair, and $U$-relabeled into clarification dialogues. We fine-tune the same small open code model on each with equal token budgets. Evaluation uses HumanEval and MBPP pass@1 to detect any cost on well-specified tasks; CAPA and ICT for asking or abstaining appropriately; and HE-R and MBPP-R for whether the scorer ranks subtly buggy code correctly.

Decisive checks. Three results would support the proposal. The first is higher detection recall than sampling disagreement on the unanimous subset. The second is better CAPA and ICT behavior after training, with HumanEval pass@1 within noise of the correctness-filtered model. The third is that accepted repairs lower $U$ while preserving $s(x,c^*)$, and are judged by humans to add only the missing detail. If the scorer's probabilities are poorly calibrated across prompt paraphrases, the method fails on its own terms, and we will report that as the outcome.