arXiv:2508.18462cs.LGcs.AI2025-08被引 3

用强化学习提升大模型生成硬件代码的准确性和可靠性。

VERIRL: Boosting the LLM-based Verilog Code Generation via Reinforcement Learning

  • 设计基于回溯重评分的强化学习框架,改善稀疏反馈问题。
  • 在53K高质量数据集上实现91.2%测试通过率,优于现有方法。
  • 适合关注硬件代码生成、大模型微调的研究者和工程师。

近年来,代码生成在软件领域取得显著进展,但硬件描述语言(如Verilog)因并发语义、语法严格性和仿真复杂性仍被忽视。本文提出面向Verilog代码生成的强化学习框架VERIRL。构建了包含53,000条高质量样本的Veribench-53K数据集,涵盖结构化提示、复杂度标签与多样化测试平台。针对奖励信号稀疏噪声问题,提出基于回溯的重评分机制,利用推理路径与迭代优化提升反馈可靠性,支持奖励模型训练。为缓解强化学习微调中的灾难性遗忘与过拟合,引入样本平衡加权策略,依据奖励概率分布自适应调节学习动态。该框架集成于迭代式强化学习流程中,协同优化策略与奖励模型。相比依赖大规模闭源模型蒸馏的CraftRTL及在稀疏反馈下表现不佳的DeepSeek类方法,本方法仅使用更小但高质量的数据集即达成领先性能。在Verilog生成任务中,测试通过率、功能正确性与编译鲁棒性均有显著提升,验证了强化学习在硬件导向代码生成中的潜力。项目开源:https://github.com/omniAI-Lab/VeriRL。

原文摘要 · Abstract (English)

Recent advancements in code generation have shown remarkable success across software domains, yet hardware description languages (HDLs) such as Verilog remain underexplored due to their concurrency semantics, syntactic rigidity, and simulation complexity. In this work, we address these challenges by introducing a reinforcement learning (RL) framework tailored for Verilog code generation. We first construct Veribench-53K, a high-quality dataset curated from over 700K Verilog problems, enriched with structured prompts, complexity labels, and diverse testbenches. To tackle the problem of sparse and noisy reward signals, we propose a Trace-back based Rescore mechanism that leverages reasoning paths and iterative refinement to enhance feedback reliability and support reward model training. Furthermore, to mitigate catastrophic forgetting and overfitting during RL fine-tuning, we introduce a sample-balanced weighting strategy that adaptively balances learning dynamics based on reward-probability distributions. These innovations are integrated into an iterative RL pipeline that co-evolves the policy and reward models. In contrast to recent work such as CraftRTL, which relies on large-scale closed-source model distillation, and DeepSeek-style approaches that struggle with sparse feedback, our method demonstrates superior performance using a smaller but high-quality dataset combined with RL optimization. Experiments on Verilog generation tasks demonstrate state-of-the-art performance, with substantial gains in test pass rate, functional correctness, and compilation robustness. Our findings highlight the potential of RL-driven approaches for structured code generation in hardware-centric domains. VERIRL is publicly available at https://github.com/omniAI-Lab/VeriRL.

代码生成强化学习Verilog

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。