VerilogCL:一种用于鲁棒LLM基于Verilog生成的对比学习框架
VerilogCL: A Contrastive Learning Framework for Robust LLM-Based Verilog Generation
AI总结:
本文提出VerilogCL框架,通过对比学习和主动错误筛查提升Verilog代码生成的鲁棒性,实验表明其在编译成功率和功能正确性上优于现有基线。
摘要:
大型语言模型(LLMs)最近在软件代码生成中取得了强劲表现,但将其应用于硬件描述语言(HDLs)如Verilog仍具挑战性,因为高质量训练数据相对稀缺。在实践中,LLM生成的Verilog代码常包含语法或结构错误,导致编译失败或功能不正确,限制其在硬件设计工作流中的可靠性。本文提出VerilogCL,一种集成框架,通过对比学习和主动错误筛查明确学习正确与错误RTL之间的边界,以增强Verilog代码生成。我们的方法引入最小错误数据增强,生成正确RTL与轻微扰动的错误RTL的配对训练样本,以教导模型识别正确与错误代码的细微差异。然后应用对比学习在表示空间中学习更清晰的有效性边界,提高正确与错误RTL代码的分离度。此外,我们引入一个主动筛查模块,结合语义嵌入与token级不确定性特征,在生成过程中过滤低置信度候选。在公开基准测试(包括VerilogEval和RTLLM)上,实验表明我们的7B参数模型在编译成功率和功能正确性上均优于评估的开源、Verilog专用和商业基线。
英文摘要:
Large Language Models (LLMs) have recently achieved strong performance in software code generation. However, applying them to hardware description languages (HDLs), such as Verilog, remains challenging because high-quality training data are relatively scarce. In practice, LLM-generated Verilog often contains syntactic or structural errors that either cause compilation failures or produce functionally incorrect designs, which limit its reliability in hardware design workflows. In this work, we propose VerilogCL, an integrated framework that enhances Verilog code generation by explicitly learning the boundary between correct and erroneous RTL through contrastive learning and proactive error screening. Our approach introduces minimal-error data augmentation, generating paired training samples of correct RTL and minimally perturbed erroneous RTL to teach the model to recognize fine-grained distinctions between correct and erroneous code. We then apply contrastive learning to learn a clearer validity boundary in the representation space, improving the separation between correct and erroneous RTL code. In addition, we introduce a proactive screening module that combines semantic embeddings with token-level uncertainty features to filter low-confidence candidates during generation. Experiments on public benchmarks, including VerilogEval and RTLLM, show that our 7B-parameter model outperforms the evaluated open-source, Verilog-specialized, and commercial baselines in both compilation success rate and functional correctness.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。