NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Hybrid-NL2SVA: Integrating RAG and Finetuning for LLM-based NL2SVA

Weihua Xiao, Derek Ekberg, Siddharth Garg, Ramesh Karri · DOI

Abstract

SystemVerilog Assertions (SVAs) are essential for hardware verification but are notoriously difficult to write due to their complex temporal logic. While Large Language Models (LLMs) show promise in code generation, they often struggle with the specific nuances of SVA syntax and semantics. This paper presents Hybrid-NL2SVA, a framework that enhances LLM performance on the Natural Language to SVA (NL2SVA) task. By integrating a customized Retrieval-Augmented Generation (RAG) pipeline with prompt-guided fine-tuning, the researchers achieved a 59% improvement in functional accuracy.

Introduction: The SVA Bottleneck

In modern chip design, SVAs serve as critical checkpoints to ensure functional correctness. However, the manual creation of these assertions is a significant bottleneck. Engineers must translate high-level natural language requirements into precise temporal logic, a process prone to errors and misunderstandings.

LLMs like GPT-4 offer a potential solution, yet they face three primary hurdles in NL2SVA:

  1. Temporal Nuance: Difficulty distinguishing between immediate (|->) and non-overlapping (|=>) implications.
  2. Context Loss: Standard RAG techniques often fragment technical documentation, losing the link between code examples and their explanations.
  3. Hallucinations: The generation of syntactically valid but logically incorrect assertions.

The Hybrid-NL2SVA Framework

To address these challenges, Hybrid-NL2SVA employs a two-pronged strategy: a domain-specific RAG pipeline and a structured fine-tuning approach.

The overall Hybrid-NL2SVA architecture, showing the flow from assertion specification to refined LLM output.

1. Customized RAG for Hardware Verification

The framework moves beyond generic RAG by implementing three specialized components:

  • Dynamic Splitting: This technique identifies code blocks within SystemVerilog textbooks and groups them with adjacent explanatory text. This "code-centric" chunking ensures that the semantic context of examples is preserved during retrieval.
  • Hybrid Retrieval: Unlike standard vector search, this system uses a dual-path approach. It combines general semantic similarity with explicit keyword extraction (e.g., "rising edge") to retrieve precise documentation for SVA operators.
  • Operator-based Rechecking: A post-generation phase where the LLM reviews the operators it used against their official definitions, allowing for automated self-correction.
The detailed Hybrid Retrieval process, illustrating how keywords and SVA operators are extracted to provide relevant context.

2. Prompt-Guided Fine-tuning

The authors found that simply providing input-output pairs was insufficient for complex logic. Instead, they developed a "prompt-guided" dataset. This dataset includes step-by-step derivation traces that teach the model to:

  1. Identify the top-level property operator.
  2. Decompose the English description into functional fragments.
  3. Translate these fragments into individual sequences.
  4. Synthesize the final assertion.

Evaluation and Results

The framework was evaluated using a comprehensive dataset of 40 Verilog designs and 229 human-annotated SVAs. Performance was measured using "Functionality Match" (FM), verified via formal tools like Cadence JasperGold.

  • GPT-4o-mini: The customized RAG framework improved functional correctness by 58.42% over the base model.
  • Qwen2.5-Coder-7B: When fine-tuned with the prompt-guided dataset and integrated with Hybrid Retrieval, this 7B model saw a 59.05% improvement in FM.

These results highlight that teaching the process of derivation is more impactful than simply increasing the volume of training data, especially for smaller models.

Conclusion

Hybrid-NL2SVA demonstrates that a combination of context-aware retrieval and process-oriented fine-tuning can significantly bridge the gap between natural language and formal hardware assertions. Future work will focus on handling more complex multi-cycle relationships and integrating these tools directly into hardware development environments.

Summary updated

BibTeX
@inproceedings{xiao2025hybrid,
  author = {Weihua Xiao and Derek Ekberg and Siddharth Garg and Ramesh Karri},
  title = {{Hybrid-NL2SVA: Integrating RAG and Finetuning for LLM-based NL2SVA}},
  booktitle = {MLCAD},
  year = {2025},
  doi = {10.1109/mlcad65511.2025.11189208},
}
Figure