arXiv:2602.00066cs.SEcs.CL2026-02ACL被引 1

通过增强用户意图影响,提升代码生成对多约束的遵循能力。

IntentCoding: Amplifying User Intent in Code Generation

  • 用掩码机制捕捉意图影响,再通过多强度集成放大其作用。
  • 在多约束任务上相对基线提升最高达71%,功能正确率显著提高。
  • 无需训练、兼容现有解码器,适合需精准控制生成的开发者。

大型语言模型在代码生成中表现强劲,但对包含多个约束的细粒度用户意图遵循仍存挑战。实证分析发现:1)用户意图中约束数量增加时模型性能迅速下降;2)尽管意图会影响模型输出概率,但影响力度不足以有效引导解码过程。为此,我们提出意图增强型代码生成方法(IntentCoding),通过掩码意图并采用多强度集成机制,在生成过程中放大意图的影响。该方法不依赖特定模型,无需额外训练,可无缝融入现有解码流程。为系统评估,我们构建了专门测试意图遵循能力的基准数据集CodeConstraints。在自建数据集及IFEvalCode、HumanEval和LiveCodeBench等主流数据集上的实验表明,相比标准解码策略,IntentCoding显著提升了约束满足率与功能正确性:在CodeConstraints上相对提升最高达71.0%,IFEvalCode上达67.3%,HumanEval和LiveCodeBench的pass@1提升最高达29.3%(相较于贪心解码)。

原文摘要 · Abstract (English)

Large Language Models (LLMs) have shown strong capabilities in code generation, but their adherence to fine-grained user intent with multiple constraints remains a significant challenge. Our empirical analysis reveals two key observations: 1) Model performance deteriorates quickly as the number of constraints in the user intent increases, and 2) While user intent does influence the model's logits, such an influence may not be strong enough to effectively steer the decoding process. To this end, we propose Intent-Amplified Code Generation (IntentCoding), a novel decoding strategy that enhances an LLM's ability to follow user intent. IntentCoding captures the influence of user intent by masking out the intent, and applies a multi-strength ensemble mechanism to amplify the effect of user intent during generation. IntentCoding is model-agnostic, requires no additional training, and integrates seamlessly with existing decoding procedures. To enable systematic evaluation, we also construct CodeConstraints, a benchmark dataset specifically designed to test user intent compliance under varying numbers of constraints. Experiments on our constructed Constraints, as well as popular IFEvalCode, HumanEval and LiveCodeBench datasets, show that our IntentCoding model significantly improves both constraint satisfaction and functional correctness compared to standard decoding approaches. IntentCoding achieves up to 71.0% relative improvement on CodeConstraints, achieves up to 67.3% relative improvement on IFEvalCode and achieves up to 29.3% relative improvement in pass@1 on HumanEval and LiveCodeBench compared with greedy decoding.

代码生成意图理解解码优化LLM

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。