ConceptioArchivearXiv CS
arXiv CSopen access

Bridging the Gap between User Intent and LLM: A Requirement Alignment Approach for Code Generation

Unknown · 2026 · arxiv_cs
arXiv CS · Papers · License: Open Access · 2026
Open Source ↗Direct PDF ↓
softwarearchitecturesoftwareengineeringtesting
software engineering, software architecture, testing

arXiv:2604.16198v1 [cs.SE] 17 Apr 2026

Bridging the Gap between User Intent and LLM: A Requirement Alignment Approach for Code Generation Jia Li∗

Ruiqi Bai∗

Yangkang Luo

School of Computer Science, Wuhan University Wuhan, China [email protected]

School of Computer Science, Wuhan University Wuhan, China [email protected]

School of Computer Science, Wuhan University Wuhan, China [email protected]

Yiran Zhang

Wentao Yang

Zeyu Sun

Nanyang Technological University Singapore [email protected]

School of Computer Science, Wuhan University Wuhan, China [email protected]

Institute of Software, Chinese Academy of Sciences Beijing, China [email protected]

Tiankuo Zhao

Dongming Jin

Lei Li

School of Computer Science, Wuhan University Wuhan, China [email protected]

Key Lab of High Confidence Software Technology, MoE (Peking University) Beijing, China [email protected]

The University of Hong Kong Hong Kong, China [email protected]

Zhi Jin† Wuhan University, Peking University Wuhan, China [email protected]

Abstract Code generation refers to automatically producing executable programs from user requirements. Recently, researchers have explored approaches to enhance the correctness of generated code with advanced large language models. Although achieving improvements, existing approaches focus on designing reasoning strategies or post-refinement methods to enhance code generation performance. Despite their differences, all these methods share a common assumption: the LLM can correctly understand the given requirement. However, this assumption does not always hold. To fill this gap, we propose REA-Coder, a requirement alignment approach to enhance the code generation performance of LLMs. REA-Coder involves first identifying the requirement content that does not align with LLMs and aligning the requirements. Then, based on

the aligned requirements, LLMs generate code and further verify whether the generated code aligns with the requirements, iterating this process of requirement alignment and code generation until generating correct code or achieving the maximum number of iterations. Experimental results show that REA-Coder outperforms all advanced baselines on four LLMs across five programming benchmarks. Concretely, REA-Coder achieves average improvements of 7.93%, 30.25%, 26.75%, 8.59%, and 8.64% on the five benchmark datasets, demonstrating the effectiveness of requirement alignment for improving the code generation performance of LLMs.

CCS Concepts • Automated Software Engineering → Code Generation; Large Language Model.

∗ Both authors contributed equally to this research. † Corresponding author.

Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]. Conference acronym ’XX, Woodstock, NY © 2018 Copyright held by the owner/author(s). Publication rights licensed to ACM. ACM ISBN 978-1-4503-XXXX-X/2018/06 https://doi.org/XXXXXXX.XXXXXXX

Keywords Code Generation, Large Language Model, Requirement Alignment ACM Reference Format: Jia Li, Ruiqi Bai, Yangkang Luo, Yiran Zhang, Wentao Yang, Zeyu Sun, Tiankuo Zhao, Dongming Jin, Lei Li, and Zhi Jin. 2018. Bridging the Gap between User Intent and LLM: A Requirement Alignment Approach for Code Generation. In Proceedings of Make sure to enter the correct conference title from your rights confirmation email (Conference acronym ’XX). ACM, New York, NY, USA, 12 pages. https://doi.org/XXXXXXX.XXXXXXX

Conference acronym ’XX, June 03–05, 2018, Woodstock, NY

1

Introduction

Code generation aims to automatically transform user requirements into executable programs. With the rapid advances in large language models (LLMs), automated code generation has attracted significant attention from both academia and industry [19, 27, 41]. Despite notable progress, LLMs still struggle with complex requirements. For example, Qwen3-Coder [2] achieves only 15.15% Pass@1 on competitive programming benchmark CodeContests [29]. This limits the application of LLMs in practical software development. To date, various methods have been proposed to improve code generation. One category of work designs reasoning strategies to enhance the generation process, such as structured chain-ofthought prompting [26], difficulty-aware routing [28], and iterative plan-code-test workflows [40]. Another category focuses on postprocessing to fix the generated code. Some methods directly repair code based on execution feedback [33, 38], while others [21, 32, 37] go further by detecting the inconsistency between generated code and the requirement, and refining code accordingly. Despite their differences, all these methods share a common assumption: the LLM can correctly understand the given requirement. Reasoning-based methods focus on improving how the model plans and generates code. Post-processing methods focus on repairing outputs or refining requirements based on the model’s generated results. However, none of them verifies whether the model has truly understood what the requirement asks for. Our analysis reveals that this assumption does not always hold (as illustrated in Figure 1). LLMs can fundamentally misunderstand the requirement, rather than merely making mistakes during reasoning or code writing. When such misunderstanding occurs, the model is working from a wrong interpretation of the task. In this case, neither stronger reasoning strategies nor output-level repairs can fix the root cause, as they are all built upon the same flawed understanding. To address this limitation, we propose REA-Coder, a requirement alignment approach designed to boost the code generation performance of LLMs. REA-Coder starts by identifying the requirement content that does not align with LLMs, where we construct requirement-oriented question checklists and reference answers that cover core requirement elements. By comparing the model’s generated answers of questions against the reference answers, REACoder pinpoints requirement items misunderstood by LLMs, and further aligns the requirement. Then, based on the aligned requirement, LLMs generate code and further verify whether the generated code aligns with the requirement, iterating this process of requirement alignment and code generation until the generated code passes all public test cases or hits a preset iteration budget. In this way, REA-Coder enables LLMs to generate functionally correct code based on requirement alignment. We conduct experiments to evaluate the effectiveness of REACoder on four LLMs (i.e., DeepSeek-v3.2 [30], Qwen3-Coder [2], GPT-5-mini [36], and Gemini-3-Flash [9]) with five widely used programming benchmarks(i.e., APPS [15], CodeContests-raw [29], CodeContests [29], xCodeEval [24], and LiveCodeBench-Lite [20]).

Trovato et al.

Experimental results show that REA-Coder significantly outperforms 8 state-of-the-art baselines across 20 (4 × 5) model and benchmark combinations, validating the significant effectiveness of aligning requirements with LLMs in code generation. Concretely, REACoder achieves average improvements of 7.93%, 30.25%, 26.75%, 8.59%, and 8.64% on the five benchmarks, respectively. Ablation studies show that both aligning the requirement before code generation and alignment requirement verification after generating code make substantial contributions to the effectiveness of REACoder. We also investigate the effect of the number of iterations. We find that REA-Coder outperforms other iterative approaches in all iteration times. In addition, the performance gain is much larger in the early iterations, and then gradually becomes smaller, which suggests that requirement misalignment is particularly prominent during the early iterations. We also verify the first generated code based only on requirement alignment before code generation outperforms the zero-shot approach 210.44% and 344.67% on APPS and xCodeEval. The results validate the central design principle of REA-Coder that requirement alignment should be moved as early as possible, rather than relying primarily on execution feedback after acquiring code. The main contributions of this paper are summarized as follows: • We argue that the assumption (i.e., the LLM can correctly understand the given requirement) does not always hold. • We propose REA-Coder, an approach to enhance the code generation performance of LLMs through sophisticated requirement alignment. • We evaluate REA-Coder across four LLMs and five programming benchmarks, achieving state-of-the-art performance compared to 8 advanced code generation baselines on all (4 × 5) LLMs and benchmarks.

(Zero-Shot) ... (SCOT) ... (Self-Repair) ... while a>0 and b>0:(Lack) while a>0 and b>0:(Lack) while a > 0 and b > 0: if a >= 2 * b: if a >= 2 * b: if a >= 2 * b: a -= (2 * b) a %= (2 * b) a -= (2 * b) elif b >= 2 * a: elif b >= 2 * a: elif b >= 2 * a: b -= (2 * a) b %= (2 * a) b -= (2 * a) else: else: else: pass break break ... ... ... Original Requirement

