arXivDaily arXiv每日学术速递 周一至周五更新

AI 大模型

代码大模型 / AI 编程

代码生成、软件工程智能体、程序修复、测试生成和开发者工具。

至 收录 11887 信号源:cs.SE, cs.CL, cs.AI, cs.LG, cs.PL
2607.10621 2026-07-14 cs.SE 新提交 89%

WebDesignIter: Co-Evolving Design Knowledge for Repository-Level Front-End Code Generation

WebDesignIter:用于仓库级前端代码生成的协同进化设计知识

Zheng Pei, Mingwei Liu, Zhenxi Chen, Zihao Wang, Yanlin Wang

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);coding agent(abstract);分类 cs.SE

AI总结 研究针对前端开发仓库级代码生成问题,提出WebDesignIter框架,通过持久知识图谱融合设计知识与仓库结构,分两阶段工作,实验证明其相比基线和通用编码代理有优势,凸显设计知识对仓库级代码生成的重要性。

详情
AI中文摘要

前端开发在仓库级别不断积累变化,形成复杂的跨文件依赖关系,当前针对单次任务调整的大型语言模型编码代理无法在多个迭代中可靠跟踪,导致功能回归和难以维护的代码。我们认为缺失的是设计知识,如架构原则、模块职责和结构约束等。为此,我们提出WebDesignIter框架,围绕持久知识图谱(WebAppArchKG)构建,融合仓库结构与设计知识并在开发周期中保持同步。WebDesignIter分两个阶段工作:设计知情规划从WebAppArchKG获取历史上下文和架构概述以生成带有相应测试脚本的实施计划,设计感知生成通过基于目标差异的补丁执行该计划,并通过沙盒执行和自动语法修复进行验证。在Web-Bench上,与现有基线相比,WebDesignIter在九个基础模型上平均Pass@2增益9.55个百分点。更重要的是,在每个模型配置上,WebDesignIter均优于通用编码代理Claude Code、OpenHands、SWE-Agent、Codex CLI,Pass@1和Pass@2最高且输入令牌少2530个。消融实验表明设计知识是最有影响力的组件,去除它会使Pass@1下降11.40个百分点,降幅远大于去除代码图检索、基于补丁的生成或沙盒验证,证实设计知识为仓库级代码生成提供了更高效可靠的路径。

英文摘要

Front-end development accumulates change after change at the repository level, weaving complex cross-file dependencies that current LLM coding agents tuned for single-shot tasks cannot reliably track across multiple iterations, leading to functional regressions and code that resists maintenance. We argue the missing piece is design knowledge: architectural principles, module responsibilities, and structural constraints that developers lean on to keep code readable, maintainable, and evolvable as a system scales. To operationalize this, we propose WebDesignIter, a framework built around a persistent knowledge graph (WebAppArchKG) that fuses repository structure with design knowledge and keeps both in sync across development cycles. WebDesignIter works in two stages: design-informed planning pulls historical context and architectural overviews from WebAppArchKG to produce an implementation plan with corresponding test scripts, and design-aware generation executes that plan through targeted diff-based patches, validated by sandbox execution and automatic syntax repair. On Web-Bench, WebDesignIter delivers an average Pass@2 gain of 9.55 percentage points across nine foundation models over existing baselines. More importantly, WebDesignIter outperforms every general-purpose coding agent Claude Code, OpenHands, SWE-Agent, Codex CLI on every model configuration, posting the highest Pass@1 and Pass@2 while consuming 2530 fewer input tokens. Ablation singles out design knowledge as the most impactful component: stripping it drops Pass@1 by 11.40 percentage points, a degradation far larger than removing code-graph retrieval, patch-based generation, or sandbox verification, confirming that design knowledge provides a fundamentally more efficient and reliable path to repository-level code generation.

URL PDF HTML 收藏
2605.08112 2026-05-12 cs.SE cs.AI cs.CE cs.LG cs.LO 89%

Context-Augmented Code Generation: How Product Context Improves AI Coding Agent Decision Compliance by 49%

上下文增强的代码生成:产品上下文如何通过49%提高AI编码代理的决策合规性

Drew Dillon, Kasyap Varanasi

机构 * Brief(简述)

专题命中 代码生成 :coding agent(title,abstract);code generation(title);repository(abstract,comments);分类 cs.SE、cs.AI、cs.LG

AI总结 本文提出一个衡量决策合规性的基准,通过产品上下文检索系统提升AI编码代理的决策合规性,实验结果显示合规率从46%提升至95%。

Comments 16 pages, 3 figures, 16 tables. Benchmark repository: https://github.com/brief-hq/dcbench

详情
AI中文摘要

基于大型语言模型的AI编码代理能够阅读代码库并生成功能性代码,但它们经常违反团队特定的产品决策,这些决策在源代码中不可见。我们引入了一个受控基准,测量决策合规性,即AI编码代理在8个现实软件工程任务中遵循已确立的产品、设计和工程决策的比率,包含41个加权决策点。我们比较了基线配置(仅代码库访问的Claude Code)与增强配置,后者添加了Brief,一个提供规范生成、中期构建咨询和记录决策检索的产品上下文检索系统。在相同的提示和相同仓库上,增强配置实现了95%的决策合规性,而基线配置仅为46%,提高了49个百分点。对每个决策的分析显示,基线在代码库中可见的决策上达到100%合规性,而在需要产品上下文的决策上为0-33%,表明产品上下文检索是改进的关键驱动力。我们发布了基准仓库、所有16个拉取请求和评分工具,供独立复现。

英文摘要

AI coding agents powered by large language models can read codebases and produce functional code, but they routinely violate team-specific product decisions that are invisible in the source code alone. We introduce a controlled benchmark measuring decision compliance, the rate at which an AI coding agent follows established product, design, and engineering decisions, across 8 realistic software engineering tasks containing 41 weighted decision points. We compare a baseline configuration (Claude Code with codebase access only) against an augmented configuration that adds Brief, a product-context retrieval system providing spec generation, mid-build consultation, and retrieval of recorded decisions, persona pain points, customer signals, and competitive intelligence. On identical prompts and the same repository, the augmented configuration achieves 95% decision compliance versus 46% for the baseline, a 49 percentage point improvement. Per-decision analysis reveals that the baseline achieves 100% compliance on decisions visible in the codebase and 0-33% on decisions requiring product context, suggesting that product-context retrieval is a key driver of the improvement. We release the benchmark repository, all 16 pull requests, and scoring harness for independent reproduction.

URL PDF HTML 收藏
2510.10216 2026-02-09 cs.PL cs.AI cs.SE 89%

Learning to Guarantee Type Correctness in Code Generation through Type-Guided Program Synthesis

通过类型引导的程序合成学习保证类型正确性

Zhechong Huang, Zhao Zhang, Ruyi Ji, Tingxuan Xia, Qihao Zhu, Qinxiang Cao, Zeyu Sun, Wiggin Zhou, Yingfei Xiong

机构 * Peking University(北京大学) University of Michigan(密歇根大学) Shanghai Jiao Tong University(上海交通大学) Institute of Software, Chinese Academy of Sciences(中国科学院软件研究所) Tencent(腾讯)

专题命中 代码生成 :code generation(title,abstract);program synthesis(title,abstract);分类 cs.SE、cs.AI、cs.PL

AI总结 TyFlow 通过内部化类型推理,提升代码生成的类型正确性与功能正确性。

详情
AI中文摘要

语言模型在代码生成方面表现出显著的 proficiency,但确保类型正确性仍是一个挑战。尽管传统方法,如受约束解码,通过外部拒绝无法类型化的代码来缓解这一问题,但模型本身并未有效内部学习类型推理,这最终限制了其整体性能。本文介绍了一个名为 TyFlow 的新型系统,该系统在代码生成中内部化类型推理,以引导模型学习类型系统。我们的核心方法是一种新的类型引导程序合成系统,它在类型推导树和合成推导树之间保持同构性,从而基于合成决策序列而非传统文本令牌序列建立新的代码表示。通过将类型系统学习的复杂性转移给表示本身,模型可以将计算资源重新定向到更高层次的程序语义。我们的评估表明,TyFlow 不仅消除了类型错误,还显著提高了功能正确性,突显了将 LMs 与类型系统内部对齐的重要性。

英文摘要

Language models have shown remarkable proficiency in code generation; nevertheless, ensuring type correctness remains a challenge. Although traditional methods, such as constrained decoding, alleviate this problem by externally rejecting untypable code, the model itself does not effectively learn type reasoning internally, which ultimately limits its overall performance. This paper introduces TyFlow, a novel system that internalizes type reasoning within code generation to guide the model to learn the type system. The core of our approach is a novel type-guided program synthesis system that maintains an isomorphism between type derivation trees and synthesis derivation trees, enabling a new code representation based on synthesis decision sequences rather than traditional text-based token sequences. By offloading the complexity of type system learning to the representation itself, models can redirect their computational resources toward higher-level program semantics. Our evaluation shows that TyFlow not only eliminates type errors but also significantly improves functional correctness, highlighting the importance of aligning LMs with type systems internally.

URL PDF HTML 收藏
2608.01927 2026-08-04 cs.SE cs.AI 新提交 88%

Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generation

基于部分依赖图的高效上下文检索用于仓库级代码生成

