arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2504.08862cs.SEcs.AI
收藏

RTLRepoCoder:通过微调与检索增强结合实现仓库级RTL代码补全

RTLRepoCoder: Repository-Level RTL Code Completion through the Combination of Fine-Tuning and Retrieval Augmentation

Institute of Computing Technology, Chinese Academy of Sciences(中国科学院计算技术研究所)

Peiyang Wu, Nan Guo, Junliang Lv, Xiao Xiao, Xiaochun Ye

AI总结:

针对现有大语言模型无法处理大规模Verilog仓库级RTL代码补全的问题,提出结合领域微调与检索增强生成的RTLRepoCoder方案,其在公共基准上的编辑相似度和精确匹配率显著超过GPT-4等模型,实现仓库级代码补全突破。

摘要:

作为现代硬件设计的重要组成部分,手动编写寄存器传输级(RTL)代码(如Verilog)通常耗时费力。随着大语言模型(LLMs)的巨大成功,研究人员开始探索利用LLMs生成RTL代码。然而,当前研究主要聚焦于生成简单的单个模块,无法满足现实需求。事实上,由于管理长上下文RTL代码和复杂跨文件依赖的挑战,现有解决方案无法处理实际硬件开发中的大规模Verilog仓库。作为首次专门使LLMs适配大规模RTL开发的尝试,我们提出RTLRepoCoder,这是一种结合特定微调与检索增强生成(RAG)的突破性解决方案,用于仓库级Verilog代码补全。我们使用来自现实世界的开源Verilog仓库以及扩展的上下文大小进行领域特定微调。优化后的RAG系统通过检索相关代码片段提高输入上下文的信息密度。我们针对RAG进行了定制优化,包括嵌入模型、跨文件上下文拆分策略和块大小。我们的解决方案在公共基准上实现了最先进的性能,在编辑相似度和精确匹配率上显著超过GPT-4和先进的领域特定LLMs。全面实验证明了我们方法的显著有效性,并为未来工作提供了见解。

英文摘要:

As an essential part of modern hardware design, manually writing Register Transfer Level (RTL) code such as Verilog is often labor-intensive. Following the tremendous success of large language models (LLMs), researchers have begun to explore utilizing LLMs for generating RTL code. However, current studies primarily focus on generating simple single modules, which can not meet the demands in real world. In fact, due to challenges in managing long-context RTL code and complex cross-file dependencies, existing solutions cannot handle large-scale Verilog repositories in practical hardware development. As the first endeavor to exclusively adapt LLMs for large-scale RTL development, we propose RTLRepoCoder, a groundbreaking solution that incorporates specific fine-tuning and Retrieval-Augmented Generation (RAG) for repository-level Verilog code completion. Open-source Verilog repositories from the real world, along with an extended context size, are used for domain-specific fine-tuning. The optimized RAG system improves the information density of the input context by retrieving relevant code snippets. Tailored optimizations for RAG are carried out, including the embedding model, the cross-file context splitting strategy, and the chunk size. Our solution achieves state-of-the-art performance on public benchmark, significantly surpassing GPT-4 and advanced domain-specific LLMs on Edit Similarity and Exact Match rate. Comprehensive experiments demonstrate the remarkable effectiveness of our approach and offer insights for future work.

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

↑