# Model-Driven Quantum Code Generation Using Large Language Models and Retrieval-Augmented Generation

**Authors:** Nazanin Siavash, Armin Moin

arXiv: 2508.21097 · 2025-12-03

## TL;DR

This paper explores using Large Language Models with Retrieval-Augmented Generation to improve quantum code generation from UML models, demonstrating significant accuracy improvements and proposing future research directions.

## Contribution

It introduces a novel approach combining LLMs and RAG pipelines for quantum code generation from UML models, with experimental validation showing enhanced code accuracy.

## Key findings

- Prompt engineering improves CodeBLEU scores by up to four times.
- Using public GitHub code samples enhances code generation quality.
- Future work includes deploying models for code transpilation and model-to-model transformations.

## Abstract

This paper introduces a novel research direction for model-to-text/code transformations by leveraging Large Language Models (LLMs) that can be enhanced with Retrieval-Augmented Generation (RAG) pipelines. The focus is on quantum and hybrid quantum-classical software systems, where model-driven approaches can help reduce the costs and mitigate the risks associated with the heterogeneous platform landscape and lack of developers' skills. We validate one of the proposed ideas regarding generating code out of UML model instances of software systems. This Python code uses a well-established library, called Qiskit, to execute on gate-based or circuit-based quantum computers. The RAG pipeline that we deploy incorporates sample Qiskit code from public GitHub repositories. Experimental results show that well-engineered prompts can improve CodeBLEU scores by up to a factor of four, yielding more accurate and consistent quantum code. However, the proposed research direction can go beyond this through further investigation in the future by conducting experiments to address our other research questions and ideas proposed here, such as deploying software system model instances as the source of information in the RAG pipelines, or deploying LLMs for code-to-code transformations, for instance, for transpilation use cases.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/2508.21097/full.md

## Figures

3 figures with captions in the complete paper: https://tomesphere.com/paper/2508.21097/full.md

## References

34 references — full list in the complete paper: https://tomesphere.com/paper/2508.21097/full.md

---
Source: https://tomesphere.com/paper/2508.21097