Zhongxin Liu, Zhonghao Jiang, Zhifan Ye, Haoye Wang, Jiakun Liu, Xiaoxue Ren

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE、cs.AI

AI总结 该研究针对仓库级代码生成中RAG方法的不足,提出基于部分依赖图的DyRetriever,构建DyCoder并在CoderEval、DevEval上取得显著性能提升且效率更高。

Comments Accepted by ASE 2026

详情
AI中文摘要

基于大语言模型(LLM)的仓库级代码生成旨在利用软件仓库中的可用上下文生成代码,要求LLM对复杂的代码依赖关系进行推理。由于上下文窗口有限且对仓库特定的理解不足,LLM通常依赖检索增强生成(RAG)来纳入相关代码。早期的RAG方法主要采用基于相似度的检索,往往无法检索到目标函数所依赖的代码片段。近期的研究引入了基于图的检索来建模此类依赖关系,但通常依赖人工设计的规则和静态全局图,导致灵活性有限且构建与维护成本较高。相比之下,人类开发者会通过隐式构建部分依赖图并沿其迭代检查来收集有用的上下文。受此行为启发,我们提出了DyRetriever,一种通过部分依赖图实现的高效上下文检索方法。DyRetriever首先使用LLM选择一组入口点函数,然后沿代码依赖图执行多跳推理。在多跳推理过程中,它利用LLM的语义理解来验证某个函数是否有助于生成目标函数,消除了人工设计的规则,并实现了跨场景的灵活性。DyRetriever不会静态构建全局依赖图,而是按需构建部分图,使用后丢弃,从而降低了构建和维护成本。我们将DyRetriever与基于相似度的代码检索器集成,构建了DyCoder,并在CoderEval和DevEval上对其进行评估。实验结果表明,与现有的基于RAG的方法相比,DyCoder在CoderEval和DevEval上分别实现了25.63%和59.73%的相对Pass@1提升,同时比基于静态依赖图构建的基准方法快7.4倍。

英文摘要

LLM-based repository-level code generation aims to generate code using the context available in a software repository, requiring LLMs to reason over complex code dependencies. Due to limited context windows and insufficient repository-specific understanding, LLMs typically rely on retrieval-augmented generation (RAG) to incorporate relevant code. Early RAG approaches primarily employ similarity-based retrieval, which often fails to retrieve code snippets that the target function depends on. Recent work introduces graph-based retrieval to model such dependencies, but typically relies on manually designed rules and static global graphs, leading to limited flexibility and high construction and maintenance costs. In contrast, human developers collect helpful context by implicitly constructing a partial dependency graph and iteratively inspecting along it. Inspired by this behavior, we propose DyRetriever, an efficient context retrieval method via partial dependency graphs. DyRetriever uses an LLM to first select a set of entry-point functions and then perform multi-hop reasoning along the code dependency graph. During multi-hop reasoning, it uses the LLM's semantic understanding to validate whether a function can help generate the target function, eliminating manually designed rules and enabling flexibility across scenarios. Instead of statically constructing a global dependency graph, DyRetriever builds a partial graph on demand and discards it after use, reducing construction and maintenance costs. We integrate DyRetriever with a similarity-based code retriever to build DyCoder and evaluate it on CoderEval and DevEval. Experimental results show that DyCoder achieves relative Pass@1 improvements of 25.63% and 59.73% on CoderEval and DevEval, respectively, compared with existing RAG-based methods, while being 7.4x faster than baselines based on static dependency graph construction.

URL PDF HTML 收藏
2509.24148 2026-07-14 cs.SE cs.AI 版本更新 88%

TENET: One Step Toward Test-Driven Development for Repository-Level Code Generation

TENET:迈向仓库级代码生成的测试驱动开发的第一步

Yiran Hu, Nan Jiang, Shanchao Liang, Yi Wu, Lin Tan

机构 * Purdue University(普渡大学) Microsoft Office AI(微软办公人工智能)

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE、cs.AI

AI总结 研究仓库级代码生成的测试驱动开发问题,提出TENET框架,含测试harness机制、定制工具集和细化工作流程,能选简洁测试套件,实现高效检索调试与迭代改进,性能优于基线,还研究了测试套件特征对LLM代理性能的影响。

Comments Accepted at the 37th IEEE International Symposium on Software Reliability Engineering (ISSRE 2026)

详情
AI中文摘要

测试驱动开发(TDD)是一种广泛采用的实践,要求开发人员在实现的同时创建并执行测试。随着大语言模型(LLMs)的发展,开发者可将编写代码转变为定义可执行规范并将代码合成委托给人工智能代理。然而,在开发者编写的测试下实现仓库级TDD具有挑战性,需要规范增强、检索增强和测试驱动细化。我们提出了TENET,一个在TDD范式下用于仓库级代码生成的代理框架。它包括测试 harness 机制、定制代理工具集和基于反射的细化工作流程。TENET在多个主干上始终优于最强基线,在RepoCod和RepoEval上使用Claude Sonnet 4时分别达到69.08%和81.77%的Pass@1,分别提高了9.49和2.17个百分点。此外,我们首次系统研究了测试套件特征如何影响TDD设置中的LLM代理性能。

英文摘要

Test-Driven Development (TDD) is a widely adopted practice that requires developers to create and execute tests alongside implementation. With recent advances in Large Language Models (LLMs), developers can shift from manually writing the code to defining tests as executable specifications and delegating code synthesis to AI agents. However, enabling repository-level TDD under developer-written tests is challenging, requiring: (1) specification enhancement: identifying a concise yet representative test subset from large suites with rich task semantics; (2) retrieval augmentation: using tests to guide reasoning and context retrieval; and (3) test-driven refinement: interpreting test feedback for iterative improvement. We propose TENET, an agentic framework for repository-level code generation under the TDD paradigm. TENET includes: (1) a test harness mechanism that selects a concise test suite to maximize diversity of the target usage scenarios; (2) a tailored agent toolset for efficient retrieval and debugging; and (3) a reflection-based refinement workflow that iteratively analyzes failures and updates implementations. TENET consistently outperforms the strongest baselines across backbones, achieving 69.08% and 81.77% Pass@1 on RepoCod and RepoEval with Claude Sonnet 4, improving by 9.49 and 2.17 percentage points, respectively. Additionally, we present the first systematic study of how test suite characteristics influence LLM agent performance in TDD settings.

URL PDF HTML 收藏
2607.08691 2026-07-10 cs.SE cs.AI cs.IR 新提交 88%

ProjAgent: Procedural Similarity Retrieval for Repository-Level Code Generation

ProjAgent:用于仓库级代码生成的过程相似性检索

QiHong Chen, Aaron Imani, Iftekhar Ahmed

机构 * University of California, Irvine(加州大学伊文斯分校)

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE、cs.AI

AI总结 研究仓库级代码生成问题,提出ProjAgent系统,将目标函数分解为中间推理步骤,通过代理工作流程检索相似过程行为的函数,结合语义检索构建丰富上下文,并利用静态分析反馈循环修复代码,实验表明该方法有效。

详情
AI中文摘要

仓库级代码生成需要在考虑复杂的跨文件依赖关系和项目特定约定的情况下实现目标函数。现有检索方法主要依赖词汇、结构或语义相似性,常常忽略那些实现相似过程逻辑但标识符或应用领域不同的仓库函数。我们提出了ProjAgent,一个仓库级代码生成系统,它引入过程相似性作为显式检索信号。ProjAgent将目标函数分解为中间推理步骤,并采用代理工作流程在每个步骤中检索表现出相似过程行为的仓库函数。检索到的过程上下文与传统语义检索相结合,为代码生成构建更丰富的仓库上下文。ProjAgent还纳入了一个保守的静态分析反馈循环,使用编译器和静态分析反馈迭代修复生成的代码。在REPOCOD上进行评估时,ProjAgent的Pass@1达到41.14% ,优于现有的基于检索的基线。这些结果表明,过程相似性是仓库级代码生成中一个有效且以前未被探索的检索维度。

英文摘要

Repository-level code generation requires implementing target functions while accounting for complex cross-file dependencies and project-specific conventions. Existing retrieval methods predominantly rely on lexical, structural, or semantic similarity, often overlooking repository functions that implement similar procedural logic despite differing in identifiers or application domains. We propose ProjAgent, a repository-level code generation system that introduces procedural similarity as an explicit retrieval signal. ProjAgent decomposes the target function into intermediate reasoning steps and employs an agentic workflow to retrieve repository functions that exhibit similar procedural behavior at each step. The retrieved procedural context is integrated with conventional semantic retrieval to construct a richer repository context for code generation. ProjAgent further incorporates a conservative static-analysis feedback loop that iteratively repairs generated code using compiler and static-analysis feedback. Evaluated on REPOCOD, ProjAgent achieves 41.14% Pass@1, outperforming existing retrieval-based baselines. These results demonstrate that procedural similarity is an effective and previously unexplored retrieval dimension for repository-level code generation.

URL PDF HTML 收藏
2606.22082 2026-06-23 cs.SE cs.AI 新提交 88%

CodeTeam: An LLM-Powered Multi-Agent Framework for Repository-Level Code Generation

CodeTeam: 一个基于LLM的多智能体框架用于仓库级代码生成

