arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2306.11981cs.SE
收藏

基于人工智能的解决方案链:解析部分代码中的全限定名与修复语法错误

A Chain of AI-based Solutions for Resolving FQNs and Fixing Syntax Errors in Partial Code

Qing Huang, Jiahui Zhu, Zhenchang Xing, Huan Jin, Changjing Wang, Xiwei Xu

AI总结:

针对部分代码因名称未解析和语法错误而无法编译的问题,提出基于大语言模型的PCR-Chain,通过上下文学习解析全限定名并修复语法错误,在Python和Java上超越现有方法,准确率达80.5%。

摘要:

API文档、技术博客和编程问答网站包含大量可在编程任务中复用的部分代码,但这些代码常常因名称未解析和语法错误而无法编译。为了促进部分代码的复用,我们提出了部分代码复用链(PCR-Chain),基于像ChatGPT这样的大型语言模型(LLM),用于解析部分代码中的全限定名(FQNs)并修复最后一公里的语法错误。在方法论上,PCR-Chain由底层的全局级提示架构(结合了三个设计理念:层次化任务分解、提示组合以及基于提示的AI与非AI单元的混合)和局部级提示设计所支撑。在技术上,我们提出了PCR-Chain,它采用上下文学习而非符号化的、昂贵的训练方法。实验结果表明,在动态类型语言(Python)中,PCR-Chain在解析FQNs和修复语法错误方面优于当前最先进(SOTA)的方法,如RING,准确率提升5%。对于静态类型语言(Java),我们的方法在解析非FQNs和修复最后一公里语法错误方面达到了80.5%的高准确率,超越了只能处理最后一公里语法错误的SOTA方法(RING)。单元、模块和PCR-Chain的正确执行证明了提示设计、组合和架构的有效性,并为基于LLM构建软件工程工具、取代传统程序分析方法开辟了可能性。

英文摘要:

API documentation, technical blogs and programming Q&A sites contain numerous partial code that can be reused in programming tasks, but often these code are uncompilable due to unresolved names and syntax errors. To facilitate partial code reuse, we propose the Partial Code Reuse Chain (PCR-Chain) for resolving fully-qualified names (FQNs) and fixing last-mile syntax errors in partial code based on a giant large language model (LLM) like ChatGPT. Methodologically, PCR-Chain is backed up by the underlying global-level prompt architecture (which combines three design ideas: hierarchical task breakdown, prompt composition, and a mix of prompt-based AI and non-AI units) and the local-level prompt design. Technically, we propose PCR-Chain, which employs in-context learning rather than symbolic, costly training methods. Experimental results demonstrate that in dynamically-typed languages (Python), PCR-Chain outperforms current state-of-the-art (SOTA) 5% accuracy like RING. For statically-type languages (Java), our approach achieves high accuracy of 80.5% in resolving both non-FQNs and last-mile syntax errors, surpassing SOTA methods (RING) that can only address last-mile syntax errors. The correct execution of the unit, module, and PCR-Chain demonstrates the effectiveness of the prompt design, composition, and architecture and opens up possibilities for building software engineering tools based on LLMs, replacing traditional program analysis methods.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