arXiv:2507.19562quant-phcs.AI2025-07中稿 · QCE 2025被引 9

轻量级本地量子编程助手,让设备端生成正确代码

PennyCoder: Efficient Domain-Specific LLMs for PennyLane-Based Quantum Code Generation

  • 用LoRA微调LLaMA 3.1-8B模型,专攻PennyLane语法与逻辑
  • 在量子编程数据集上准确率达44.3%,显著优于基线模型
  • 适合需要隐私保护和低延迟的嵌入式量子开发场景

随着对强大量子编程框架的需求增长,现有基于大语言模型(LLM)的量子代码助手严重依赖远程API,带来隐私、延迟和高昂使用成本问题。为此,我们提出PennyCoder,一种专为本地和嵌入式部署设计的轻量级量子代码生成框架,实现无需外部API的设备端量子编程辅助。PennyCoder基于经过参数高效低秩适应(LoRA)微调的LLaMA 3.1-8B模型,并通过领域特定指令微调优化了PennyLane中的量子编程语法与计算逻辑,涵盖量子机器学习与量子强化学习任务。不同于以往聚焦云端生成的研究,本方法强调设备原生可操作性,同时保持高模型效能。我们在全面的量子编程数据集上进行严格评估,微调模型准确率达到44.3%(基线模型为33.7%,RAG增强基线为40.1%),显著提升代码功能性正确性。

原文摘要 · Abstract (English)

The growing demand for robust quantum programming frameworks has unveiled a critical limitation: current large language model (LLM) based quantum code assistants heavily rely on remote APIs, introducing challenges related to privacy, latency, and excessive usage costs. Addressing this gap, we propose PennyCoder, a novel lightweight framework for quantum code generation, explicitly designed for local and embedded deployment to enable on-device quantum programming assistance without external API dependence. PennyCoder leverages a fine-tuned version of the LLaMA 3.1-8B model, adapted through parameter-efficient Low-Rank Adaptation (LoRA) techniques combined with domain-specific instruction tuning optimized for the specialized syntax and computational logic of quantum programming in PennyLane, including tasks in quantum machine learning and quantum reinforcement learning. Unlike prior work focused on cloud-based quantum code generation, our approach emphasizes device-native operability while maintaining high model efficacy. We rigorously evaluated PennyCoder over a comprehensive quantum programming dataset, achieving 44.3% accuracy with our fine-tuned model (compared to 33.7% for the base LLaMA 3.1-8B and 40.1% for the RAG-augmented baseline), demonstrating a significant improvement in functional correctness.

量子编程轻量模型本地部署LoRA微调

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