Yifei Wang, Ruiyin Li, Peng Liang, Qiong Feng, Zengyang Li, Mojtaba Shahin, Arif Ali Khan

机构 * School of Computer Science, Wuhan University(武汉大学计算机学院) School of Computer Science, Nanjing University of Science and Technology(南京理工大学计算机学院) School of Computer Science, Central China Normal University(中央财经大学计算机学院) School of Computing Technologies, RMIT University(皇家墨尔本理工学院计算技术学院) M3S Research Group, SEIS Unit, University of Oulu(奥卢大学M3S研究组,SEIS单元)

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE、cs.AI

AI总结 提出CodeTeam框架,通过分离规划、决策和实现阶段,结合多智能体协作与依赖感知调度,解决仓库级代码生成中的长程规划与跨文件一致性问题,在SketchEval和NL2Repo-Bench上取得显著提升。

Comments 36 pages, 5 images, 9 tables, Manuscript submitted to a Journal (2026)

详情
AI中文摘要

自然语言到仓库生成(NL2Repo)要求系统从自然语言需求文档构建整个软件仓库。与函数级代码生成相比,此任务需要更长的规划周期、稳定的跨文件接口以及跨文件不一致性的迭代调试。为应对这些挑战,我们提出CodeTeam,一个基于LLM的多智能体框架,将规划、决策和实现分离为不同的协调阶段。在规划阶段,多个架构师智能体起草竞争性的软件设计草图(SDS),可选地由检索到的设计参考作为支撑。然后,CTO智能体评估、选择并规范化最有前景的SDS,形成机器可检查的契约,指定文件所有权、公共接口和依赖约束。在实现阶段,开发者智能体在依赖感知调度器下生成代码,具有受限上下文和轻量级基于Git的协调,而QA智能体运行测试并驱动迭代修复。在基于合成的SketchEval基准上,我们明确比较了CodeTeam的提示工程(PE)和监督微调(SFT)变体与相应的CodeS变体,CodeTeam分别将整体SketchBLEU提高了4.1和2.9个绝对点。在基于执行的NL2Repo-Bench基准(作为外部验证协议)上,CodeTeam在两种设置下均实现了最高的平均测试通过率(PE为34.6%,SFT为42.3%),证实了草图改进在上级测试套件下延伸至功能正确性。消融实验表明,项目特定的开发者分配和检索增强规划各自对SketchBLEU改进有显著贡献(分别相对提升9.9%和8.1%)。CodeTeam和实验结果可在以下网址获取:此 https URL。

英文摘要

Natural language to repository generation (NL2Repo) requires a system to construct an entire software repository from a natural-language requirements document. Compared with function-level code generation, this task demands longer planning horizons, stable interfaces across files, and iterative debugging of cross-file inconsistencies. To address these challenges, we propose CodeTeam, an LLM-based multi-agent framework that separates planning, decision making, and implementation into distinct, coordinated stages. In the planning stage, multiple Architect agents draft competing software design sketches (SDS), optionally grounded by retrieved design references. A CTO agent then evaluates, selects, and normalizes the most promising SDS into a machine-checkable contract that specifies file ownership, public interfaces, and dependency constraints. In the implementation stage, Developer agents generate code under a dependency-aware scheduler with bounded context and lightweight Git-based coordination, while a QA agent runs tests and drives iterative repairs. On the synthesis-based SketchEval benchmark, we explicitly compare CodeTeam's prompt-engineering (PE) and supervised fine-tuning (SFT) variants with the corresponding CodeS variants, where CodeTeam improves the overall SketchBLEU by 4.1 and 2.9 absolute points, respectively. On the execution-based NL2Repo-Bench benchmark, used as an external validation protocol, CodeTeam achieves the highest average test pass rate in both settings (34.6% PE, 42.3% SFT), confirming that the sketch-improvements extend to functional correctness under upstream test suites. Ablation results show that project-specific developer allocation and retrieval-augmented planning each contribute substantially to the SketchBLEU improvement (9.9% and 8.1% relative, respectively). CodeTeam and the experimental results are available at https://github.com/WhitenWhiten/CodeTeam

URL PDF HTML 收藏
2511.20709 2026-06-16 cs.SE cs.AI cs.CR 版本更新 88%

DualGauge: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agents

DualGauge: 对仅由LLM和编码代理生成的规范代码进行自动化联合安全-功能基准测试

Rupam Patir, Keyan Guo, Suvadra Barua, Abhijeet Pathak, Dinesh Gudimetla, Jiawei Guo, Hongxin Hu, Haipeng Cai

机构 * University at Buffalo, SUNY(布法罗大学)

专题命中 代码生成 :code generation(title,abstract);coding agent(title,abstract);分类 cs.SE、cs.AI

AI总结 提出DualGauge框架,首个自动化联合评估规范代码正确性与安全性的系统,通过307个任务基准测试发现功能正确性高估可靠代码生成,联合成功率低于15%,且模型因素和代理系统均无法可靠提升。

详情
AI中文摘要

大型语言模型(LLM)和基于LLM的编码代理现在被用于从自然语言规范生成代码,然而确保此类代码既功能正确又安全仍然是一个挑战。我们提出了DualGauge,这是第一个用于联合评估仅规范代码生成正确性和安全性的全自动化框架,并由DualGauge-Bench支持,这是一个语言无关的基准测试,包含307个编码任务,每个任务都配有从相同规范派生的功能和安全性测试。通过评估Python、C++和JavaScript中的10个代表性LLM,我们发现功能正确性显著高估了可靠代码生成:即使是最强的模型,在每种语言中联合安全-功能成功率仍低于15%。常见的模型侧因素——规模、扩展思维、量化、指令调优和代码专业化——并不能可靠地提高联合性能,这表明安全且正确的代码生成并非仅仅从更强的编码能力中涌现。对3个领先的代理编码系统(Codex、OpenHands和Claude Code)的评估表明,在仅规范任务上,迭代脚手架相比直接(基于LLM的)生成没有优势。定性审计揭示,失败集中在输出契约边界以及存在但不足的防护措施上——这些模式只有联合基准测试才能可靠地暴露。

英文摘要

Large language models (LLMs) and LLM-based coding agents are now used to generate code from natural-language specifications, yet ensuring such code is both functionally correct and secure remains a challenge. We present DualGauge, the first fully automated framework for jointly evaluating correctness and security of specification-only code generation, supported by DualGauge-Bench, a language-agnostic benchmark of 307 coding tasks each paired with functional and security tests derived from the same specification. Evaluating 10 representative LLMs across Python, C++, and JavaScript, we find that functional correctness substantially overestimates reliable code generation: even the strongest model remains below 15% joint security-functionality success in every language. Common model-side factors--scale, extended thinking, quantization, instruction tuning, and code specialization--do not reliably improve joint performance, suggesting secure-and-correct code generation does not simply emerge from stronger coding capability. Evaluation of 3 leading agentic coding systems (Codex, OpenHands, and Claude Code) shows that iterative scaffolding provides no advantage over direct (LLM-based) generation on specification-only tasks. A qualitative audit reveals failures concentrate at the output contract boundary and in guards that exist but are insufficient--patterns that only joint benchmarking reliably exposes.

URL PDF HTML 收藏
2510.04905 2026-05-21 cs.SE cs.CL 88%

Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches

检索增强的代码生成:聚焦于仓库级方法的综述

Yicheng Tao, Yuante Li, Yao Qin, Yepang Liu

机构 * Carnegie Mellon University(卡内基梅隆大学) Chinese University of Hong Kong(香港中文大学) Southern University of Science and Technology(南方科技大学)

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE、cs.CL

AI总结 本文综述了检索增强的代码生成方法,重点探讨仓库级方法,分析了其在大规模代码生成中的挑战与解决方案,总结了现有方法的分类框架及关键挑战。

详情
AI中文摘要

近年来,大型语言模型(LLMs)的进展显著提升了自动化代码生成的能力。尽管现有方法在函数和文件级别上表现优异,但现实中的软件工程需要对整个仓库进行推理,包括跨文件依赖、不断演变的执行环境和全局语义一致性。这一挑战催生了仓库级代码生成(RLCG),其中模型必须检索、组织并利用仓库级上下文以生成连贯且可执行的代码变更。为解决这些挑战,检索增强生成(RAG)已成为仓库级代码智能的重要范式。本文综述了检索增强代码生成(RACG),特别关注仓库级方法。不同于将RACG视为静态的“检索后生成”流程,我们将其视为一个耦合且不断演变的过程,涉及上下文构建、检索优化、生成和环境交互。通过统一的分析框架,我们组织现有方法,涵盖检索子系统、控制机制和评估设置。基于此框架,我们系统地考察了检索策略、基于图和非基于图的检索范式、训练驱动的优化以及自主代理架构。我们进一步总结了广泛使用的数据集、基准和系统配置,并讨论了关键挑战,包括可扩展性、可靠性、效率以及RACG与长上下文LLMs之间的必要性边界。通过本文综述,我们旨在为快速发展的RACG领域提供结构化的理解,并突出未来人工智能驱动的软件工程研究的有前景方向。

英文摘要