TestPass:0/7 (REA-Coder)

1. Description: You have two variables a and b... 2. Input: The only line of the input contains two integers... 3. Output: Print two composite integers ( 4. Examples: {"inputs": ["1", ...], "outputs": ["9 8", ...]}

Aligned Requirement (#Iter = 1)

)...

TestPass:3/7 (REA-Coder)

[Original Requirement] 5. Explanation of Examples: For 12, 5, continuously subtract twice...

Aligned Requirement (#Iter = 2)

TestPass:7/7 (REA-Coder)

[Original Requirement] 5. Explanation of Examples: For 12, 5, continuously subtract twice... 6. Hints or Tips: This process is analogous to a Euclidean algorithm...

Figure 1: An example of how requirement alignment improves code generation over iterations.

Bridging the Gap between User Intent and LLM: A Requirement Alignment Approach for Code Generation

2

Motivation Example

Figure 1 presents an example from APPS. In this example, input two integers 𝑎 and 𝑏, the requirement is to repeat the following process: if 𝑎 = 0 or 𝑏 = 0, or both 𝑎 < 2𝑏 and 𝑏 < 2𝑎, the process ends. Otherwise, if 𝑎 ≥ 2𝑏, subtract 2𝑏 from 𝑎 repeatedly until 𝑎 < 2𝑏; else if 𝑏 ≥ 2𝑎, subtract 2𝑎 from 𝑏 repeatedly until 𝑏 < 2𝑎. Finally, output the resulting values of 𝑎 and 𝑏. We first employ Qwen3-Coder with zero-shot prompting to directly generate code based on the requirement. However, the generated code is incorrect. Specifically, the LLM does not implement the required loop and uses subtraction to execute the process, which leads to time limit exceeded. This misunderstanding leads to an incorrect implementation that fails to satisfy the output constraint. To further investigate whether existing approaches can resolve this issue, we apply reasoning-based and post-processing methods (e.g., SCOT [26] and Self-Repair [33]). However, they still fail to correct the core logic (one fails to implement the required loop, while the other does not use the modulo operation to replace repeated subtraction). This is because all subsequent reasoning and repair steps are built upon the same flawed understanding of the requirement. In contrast, REA-Coder explicitly aligns the LLM with the requirement before code generation. Through the requirement alignment stage, REA-Coder is able to identify a critical misunderstanding and iteratively align the requirement. In subsequent iterations, it explicitly provides explanations of input-output examples and further introduces additional guidance, such as “use the Euclidean algorithm for solving”. With the aligned requirement, the model is finally able to generate correct code that passes all test cases. This example highlights the key challenges. LLMs may fundamentally misunderstand the requirement, rather than merely making implementation errors. Reasoning and repair methods are insufficient to address errors caused by requirement misunderstanding. These observations motivate the design of REA-Coder, which systematically performs requirement alignment before code generation and alignment verification after generation.

3

Approach

In this paper, we propose REA-Coder, a requirement alignment approach to improve the code generation performance of LLMs. As illustrated in Figure 2, REA-Coder first examines the model’s comprehension of the requirement from multiple dimensions, and then aligns requirements with the model. Based on the aligned requirement, the model begins to generate code. If the generated code fails to pass the public test cases, we mask key semantic spans of the requirement and task the LLM to recover the masked spans based on the generated code. The intuition is that if the code is well-aligned with the original requirement, the masked spans can be correctly recovered; otherwise, recovery errors indicate misalignment. The recovered content is therefore compared against the original unmasked requirement to identify and correct misalignment, after which the entire process of requirement alignment and code generation is restarted. This process is repeated iteratively until the code passes all public test cases or the predefined maximum number of iterations is reached.

3.1

Conference acronym ’XX, June 03–05, 2018, Woodstock, NY

Requirement Alignment

Direct code generation immediately upon requirement input may lead to fundamental misinterpretation of the requirement by the LLM as demonstrated in Figure 1, resulting in erroneous outputs across all subsequent stages. To prevent the model from generating code based on a misaligned requirement, REA-Coder verifies the model’s understanding of the input requirement. To render the process of requirement understanding explicit and testable, we define a set of requirement dimensions. These dimensions build on established foundations in requirements engineering [11, 12] and align with the IEEE recommended practice for software requirements specifications [7]. The core requirement dimensions are shown in Figure 3. Based on these dimensions, REA-Coder first requires the LLM to analyze the original requirement and construct a question checklist along with corresponding reference answers from the core requirement dimensions. To guide the LLM to generate high-quality reference answers, we add a small set of manually annotated few-shot examples as additional input in the prompt. These examples are high-quality question-answer pairs for typical code generation tasks that are strictly aligned with the requirements, which clarify the expected format, specificity requirements of the generated content, and the criteria for strict alignment with the original requirement text. After acquiring the question checklist, REA-Coder is instructed to answer the constructed questions based on the current requirement. The LLM then compares REA-Coder’s answers with the reference answers, and identifies whether the LLM correctly understands the requirement for each question. For correctly answered questions, which indicate that the model has properly comprehended the relevant content, they are removed from the question checklist. For every incorrectly answered question, REA-Coder records the question itself, the reference answer, and the model’s generated answer, and produces corresponding feedback. Upon receiving the evaluation feedback on requirement understanding deviations, REA-Coder conducts systematic integration and attribution analysis of the identified misunderstandings. Specifically, it uses the LLM to map the evaluation feedback back to the predefined system of core requirement dimensions, and on this basis, constructs an aligned requirement with disambiguated and supplemented information, as illustrated in Figure 3. The aligned requirement fully retains the original problem description, while explicitly supplementing the requirement elements that the LLMs failed to correctly align.

3.2

Code Generation

Upon completion of the requirement alignment, REA-Coder performs code generation based on the enhanced requirement. Most existing code generation paradigms directly take raw, unprocessed original requirements as input, while REA-Coder performs code generation with the aligned requirement as its core input. Accordingly, REA-Coder is not limited to improving generation performance via existing approaches such as designing reasoning strategies or post-processing of the generated code. Instead, it adheres to the core principle of aligning LLMs with requirements first, and

Conference acronym ’XX, June 03–05, 2018, Woodstock, NY

Trovato et al.

Requirement Alignment

Code Generation

Question Generation Question: What are the requirements for the outputs i and j?

Iterations += 1

Gold Answer: Make sure that A[i] + A[j] = A[i+j] and i ≠ j.

Evaluate

Answer

Update

Requirement: You are given an array A of length n. Find two indices i, j such that A[i] + A[j] = A[i+j], under the constraint that i ≠ j.

Question Answer Answer: It is explicitly stated that the indices i and j should not be equal in the requirement.

Public Test Cases

If Passed or Iterations > N

Test Execute

Code

Requirement Alignment Verification Final Code Mask

def func_1(A: List): for i in range(len(A)): for j in range(i+1, len(A)): if A[i]+A[j] == i+j: return i, j

If not Passed and Iterations ≤ N

Generate

Generate

Aligned Requirement You are given an array A of length n. Find two indices i, j such that A[i] + A[j] = A[i+j], under ... Hints or Tips: i and j must ensure that A[i] + A[j] = A[i+j].

Question: What are ... Gold Answer: Make ... Answer: It is explicitly ... Why: The answer ... Diff: The i and j also ...

Masked Requirement You are given an array A of length [MASK_1]. Find two indices i, j such that A[i] + A[j] = [MASK_2], under the constraint that i ≠ j.

Requirement Background

Edge/Corner Cases

Requirement Purpose

Noteworthy Functionalities

Terminology Explanation

APIs

Input Requirement

Error Handling Requirement

Output Requirement

Invariants/Global Constraints

Explanations of Examples

Hints or Tips

Recovered Requirement You are given an array A of length n. Find two indices i, j such that A[i] + A[j] = i+j, under the constraint that i ≠ j.

Evaluate

Question: Fill MASK_2 Gold Answer: A[i+j] Answer: i+j Why: It's missing ... Diff: i + j as an index ...

Figure 2: Overview of REA-Coder.

Figure 3: Core requirement dimensions in REA-Coder. code generation second: after correcting the model’s misunderstanding of the requirements, it performs code generation based on the requirement that is fully aligned with the target intent. For the generated code, we perform functional correctness verification via public test cases. If the generated code passes all public test cases, the iterative optimization process terminates. The current code is returned as the final output. If the code fails to pass all public test cases, REA-Coder enters the subsequent in-depth requirement alignment process as described in Section 3.3.

3.3

Requirement Alignment Verification

Although the question answering-based requirement alignment and enhancement mechanism can bridge the gap between the model’s

comprehension and the user’s intent, they are still insufficient to guarantee the deep logical consistency between the generated code and the target requirement. The model may fail to internalize the requirement semantics into the program logic it generates, leading to potential functional deviations in the code. To further verify the authenticity and depth of requirement alignment after code generation, REA-Coder introduces a masked-requirement-recovery verification mechanism. In the requirement alignment verification stage, REA-Coder first masks a portion of the key semantic spans of the requirement. To ensure that the masking strategy can effectively probe the misunderstanding points of generated code while maintaining the contextual semantic coherence and derivability, we design the following two core masking rules. The first rule adheres to a content priority principle. We focus masking operations on the semantic elements within the core requirement dimensions defined in Section 3.1 since they play a decisive role in code logic generation. The second rule follows a semantic coherence principle, which is designed to ensure the masked requirement remains semantically interpretable and logically complete. To this end, we set the following executable rules for masking operations: (1) Each masked span covers a complete semantic unit (e.g., noun phrases, verb phrases, constraint clauses) without splitting individual words; (2) Sufficient consecutive unmasked context must be reserved between any two adjacent masked spans to guarantee contextual semantic continuity; (3) The number of masked spans in a sentence is limited to preserve the logical consistency of each sentence; (4) Masking operations shall not damage the overall framework of the requirement, where the suggestive keywords (e.g., input, output, and constraint) must be retained meanwhile their values of these keys can be masked.

Bridging the Gap between User Intent and LLM: A Requirement Alignment Approach for Code Generation

Next, REA-Coder requires LLM to recover the masked content based on the generated code. If the generated code faithfully embodies the logic of the requirement, the LLM should be able to accurately infer the masked requirement spans according to the generated code. Conversely, systematic deviations between the recovered content and the requirement indicate that the generated code is still based on an incomplete requirement understanding of LLMs. To verify the consistency, REA-Coder conducts a semantic comparison across multiple dimensions between the original enhanced requirement and the requirement content recovered by the model. For each masked span, the model generates corresponding feedback covering the accuracy judgment of the recovery, the discrepancy analysis between the recovered content and the original semantics, and the core requirement semantic elements that remain missing. This feedback is converted into complementary requirement alignment signals and fed back to the requirement alignment stage. Finally, REA-Coder updates the question checklist for the requirement alignment stage. It removes questions that have passed verification, retains previously incorrectly answered questions, and converts the newly exposed requirement understanding deviations from the requirement alignment verification stage into new question items. The iterative process is restarted based on the updated question checklist. The iteration terminates only when the generated code passes all public test cases, or the predefined maximum number of iterations is reached.

4

Experiments

We aim to answer the following research questions (RQs): • RQ1: What is the performance of REA-Coder in code generation tasks compared to the state-of-the-art approaches? • RQ2: What is the contribution of each component in REACoder to the overall effectiveness? • RQ3: How does the number of iterations influence the performance of REA-Coder?

4.1

Benchmarks

To comprehensively evaluate the performance of our approach, we apply five code generation benchmarks, including APPS [15], CodeContests-raw [29], CodeContests [29], xCodeEval [24], and LiveCodeBench-Lite [20]. These benchmarks are widely used, providing a robust testbed for assessing code generation capabilities of models. APPS [15] aggregates programming problems from various online coding platforms (e.g., Codeforces, LeetCode) across diverse difficulty levels. It contains 5,000 training data and 5,000 test data. Each example provides requirement descriptions, test cases, and reference solutions. Following existing works [37], we use 300 problems of the test set to balance evaluation costs and statistical representativeness, which proportionally matches its original difficulty distribution (i.e., introductory, interview, and competition). CodeContests-raw [29] is introduced by Google DeepMind, which is sourced from platforms like Codeforces and AtCoder. This benchmark is designed to evaluate models on competitive programming problems. CodeContests [29] extends CodeContests-raw by increasing the number of hidden test cases per problem to enforce

Conference acronym ’XX, June 03–05, 2018, Woodstock, NY

stricter evaluation criteria. Following the evaluation established by previous works [3, 37, 43], we use 165 problems from both CodeContests-raw and CodeContests, respectively. xCodeEval [24] is a large-scale, competition-level code generation benchmark containing approximately 7,500 programming problems. It divides these problems into three levels, including easy, medium, and hard modes. Similarly, we use a subset of data with 300 problems to evaluate our approach and baselines following the previous works [37]. LiveCodeBench-Lite [20] comprises recent programming problems sourced from real-world online judge environments. Compared with static benchmarks built from older datasets, it better reflects the evolving difficulty, style, and implementation requirements of contemporary code generation. We include this benchmark to further validate the practical generalization of our approach in real-world code generation scenarios.

4.2

Comparison Baselines

We benchmark our approach against a diverse set of representative code generation baselines. Beyond the standard zero-shot baseline, the compared methods can be broadly categorized into two paradigms. Reasoning-based paradigm: SCoT [26], Self-Collaboration [8], ICOT [28], which introduces reasoning strategies to enhance the quality of generated code. Post-processing paradigm: Self-Repair [33], SpecFix [21], 𝜇Fix [38], and Specine [37], aiming to fix generated code through execution feedback or detecting semantic misalignment between requirements and output code.

4.3

Base LLMs

To evaluate the effectiveness of REA-Coder, we conduct experiments on four advanced LLMs (i.e., DeepSeek-v3.2-Chat [30], Qwen3Coder-30B-A3B-Instruct [2], GPT-5-mini [36], and Gemini-3-FlashPreview [9]) across five benchmarks compared to eight baselines.

4.4

Metrics

Following previous works, we use Pass@k, a popular metric in code generation, as shown in Format 1. It is the expectation of passing all tests of a task at least once within 𝑘 attempts, where 𝑛 is the number of solutions of a task sampled from an LLM and 𝑐 is the number of correct solutions. In this paper, we use Pass @1 since in real-world scenarios, developers usually only consider the single generated code. " # 𝑛−𝑐  Pass@k = 𝐸 1 −

𝑘 𝑛 𝑘

(1)

We further evaluate the efficiency of REA-Coder in terms of time overhead and token overhead. Time overhead measures the average runtime of the method, and token overhead measures the average tokens consumed, including both prompt tokens and generated tokens. Lower values of time overhead and token overhead indicate better efficiency.

4.5

Implementation Details

To improve generation stability, we set the temperature to 0 for code generation and 0.2 for other steps. The maximum number of questions generated is 20, and the maximum number of iterations

Conference acronym ’XX, June 03–05, 2018, Woodstock, NY

Trovato et al.

is set to 10. Moreover, public test cases are used during the iterative process to assess whether the generated code satisfies the requirement, whereas the final results are reported only on hidden test cases in order to avoid evaluation bias and potential leakage.

alignment such as SpecFix and Specine, REA-Coder has a comparable cost. Meanwhile, REA-Coder achieves consistently higher Pass@1 scores across all settings, which makes the additional cost over simpler baselines a worthwhile trade-off.

5 Experimental Results 5.1 RQ1: Overall Performance

Finding 1: REA-Coder consistently achieves the best overall code generation performance across different LLMs and benchmarks. Its gains are more pronounced on relatively weaker models and more challenging benchmarks.

To answer RQ1, we compare REA-Coder with zero-shot and a diverse set of representative baselines, including reasoning-based methods and post-processing methods. We conduct experiments on four LLMs across five benchmarks, using Pass@1 as the evaluation metric, and additionally report time cost and token cost to assess the effectiveness-efficiency trade-off of REA-Coder in a more comprehensive manner. Table 1 shows the performance of all methods across different models and benchmarks. Table 1 shows that in experiments across all four LLMs and five benchmarks, REA-Coder consistently maintains the optimal Pass@1 performance when compared with eight baselines. Compared with the existing state-of-the-art methods, REA-Coder achieves average improvements of 7.93%, 30.25%, 26.75%, 8.59%, and 8.64% on the five benchmarks, respectively. Grouped by methodological paradigm, REA-Coder outperforms the four types of reasoning-based methods by an average of 30.34%, and the four types of post-processing methods by an average of 19.51%. When requirements are not properly aligned, even advanced reasoning methods and post-processing strategies can still lead to incorrect code generation. In contrast, REA-Coder verifies requirement understanding before code generation, which helps reduce errors caused by misunderstood requirements. REA-Coder achieves a more pronounced improvement on more challenging benchmarks. Among the five benchmarks in our work, APPS is a relatively easy dataset with routine programming tasks, while the remaining four benchmarks consist of competitive programming problems with higher task complexity. On CodeContestsraw and CodeContests, REA-Coder achieves improvements of 30.25% and 26.75% over the existing state-of-the-art methods, which are significantly higher than its performance on the APPS (7.93% relative improvements). This result indicates that REA-Coder delivers a particularly prominent optimization effect when the requirements involve more complex constraints, where requirement misunderstanding is more likely to occur. In addition, the gains are also larger on relatively weaker models. The average relative improvement of REA-Coder reaches 38.13% on Qwen3-Coder and 15.66% on DeepSeek-v3.2, while the corresponding improvements on Gemini-3-Flash and GPT-5-mini are 6.16% and 5.39%. This result shows that REA-Coder brings larger improvements on models with weaker code generation ability. A likely reason is that these models cannot fully align with the requirement during code generation, and therefore benefit more from the requirement alignment process in REA-Coder. At the same time, the results also show that requirement alignment remains beneficial even when the model already has strong code generation ability. In terms of efficiency, REA-Coder requires more time and tokens than zero-shot and reasoning-based methods, which is expected given its multi-stage requirement alignment process. However, compared with other post-processing methods through requirement

5.2

RQ2: Contribution of Main Component

To answer RQ2, we perform an ablation study by removing each of the two main stages in REA-Coder. Specifically, 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑄𝐴 removes the QA-based requirement alignment stage and retains only the code generation and masking-based verification stages. 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑀𝐴𝑆𝐾 removes the masking-based verification stage and retains only the requirement alignment and code generation stages. Note that both variants retain the iterative refinement process with a maximum of 10 iterations over their remaining stages. Table 2 reports the Pass@1 results of REA-Coder and its two variants on all 20 settings (4 LLMs × 5 benchmarks). REA-Coder consistently outperforms 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑄𝐴 in all settings. On average, REA-Coder improves over 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑄𝐴 by 5.82%, with relative improvements ranging from 0.42% to 12.57%. This result shows that removing the question generation, answering, evaluation, and requirement revision steps leads to clear performance degradation. It suggests that these steps are effective in identifying misunderstood requirement details before code generation and revising the requirement accordingly. REA-Coder also consistently outperforms 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑀𝐴𝑆𝐾 , and the performance drop is generally larger than that caused by removing the first group of steps. On average, REA-Coder improves over 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑀𝐴𝑆𝐾 by 9.99%. Across the five benchmarks, the average relative improvement ranges from 4.65% to 17.14%. This result shows that removing the masking, recovery, evaluation, and further refinement steps has a stronger negative impact on performance. These steps help check whether the generated code faithfully reflects the aligned requirement and provide useful signals for subsequent refinement. Finding 2: Both groups of steps make substantial contributions to the effectiveness of REA-Coder. In particular, removing the masking, recovery, evaluation, and refinement steps causes a larger performance drop than removing the question generation, answering, evaluation, and requirement revision steps.

5.3

RQ3: Influence of the Number of Iterations

To answer RQ3, we investigate how the number of iterations affects the effectiveness of REA-Coder. Since this RQ focuses on iterative refinement, we only include baselines that adopt an iterative fixing strategy, namely Self-Collaboration, Self-Repair, 𝜇Fix, and Specine. We vary the maximum number of iterations from 1 to 10 and evaluate the corresponding Pass@1 performance across different LLMs and benchmarks. Figure 4 shows that increasing the number of iterations consistently improves the performance of REA-Coder. Averaged over all 20 settings, REA-Coder achieves an average improvement of

Bridging the Gap between User Intent and LLM: A Requirement Alignment Approach for Code Generation

Conference acronym ’XX, June 03–05, 2018, Woodstock, NY

Table 1: Overall performance and efficiency across LLMs and benchmarks. LLM

DeepSeek-v3.2

Qwen3-Coder

GPT-5-mini

Gemini-3-Flash

Pass@1

Method

Time (h)

Token (M)

40.57% 52.00% 52.57% 50.86% 56.57% 50.86% 54.86% 56.57% 62.86% 11.12% ↑

0.32 0.47 0.62 2.56 1.14 0.68 3.08 2.32 2.78 –

0.37 1.20 0.96 6.60 1.66 1.45 13.61 5.48 9.74 –

9.67% 26.33% 28.33% 33.00% 29.33% 27.67% 44.67% 44.00% 52.00% 16.41% ↑

16.57% 30.29% 31.43% 28.00% 33.14% 33.71% 33.14% 32.00% 38.29% 15.54% ↑

0.34 0.51 0.32 2.44 1.22 0.72 2.78 1.97 2.65 –

0.74 1.79 0.90 8.77 2.94 1.89 13.92 5.56 11.78 –

45.45% 44.24% 40.61% 57.58% 49.09% 45.45% 50.91% 55.76% 60.61% 5.26% ↑

54.67% 56.00% 51.33% 57.67% 58.67% 55.33% 60.33% 69.00% 71.33% 3.38% ↑

48.00% 56.57% 53.14% 54.86% 52.57% 56.57% 57.71% 60.00% 62.86% 4.77% ↑

0.18 0.22 0.67 1.85 0.77 0.54 2.92 1.82 2.36 –

0.34 0.79 0.80 3.40 1.15 0.89 9.79 7.46 8.58 –

53.33% 56.36% 58.18% 63.03% 63.03% 64.85% 63.63% 67.88% 75.15% 10.71% ↑

69.67% 73.33% 73.67% 75.33% 76.33% 74.00% 75.67% 78.33% 83.33% 6.38% ↑

57.14% 69.14% 70.29% 68.00% 72.00% 71.43% 73.14% 71.43% 75.43% 3.13% ↑

0.12 0.15 0.44 1.27 0.65 0.81 2.51 1.33 1.98 –

0.38 0.71 0.79 3.21 1.82 1.66 9.95 7.33 8.96 –

APPS

CodeContests-raw

CodeContests

xCodeEval

LC-Lite

zero-shot SCoT [26] ICoT [28] Self-Collaboration [8] 𝜇Fix [38] Self-Repair [33] SpecFix [21] Specine [37] REA-Coder

66.00% 67.33% 68.00% 70.33% 71.67% 71.00% 72.00% 74.33% 81.67% 9.87% ↑

38.79% 41.21% 47.27% 42.42% 53.94% 52.72% 47.27% 50.30% 67.27% 24.71% ↑

37.20% 38.18% 43.03% 39.39% 49.70% 46.67% 44.24% 48.48% 61.82% 24.39% ↑

50.33% 53.67% 59.00% 60.33% 63.33% 62.33% 63.33% 65.00% 70.33% 8.20% ↑

zero-shot SCoT ICoT Self-Collaboration 𝜇Fix Self-Repair SpecFix Specine REA-Coder

16.00% 37.33% 44.00% 40.33% 43.67% 49.33% 56.67% 52.67% 66.67% 17.68% ↑

16.97% 19.39% 15.76% 18.79% 20.61% 22.56% 22.42% 23.03% 40.61% 76.34% ↑

15.15% 13.33% 12.73% 13.93% 15.15% 15.85% 19.39% 20.00% 33.33% 66.65% ↑

zero-shot SCoT ICoT Self-Collaboration 𝜇Fix Self-Repair SpecFix Specine REA-Coder

79.33% 73.67% 67.67% 78.00% 75.33% 73.67% 79.33% 82.89% 85.00% 2.55% ↑

61.82% 48.48% 43.03% 66.06% 51.52% 49.09% 52.73% 63.03% 73.33% 11.01% ↑

zero-shot SCoT ICoT Self-Collaboration 𝜇Fix Self-Repair SpecFix Specine REA-Coder

79.00% 80.00% 81.33% 81.67% 82.67% 82.00% 80.00% 86.91% 88.33% 1.63% ↑

55.76% 58.79% 61.21% 66.67% 69.09% 68.48% 67.88% 74.55% 81.21% 8.93%↑

19.80% from iteration 1 to iteration 10. This result indicates that iterative requirement alignment is effective for improving code generation quality. In particular, we observe that even when the maximum number of iterations is set to only 1, REA-Coder already outperforms all compared baseline methods in terms of Pass@1 performance. This result fully demonstrates that the upfront requirement alignment process conducted prior to code generation can inherently and effectively boost the foundational performance of code generation. We further observe that the performance gain is much larger in the early iterations, and then gradually becomes smaller. In particular, the average improvement from iteration 1 to 5 is 12.18%, whereas the additional improvement from iteration 5 to 10 is only

6.29%. This suggests that most requirement misunderstandings are corrected in the early iterations, while later iterations mainly provide limited refinement. In addition, the performance of several baselines becomes much flatter in the later iterations, suggesting that their gains gradually saturate after the early rounds. By contrast, REA-Coder continues to achieve steady improvements as the number of iterations increases. This indicates that REA-Coder can better exploit additional iterations for further requirement alignment and refinement. Finding 3: Increasing the number of iterations consistently improves the effectiveness of REA-Coder. Compared with several

Conference acronym ’XX, June 03–05, 2018, Woodstock, NY

Trovato et al.

Table 2: Ablation results across LLMs and benchmarks.

Pass@1

LLM

Pass@1 Pass@1 Pass@1

CodeContests-raw

CodeContests

xCodeEval

LiveCodeBench-Lite

REA-Coder 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑄𝐴 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑀𝐴𝑆𝐾

81.67% 81.33% 80.33%

67.27% 63.03% 58.18%

61.82% 58.79% 54.54%

70.33% 67.67% 69.67%

62.86% 57.71% 57.14%

Qwen3-Coder

REA-Coder 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑄𝐴 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑀𝐴𝑆𝐾

66.67% 63.00% 59.00%

40.61% 36.97% 29.70%

33.33% 30.30% 25.45%

52.00% 50.00% 45.67%

38.29% 35.43% 33.14%

GPT-5-mini

REA-Coder 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑄𝐴 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑀𝐴𝑆𝐾

85.00% 83.33% 83.33%

73.33% 65.14% 67.27%

60.61% 54.86% 56.36%

71.33% 70.00% 66.33%

62.86% 58.86% 61.14%

Gemini-3-Flash

REA-Coder 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑄𝐴 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟𝑊 𝑂 −𝑀𝐴𝑆𝐾

88.33% 86.00% 86.67%

81.21% 78.79% 75.76%

75.15% 72.12% 71.52%

83.33% 80.00% 80.00%

75.43% 71.43% 74.86%

75.0% 1 2 3 4 5 6 7 8 9 10

65.0% Qwen, APPS 55.0% 45.0% 35.0%

APPS DeepSeek-v3.2

85.0% DeepSeek, APPS 65.0%

Pass@1

Method

1 2 3 4 5 6 7 8 9 10

65.0% 55.0% 45.0% 35.0% 40.0% 30.0% 20.0% 10.0%

Self-Collaboration

Self-Repair

DeepSeek, CodeContests-Raw

60.0% 50.0% 40.0% 30.0%

1 2 3 4 5 6 7 8 9 10

FiX

Specine

Ours

70.0% DeepSeek, LC-Lite 60.0% 60.0% 50.0% 50.0% 40.0% 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10

DeepSeek, CodeContests

70.0% DeepSeek, xCodeEval

55.0% Qwen, xCodeEval 45.0% 35.0% 25.0% 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10

40.0% Qwen, LC-Lite 35.0% 30.0% 25.0% 1 2 3 4 5 6 7 8 9 10

75.0% GPT, xCodeEval 65.0% 50.0% 55.0% 40.0% 45.0% 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10

65.0% GPT, LC-Lite 60.0% 55.0% 50.0% 1 2 3 4 5 6 7 8 9 10

Qwen, CodeContests-Raw

1 2 3 4 5 6 7 8 9 10

Qwen, CodeContests

85.0% GPT, APPS 80.0% 75.0% 70.0% 1 2 3 4 5 6 7 8 9 10

70.0% 60.0% 50.0% 40.0%

90.0% Gemini, APPS 85.0%

80.0% Gemini, CodeContests-Raw

80.0% Gemini, CodeContests

85.0% Gemini, xCodeEval

70.0%

70.0%

75.0%

60.0%

60.0%

80.0% 1 2 3 4 5 6 7 8 9 10

# Iterations

GPT, CodeContests-Raw

30.0% 20.0% 10.0%

1 2 3 4 5 6 7 8 9 10

60.0% GPT, CodeContests

# Iterations

1 2 3 4 5 6 7 8 9 10

# Iterations

65.0%

1 2 3 4 5 6 7 8 9 10

# Iterations

75.0% 65.0%

Gemini, LC-Lite

1 2 3 4 5 6 7 8 9 10

# Iterations

Figure 4: Pass@1 across iterations for REA-Coder and iterative baselines. baselines whose performance saturates in the later iterations, REA-Coder continues to improve steadily.

6 Analysis 6.1 Performance of the First Code Generation To examine whether REA-Coder can already improve requirement alignment at the initial generation stage and thereby produce more accurate code, we analyze the performance of its first code generation. We named this stage 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟 𝑓 , which refers to the code generated after the requirement alignment based on questionanswer-verification steps, without subsequent masking-based verification and iterative refinement. Table 3 reports the Pass@1 results of zero-shot and 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟 𝑓 . Overall, 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟 𝑓 consistently outperforms zero-shot across all model and benchmark combinations in terms of Pass@1, showing

that the benefit of our method emerges before multi-round refinement begins. On models with weaker code generation capability or datasets with more challenging tasks, the performance gains brought by REA-Coder are particularly substantial. For example, on Qwen3-Coder, REA-Coder improves first-round Pass@1 by 210.44% on APPS, 113.82% on LiveCodeBench-Lite, and 344.67% on xCodeEval. On DeepSeek-v3.2, the improvements are also consistently strong, reaching 32.79% on CodeContests-raw, 31.96% on CodeContests, and 40.84% on LiveCodeBench-Lite. On stronger models such as GPT-5-mini and Gemini-3-Flash, REA-Coder still delivers stable gains. For instance, it improves GPT-5-mini by 20.23% on LiveCodeBench-Lite and 25.37% on CodeContests, while improving Gemini-3-Flash by 25.01% on LiveCodeBench-Lite and 23.91% on CodeContests-raw. The results validate the central design principle of REA-Coder: requirement alignment should be moved as early as possible in the

Bridging the Gap between User Intent and LLM: A Requirement Alignment Approach for Code Generation

Conference acronym ’XX, June 03–05, 2018, Woodstock, NY

Table 3: The performance of zero-shot and REA-Coderf across LLMs and benchmarks. Pass@1

LLM

Method APPS

CodeContests-raw

CodeContests

xCodeEval

LiveCodeBench-Lite

DeepSeek-v3.2

zero-shot 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟 𝑓

66.00% 73.00%

38.79% 51.51%

37.20% 49.09%

50.33% 63.67%

40.57% 57.14%

Qwen3-Coder

zero-shot 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟 𝑓

16.00% 49.67%

16.97% 23.03%

15.15% 18.18%

9.67% 43.00%

16.57% 35.43%

GPT-5-mini

zero-shot 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟 𝑓

79.33% 81.00%

61.82% 65.45%

45.45% 56.97%

54.67% 64.00%

48.00% 57.71%

Gemini-3-Flash

zero-shot 𝑅𝐸𝐴-𝐶𝑜𝑑𝑒𝑟 𝑓

79.00% 84.33%

55.76% 69.06%

53.33% 67.27%

69.67% 80.67%

57.14% 73.14%

[Original Requirement]

[Requirement Gaps]

Problem Statement: Little Petya loves playing with squares. Mum bought him a square 2n × 2n in size. Petya marked a cell inside the square... The task is to draw a broken line that would go along the grid lines and that would cut the square into two equal parts. The cutting line should not have any common points with the marked cell and the resulting two parts should be equal up to rotation.Petya wants to determine whether it is possible to cut the square... ... (Input, output specifications and examples are omitted here)

QUESTION: When 2n = 2 (smallest possible square), the square is 2×2. For marked cell at (1, 1), is cutting possible? What about marked cell at (2, 2)? Does the example with input 2 2 2' and output 'NO' cover all 2×2 cases?

[Generated Code with Original Requirement] import ... def solve() -> bool: ... n = side // 2 if (x == n and y == n) or (x == n + 1 and y == n + 1): print("No") ...

GOLD ANSWER: For 2n = 2, the square is 2x2. Cutting is possible only if the marked cell is not in the central 2x2 block. Since the entire square is the central block, cutting is impossible for any cell. The example '2 2 2' → 'NO' covers all cases for 2x2. ANSWER: For 2n = 2, the only central 2×2 block is the whole square. Marked cell at (1, 1) or (2, 2) → NO. Marked cell at (1,2) or (2,1) → YES. Example '2 2 2' → NO.

[Aligned Requirement] Problem Statement: Little Petya loves playing with squares. Mum bought him a square... ... Edge/Corner Cases: For the smallest square (2n = 2), it is impossible to draw the required cutting line for any marked cell position (1 ≤ x, y ≤ 2). Hints or Tips: The condition "equal up to rotation" reduces the problem to determining whether the marked cell lies within the central 2×2 block of the square.

[Generated Code with Aligned Requirement] import ... def solve() -> bool: ... n = side // 2 if (x == n or x == n + 1) and (y == n or y == n + 1): print("No") ...

Figure 5: Case Study of REA-Coder: An example of requirement alignment corrects an edge-case misunderstanding.

56.36%

Tip s

56.97%

Is

55.75%

or

55.15%

58.79%

AP

56.97%

59.39% 57.58%

nts

56.97%

58.79%

Hi

58.18% 58.79%

R Ba equ ck ire gro me Re und nt q Pu uire rp m ose en t Te K rm e ino y Fu Not logy nc ew tio or na thy lit Re In ies qu pu ire t me Re O nt qu utp ire ut m Ed ent g Cae/Co se rn E s er of xpla Ex na E amp tion Rerror les s qu Ha Inv ire nd a m li Co rian ent ng nst ts / rai Gl nts ob al

Pass@1

61.82% 60% 58% 56% 54% 52% 50%

Figure 6: Effectiveness of requirement dimension.

code generation pipeline, rather than relying primarily on execution feedback after code has already been produced. Compared with methods that correct errors only after observing failed executions, REA-Coder enhances the requirement before the code generation, allowing the model to generate code on an aligned requirement.

6.2

Influence of Dimension

To better understand which requirement dimensions contribute most to REA-Coder, we conduct an analysis. Specifically, for each run, we remove one dimension from the entire alignment pipeline, while keeping all other stages unchanged. We then measure the

resulting overall performance and compare it with the full REACoder setting. Figure 6 shows that removing any single dimension reduces performance. This consistent degradation indicates that all dimensions contribute positively to requirement alignment, and that the gains of REA-Coder do not come from a single dominant factor. Among all dimensions, Requirement Purpose has the largest impact. Removing it reduces performance to 55.15%, a drop of 12.09%. This suggests that explicitly clarifying what the program is expected to accomplish is central to correct code generation. The second largest drop is from removing Explanations of Examples, which lowers performance to 55.75%. This highlights the importance of examples not merely as demonstrations of input and output pairs, but as concrete explanations of the underlying transformation logic. This finding suggests that developers should focus on these two aspects when specifying requirements for code generation. In the future, we plan to explore more effective alignment rules for better requirement alignment.

6.3

Case Study

To further understand why REA-Coder improves code generation, we conduct a qualitative case study focusing on the two core stages

Conference acronym ’XX, June 03–05, 2018, Woodstock, NY

of our approach: requirement alignment and requirement alignment verification. We use two representative examples to illustrate how REA-Coder progressively identifies requirement misunderstandings, generates enhanced requirement, and finally improves the generated code. Figure 5 presents a representative case where direct code generation from the original requirement produces an incorrect solution, while REA-Coder succeeds after the requirement alignment stage. The task asks whether a 2𝑛 × 2𝑛 square can be cut into two centrally symmetric parts without the cut touching the marked cell. The model does not correctly understand the centrally symmetric constraint, and thus misjudges the smallest 2 × 2 case. This misalignment is reflected in the generated code, which uses an incorrect condition for the marked cell. REA-Coder identifies this error through question answering, clarifies the edge case and the equivalent condition in the enhanced requirement, and thereby guides the model to generate correct code. Figure 7 presents a second representative case where only requirement alignment stage is still insufficient. The task requires outputting the numbers of bonds between atom pairs (1, 2), (2, 3), and (3, 1) in this exact order. Although the model captures the main solution logic after the requirement alignment stage, it still fails to align with the output requirement and generates the last two numbers in the wrong order. REA-Coder exposes this remaining misalignment by masking some parts of the requirement and asking for recovering them from the generated code. Based on the recovery error, REA-Coder further strengthens the requirement in the next round, which finally leads to correct code generation.

6.4

Threats and Validity

To mitigate external threats, we evaluate REA-Coder on four different LLMs and five widely used code generation benchmarks, covering diverse problem characteristics and difficulty levels. In addition, we adopt Pass@1 as the main evaluation metric, which is widely used in code generation research and directly measures functional correctness through test execution. We also compare REA-Coder against a diverse set of strong baselines spanning reasoning-based methods and post-processing methods, demonstrating that our performance gains are consistent across different scenarios and not limited to a specific setting. The internal validity mainly lies in the used LLMs. Following common practice in recent studies, we mitigate this threat by carefully controlling the experimental setup, including the model configuration, prompting procedure, and iteration budget. In particular, we set the temperature to 0 for code generation, 0.2 for other steps, and 10 for the maximum iteration number. Moreover, we repeat each experiment three times and report the average results, which helps reduce the influence of random variation in model outputs. We conduct the significance test and the p-value of the experimental results is less than 0.05. Furthermore, we only use public test cases to determine whether to stop iterations and leave out the execution feedback to LLMs, aiming to evaluate the effectiveness of requirement alignment that is the focus of this paper.

Trovato et al.

7

Related Work

Code generation aims to automatically generate executable programs from natural language requirements. Recent advances in LLMs have stimulated extensive research on improving code generation [1, 4, 22]. Existing methods can be broadly divided into two lines of work: reasoning-based generation and post-processing improvement. Reasoning-based generation aims to improve code quality by enhancing the intermediate reasoning process before code is produced [14, 23]. A representative direction is to design better prompting strategies for structured reasoning. For example, SCoT [26] introduces structured chain-of-thought prompting to guide the model through explicit intermediate steps prior to code generation. RoutingGen further proposes ICoT [28], a difficulty-aware routing framework that adaptively selects prompting strategies according to task complexity and invokes reasoning for harder problems. Another direction is to organize code generation into multiple collaborative stages [16, 18, 35]. Self-Collaboration [8], for instance, decomposes the process into planning, coding, testing, and iterative revision, enabling the model to reason and refine in a more structured workflow [31]. These methods mainly focus on improving how the model reasons about the task and translates its reasoning results into code [17]. Post-processing improvement focuses on improving code generation after an initial code solution has been produced [5, 39, 44]. One branch directly repairs generated code using execution feedback [10, 13, 34]. For example, Self-Edit [42] converts executiontime fault information into targeted editing signals for code correction. Another branch further considers the mismatch between the generated result and the requirement, and attempts to refine either the code or the requirement accordingly [6, 45]. ClarifyGPT [32] detects misaligned requirements through code consistency checks. 𝜇FiX [38] first outputs code based on the original requirement and mitigates specification misunderstanding by combining stronger reasoning prompts with feedback-driven correction. Specine [37] also previously generates code and iteratively supplements the requirement. SpecFix [21] analyzes behavioral divergence among generated solutions and produces minimal textual patches to repair ambiguous problem descriptions. These methods show that refining the generated code or refining the requirement after generation can effectively improve performance [25]. Despite their differences, these approaches share a common assumption: the model has already understood the given requirement correctly, and the remaining challenge is how to reason better or how to repair the generated result more effectively. However, this assumption does not always hold. In practice, LLMs may misunderstand the requirement itself before code generation begins. Under such requirement misalignment, even strong reasoning strategies or powerful post-processing mechanisms may still fail. This limitation motivates our work, which aligns requirements before code generation and verifies whether requirements have been understood through requirement alignment verification.

8

Conclusion

In this paper, we propose REA-Coder, a requirement alignment approach to enhance code generation performance of LLMs. We

Bridging the Gap between User Intent and LLM: A Requirement Alignment Approach for Code Generation

Conference acronym ’XX, June 03–05, 2018, Woodstock, NY

[Original Requirement]

[Requirement Gaps]

Problem Statement: Mad scientist Mike... Find a molecule that can be built from these atoms according to the stated rules, or determine that it is impossible. ... (Input is omitted here) Output: If such a molecule can be built, print three space-separated integers — the number of bonds between the 1-st and the 2-nd, the 2-nd and the 3-rd, the 3-rd and the 1-st atoms... ... (Examples is omitted here)

QUESTION: Recover the missing requirement span MASK_13. GOLD ANSWER: the 2-nd and the 3-rd ANSWER: the 3-rd and the 1-st

[Generated Code with Original Requirement] def solve(a: int, b: int, c: int) -> tuple[int, int, int]: ... x, y, z = (a + b - c) // 2, (a + c - b) // 2, (b + c - a) // 2 if x >= 0 and y >= 0 and z >= 0: return x, y, z ... if __name__ == "__main__": ...

[Generated Code with Aligned Requirement] def solve(a: int, b: int, c: int) -> tuple[int, int, int]: ... x, y, z = (a + b - c) // 2, (a + c - b) // 2, (b + c - a) // 2 if x >= 0 and y >= 0 and z >= 0: return x, z, y ... if __name__ == "__main__": ...

QUESTION: Recover the missing requirement span MASK_14. GOLD ANSWER: the 3-rd and the 1-st ANSWER: the 2-nd and the 3-rd

[Aligned Requirement] Problem Statement: Mad scientist Mike... Find a molecule that can be built from these atoms according to the stated rules, or determine that it is impossible. ... Output Requirements: If a valid configuration exists, output three space-separated integers indicating the number of bonds between atoms (1,2), (2,3), and (3,1) respectively. If no valid configuration exists, output "Impossible".

Figure 7: Case Study of REA-Coder: An example of requirement alignment verification corrects output-order misalignment. evaluate REA-Coder on four LLMs and five benchmarks. Experimental results show that it consistently outperforms four state-of-theart baselines. The results demonstrate that requirement alignment should be moved as early as possible, being consistent with the central design principle of REA-Coder.

References [1] Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie Cai, Michael Terry, Quoc Le, et al. 2021. Program synthesis with large language models. arXiv preprint arXiv:2108.07732 (2021). [2] Ruisheng Cao, Mouxiang Chen, Jiawei Chen, Zeyu Cui, Yunlong Feng, Binyuan Hui, Yuheng Jing, Kaixin Li, Mingze Li, Junyang Lin, et al. 2026. Qwen3-CoderNext Technical Report. arXiv preprint arXiv:2603.00729 (2026). [3] Bei Chen, Fengji Zhang, Anh Nguyen, Daoguang Zan, Zeqi Lin, Jian-Guang Lou, and Weizhu Chen. 2022. Codet: Code generation with generated tests. arXiv preprint arXiv:2207.10397 (2022). [4] Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde De Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. 2021. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374 (2021). [5] Xinyun Chen, Maxwell Lin, Nathanael Schärli, and Denny Zhou. 2023. Teaching large language models to self-debug. arXiv preprint arXiv:2304.05128 (2023). [6] Xiancai Chen, Zhengwei Tao, Kechi Zhang, Changzhi Zhou, Xinyu Zhang, Wanli Gu, Yuanpeng He, Mengdi Zhang, Xunliang Cai, Haiyan Zhao, and Zhi Jin. 2025. Revisit Self-Debugging with Self-Generated Tests for Code Generation. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), Wanxiang Che, Joyce Nabende, Ekaterina Shutova, and Mohammad Taher Pilehvar (Eds.). Association for Computational Linguistics, Vienna, Austria, 18003–18023. doi:10.18653/v1/2025.acl-long.881 [7] John Doe. 2011. Recommended Practice for Software Requirements Specifications (IEEE Std 830-1998). IEEE, New York. [8] Yihong Dong, Xue Jiang, Zhi Jin, and Ge Li. 2024. Self-collaboration code generation via chatgpt. ACM Transactions on Software Engineering and Methodology 33, 7 (2024), 1–38. [9] Tulsee Doshi and Gemini Team. 2025. Gemini 3 Flash: frontier intelligence built for speed. https://blog.google/products-and-platforms/products/gemini/gemini3-flash. Google Blog Post. [10] Shihan Dou, Yan Liu, Haoxiang Jia, Enyu Zhou, Limao Xiong, Junjie Shan, Caishuang Huang, Xiao Wang, Xiaoran Fan, Zhiheng Xi, et al. 2024. Stepcoder: improving code generation with reinforcement learning from compiler feedback. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). 4571–4585. [11] Martin Glinz. 2000. Problems and deficiencies of UML as a requirements specification language. In Tenth International Workshop on Software Specification and Design (IWSSD-10). IEEE, 11–22.

[12] Sol Greenspan, John Mylopoulos, and Alex Borgida. 1994. On formal requirements modeling languages: RML revisited. In Proceedings of 16th International Conference on Software Engineering. IEEE, 135–147. [13] Dejan Grubisic, Chris Cummins, Volker Seeker, and Hugh Leather. 2024. Compiler generated feedback for large language models. arXiv preprint arXiv:2403.14714 (2024). [14] Yewei Han and Chen Lyu. 2025. Multi-stage guided code generation for large language models. Engineering Applications of Artificial Intelligence 139 (2025), 109491. [15] Dan Hendrycks, Steven Basart, Saurav Kadavath, Mantas Mazeika, Akul Arora, Ethan Guo, Collin Burns, Samir Puranik, Horace He, Dawn Song, et al. 2021. Measuring coding challenge competence with apps (2021). URL https://arxiv. org/abs/2105.09938 7 (2021). [16] Sirui Hong, Mingchen Zhuge, Jonathan Chen, Xiawu Zheng, Yuheng Cheng, Jinlin Wang, Ceyao Zhang, Zili Wang, Steven Ka Shing Yau, Zijuan Lin, et al. 2023. MetaGPT: Meta programming for a multi-agent collaborative framework. In The twelfth international conference on learning representations. [17] Dong Huang, Qingwen Bu, Yuhao Qing, and Heming Cui. 2023. Codecot: Tackling code syntax errors in cot reasoning for code generation. arXiv preprint arXiv:2308.08784 (2023). [18] Dong Huang, Jie M Zhang, Michael Luck, Qingwen Bu, Yuhao Qing, and Heming Cui. [n. d.]. Agentcoder: Multi-agent-based code generation with iterative testing and optimisation, 2024. URL https://arxiv. org/abs/2312.13010 ([n. d.]). [19] Md Ashraful Islam, Mohammed Eunus Ali, and Md Rizwan Parvez. 2025. Codesim: Multi-agent code generation and problem solving through simulation-driven planning and debugging. In Findings of the Association for Computational Linguistics: NAACL 2025. 5113–5139. [20] Naman Jain, King Han, Alex Gu, Wen-Ding Li, Fanjia Yan, Tianjun Zhang, Sida Wang, Armando Solar-Lezama, Koushik Sen, and Ion Stoica. 2025. LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Code. In The Thirteenth International Conference on Learning Representations. https://openreview.net/forum?id=chfJJYC3iL [21] Haoxiang Jia, Robbie Morris, He Ye, Federica Sarro, and Sergey Mechtaev. 2025. Automated Repair of Ambiguous Problem Descriptions for LLM-Based Code Generation. arXiv preprint arXiv:2505.07270 (2025). [22] Juyong Jiang, Fan Wang, Jiasi Shen, Sungju Kim, and Sunghun Kim. 2026. A survey on large language models for code generation. ACM Transactions on Software Engineering and Methodology 35, 2 (2026), 1–72. [23] Xue Jiang, Yihong Dong, Lecheng Wang, Zheng Fang, Qiwei Shang, Ge Li, Zhi Jin, and Wenpin Jiao. 2024. Self-planning code generation with large language models. ACM Transactions on Software Engineering and Methodology 33, 7 (2024), 1–30. [24] Mohammad Abdullah Matin Khan, M Saiful Bari, Xuan Long Do, Weishi Wang, Md Rizwan Parvez, and Shafiq Joty. 2024. Xcodeeval: An execution-based large scale multilingual multitask benchmark for code understanding, generation, translation and retrieval. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). 6766–6805. [25] Hung Le, Yue Wang, Akhilesh Deepak Gotmare, Silvio Savarese, and Steven Chu Hong Hoi. 2022. Coderl: Mastering code generation through pretrained

Conference acronym ’XX, June 03–05, 2018, Woodstock, NY

models and deep reinforcement learning. Advances in Neural Information Processing Systems 35 (2022), 21314–21328. [26] Jia Li, Ge Li, Yongmin Li, and Zhi Jin. 2025. Structured chain-of-thought prompting for code generation. ACM Transactions on Software Engineering and Methodology 34, 2 (2025), 1–23. [27] Jia Li, Ge Li, Zhuo Li, Zhi Jin, Xing Hu, Kechi Zhang, and Zhiyi Fu. 2023. Codeeditor: Learning to edit source code with pre-trained models. ACM Transactions on Software Engineering and Methodology 32, 6 (2023), 1–22. [28] Shen Li, Li Huang, Shaoxiong Zhan, Weifeng Sun, Tao Yin, Zhongxin Liu, and Meng Yan. 2025. Intention Chain-of-Thought Prompting with Dynamic Routing for Code Generation. arXiv preprint arXiv:2512.14048 (2025). [29] Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, et al. 2022. Competition-level code generation with alphacode. Science 378, 6624 (2022), 1092–1097. [30] Aixin Liu, Aoxue Mei, Bangcai Lin, Bing Xue, Bingxuan Wang, Bingzheng Xu, Bochao Wu, Bowei Zhang, Chaofan Lin, Chen Dong, et al. 2025. Deepseekv3. 2: Pushing the frontier of open large language models. arXiv preprint arXiv:2512.02556 (2025). [31] Kehao Mao, Baokun Hu, Ruixin Lin, Zewen Li, Guanyu Lu, and Zhengyu Zhang. 2025. Blueprint2Code: a multi-agent pipeline for reliable code generation via blueprint planning and repair. Frontiers in Artificial Intelligence 8 (2025), 1660912. [32] Fangwen Mu, Lin Shi, Song Wang, Zhuohao Yu, Binquan Zhang, Chenxue Wang, Shichao Liu, and Qing Wang. 2023. Clarifygpt: Empowering llm-based code generation with intention clarification. arXiv preprint arXiv:2310.10996 (2023). [33] Theo X Olausson, Jeevana Priya Inala, Chenglong Wang, Jianfeng Gao, and Armando Solar-Lezama. 2023. Is self-repair a silver bullet for code generation? arXiv preprint arXiv:2306.09896 (2023). [34] Yun Peng, Akhilesh Deepak Gotmare, Michael R Lyu, Caiming Xiong, Silvio Savarese, and Doyen Sahoo. 2025. Perfcodegen: Improving performance of llm generated code with execution feedback. In 2025 IEEE/ACM Second International Conference on AI Foundation Models and Software Engineering (Forge). IEEE, 1–13. [35] Chen Qian, Wei Liu, Hongzhang Liu, Nuo Chen, Yufan Dang, Jiahao Li, Cheng Yang, Weize Chen, Yusheng Su, Xin Cong, et al. 2024. Chatdev: Communicative agents for software development. In Proceedings of the 62nd annual meeting of the association for computational linguistics (volume 1: Long papers). 15174–15186. [36] Aaditya Singh, Adam Fry, Adam Perelman, Adam Tart, Adi Ganesh, Ahmed El-Kishky, Aidan McLaughlin, Aiden Low, AJ Ostrow, Akhila Ananthram, et al.

Trovato et al.

2025. Openai gpt-5 system card. arXiv preprint arXiv:2601.03267 (2025). [37] Zhao Tian and Junjie Chen. 2025. Aligning Requirement for Large Language Model’s Code Generation. arXiv preprint arXiv:2509.01313 (2025). [38] Zhao Tian, Junjie Chen, and Xiangyu Zhang. 2025. Fixing Large Language Models’ Specification Misunderstanding for Better Code Generation. In 2025 IEEE/ACM 47th International Conference on Software Engineering (ICSE). IEEE Computer Society (2025), 645–645. [39] Xin Wang, Yasheng Wang, Yao Wan, Fei Mi, Yitong Li, Pingyi Zhou, Jin Liu, Hao Wu, Xin Jiang, and Qun Liu. 2022. Compilable Neural Code Generation with Compiler Feedback. In Findings of the Association for Computational Linguistics: ACL 2022, Smaranda Muresan, Preslav Nakov, and Aline Villavicencio (Eds.). Association for Computational Linguistics, Dublin, Ireland, 9–19. doi:10.18653/ v1/2022.findings-acl.2 [40] Huan Zhang, Wei Cheng, Yuhan Wu, and Wei Hu. 2024. A pair programming framework for code generation via multi-plan exploration and feedback-driven refinement. In Proceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering. 1319–1331. [41] Kechi Zhang, Jia Li, Ge Li, Xianjie Shi, and Zhi Jin. 2024. CodeAgent: Enhancing Code Generation with Tool-Integrated Agent Systems for Real-World Repo-level Coding Challenges. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). 13643–13658. [42] Kechi Zhang, Zhuo Li, Jia Li, Ge Li, and Zhi Jin. 2023. Self-edit: Fault-aware code editor for code generation. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). 769–787. [43] Shun Zhang, Zhenfang Chen, Yikang Shen, Mingyu Ding, Joshua B Tenenbaum, and Chuang Gan. 2023. Planning with large language models for code generation. arXiv preprint arXiv:2303.05510 (2023). [44] Tianyu Zheng, Ge Zhang, Tianhao Shen, Xueling Liu, Bill Yuchen Lin, Jie Fu, Wenhu Chen, and Xiang Yue. 2024. Opencodeinterpreter: Integrating code generation with execution and refinement. In Findings of the Association for Computational Linguistics: ACL 2024. 12834–12859. [45] Changzhi Zhou, Xinyu Zhang, Dandan Song, Xiancai Chen, Wanli Gu, Huipeng Ma, Yuhang Tian, Mengdi Zhang, and Linmei Hu. 2025. Refinecoder: Iterative improving of large language models via adaptive critique refinement for code generation. arXiv preprint arXiv:2502.09183 (2025).

Received 20 February 2007; revised 12 March 2009; accepted 5 June 2009

Related documents

Record · ID 31334 · SHA-256 998be1bd02747577
Conceptio Open Knowledge Archive — every document is proof-bundled with source, license, and retrieval metadata.