arXiv:2503.02497cs.SEcs.AI2025-03中稿 · IJCNN 2026被引 12

用高质量数据集提升大模型生成量子代码能力

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

  • 构建3347个PennyLane代码样本数据集,含上下文描述
  • 结合RAG技术使大模型代码成功率最高提升至84.8%
  • 适合量子计算与AI融合方向研究者参考

大型语言模型在代码生成和领域推理方面具有强大能力,但在量子软件开发中的应用受限于高质量数据集的缺乏。为此,我们推出名为PennyLang的即用型高质量数据集,包含3,347个来自教材、官方文档和开源仓库的PennyLane专用量子代码样本及上下文描述。贡献包括:(1) 构建并开源PennyLang,专为PennyLane量子编程设计;(2) 提出自动化数据集构建框架,系统化完成采集、标注与格式化以优化下游大模型使用;(3) 在检索增强生成(RAG)流程中对多个开源与商业模型进行基线评估,包括消融实验。使用PennyLang配合RAG显著提升性能:例如Qwen 7B的成功率从无检索时的8.7%升至41.7%,LLaMa 4从78.8%提升至84.8%,同时减少幻觉,提高代码正确性。该工作突破以往以Qiskit为中心的研究,将可复现的AI辅助量子开发方法推广至PennyLane。

原文摘要 · Abstract (English)

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. 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.

量子计算大模型RAG代码生成

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