Recent advances in large language models (LLMs) have significantly improved automated code generation. While existing approaches have achieved strong performance at the function and file levels, real-world software engineering requires reasoning over entire repositories, including cross-file dependencies, evolving execution environments, and global semantic consistency. This challenge has led to the emergence of Repository-Level Code Generation (RLCG), where models must retrieve, organize, and utilize repository-scale context to generate coherent and executable code changes. To address these challenges, Retrieval-Augmented Generation (RAG) has become an increasingly important paradigm for repository-level code intelligence. In this survey, we present a comprehensive review of Retrieval-Augmented Code Generation (RACG), with a particular focus on repository-level approaches. Rather than viewing RACG as a static ``retrieve-then-generate'' pipeline, we characterize it as a coupled and evolving process involving context construction, retrieval optimization, generation, and environment interaction. We organize existing methods through a unified analytical framework spanning retrieval substrate, control regime, and evaluation setting. Based on this framework, we systematically examine retrieval strategies, graph-based and non-graph-based retrieval paradigms, training-driven optimizations, and autonomous agent architectures. We further summarize widely used datasets, benchmarks, and system configurations, and discuss key challenges including scalability, reliability, efficiency, and the necessity boundary between RACG and long-context LLMs. Through this survey, we aim to provide a structured understanding of the rapidly evolving RACG landscape and highlight promising directions for future AI-powered software engineering research.

URL PDF HTML 收藏
2601.00376 2026-05-01 cs.SE cs.AI 88%

In Line with Context: Repository-Level Code Generation via Context Inlining

与上下文一致:通过上下文内联实现仓库级代码生成

Chao Hu, Wenhao Zeng, Yuling Shi, Beijun Shen, Xiaodong Gu

机构 * Shanghai Jiao Tong University(上海交通大学)

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE、cs.AI

AI总结 本文提出InlineCoder框架,通过内联未完成函数到调用图中,将仓库理解转化为更易处理的函数级编码任务,提升仓库级代码生成能力。

Comments Accepted to FSE 2026

详情
AI中文摘要

仓库级代码生成近年来受到越来越多关注。与函数级代码生成不同,它要求模型理解整个仓库,推理函数、类和模块之间的复杂依赖关系。然而,现有方法如检索增强生成(RAG)或基于上下文的函数选择往往不足:它们主要依赖于表面相似性,难以捕捉支配仓库级语义的丰富依赖关系。在本文中,我们引入InlineCoder,一种新的仓库级代码生成框架。InlineCoder通过将未完成的函数内联到其调用图中,增强对仓库上下文的理解,从而将具有挑战性的仓库理解转化为更简单的函数级编码任务。给定一个函数签名,InlineCoder首先生成一个草稿完成,称为锚点,该锚点近似下游依赖关系并启用基于困惑度的置信度估计。此锚点驱动双向内联过程:(i)上游内联,将锚点嵌入到调用者中以捕捉多样的使用场景;(ii)下游检索,将锚点的被调用者整合到提示中以提供精确的依赖上下文。丰富的上下文,结合草稿完成与上游和下游视角,使LLM具备全面的仓库视图。

英文摘要

Repository-level code generation has attracted growing attention in recent years. Unlike function-level code generation, it requires the model to understand the entire repository, reasoning over complex dependencies across functions, classes, and modules. However, existing approaches such as retrieval-augmented generation (RAG) or context-based function selection often fall short: they primarily rely on surface-level similarity and struggle to capture the rich dependencies that govern repository-level semantics. In this paper, we introduce InlineCoder, a novel framework for repository-level code generation. InlineCoder enhances the understanding of repository context by inlining the unfinished function into its call graph, thereby reframing the challenging repository understanding as an easier function-level coding task. Given a function signature, InlineCoder first generates a draft completion, termed an anchor, which approximates downstream dependencies and enables perplexity-based confidence estimation. This anchor drives a bidirectional inlining process: (i) Upstream Inlining, which embeds the anchor into its callers to capture diverse usage scenarios; and (ii) Downstream Retrieval, which integrates the anchor's callees into the prompt to provide precise dependency context. The enriched context, combining draft completion with upstream and downstream perspectives, equips the LLM with a comprehensive repository view.

URL PDF HTML 收藏
2604.03632 2026-04-07 cs.SE cs.AI 88%

Persistent Cross-Attempt State Optimization for Repository-Level Code Generation

持久的跨尝试状态优化用于仓库级代码生成

Ruwei Pan, Jiangshuai Wang, Qisheng Zhang, Yueheng Zhu, Linhao Wu, Zixiong Yang, Yakun Zhang, Lu Zhang, Hongyu Zhang

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE、cs.AI

AI总结 本文提出LiveCoder框架,通过跨尝试知识优化提升仓库级代码生成效率,通过保留任务特定状态提升生成效果,实验表明在RAL-Bench上功能得分提升22.94个百分点,仓库复用率提升至81.58%。

详情
AI中文摘要

大型语言模型(LLMs)在仓库级代码生成中取得了显著进展。然而,解决相同任务往往需要多次尝试,而现有方法仍孤立优化每次尝试,未能在尝试间保留或重用任务特定状态。本文提出LiveCoder,一种基于跨尝试知识优化的仓库级代码生成新框架。LiveCoder通过维护先前尝试的任务特定状态来引导后续生成。这些状态包括成功知识(捕捉来自先前强仓库的可重用信号)、失败知识(记录失败结果及其诊断信号)以及历史最佳仓库(保存迄今最强的结果以防止退化)。这些组件共同将重复的仓库生成转化为持续的知识驱动优化过程。我们使用四个前沿LLMs在两个代表性仓库级代码生成基准上评估LiveCoder。广泛实验结果证明了LiveCoder的有效性和效率,在RAL-Bench上功能得分提升最高22.94个百分点,仓库复用率提升至81.58%,成本降低最高53.63%,同时保持非功能质量总体稳定。

英文摘要

Large language models (LLMs) have achieved substantial progress in repository-level code generation. However, solving the same repository-level task often requires multiple attempts, while existing methods still optimize each attempt in isolation and do not preserve or reuse task-specific state across attempts. In this paper, we propose LiveCoder, a novel framework for repository-level code generation based on cross-attempt knowledge optimization. LiveCoder maintains persistent task-specific state from prior attempts to guide subsequent generation. This state includes success knowledge, which captures reusable signals from previously strong repositories, failure knowledge, which records unsuccessful outcomes and their diagnostic signals, and a historical-best repository, which preserves the strongest result found so far and prevents regression. These components collectively transform repeated repository generation into a persistent, knowledge-driven optimization process. We evaluate LiveCoder using four frontier LLMs on two representative repository-level code generation benchmarks. Extensive experimental results demonstrate the effectiveness and efficiency of LiveCoder, improving the functional score by up to 22.94 percentage points, increasing repository reuse to 81.58%, and reducing cost by up to 53.63% on RAL-Bench while maintaining broadly stable non-functional quality.

URL PDF HTML 收藏
2406.03283 2025-11-24 cs.SE cs.AI 88%

CATCODER: Repository-Level Code Generation with Relevant Code and Type Context

CATCODER: 基于相关代码和类型上下文的仓库级代码生成

Zhiyuan Pan, Xing Hu, Xin Xia, Xiaohu Yang

机构 * The State Key Laboratory of Blockchain and Data Security, Zhejiang University(区块链与数据安全国家重点实验室,浙江大学)

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE、cs.AI

AI总结 CatCoder通过整合相关代码和类型上下文,提升仓库级代码生成的性能和可扩展性。

Comments Revised and extended version; To be published in ACM Transactions on Software Engineering and Methodology

详情
AI中文摘要

大型语言模型(LLMs)在代码生成任务中展现了显著的能力。然而,仓库级代码生成面临着独特的挑战,特别是由于需要利用存储在仓库中的多个文件的信息。具体而言,成功的生成依赖于对一般性的、上下文无关的知识和特定的、上下文相关的知识的深刻理解。尽管LLMs被广泛用于上下文无关方面,但现有的基于检索的方法有时效果有限,因为它们在获取更广泛和深入的仓库上下文方面存在局限。在本文中,我们提出了CatCoder,一种针对静态类型编程语言的新型代码生成框架。CatCoder通过整合相关代码和类型上下文来增强仓库级代码生成。具体而言,它利用静态分析工具提取类型依赖关系,并将此信息与检索到的代码合并,以创建全面的提示供LLMs使用。为了评估CatCoder的有效性,我们调整并构建了包含199个Java任务和90个Rust任务的基准测试。结果表明,CatCoder在compile@k和pass@k得分上比RepoCoder基线高出高达14.44%和17.35%。此外,通过使用各种LLMs,包括专门用于代码的模型和通用模型,评估了CatCoder的通用性。我们的发现表明,在所有模型上都实现了持续的性能提升,这证明了CatCoder的实用性。此外,我们评估了CatCoder在大型开源仓库中的时间消耗,结果展示了CatCoder的可扩展性。

英文摘要

