用测试平台反馈训练生成正确硬件代码的AI模型
Insights from Verification: Training a Verilog Generation LLM with Reinforcement Learning with Testbench Feedback
- 通过测试平台反馈构建强化学习信号,让模型生成更可靠的Verilog代码
- 在多个基准上生成正确代码率超越现有方法,最高提升18.3%
- 适合芯片设计自动化与AI辅助硬件开发的研究者使用
大型语言模型在从自然语言描述生成Verilog代码方面表现优异,但确保生成代码的功能正确性仍是重大挑战。本文提出一种将测试平台验证结果融入训练过程的方法,使模型训练目标与硬件设计的核心目标——功能正确性对齐。主要障碍在于缺乏足够配对的验证数据,尤其是与设计说明和代码对应的测试平台。为此,我们构建了自动测试平台生成流程,分解生成步骤并利用Verilog编译器仿真器(VCS)的反馈减少幻觉、保证正确性。随后用测试平台评估生成代码并收集数据用于后续训练,引入验证洞察。方法采用强化学习中的直接偏好优化(DPO),基于测试平台结果训练偏好对,使生成代码趋向功能正确。在VerilogEval-Machine、VerilogEval-Human、RTLLM v1.1、RTLLM v2和VerilogEval v2上的评估显示,本方法持续优于当前最优基线,功能正确率显著提升。所有训练代码、数据和模型已在https://anonymous.4open.science/r/VeriPrefer-E88B开源。
原文摘要 · Abstract (English)
Large language models (LLMs) have shown strong performance in Verilog generation from natural language description. However, ensuring the functional correctness of the generated code remains a significant challenge. This paper introduces a method that integrates verification insights from testbench into the training of Verilog generation LLMs, aligning the training with the fundamental goal of hardware design: functional correctness. The main obstacle in using LLMs for Verilog code generation is the lack of sufficient functional verification data, particularly testbenches paired with design specifications and code. To address this problem, we introduce an automatic testbench generation pipeline that decomposes the process and uses feedback from the Verilog compiler simulator (VCS) to reduce hallucination and ensure correctness. We then use the testbench to evaluate the generated codes and collect them for further training, where verification insights are introduced. Our method applies reinforcement learning (RL), specifically direct preference optimization (DPO), to align Verilog code generation with functional correctness by training preference pairs based on testbench outcomes. In evaluations on VerilogEval-Machine, VerilogEval-Human, RTLLM v1.1, RTLLM v2, and VerilogEval v2, our approach consistently outperforms state-of-the-art baselines in generating functionally correct Verilog code. We open source all training code, data, and models at https://anonymous.4open.science/r/VeriPrefer-E88B.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。