通过关注高不确定性代码片段,提升大模型生成可靠硬件代码的能力
EARL: Entropy-Aware RL Alignment of LLMs for Reliable RTL Code Generation
- 识别关键控制词作为高熵区域,仅对这些部分进行强化学习更新
- 在VerilogEval和RTLLM上功能通过率提升最高达14.7%
- 适合需要生成正确硬件逻辑的AI辅助设计人员
大语言模型在自然语言驱动的寄存器传输级(RTL)代码生成中展现出巨大潜力,但实际应用中仍存在语法错误、功能幻觉及与设计意图偏差等问题。基于可验证奖励的强化学习(RLVR)可通过可执行且形式可验证的信号改善对齐。然而,在长而结构化的RTL代码中,并非所有标记都同等影响功能正确性,若对全部标记均匀传播梯度,会稀释学习信号。我们对RTL生成中的熵分析发现,仅有少量标记(如always、if、assign、posedge)具有高不确定性并显著影响控制流与模块结构。为此,我们提出熵感知强化学习框架EARL,利用可验证奖励进行策略优化,并引入熵引导的选择性更新机制,仅对高熵标记施加策略梯度。该方法保持训练稳定性,聚焦于代码中功能关键区域。在VerilogEval和RTLLM上的实验表明,相比现有基线,EARL将功能通过率提升最高达14.7%,同时减少无效更新,增强训练稳定性。结果表明,聚焦于高不确定性关键标记,可实现更可靠、精准的策略改进。
原文摘要 · Abstract (English)
Recent advances in large language models (LLMs) have demonstrated significant potential in hardware design automation, particularly in using natural language to synthesize Register-Transfer Level (RTL) code. Despite this progress, a gap remains between model capability and the demands of real-world RTL design, including syntax errors, functional hallucinations, and weak alignment to designer intent. Reinforcement Learning with Verifiable Rewards (RLVR) offers a promising approach to bridge this gap, as hardware provides executable and formally checkable signals that can be used to further align model outputs with design intent. However, in long, structured RTL code sequences, not all tokens contribute equally to functional correctness, and naïvely spreading gradients across all tokens dilutes learning signals. A key insight from our entropy analysis in RTL generation is that only a small fraction of tokens (e.g., always, if, assign, posedge) exhibit high uncertainty and largely influence control flow and module structure. To address these challenges, we present EARL, an Entropy-Aware Reinforcement Learning framework for Verilog generation. EARL performs policy optimization using verifiable reward signals and introduces entropy-guided selective updates that gate policy gradients to high-entropy tokens. This approach preserves training stability and concentrates gradient updates on functionally important regions of code. Our experiments on VerilogEval and RTLLM show that EARL improves functional pass rates over prior LLM baselines by up to 14.7%, while reducing unnecessary updates and improving training stability. These results indicate that focusing RL on critical, high-uncertainty tokens enables more reliable and targeted policy improvement for structured RTL code generation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。