Large language models (LLMs) have demonstrated remarkable capabilities in code generation tasks. However, repository-level code generation presents unique challenges, particularly due to the need to utilize information spread across multiple files within a repository. Specifically, successful generation depends on a solid grasp of both general, context-agnostic knowledge and specific, context-dependent knowledge. While LLMs are widely used for the context-agnostic aspect, existing retrieval-based approaches sometimes fall short as they are limited in obtaining a broader and deeper repository context. In this paper, we present CatCoder, a novel code generation framework designed for statically typed programming languages. CatCoder enhances repository-level code generation by integrating relevant code and type context. Specifically, it leverages static analyzers to extract type dependencies and merges this information with retrieved code to create comprehensive prompts for LLMs. To evaluate the effectiveness of CatCoder, we adapt and construct benchmarks that include 199 Java tasks and 90 Rust tasks. The results show that CatCoder outperforms the RepoCoder baseline by up to 14.44% and 17.35%, in terms of compile@k and pass@k scores. In addition, the generalizability of CatCoder is assessed using various LLMs, including both code-specialized models and general-purpose models. Our findings indicate consistent performance improvements across all models, which underlines the practicality of CatCoder. Furthermore, we evaluate the time consumption of CatCoder in a large open source repository, and the results demonstrate the scalability of CatCoder.

URL PDF HTML 收藏
2511.07584 2025-11-12 cs.SE cs.AI cs.DC 88%

SemanticForge: Repository-Level Code Generation through Semantic Knowledge Graphs and Constraint Satisfaction

Wuyang Zhang, Chenkai Zhang, Zhen Luo, Jianming Ma, Wangming Yuan, Chuqiao Gu, Chenwei Feng

机构 * Department of Elec.&Comp. Science, University of Massachusetts Amherst(马萨诸塞大学阿姆赫斯特分校电子与计算机科学系) Department of Computer Sys. Engineering, Northeastern University(东北大学计算机系统工程系) Department of Computer Science, George Mason University(乔治·梅森大学计算机科学系) Department of Info. Networking Institude, Carnegie Mellon University(卡内基梅隆大学信息网络研究所) Department of Computer & Mathematical Sciences, Auckland University of Technology(奥克兰理工大学计算机与数学科学系)

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE、cs.AI

Journal ref INNO-PRESS: Journal of Emerging Applied AI, 2025

详情
英文摘要

Large language models (LLMs) have transformed software development by enabling automated code generation, yet they frequently suffer from systematic errors that limit practical deployment. We identify two critical failure modes: \textit{logical hallucination} (incorrect control/data-flow reasoning) and \textit{schematic hallucination} (type mismatches, signature violations, and architectural inconsistencies). These errors stem from the absence of explicit, queryable representations of repository-wide semantics. This paper presents \textbf{SemanticForge}, which introduces four fundamental algorithmic advances for semantically-aware code generation: (1) a novel automatic reconciliation algorithm for dual static-dynamic knowledge graphs, unifying compile-time and runtime program semantics; (2) a neural approach that learns to generate structured graph queries from natural language, achieving 73\% precision versus 51\% for traditional retrieval; (3) a novel beam search algorithm with integrated SMT solving, enabling real-time constraint verification during generation rather than post-hoc validation; and (4) an incremental maintenance algorithm that updates knowledge graphs in $O(|ΔR| \cdot \log n)$ time while maintaining semantic equivalence.

URL PDF HTML 收藏
2503.06680 2025-06-23 cs.SE cs.CL 88%

FEA-Bench: A Benchmark for Evaluating Repository-Level Code Generation for Feature Implementation

Wei Li, Xin Zhang, Zhongxin Guo, Shaoguang Mao, Wen Luo, Guangyue Peng, Yangyu Huang, Houfeng Wang, Scarlett Li

机构 * State Key Laboratory of Multimedia Information Processing, School of Computer Science, Peking University(信息处理国家重点实验室,计算机学院,北京大学) Microsoft Research Asia(微软亚洲研究院)

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE、cs.CL

Comments V2, Accepted by ACL 2025 main conference

详情
英文摘要

Implementing new features in repository-level codebases is a crucial application of code generation models. However, current benchmarks lack a dedicated evaluation framework for this capability. To fill this gap, we introduce FEA-Bench, a benchmark designed to assess the ability of large language models (LLMs) to perform incremental development within code repositories. We collect pull requests from 83 GitHub repositories and use rule-based and intent-based filtering to construct task instances focused on new feature development. Each task instance containing code changes is paired with relevant unit test files to ensure that the solution can be verified. The feature implementation requires LLMs to simultaneously possess code completion capabilities for new components and code editing abilities for other relevant parts in the code repository, providing a more comprehensive evaluation method of LLMs' automated software engineering capabilities. Experimental results show that LLMs perform significantly worse in the FEA-Bench, highlighting considerable challenges in such repository-level incremental code development.

URL PDF HTML 收藏
2410.19736 2024-10-29 cs.SE cs.LG cs.LO 88%

Combining LLM Code Generation with Formal Specifications and Reactive Program Synthesis

William Murphy, Nikolaus Holzer, Feitong Qiao, Leyi Cui, Raven Rothkopf, Nathan Koenig, Mark Santolucito

专题命中 代码生成 :code generation(title,abstract);program synthesis(title,abstract);分类 cs.SE、cs.LG

详情
英文摘要

In the past few years, Large Language Models (LLMs) have exploded in usefulness and popularity for code generation tasks. However, LLMs still struggle with accuracy and are unsuitable for high-risk applications without additional oversight and verification. In particular, they perform poorly at generating code for highly complex systems, especially with unusual or out-of-sample logic. For such systems, verifying the code generated by the LLM may take longer than writing it by hand. We introduce a solution that divides the code generation into two parts; one to be handled by an LLM and one to be handled by formal methods-based program synthesis. We develop a benchmark to test our solution and show that our method allows the pipeline to solve problems previously intractable for LLM code generation.

URL PDF HTML 收藏
2406.16526 2024-06-25 cs.SE cs.AI 88%

NARRepair: Non-Autoregressive Code Generation Model for Automatic Program Repair

Zhenyu Yang, Zhen Yang, Zhongxing Yu

专题命中 代码生成 :code generation(title,abstract);program repair(title,abstract);分类 cs.SE、cs.AI

详情
英文摘要

With the advancement of deep learning techniques, the performance of Automatic Program Repair(APR) techniques has reached a new level. Previous deep learning-based APR techniques essentially modified program sentences in the Autoregressive(AR) manner, which predicts future values based on past values. Due to the manner of word-by-word generation, the AR-based APR technique has a huge time delay. This negative consequence overshadows the widespread adoption of APR techniques in real-life software development. To address the issue, we aim to apply the Non-Autoregressive(NAR) method to the APR task, which can output target code in a parallel manner to avoid huge inference delays. To effectively adapt the NAR manner for the APR task, we in this paper propose NARRepair, the first customized NAR code generation model for the APR task. The NARRepair features three major novelties, including 1) using repair actions to alleviate the over-correction issue, 2) extracting dependency information from AST to alleviate the issue of lacking inter-word dependency information, 3) employing two-stage decoding to alleviate the issue of lacking contextual information. We evaluated NARRepair on three widely used datasets in the APR community, and the results show that our technique can significantly improve the inference speed while maintaining high repair accuracy.

URL PDF HTML 收藏
2607.26805 2026-07-30 cs.SE 新提交 88%

MRCoder: An Efficient Context Selecting Approach for Repository-Level Code Generation

MRCoder:一种面向仓库级代码生成的高效上下文选择方法

Peiding Wang, Li Zhang, Fang Liu

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE

AI总结 MRCoder是一种基于Map-Reduce范式的仓库级代码生成上下文选择框架,通过SADGS策略和并行验证,在提升代码生成准确率的同时降低了token消耗与推理时间。

Comments Under review in TOSEM

详情
AI中文摘要

大型语言模型(LLM)已展现出强大的代码生成能力,但仓库级代码生成仍具挑战性,因为它需要有效识别和利用仓库特定上下文。检索增强生成(RAG)虽会纳入相关代码片段,却常引入冗余上下文干扰LLM利用有效信息,导致生成质量下降、计算成本增加。此外,现有上下文选择与压缩方法难以平衡效率与质量,要么引入额外计算开销,要么无法有效选择有效上下文。本文提出MRCoder,一种可提升仓库级代码生成有效性与效率的高效上下文选择框架。MRCoder采用Map-Reduce范式:在Map阶段,轻量级草稿模型对分区上下文生成草稿,结构感知草稿引导选择(SADGS)通过API一致性与逻辑相似性,基于草稿选择信息丰富的上下文;在Reduce阶段,将优化后的上下文聚合用于最终生成,并行验证策略进一步加速解码。我们在CoderEval和DevEval两个广泛使用的仓库级代码生成基准上,以Qwen2.5-Coder和DeepSeek-Coder作为骨干LLM评估MRCoder。实验结果表明,MRCoder相比强基线提升了代码生成准确率,同时将token消耗降低30%至50%,推理时间最多缩短52%。这些结果证明,本文提出的结构化草稿引导上下文选择策略,对提升仓库级代码生成的质量与效率至关重要。

英文摘要

