A PennyLane-Centric Dataset to Enhance LLM-based Quantum Code Generation using RAG

Abdul Basit, Nouhaila Innan, Muhammad Haider Asif, Minghao Shao, Muhammad Kashif +2 more
3/4/2025
cs.SEcs.AIquant-ph
benchmark-datasetrag

No confident code implementation found for this paper.

Abstract

Large Language Models (LLMs) offer powerful capabilities in code generation, natural language understanding, and domain-specific reasoning. Their application to quantum software development remains limited, in part because of the lack of high-quality datasets both for LLM training and as dependable knowledge sources.

Show full abstract

To bridge this gap, we introduce \textit{PennyLang}, an off-the-shelf, high-quality dataset of 3,347 PennyLane-specific quantum code samples with contextual descriptions, curated from textbooks, official documentation, and open-source repositories. Our contributions are threefold: (1) the creation and open-source release of PennyLang, a purpose-built dataset for quantum programming with PennyLane; (2) a framework for automated quantum code dataset construction that systematizes curation, annotation, and formatting to maximize downstream LLM usability; and (3) a baseline evaluation of the dataset across multiple open-source and commercial models, including ablation studies, all conducted within a retrieval-augmented generation (RAG) pipeline. Using PennyLang with RAG substantially improves performance: for example, Qwen 7B's success rate rises from 8.7% without retrieval to 41.7% with full-context augmentation, and LLaMa 4 improves from 78.8% to 84.8%, while also reducing hallucinations and enhancing quantum code correctness. Moving beyond Qiskit-focused studies, we bring LLM-based tools and reproducible methods to PennyLane for advancing AI-assisted quantum development.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{basit2025pennylanecentric,
  title  = {A PennyLane-Centric Dataset to Enhance LLM-based Quantum Code Generation using RAG},
  author = {Abdul Basit and Nouhaila Innan and Muhammad Haider Asif and Minghao Shao and Muhammad Kashif and Alberto Marchisio and Muhammad Shafique},
  year   = {2025},
  eprint = {2503.02497},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2503.02497v4}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2503.02497.svg)](https://codeofpaper.com/paper/2503.02497)

Discussion