Large language models (LLMs) have demonstrated strong capabilities in code generation. However, repository-level code generation remains challenging, as it requires effectively identifying and utilizing repository-specific context. While retrieval-augmented generation (RAG) incorporates relevant code snippets, it often introduces redundant context that interferes with the LLM's ability to utilize relevant information, leading to degraded generation quality and increased computational cost. Moreover, existing context selection and compression methods struggle to balance efficiency and quality, either introducing additional computational overhead or failing to effectively select valid context. In this paper, we propose MRCoder, an efficient context selection framework that improves both the effectiveness and efficiency of repository-level code generation. MRCoder adopts a Map-Reduce paradigm: in the Map Phase, a lightweight draft model generates drafts over partitioned contexts, and Structure-Aware Draft-Guided Selection (SADGS) selects informative contexts based on drafts through API consistency and logical similarity; in the Reduce Phase, the refined contexts are aggregated for final generation, with a parallel verification strategy further accelerating decoding. We evaluate MRCoder on two widely used repository-level code generation benchmarks, CoderEval and DevEval, using Qwen2.5-Coder and DeepSeek-Coder as backbone LLMs. Experimental results show that MRCoder improves code generation accuracy over strong baselines while reducing token consumption by 30 to 50% and inference time by up to 52%. These results demonstrate that our proposed structured and draft-guided context selection strategy is crucial for improving both the quality and efficiency of repository-level code generation

URL PDF HTML 收藏
2607.04212 2026-07-07 cs.SE 新提交 88%

An Evaluation of Role-Based Multi-Agent Code Generation on Repository-Scale Problems

基于角色的多智能体代码生成在仓库规模问题上的评估

Benedetta Donato, Noah Hagar-Dent, Aaron Worsnop, Leonardo Mariani, Valerio Terragni

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE

AI总结 研究基于角色的多智能体代码生成在仓库规模问题上的效果,通过对12个Java仓库评估,发现其生成代码与开发者代码更相似,但与人工实现仍有差距。

Comments 8 pages, 1 figure, 2 tables. Accepted for publication in the IEEE Software Special Issue on Engineering Agentic Systems

Journal ref IEEE Software 2026 - Special Issue on Engineering Agentic Systems

详情
AI中文摘要

基于角色的多智能体代码生成旨在使语言模型在仓库规模问题上更有效,超越小型编程任务。我们在12个Java仓库上评估了这种方法,发现其生成的代码与开发者代码的相似度高于单个语言模型,但与人工实现仍存在持续差距。

英文摘要

Role-based multiagent code generation aims to make LLMs more effective on repository-scale problems, moving beyond small programming tasks. We evaluate this approach on 12 Java repositories, finding greater similarity to developer code than single LLMs, but a persistent gap from human implementations.

URL PDF HTML 收藏
2606.19988 2026-06-19 cs.SE 新提交 88%

Repository-Level Solidity Code Generation with Large Language Models: From Prompting to Fine-Tuning

基于大语言模型的仓库级Solidity代码生成:从提示到微调

Shi Chen, Rongcun Wang, Yuan Tian, Xiaoyuan Xie, Wei Song, Rubing Huang

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE

AI总结 提出SolidityBench基准和SolidityScore指标,评估多种LLM方法在仓库级Solidity代码生成中的表现,发现监督微调最有效。

Comments 33 pages

详情
AI中文摘要

大语言模型(LLMs)在通用代码生成方面表现出强大的能力,但其在专业软件领域的有效性仍未得到充分探索。Solidity智能合约代表了一个高风险领域,生成的代码必须满足严格的语言级、安全性和软件工程约束。现有的基准和指标对于仓库级Solidity生成仍然不足,其中模型必须从自然语言需求中合成完整的合约。为了解决这一差距,我们引入了SolidityBench,一个包含5,470个仓库级Solidity智能合约及其自然语言描述的基准。我们还提出了SolidityScore,一种基于Solidity的语义度量,强调领域关键结构,如安全修饰符、合约声明和Solidity特定关键词。使用该基准,我们评估了代表性的代码LLM,包括Qwen2.5-Coder、DeepSeek-Coder和CodeLlama,涵盖零样本提示、思维链推理、上下文学习、检索增强生成和监督微调。结果表明,通用模型在仓库级Solidity生成中表现出系统性的结构缺陷。在非参数方法中,检索增强生成表现最佳,而上下文学习在超过两个示例后因上下文饱和而性能下降。监督微调通过将Solidity特定约束内化到模型参数中实现了最大的改进。总体而言,我们的研究为仓库级Solidity代码生成提供了全面的基准,并表明高质量领域数据结合监督微调是提高LLM生成智能合约可靠性的最有效策略。

英文摘要

Large Language Models (LLMs) have shown strong capabilities in general-purpose code generation, but their effectiveness in specialized software domains remains underexplored. Solidity smart contracts represent a high-stakes domain where generated code must satisfy strict language-level, security, and software-engineering constraints. Existing benchmarks and metrics remain insufficient for repository-level Solidity generation, where models must synthesize complete contracts from natural language requirements. To address this gap, we introduce SolidityBench, a benchmark of 5,470 repository-level Solidity smart contracts paired with natural language descriptions. We also propose SolidityScore, a Solidity-aware semantic metric that emphasizes domain-critical constructs such as security modifiers, contract declarations, and Solidity-specific keywords. Using this benchmark, we evaluate representative code LLMs, including Qwen2.5-Coder, DeepSeek-Coder, and CodeLlama, across zero-shot prompting, Chain-of-Thought reasoning, in-context learning, retrieval-augmented generation, and supervised fine-tuning. The results show that general-purpose models exhibit systematic structural deficiencies in repository-level Solidity generation. Among non-parametric methods, retrieval-augmented generation performs best, while in-context learning degrades beyond two examples due to context saturation. Supervised fine-tuning achieves the largest improvement by internalizing Solidity-specific constraints into model parameters. Overall, our study provides a comprehensive benchmark for repository-level Solidity code generation and shows that high-quality domain data combined with supervised fine-tuning is the most effective strategy for improving the reliability of LLM-generated smart contracts.

URL PDF HTML 收藏
2606.08135 2026-06-09 cs.SE 新提交 88%

TICoder: A Repository-Level Code Generation Framework with Test-Driven Planning and Implementation-Aware Reuse

TICoder: 一种具有测试驱动规划和实现感知复用的仓库级代码生成框架

Siyu Nan, Yaling Luo, Jian Wang, Neng Zhang, Bing Li

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE

AI总结 提出TICoder框架,通过测试驱动迭代规划机制和实现感知代码复用策略,解决仓库级代码生成中的依赖和上下文限制问题,在多个基准上平均提升11.52%。

Comments 11 pages

详情
AI中文摘要

使用大型语言模型(LLMs)进行仓库级代码生成仍然具有挑战性,主要由于复杂的依赖关系和有限的上下文窗口。最近的方法采用检索增强生成(RAG)和规划机制来重用仓库中潜在的被调用函数。然而,这些方法通常存在两个局限性:规划过程中缺乏测试驱动的行为指导,以及在重用过程中忽略了仓库代码中嵌入的实现逻辑。因此,生成的计划可能不符合预期行为,检索到的函数可能无法有效重用。在本文中,我们提出了TICoder,一种新颖的仓库级代码生成框架,改进了规划和重用。TICoder引入了一种测试驱动的迭代规划机制,利用测试用例作为行为规范来细化实现步骤。此外,TICoder采用了一种实现感知的代码复用策略,通过双视图相似性检索潜在的被调用函数,该相似性捕获了功能和实现两个方面。然后,我们通过结合基于结构的聚类和基于困惑度的过滤的两阶段选择策略,识别相关的使用模式。我们在广泛使用的仓库级代码生成基准上使用各种LLMs进行了大量实验。实验结果表明,TICoder优于最先进(SOTA)方法,平均提升11.52%。

英文摘要

Repository-level code generation with Large Language Models (LLMs) remains challenging, primarily due to complex dependencies and limited context windows. Recent approaches adopt retrieval-augmented generation (RAG) and the planning mechanism to reuse potential callee functions in the repository. However, these approaches often suffer from two limitations: lack of test-driven behavioral guidance during planning and overlooking the implementation logic embedded in repository code during reuse. As a result, generated plans may not align with expected behaviors, and retrieved functions may not be effectively reused. In this paper, we propose TICoder, a novel repository-level code generation framework that improves both planning and reuse. TICoder introduces a test-driven iterative planning mechanism that leverages test cases as behavioral specifications to refine implementation steps. Furthermore, TICoder employs an implementation-aware code reuse strategy, which retrieves potential callee functions using a dual-view similarity that captures both functional and implementation aspects. We then identify relevant usage patterns through a dual-stage selection strategy, combining structure-based clustering and perplexity-based filtering. We conduct extensive experiments on widely used repository-level code generation benchmarks with various LLMs. Experimental results demonstrate that TICoder outperforms state-of-the-art (SOTA) methods, achieving an average improvement of 11.52%.

URL PDF HTML 收藏
2602.11671 2026-02-13 cs.SE 88%

Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond

不要将代码视为自然语言:对仓库级代码生成及更广泛领域的启示

Minh Le-Anh, Huyen Nguyen, Khanh An Tran, Nam Le Hai, Linh Ngo Van, Nghi D. Q. Bui, Bach Le

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE

AI总结 Hydra通过结构化代码生成框架提升仓库级代码生成性能,超越现有方法并实现更高效依赖检索。

Comments Accepted to FSE 2026

详情
AI中文摘要

大型语言模型用于代码(CodeLLMs)在独立的代码补全和生成任务中表现出色,有时甚至超越人类表现,但在仓库级设置中效果下降,因为需要跨文件依赖和结构上下文。现有的检索增强生成(RAG)方法通常借鉴自然语言处理的策略,依赖基于分块的索引和相似性检索。分块导致代码单元之间的连贯性丧失,并忽略了结构关系,而基于相似性的方法经常遗漏功能相关依赖,如辅助函数、类或全局变量。为了解决这些限制,我们提出了Hydra,一个仓库级代码生成框架,将代码视为结构化的代码而非自然语言。我们的方法引入(i)一种结构感知的索引策略,将仓库表示为函数、类和变量的层次树,保留代码结构和依赖关系;(ii)一种轻量级的依赖感知检索器(DAR),明确识别和检索目标函数所需的真实依赖;(iii)一种混合检索机制,结合DAR和基于相似性的检索,提供必要的构建块和实用使用示例。在挑战性的DevEval和RepoExec基准测试中,广泛实验表明Hydra在开源和闭源CodeLLMs上均达到最先进的性能。值得注意的是,我们的方法在仓库级代码生成中建立了新的状态,比最强基线在Pass@1上高出超过5%,甚至使较小的模型能够匹配或超越依赖现有检索器的更大模型的性能。

英文摘要

Large language models for code (CodeLLMs) have demonstrated remarkable success in standalone code completion and generation, sometimes even surpassing human performance, yet their effectiveness diminishes in repository-level settings where cross-file dependencies and structural context are essential. Existing Retrieval-Augmented Generation (RAG) approaches often borrow strategies from NLP, relying on chunking-based indexing and similarity-based retrieval. Chunking results in the loss of coherence between code units and overlooks structural relationships, while similarity-driven methods frequently miss functionally relevant dependencies such as helper functions, classes, or global variables. To address these limitations, we present Hydra, a repository-level code generation framework that treats code as structured code rather than natural language. Our approach introduces (i) a structure-aware indexing strategy that represents repositories as hierarchical trees of functions, classes, and variables, preserving code structure and dependencies, (ii) a lightweight dependency-aware retriever (DAR) that explicitly identifies and retrieves the true dependencies required by a target function, and (iii) a hybrid retrieval mechanism that combines DAR with similarity-based retrieval to provide both essential building blocks and practical usage examples. Extensive experiments on the challenging DevEval and RepoExec benchmarks, both requiring function implementation from real-world repositories with complex large repository context, show that Hydra achieves state-of-the-art performance across open- and closed-source CodeLLMs. Notably, our method establishes a new state of the art in repository-level code generation, surpassing strongest baseline by over 5% in Pass@1 and even enabling smaller models to match or exceed the performance of much larger ones that rely on existing retrievers.

URL PDF HTML 收藏
2601.02868 2026-01-07 cs.SE 88%

CodeMEM: AST-Guided Adaptive Memory for Repository-Level Iterative Code Generation

CodeMEM: 基于AST的适应性内存用于仓库级迭代代码生成

Peiding Wang, Li Zhang, Fang Liu, Chongyang Tao, Yinghao Zhu

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE

AI总结 CodeMEM通过基于AST的动态内存管理,提升仓库级迭代代码生成的指令遵循能力与效率。

Comments preprint

详情
AI中文摘要

大型语言模型(LLMs)通过交互式协作显著提高了仓库级代码生成的开发人员生产力。然而,随着交互的进行,必须持续保存和更新仓库上下文以整合新验证的信息。同时,扩展的会话历史增加了认知负担,常常导致遗忘和重新引入先前解决的错误。现有内存管理方法显示出潜力,但受限于以自然语言为中心的表示。为克服这些限制,我们提出了CodeMEM,一种针对仓库级迭代代码生成定制的基于AST的动态内存管理系统。具体而言,CodeMEM引入了Code Context Memory组件,通过AST引导的LLM操作动态维护和更新仓库上下文,以及Code Session Memory,构建以代码为中心的交互历史表示,并通过基于AST的分析显式检测并缓解遗忘。在指令遵循基准CodeIF-Bench和代码生成基准CoderEval上的实验结果表明,CodeMEM实现了最先进的性能,提高了当前轮次的指令遵循能力12.2%,提高了会话级别的指令遵循能力11.5%,并减少了2-3次交互轮次,同时保持了具有竞争力的推理延迟和令牌效率。

英文摘要

Large language models (LLMs) substantially enhance developer productivity in repository-level code generation through interactive collaboration. However, as interactions progress, repository context must be continuously preserved and updated to integrate newly validated information. Meanwhile, the expanding session history increases cognitive burden, often leading to forgetting and the reintroduction of previously resolved errors. Existing memory management approaches show promise but remain limited by natural language-centric representations. To overcome these limitations, we propose CodeMEM, an AST-guided dynamic memory management system tailored for repository-level iterative code generation. Specifically, CodeMEM introduces the Code Context Memory component that dynamically maintains and updates repository context through AST-guided LLM operations, along with the Code Session Memory that constructs a code-centric representation of interaction history and explicitly detects and mitigates forgetting through AST-based analysis. Experimental results on the instruction-following benchmark CodeIF-Bench and the code generation benchmark CoderEval demonstrate that CodeMEM achieves state-of-the-art performance, improving instruction following by 12.2% for the current turn and 11.5% for the session level, and reducing interaction rounds by 2-3, while maintaining competitive inference latency and token efficiency.

URL PDF HTML 收藏
2507.14791 2025-11-04 cs.SE 88%

RepoScope: Leveraging Call Chain-Aware Multi-View Context for Repository-Level Code Generation

Yang Liu, Li Zhang, Fang Liu, Zhuohang Wang, Donglin Wei, Zhishuo Yang, Kechi Zhang, Jia Li, Lin Shi

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE

Comments Accepted by ICSE 2026

详情
英文摘要

Repository-level code generation aims to generate code within the context of a specified repository. Existing approaches typically employ retrieval-augmented generation (RAG) techniques to provide LLMs with relevant contextual information extracted from the repository. However, these approaches often struggle with effectively identifying truly relevant contexts that capture the rich semantics of the repository, and their contextual perspectives remains narrow. Moreover, most approaches fail to account for the structural relationships in the retrieved code during prompt construction, hindering the LLM's ability to accurately interpret the context. To address these issues, we propose RepoScope, which leverages call chain-aware multi-view context for repository-level code generation. RepoScope constructs a Repository Structural Semantic Graph (RSSG) and retrieves a comprehensive four-view context, integrating both structural and similarity-based contexts. We propose a novel call chain prediction method that utilizes the repository's structural semantics to improve the identification of callees in the target function. Additionally, we present a structure-preserving serialization algorithm for prompt construction, ensuring the coherence of the context for the LLM. Notably, RepoScope relies solely on static analysis, eliminating the need for additional training or multiple LLM queries, thus ensuring both efficiency and generalizability. Evaluation on widely-used repository-level code generation benchmarks (CoderEval and DevEval) demonstrates that RepoScope outperforms state-of-the-art methods, achieving up to a 36.35% relative improvement in pass@1 scores. Further experiments emphasize RepoScope's potential to improve code generation across different tasks and its ability to integrate effectively with existing approaches.

URL PDF HTML 收藏
2502.18793 2025-08-27 cs.SE 88%

SolEval: Benchmarking Large Language Models for Repository-level Solidity Code Generation

Zhiyuan Peng, Xin Yin, Rui Qian, Peiqin Lin, Yongkang Liu, Hao Zhang, Chenhao Ying, Yuan Luo

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE

Comments Accepted By EMNLP'25-Main

详情
英文摘要

Large language models (LLMs) have transformed code generation. However, most existing approaches focus on mainstream languages such as Python and Java, neglecting the Solidity language, the predominant programming language for Ethereum smart contracts. Due to the lack of adequate benchmarks for Solidity, LLMs' ability to generate secure, cost-effective smart contracts remains unexplored. To fill this gap, we construct SolEval, the first repository-level benchmark designed for Solidity smart contract generation, to evaluate the performance of LLMs on Solidity. SolEval consists of 1,507 samples from 28 different repositories, covering 6 popular domains, providing LLMs with a comprehensive evaluation benchmark. Unlike the existing Solidity benchmark, SolEval not only includes complex function calls but also reflects the real-world complexity of the Ethereum ecosystem by incorporating Gas@k and Vul@k. We evaluate 16 LLMs on SolEval, and our results show that the best-performing LLM achieves only 26.29% Pass@10, highlighting substantial room for improvement in Solidity code generation by LLMs. Additionally, we conduct supervised fine-tuning (SFT) on Qwen-7B using SolEval, resulting in a significant performance improvement, with Pass@5 increasing from 16.67% to 58.33%, demonstrating the effectiveness of fine-tuning LLMs on our benchmark. We release our data and code at https://github.com/pzy2000/SolEval.

URL PDF HTML 收藏
2312.05772 2024-10-29 cs.SE 88%

A^3-CodGen: A Repository-Level Code Generation Framework for Code Reuse with Local-Aware, Global-Aware, and Third-Party-Library-Aware

Dianshu Liao, Shidong Pan, Xiaoyu Sun, Xiaoxue Ren, Qing Huang, Zhenchang Xing, Huan Jin, Qinying Li

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE

详情
英文摘要

LLM-based code generation tools are essential to help developers in the software development process. Existing tools often disconnect with the working context, i.e., the code repository, causing the generated code to be not similar to human developers. In this paper, we propose a novel code generation framework, dubbed A^3-CodGen, to harness information within the code repository to generate code with fewer potential logical errors, code redundancy, and library-induced compatibility issues. We identify three types of representative information for the code repository: local-aware information from the current code file, global-aware information from other code files, and third-party-library information. Results demonstrate that by adopting the A^3-CodGen framework, we successfully extract, fuse, and feed code repository information into the LLM, generating more accurate, efficient, and highly reusable code. The effectiveness of our framework is further underscored by generating code with a higher reuse rate, compared to human developers. This research contributes significantly to the field of code generation, providing developers with a more powerful tool to address the evolving demands in software development in practice.

URL PDF HTML 收藏
2409.03267 2024-09-06 cs.SE 88%

No Man is an Island: Towards Fully Automatic Programming by Code Search, Code Generation and Program Repair

Quanjun Zhang, Chunrong Fang, Ye Shang, Tongke Zhang, Shengcheng Yu, Zhenyu Chen

专题命中 代码生成 :code generation(title,abstract);program repair(title,abstract);分类 cs.SE

详情
英文摘要

Automatic programming attempts to minimize human intervention in the generation of executable code, and has been a long-standing challenge in the software engineering community. To advance automatic programming, researchers are focusing on three primary directions: (1) code search that reuses existing code snippets from external databases; (2) code generation that produces new code snippets from natural language; and (3) program repair that refines existing code snippets by fixing detected bugs. Despite significant advancements, the effectiveness of state-of-the-art techniques is still limited, such as the usability of searched code and the correctness of generated code. Motivated by the real-world programming process, where developers usually use various external tools to aid their coding processes, such as code search engines and code testing tools, in this work, we propose \toolname{}, an automatic programming framework that leverages recent large language models (LLMs) to integrate the three research areas to address their inherent limitations. In particular, our framework first leverages different code search strategies to retrieve similar code snippets, which are then used to further guide the code generation process of LLMs. Our framework further validates the quality of generated code by compilers and test cases, and constructs repair prompts to query LLMs for generating correct patches. We conduct preliminary experiments to demonstrate the potential of our framework, \eg helping CodeLlama solve 267 programming problems with an improvement of 62.53\%. As a generic framework, \toolname{} can integrate various code search, generation, and repair tools, combining these three research areas together for the first time. More importantly, it demonstrates the potential of using traditional SE tools to enhance the usability of LLMs in automatic programming.

URL PDF HTML 收藏
2401.06391 2024-07-19 cs.SE 88%

Teaching Code LLMs to Use Autocompletion Tools in Repository-Level Code Generation

Chong Wang, Jian Zhang, Yebo Feng, Tianlin Li, Weisong Sun, Yang Liu, Xin Peng

专题命中 代码生成 :code generation(title,abstract);repository(title,abstract);分类 cs.SE

详情
英文摘要

Code large language models (LLMs) face limitations in repository-level code generation due to their lack of awareness of repository-level dependencies (e.g., user-defined attributes), resulting in dependency errors such as undefined-variable and no-member errors. In this work, we introduce ToolGen, an approach that integrates autocompletion tools into the code LLM generation process to address these dependencies. ToolGen comprises two main phases: Trigger Insertion and Model Fine-tuning (Offline), and Tool-integrated Code Generation (Online). During the offline phase, ToolGen augments functions within a given code corpus with a special mark token, indicating positions to trigger autocompletion tools. These augmented functions, along with their corresponding docstrings, are then used to fine-tune a selected code LLM. In the online phase, ToolGen iteratively generates functions by predicting tokens step-by-step using the fine-tuned LLM. Whenever a mark token is encountered, ToolGen invokes the autocompletion tool to suggest code completions and selects the most appropriate one. We conduct comprehensive experiments to evaluate ToolGen's effectiveness in repository-level code generation. To facilitate this evaluation, we create a benchmark comprising 671 real-world code repositories and introduce two new dependency-based metrics: Dependency Coverage and Static Validity Rate. The results demonstrate that ToolGen significantly improves Dependency Coverage by 31.4% to 39.1% and Static Validity Rate by 44.9% to 57.7% across the three LLMs, while maintaining competitive or improved performance in widely recognized similarity metrics such as BLEU-4, CodeBLEU, Edit Similarity, and Exact Match. On the CoderEval dataset, ToolGen achieves improvements of 40.0% and 25.0% in Pass@1 for CodeT5 and CodeLlama, respectively.

URL PDF HTML 收藏
1903.11765 2019-03-29 cs.PL 88%

Connecting Program Synthesis and Reachability: Automatic Program Repair using Test-Input Generation

ThanhVu Nguyen, Westley Weimer, Deepak Kapur, Stephanie Forrest

专题命中 代码生成 :program repair(title,abstract);program synthesis(title,abstract);分类 cs.PL

Journal ref Tools and Algorithms for the Construction and Analysis of Systems (TACAS), pages 301--318. Springer, 2017

详情
英文摘要

We prove that certain formulations of program synthesis and reachability are equivalent. Specifically, our constructive proof shows the reductions between the template-based synthesis problem, which generates a program in a pre-specified form, and the reachability problem, which decides the reachability of a program location. This establishes a link between the two research fields and allows for the transfer of techniques and results between them. To demonstrate the equivalence, we develop a program repair prototype using reachability tools. We transform a buggy program and its required specification into a specific program containing a location reachable only when the original program can be repaired, and then apply an off-the-shelf test-input generation tool on the transformed program to find test values to reach the desired location. Those test values correspond to repairs for the original programm. Preliminary results suggest that our approach compares favorably to other repair methods.

URL PDF HTML 收藏
2402.09126 2024-04-24 cs.DC cs.AI cs.CL cs.LG cs.SE 87%

MPIrigen: MPI Code Generation through Domain-Specific Language Models

Nadav Schneider, Niranjan Hasabnis, Vy A. Vo, Tal Kadosh, Neva Krien, Mihai Capotă, Guy Tamir, Ted Willke, Nesreen Ahmed, Yuval Pinter, Timothy Mattson, Gal Oren

专题命中 代码生成 :code generation(title,abstract);code model(abstract);repository(abstract);分类 cs.SE、cs.CL、cs.AI

详情
英文摘要

The imperative need to scale computation across numerous nodes highlights the significance of efficient parallel computing, particularly in the realm of Message Passing Interface (MPI) integration. The challenging parallel programming task of generating MPI-based parallel programs has remained unexplored. This study first investigates the performance of state-of-the-art language models in generating MPI-based parallel programs. Findings reveal that widely used models such as GPT-3.5 and PolyCoder (specialized multi-lingual code models) exhibit notable performance degradation, when generating MPI-based programs compared to general-purpose programs. In contrast, domain-specific models such as MonoCoder, which are pretrained on MPI-related programming languages of C and C++, outperform larger models. Subsequently, we introduce a dedicated downstream task of MPI-based program generation by fine-tuning MonoCoder on HPCorpusMPI. We call the resulting model as MPIrigen. We propose an innovative preprocessing for completion only after observing the whole code, thus enabling better completion with a wider context. Comparative analysis against GPT-3.5 zero-shot performance, using a novel HPC-oriented evaluation method, demonstrates that MPIrigen excels in generating accurate MPI functions up to 0.8 accuracy in location and function predictions, and with more than 0.9 accuracy for argument predictions. The success of this tailored solution underscores the importance of domain-specific fine-tuning in optimizing language models for parallel computing code generation, paving the way for a new generation of automatic parallelization tools. The sources of this work are available at our GitHub MPIrigen repository: https://github.com/Scientific-Computing-Lab-NRCN/MPI-rigen

URL PDF HTML 收藏
2409.10737 2024-11-06 cs.SE cs.AI 86%

AutoSafeCoder: A Multi-Agent Framework for Securing LLM Code Generation through Static Analysis and Fuzz Testing

Ana Nunez, Nafis Tanveer Islam, Sumit Kumar Jha, Peyman Najafirad

专题命中 代码生成 :code generation(title,abstract);coding agent(abstract);program synthesis(abstract);分类 cs.SE、cs.AI

Comments Accepted to NeurIPS 2024 Workshop on Safe & Trustworthy Agents

详情
英文摘要

Recent advancements in automatic code generation using large language models (LLMs) have brought us closer to fully automated secure software development. However, existing approaches often rely on a single agent for code generation, which struggles to produce secure, vulnerability-free code. Traditional program synthesis with LLMs has primarily focused on functional correctness, often neglecting critical dynamic security implications that happen during runtime. To address these challenges, we propose AutoSafeCoder, a multi-agent framework that leverages LLM-driven agents for code generation, vulnerability analysis, and security enhancement through continuous collaboration. The framework consists of three agents: a Coding Agent responsible for code generation, a Static Analyzer Agent identifying vulnerabilities, and a Fuzzing Agent performing dynamic testing using a mutation-based fuzzing approach to detect runtime errors. Our contribution focuses on ensuring the safety of multi-agent code generation by integrating dynamic and static testing in an iterative process during code generation by LLM that improves security. Experiments using the SecurityEval dataset demonstrate a 13% reduction in code vulnerabilities compared to baseline LLMs, with no compromise in functionality.

URL PDF HTML 收藏