Quantum Computing Program Generation Method and System Based on Retrieval-Augmented Generation Technology

Through mixed search and two-stage generation strategies, the retrieval accuracy, complex reasoning and efficiency problems in quantum computing program generation are solved, efficient and accurate quantum computing program generation is achieved, computing costs are reduced, and high-quality quantum computing program generation tools are provided.

CN119293140BActive Publication Date: 2025-07-22BEIJING ACAD OF QUANTUM INFORMATION SCI +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411151650.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-21
Publication Date
2025-07-22
Estimated Expiration
2044-08-21

AI Technical Summary

Technical Problem

The prior art has problems such as insufficient retrieval accuracy, insufficient complex reasoning capabilities, insufficient knowledge integration and low computing efficiency in quantum computing program generation, making it difficult to generate efficient, accurate and flexible quantum computing programs.

Method used

Using a hybrid search technology of embedded vectors and BM25 algorithms, combining block indexing and full-text search, through a two-stage search generation strategy, a quantum computing experimental plan is formed, a specific program is generated, and an adaptive filtering mechanism is introduced to improve retrieval accuracy and efficiency.

Benefits of technology

It improves the accuracy and efficiency of quantum computing program generation, reduces computing costs, enhances the success rate and availability of complex programs, and provides high-quality quantum computing program generation tools.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119293140B_ABST
    Figure CN119293140B_ABST
Patent Text Reader

Abstract

This application relates to a method and system for generating quantum computing programs based on retrieval-augmented generation technology. The method is applied to a retrieval-augmented generation scheduler and includes: receiving a user's query content; calling a large language model to generate a query statement according to the query content; respectively calling a hybrid retrieval module and the large language model to generate a quantum computing experiment plan according to the query statement, wherein the hybrid retrieval module includes a vector retrieval module and a BM25 retrieval module; and respectively calling the hybrid retrieval module and the large language model according to the quantum computing experiment plan to generate a quantum computing program corresponding to the quantum computing experiment plan. According to the solution of this application, on the one hand, an improved retrieval and filtering mechanism is introduced to improve the accuracy of knowledge matching; on the other hand, the human thinking process is simulated, generating an abstract quantum algorithm idea first and then generating a specific code implementation, which improves the success rate and usability of generating complex quantum algorithms.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of retrieval-augmented generation, and particularly to a method and system for generating quantum computing programs based on retrieval-augmented generation technology. Background Art

[0002] With the rapid development of natural language processing technology, large language models have shown great application potential in various fields. Especially in program generation, large language models can learn a large amount of code data, master the syntax and semantics of programming languages, and then automatically generate corresponding program codes according to natural language descriptions. However, existing large language models still face many challenges when dealing with highly specialized fields, such as quantum computing. Quantum computing involves complex mathematical theories and unique programming paradigms, which are difficult for general large language models to accurately understand and generate quantum computing programs that meet requirements. In addition, the knowledge update speed in the field of quantum computing is fast, and it is also a major problem to enable large language models to quickly adapt to new knowledge. To solve the above problems, researchers have proposed a series of improvement schemes. Among them, Facebook proposed the Retrieval Augmented Generation (RAG) technology in 2020. By combining information retrieval with large language models, the model can use external knowledge to assist the generation process. This provides a new idea for large language models to handle professional field tasks. Based on RAG, subsequent research work further explored how to optimize retrieval and generation strategies to improve the model's performance in specific fields. Some typical improvements include: using more accurate retrieval algorithms to screen relevant knowledge, introducing the chain of thought and multi-round interaction mechanisms to guide the generation process, and using domain ontologies and rule systems to assist semantic understanding. These efforts have promoted the practical development of RAG technology.

[0003] The basic form of RAG is to use vector retrieval methods to find relevant documents, and then add these documents to the context to assist large language models in answering questions or generating content. This method has achieved remarkable results in general fields, but still faces many challenges when applied to highly specialized fields such as quantum computing program generation. In addition to RAG technology, there are several other technical solutions with similar purposes, but they also have their own limitations:

[0004] 1. Pre-trained large language models:

[0005] Although models such as GPT-4 have powerful general reasoning abilities, their knowledge depth and accuracy in professional fields such as quantum computing are still insufficient. They are difficult to adapt to rapidly iterating professional knowledge and perform poorly when dealing with tasks that require in-depth field understanding.

[0006] 2. Domain-specific fine-tuning:

[0007] The performance of the model on specific tasks can be improved by fine-tuning the pre-trained model with domain-specific data. However, this method may lead to catastrophic forgetting, affecting the performance of the model in other domains. At the same time, the fine-tuning process requires a large amount of high-quality domain data and computing resources, making it difficult to adapt to the rapid development of the quantum computing field and the rapid iteration of related code libraries.

[0008] 3. Template-based code generation:

[0009] Program code can be generated according to given specifications through predefined code templates and rules. This method is efficient in dealing with structured and predefined tasks but lacks the flexibility to handle novel problems. In the rapidly evolving field of quantum computing, the cost of maintaining and updating the rule library and template collection is high, and it is difficult to cover all possible use cases.

[0010] Although these existing technologies have their advantages in their respective application scenarios, they all have different degrees of limitations when faced with the specific task of quantum computing program generation. They cannot simultaneously meet the requirements of efficiency, accuracy, flexibility, and scalability. Summary of the Invention

[0011] The inventors have found that when the basic form of the RAG technology is applied to highly specialized fields such as quantum computing program generation, the following technical problems exist:

[0012] 1. Insufficient retrieval accuracy:

[0013] Main problem: The vector retrieval method has low accuracy for the proprietary vocabulary and concepts in the field of quantum computing.

[0014] Technical impact: This results in the retrieved documents may not match the actual requirements, affecting the quality and accuracy of subsequent generation.

[0015] 2. Insufficient complex reasoning ability:

[0016] Main problem: For the quantum computing program generation task that requires multi-step reasoning, the direct generation has a low degree of completion.

[0017] Technical impact: This limits the system's ability to handle complex quantum algorithms and programs and cannot meet the needs of advanced users.

[0018] 3. Insufficient knowledge integration:

[0019] Main problem: It is difficult to effectively integrate the relationship between quantum computing theory knowledge and actual programming implementation.

[0020] Technical impact: This may result in a program that is theoretically correct but has problems in actual implementation, reducing the practicality of the system.

[0021] 4. Low computational efficiency:

[0022] Main problem: Incorporating a large amount of potentially relevant but actually unnecessary information into the context.

[0023] Technical impact: This significantly increases the computational cost and reduces the processing efficiency of the model, especially in scenarios that require real-time responses; longer contexts also affect the performance of LLM currently, resulting in inference errors or hallucinations.

[0024] Therefore, the present invention aims to propose a solution more suitable for quantum computing program generation by innovatively improving the RAG technology and integrating the advantages of other methods.

[0025] According to the first aspect of the present application, there is provided a method for generating a quantum computing program based on retrieval-augmented generation technology, which is applied to a retrieval-augmented generation scheduler, and is characterized by including:

[0026] Receiving the query content of the user;

[0027] Invoking a large language model to generate a query statement according to the query content;

[0028] Invoking a hybrid retrieval module and the large language model respectively according to the query statement to generate a quantum computing experiment plan, wherein the hybrid retrieval module includes a vector retrieval module and a BM25 retrieval module; and

[0029] Invoking the hybrid retrieval module and the large language model respectively according to the quantum computing experiment plan to generate a quantum computing program corresponding to the quantum computing experiment plan.

[0030] According to the second aspect of the present application, there is provided a system for generating a quantum computing program based on retrieval-augmented generation technology, which is characterized by including:

[0031] A retrieval-augmented generation scheduler for executing the method according to any one of claims 1 to 7;

[0032] A hybrid retrieval module, including a vector retrieval module and a BM25 retrieval module, for querying the quantum computing theory document library in the document library according to the query statement input by the user under the scheduling of the retrieval-augmented generation scheduler to obtain a document list of theoretical knowledge, and querying the quantum computing software package document library in the document library according to the generated quantum computing experiment plan to obtain a document list of software tool package knowledge; and

[0033] A large language model is used to generate the quantum computing experiment plan according to the list of documents of the theoretical knowledge under the scheduling of the retrieval-augmented generation scheduler, and generate the quantum computing program according to the quantum computing experiment plan and the list of documents of the software toolkit knowledge.

[0034] According to a third aspect of the present application, there is provided an electronic device, including:

[0035] A processor; and

[0036] A memory storing computer instructions, which when executed by the processor, cause the processor to execute the method described in the first aspect.

[0037] According to a fourth aspect of the present application, there is provided a non-transitory computer storage medium storing a computer program, which when executed by a plurality of processors, causes the processors to execute the method described in the first aspect.

[0038] According to the quantum computing program generation method and system based on the retrieval-augmented generation technology provided by the present application, on the one hand, an improved retrieval and filtering mechanism is introduced to improve the accuracy of knowledge matching; on the other hand, it simulates the human thinking process, first generates an abstract quantum algorithm idea, and then generates a specific code implementation, improving the generation success rate and usability of complex quantum algorithms. Thus, the solution of the present application focuses on applying advanced natural language processing technology to the field of quantum computing, breaking through the limitations of traditional methods, and providing users with a high-quality and interpretable quantum computing program generation tool, which is of great significance for reducing the threshold of quantum programming and accelerating the research and development of quantum algorithms. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application, and those of ordinary skill in the art can also obtain other drawings according to these drawings without exceeding the scope required to be protected by the present application.

[0040] Figure 1 is a schematic diagram of the architecture of a quantum computing program generation system based on the retrieval-augmented generation technology according to an embodiment of the present application.

[0041] Figure 2 is a schematic diagram of the user query response process according to an embodiment of the present application.

[0042] Figure 3 is an example of a front-end interface according to an embodiment of the present application.

[0043] Figure 4It is a flowchart of a method for generating a quantum computing program based on retrieval-augmented generation technology according to an embodiment of the present application.

[0044] Figure 5 It is a flowchart of a method for generating a quantum computing program based on retrieval-augmented generation technology according to another embodiment of the present application.

[0045] Figure 6 It is a structural diagram of an electronic device provided by the present application. Detailed implementation manners

[0046] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present application.

[0047] Overall, the present application innovatively optimizes the retrieval-augmented generation (RAG) technology applied to large language models in the professional field of quantum computing program generation, mainly reflected in the following two aspects:

[0048] First, the present application adopts a hybrid retrieval technology combining embedded vectors and the BM25 algorithm, and obtains relevant documents by combining "chunk indexing and full-text retrieval". Specifically, the text blocks processed by chunking are used as the storage and query objects of the vector database, and vector similarity is used to capture semantic relevance; at the same time, the document tokens are used as the retrieval units of BM25, and keyword matching is used to improve the recall rate. Based on vector retrieval and BM25 retrieval, the system always returns the entire document with more complete semantics to provide more comprehensive context information. In addition, the present application also combines an adaptive result filtering mechanism to dynamically adjust the quantity and sorting of the returned results according to the query statement and document relevance, ensuring a high degree of relevance of the retrieval results. While ensuring effective retrieval, it also controls the quantity of introduced context, avoiding problems such as information overload or introduction of irrelevant information.

[0049] Secondly, the present application designs a two-stage retrieval and generation strategy. In the first stage, theoretical knowledge related to the problem is retrieved and a quantum experiment scheme combining natural language and mathematical expressions is generated; in the second stage, based on this theoretical basis (including the quantum experiment scheme), relevant knowledge of the corresponding quantum computing software toolkit (such as Qiskit or PyQuafu) is retrieved, and a corresponding specific quantum program is generated using a large language model. For example, for a combinatorial optimization problem proposed by a user, in the first stage, the Hamiltonian expression of the transformed quantum system and the corresponding evolution expression of the quantum approximate optimization algorithm (QAOA) are generated, and in the second stage, an executable combinatorial optimization QAOA program is generated by combining the knowledge related to QAOA in the quantum computing software toolkit. The hierarchical generation method proposed in the present application not only ensures efficiency, but also significantly improves the success rate and accuracy of complex quantum algorithm generation by simulating the thinking process of experts in the field.

[0050] Figure 1 is a schematic diagram of the architecture of a quantum computing program generation system based on retrieval-enhanced generation technology according to an embodiment of the present application. As Figure 1 shown, the system includes the following components:

[0051] (1) Front-end interface: for user interaction and result display;

[0052] (2) Data update module: responsible for monitoring changes in the document library and updating the vector database;

[0053] (3) RAG scheduler: responsible for maintaining the request status of the front end and the corresponding response process control;

[0054] (4) Large language model (LLM, Large Language Model) interface: gives a text response to a text task by calling an external large language model API. The external model can be a general large language model or a model fine-tuned in a professional field, which are collectively referred to as "large language models" in the present application;

[0055] (5) Text Embedding (Text Embedding Model) interface: gives an embedding vector of a text block by calling an external text embedding model API. The external model can be a general text embedding model or a model fine-tuned in a professional field;

[0056] (6) Hybrid retrieval module: includes a vector retrieval module and a BM25 retrieval module, performs hybrid retrieval using the vector database and the BM25 document query module, and optionally filters the retrieval results according to the retrieval scores;

[0057] (7) Vector database: Stores the vectorized documents. The vector database needs to rely on text embedding operations to complete the vectorization operations during storage and query processes. In this application, a text embedding interface (API) is used to provide this operation, which means the vector database depends on the text embedding interface;

[0058] (8) BM25 document query module: Implements keyword-based retrieval using the BM25 algorithm;

[0059] (9) Document library: Consists of two parts, which store quantum computing-related theoretical knowledge and specific quantum computing software toolkits respectively, that is, it includes a quantum computing theory document library and a quantum computing software package document library.

[0060] Based on Figure 1 the system shown, according to the data flow and processing process of the system, it generally includes a data update process and a user query response process.

[0061] According to one embodiment, the data update process includes:

[0062] (1) The system uses a file monitoring mechanism to monitor the changes in the computing theory document library and the quantum computing software package document library in the quantum document library in real time

[0063] (2) When detecting document changes, the system triggers the update process:

[0064] · For newly added documents, after block processing, they are vectorized through the Embedding interface and stored in the vector database; among them, the relationship between the document library and the vector database includes: on the one hand, the document library is the data source of the vector database, and during the document update process, the content of the document library is vectorized and stored in the vector database; on the other hand, the vector database (actually the entire hybrid retrieval module) acts as the index of the document library, and matches the corresponding documents in the document library according to a set of query statements.

[0065] · For updated documents, re - perform block processing and vectorization, and update the corresponding records in the vector database;

[0066] · For deleted documents, remove the corresponding records from the vector database.

[0067] (3) Update the BM25 index to ensure that the BM25 document query module uses the latest document content.

[0068] (4) Record the update log, including information such as update time and the number of updated documents, for system maintenance and performance optimization.

[0069] According to one embodiment, as Figure 2 shown, the user query response process includes:

[0070] (1) The user inputs the query content through the front - end interface;

[0071] (2) The user interface sends the conversation context (the conversation context includes the input query content) to the RAG scheduler;

[0072] (3) Call the LLM to generate query statements suitable for retrieval;

[0073] (4) Obtain a list of relevant theoretical knowledge documents through hybrid retrieval;

[0074] (5) Guide the LLM to generate a quantum computing experiment plan;

[0075] (6) Obtain a list of relevant software toolkit documents through hybrid retrieval;

[0076] (7) Guide the LLM to generate a specific executable quantum computing program;

[0077] (8) The RAG scheduler returns the generated program and relevant reference content (i.e., the two query result document lists) to the user interface for display to the user.

[0078] Among the components of the system shown in Figure 1 the functions of the RAG scheduler, the hybrid retrieval module, the document library, and the front - end interface are described in detail.

[0079] First, the RAG scheduler is the core control module of the system, responsible for maintaining the user query response connection, scheduling each module, and obtaining multiple expected outputs from the LLM using the method of prompt engineering. Its main functions and workflow are as follows:

[0080] (1) Receive user queries:

[0081] · The RAG scheduler receives the question input by the user from the front - end interface and maintains the request status.

[0082] (2) Query statement generation:

[0083] · The RAG scheduler calls the LLM interface and converts the user's question into at most N optimized query statements according to the conversation context, that is, the RAG scheduler uses the LLM to generate query statements through prompt engineering;

[0084] (3) First - stage retrieval (theoretical knowledge):

[0085] · The RAG scheduler calls the hybrid retrieval module to trigger the vector database and the BM25 module, and performs parallel queries in the quantum computing theory document library according to the query statements to obtain the original query results;

[0086] ·According to an optional embodiment, the hybrid retrieval module merges and filters the original query results through the query result filtering module, and returns a list of documents of relevant theoretical knowledge.

[0087] (4) First-stage generation (experimental scheme):

[0088] ·The RAG scheduler calls the LLM interface and provides the conversation context and query results based on theoretical knowledge (including the list of theoretical knowledge documents) in the prompt message;

[0089] ·The LLM interface returns the generated abstract quantum computing experimental scheme.

[0090] (5) Second-stage retrieval (software toolkit knowledge):

[0091] ·The RAG scheduler calls the hybrid retrieval module to trigger the vector database and the BM25 module, and performs parallel queries in the quantum computing software package document library according to the experimental scheme to obtain the original query results;

[0092] ·According to an optional embodiment, the hybrid retrieval module merges and filters the original query results through the query result filtering module, and returns a list of documents of relevant software toolkit knowledge.

[0093] (6) Second-stage generation (quantum computing program):

[0094] ·The RAG scheduler calls the LLM interface and provides the conversation context, the quantum computing experimental scheme, and the relevant software toolkit query results (including the list of software toolkit knowledge documents) in the prompt message;

[0095] ·The LLM interface returns a specific executable quantum computing program.

[0096] (7) Result return:

[0097] ·The generated quantum computing program and the reference documents retrieved twice (including the list of theoretical knowledge documents and the list of software toolkit knowledge documents) are passed to the front-end interface for display.

[0098] (8) Exception handling:

[0099] ·Monitor each step in the whole process and handle possible exceptions (such as retrieval failure, generation error, etc.).

[0100] ·Implement corresponding recovery measures or provide alternative solutions.

[0101] (9) Resource management:

[0102] ·Coordinate the allocation of system resources to ensure the efficient operation of each module.

[0103] · Dynamically adjust task priorities and resource allocations according to the system load conditions.

[0104] According to some embodiments, in the above-mentioned first and second stage hybrid retrieval (especially when performing BM25 retrieval), a replaceable multilingual thesaurus (e.g., Chinese-English thesaurus) can be introduced to expand the query statement, and the hybrid retrieval module performs retrieval according to the expanded query statement to enhance the matching success rate between professional terms. According to a specific embodiment, this thesaurus can be updated, including updating according to the latest research trends of quantum computing and related development tools. For example, "spin Hamiltonian evolution under magnetic field" can be expanded to: "spin Hamiltonian evolution in magnetic field", "time evolution of spin in magnetic field", "magnetic field Hamiltonian evolution", etc.

[0105] Secondly, the hybrid retrieval module combines vector-based semantic retrieval and keyword-based BM25 retrieval to improve the retrieval effect.

[0106] (1) Vector retrieval:

[0107] · Use pre-computed document vectors to find the text block in the vector space that is most similar to the query vector;

[0108] · Use the Euclidean distance metric method to calculate similarity. Calculate the Euclidean distance between the query statement vector and the text block vector inside the vector database, which can be used to determine similarity. Generally speaking, the smaller the Euclidean distance, the greater the similarity;

[0109] · According to a specific embodiment, use the formula score_vector = (1 / (L2_dist + c) - 1) / sqrt(n_query) to obtain the original vector score of the text block, where score_vector represents the text block vector score, L2_dist represents similarity, n_query represents the number of generated query vectors, and the smoothing factor c is usually a very small positive number to prevent division by zero when L2_dist is zero.

[0110] (2) BM25 retrieval:

[0111] · Segment the query statement;

[0112] · Use the BM25 algorithm to calculate the relevance score score_bm25’ between the query term and the document;

[0113] · Obtain score_bm25 = score_bm25’ / n_query as the original BM25 score of the document, where n_query represents the number of generated query vectors.

[0114] (3) Combine and filter to obtain the final retrieval result:

[0115] · Classify and statistically analyze the text block scores retrieved by vectors on a document-by-document basis, and add the bm25 scores to obtain the total document score:

[0116] final_score = Σscore_vector + α * score_bm25

[0117] Among them, final_score represents the total document score, and α is the relative weight of the given bm25 algorithm

[0118] · Calculate the comprehensive reference value of the document in combination with the number of tokens in the document:

[0119] value = final_score / (1 + num_token / norm_factor)

[0120] Among them, num_token represents the number of tokens in the document, and norm_factor is a parameter related to the number of tokens. In the case of the same final_score, the longer the document, the lower the value obtained.

[0121] · According to a specific embodiment, filter the eligible documents according to the comprehensive reference value threshold value_thresh, sort them in descending order according to value, and take the top n as the final retrieval result and ensure that the total number of tokens of these n does not exceed a given token_limit.

[0122] That is, the retrieved document result set R = {doc_i | value_i > value_thresh, Σnum_token_i <= token_limit}

[0123] Among them, doc is the document list sorted in descending order of value, and num_token_i is the number of tokens in the document doc_i.

[0124] Furthermore, the document library is the knowledge foundation of this system and is divided into two parts: the quantum computing theory knowledge library and the quantum computing software toolkit document library.

[0125] (1) Quantum computing theory knowledge library

[0126] The quantum computing theory knowledge base can cover the basics of quantum mechanics, the basic concepts of quantum computing, the quantum simulation methods of physical systems, the algorithms and principles of quantum machine learning, quantum error correction and fault tolerance, etc. It adopts a hierarchical organizational structure, regularly obtains the latest research results from authoritative sources, and ensures the accuracy and relevance of the content through a review mechanism.

[0127] (2) Quantum computing software toolkit documentation library

[0128] The quantum computing software toolkit documentation library contains the official documentation, tutorials, example codes, etc. of a specified quantum computing software toolkit (such as Qiskit or PyQuafu). It is organized by software toolkit categories and provides content such as quick start guides, advanced usage guides, API documentation, etc. The documentation should be synchronized with the main version of the software toolkit.

[0129] According to some embodiments, the organizational structure of the above-mentioned documentation library can be organized in a hierarchical / nested manner. For example, set up hierarchical levels such as top-level categories, second-level categories, third-level categories, etc. When retrieving, return the information of the documents most relevant to the query and their parent nodes. For example, the list of documents of theoretical knowledge or the list of documents of software toolkit knowledge obtained by querying includes the list of documents whose relevance to the query statement meets the preset threshold and the information of their parent nodes, so as to help the language model more comprehensively understand the position and connection of the queried knowledge points in the entire field of quantum computing.

[0130] Finally, Figure 3 is an example of a front-end interface according to an embodiment of the present application. Among them, the front-end interface at least includes the following elements:

[0131] (1) Conversation window:

[0132] · Text description and related formulas about the quantum computing experimental scheme;

[0133] · Executable quantum computing program code;

[0134] · List of related references.

[0135] (2) Query input box: The user inputs questions related to quantum computing.

[0136] According to some embodiments, the above front-end interface design can support more complete interactive functions. For example, it can support the formatted display of formulas and code to improve readability; it can provide the visualization of quantum circuit diagrams to help users understand the generated quantum computing programs; it can introduce the functions of deleting conversation content and modifying query statements to facilitate users to adjust and optimize queries, and so on.

[0137] Based on the above description of the solution of the present application, in order to better illustrate the working process of the present application, taking a specific application scenario as an example, the general working process of the present application is explained as follows:

[0138] User query: "How to use the Quantum Approximate Optimization Algorithm (QAOA) to solve the Max-cut problem?"

[0139] (1) First-stage retrieval query:

[0140] · The system hybridly retrieves the knowledge of quantum computing theory, especially the content about QAOA and the Max-cut problem.

[0141] · Generate an experimental plan including the Hamiltonian expression for mapping the problem to the quantum system and the QAOA evolution expression.

[0142] (2) Second-stage retrieval query:

[0143] · Based on the generated experimental plan, the system hybridly retrieves the implementation method of QAOA in Qiskit.

[0144] · Generate Python code for implementing QAOA to solve the Max-cut problem using Qiskit.

[0145] Based on the above system, according to one aspect of the present application, a method for generating a quantum computing program based on retrieval-augmented generation technology executed by a RAG scheduler is provided, as Figure 4 shown, the method includes:

[0146] Step 401, receiving the query content of the user;

[0147] Step S402, calling a large language model to generate a query statement according to the query content;

[0148] Step S403, respectively calling a hybrid retrieval module and the large language model to generate a quantum computing experimental plan according to the query statement, wherein the hybrid retrieval module includes a vector retrieval module and a BM25 retrieval module; and

[0149] Step S404, respectively calling the hybrid retrieval module and the large language model according to the quantum computing experimental plan to generate a quantum computing program corresponding to the quantum computing experimental plan.

[0150] According to an optional embodiment, step S402 may include:

[0151] After generating the query statement, expand the query statement using synonym tables in multiple languages to obtain an expanded query statement, so that the BM25 retrieval module in the hybrid retrieval module performs retrieval according to the expanded query statement, where the synonym tables in multiple languages can be updated.

[0152] According to an optional embodiment, step S403 may include:

[0153] Call the vector retrieval module and the BM25 retrieval module, query the quantum computing theory document library in the document library according to the query statement, and obtain a document list of theoretical knowledge;

[0154] Filter the document list of theoretical knowledge through the filtering module to obtain a filtered document list of theoretical knowledge; and

[0155] Call the large language model to generate the quantum computing experiment plan according to the filtered document list of theoretical knowledge.

[0156] According to an optional embodiment, step S404 may include:

[0157] Call the vector retrieval module and the BM25 retrieval module, query the quantum computing software package document library in the document library according to the quantum computing experiment plan, and obtain a document list of software tool knowledge;

[0158] Filter the document list of software tool knowledge through the filtering module to obtain a filtered document list of software tool knowledge; and

[0159] Call the large language model to generate the quantum computing program according to the quantum computing experiment plan and the document list of software tool knowledge.

[0160] According to a specific embodiment, both the filtering of the document list of theoretical knowledge through the filtering module and the filtering of the document list of software tool knowledge through the filtering module include:

[0161] Determine the document score through the vector retrieval module;

[0162] Determine the relevance score between the word segmentation of the query statement and the document through the BM25 retrieval module;

[0163] Determine the total document score according to the document score and the relevance score;

[0164] Calculate the comprehensive reference value of the document according to the token number of the document and the total document score; and

[0165] Filter the retrieved document list according to the comprehensive reference value of the document and a preset comprehensive reference value threshold to obtain a filtered document list.

[0166] According to another aspect of the present application, there is also provided a method for generating a quantum computing program based on retrieval-augmented generation technology executed by an RAG scheduler, as Figure 5 shown. Compared with Figure 4 , Figure 5 Steps S501 to S504 of Figure 4 are similar to steps S401 to S404 of Figure 5 , except that

[0167] Step S505, call the front-end interface to display the quantum computing program, the document list of the theoretical knowledge, and the document list of the software toolkit knowledge.

[0168] According to the method and system for generating a quantum computing program based on retrieval-augmented generation technology provided by the present application, the following technical effects can be achieved:

[0169] First, improve retrieval accuracy and relevance: Through the hybrid retrieval of vector semantic retrieval and BM25 keywords, as well as the adaptive filtering of retrieval results, the retrieval accuracy and relevance are improved. The present application optimizes the recognition and semantic understanding ability of professional terms, effectively overcoming the problem of insufficient accuracy of traditional RAG technology in dealing with professional terms and concepts in the field of quantum computing;

[0170] Second, enhance complex reasoning ability: Adopt a two-step generation strategy. First, generate an experimental scheme combining natural language and mathematical expressions, and then generate the corresponding quantum program. This method uses the principle of the chain of thought to improve the success rate and accuracy of generating complex quantum computing programs. This overcomes the problem of poor effect of the single-step direct generation method in dealing with complex reasoning and improves the quality and usability of the generated program;

[0171] Third, enhance knowledge integration ability: Adopt a two-step retrieval strategy, decompose the complex quantum computing program generation task into two steps: quantum experiment scheme construction and program implementation. The present application can more effectively retrieve and integrate quantum computing theoretical knowledge and practical programming-related knowledge. This overcomes the problem of too large a gap between theory and practice in traditional methods and improves the accuracy and practicality of the generation result;

[0172] Finally, improve computing efficiency and resource utilization: Through the intelligent screening and optimization of the retrieval results by the query result filtering module, the present application can remove irrelevant or low-quality documents, reduce unnecessary computing overhead, and improve the processing efficiency of the system. This effectively solves the problem of increased computing costs and reduced model efficiency caused by introducing a large amount of irrelevant information in traditional RAG technology.

[0173] Thus, through a series of innovative technical means, this application effectively overcomes various problems faced by existing RAG technology in the task of quantum computing program generation, realizes the automatic generation of efficient, accurate, and interpretable quantum computing programs, and provides a powerful auxiliary tool for the research and application in the field of quantum computing.

[0174] In the above embodiments, the descriptions of the respective embodiments have their own emphases. For parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.

[0175] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this application is not limited by the described action sequence, because according to this application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.

[0176] In several embodiments provided by this application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units described above is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be an electrical connection or other forms.

[0177] Refer to Figure 6 , Figure 6 A wireless communication device is provided, including a processor and a memory. The memory stores computer instructions or one or more programs. When the computer instructions or one or more programs are executed by the processor, the processor executes the computer instructions to implement the methods and refinement solutions as shown in Figure 4 and Figure 5 shown.

[0178] It should be understood that the above device embodiments are merely illustrative, and the devices disclosed by the present invention can also be implemented in other ways. For example, the division of the units / modules described in the above embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or integrated into another system, or some features can be ignored or not executed.

[0179] In addition, unless otherwise specified, in each embodiment of the present invention, each functional unit / module can be integrated into one unit / module, or each unit / module can exist physically alone, or two or more units / modules can be integrated together. The above-mentioned integrated unit / module can be implemented in the form of hardware or in the form of a software program module.

[0180] When the above-mentioned integrated unit / module is implemented in the form of hardware, the hardware can be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor or chip can be any suitable hardware processor, such as CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the on-chip cache, off-chip memory, and memory can be any suitable magnetic storage medium or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc.

[0181] When the above-mentioned integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to enable a computer electronic device (which can be a personal computer, a server, or a network electronic device, etc.) to execute all or part of the steps of the methods described in each embodiment of this disclosure. And the aforementioned memory includes: USB flash drive, read-only memory (ROM), random access memory (RAM), mobile hard disk, magnetic disk, or optical disc, etc., all kinds of media that can store program codes.

[0182] The embodiments of the present application also provide a non-transitory computer-readable storage medium storing one or more computer programs. When the one or more computer programs are executed by multiple processors, the processors are caused to execute as Figure 4and Figure 5 The method and refinement scheme shown above.

[0183] Term Explanation:

[0184] 1. RAG (Retrieval Augmented Generation):

[0185] Retrieval Augmented Generation technology, which improves the accuracy and relevance of generated content by combining information retrieval and generation models.

[0186] 2. LLM (Large Language Model):

[0187] Large Language Model, referring to a natural language processing model trained on a large amount of data, such as GPT-4, which has powerful text generation and understanding capabilities.

[0188] 3. BM25 Algorithm:

[0189] BM25 is a document retrieval algorithm based on a probabilistic model, which comprehensively considers factors such as term frequency (TF), inverse document frequency (IDF), and document length to calculate the relevance score between a query and a document. Its core idea is that for a given query, documents containing the query terms are more relevant than those that do not, and at the same time, the higher the term frequency and the shorter the document, the greater the relevance.

[0190] 4. Vector Retrieval:

[0191] A retrieval method based on the vector space model, which retrieves relevant documents by calculating the similarity between a query vector and a document vector.

[0192] 5. Vector Database:

[0193] A database system specifically designed for storing and retrieving high-dimensional vector data, such as Faiss. In this application, it is used to store the vector representations of documents and supports efficient vector retrieval.

[0194] 6. Text Embedding Model:

[0195] A model used to convert text into vector representations, such as bge-large-zh, which can capture the semantic information of text.

[0196] 7. Qiskit:

[0197] An open-source quantum computing software development framework led by IBM, which provides tools for quantum circuit design, simulation, and execution.

[0198] 8. PyQuafu:

[0199] An open-source quantum computing software development framework developed by the Beijing Institute of Quantum Information Sciences, which provides tools for quantum circuit design, simulation, and execution.

[0200] 9. QAOA (Quantum Approximate Optimization Algorithm):

[0201] Quantum Approximate Optimization Algorithm, a quantum algorithm for solving combinatorial optimization problems.

[0202] 10. Chain of Thought:

[0203] A generation strategy that improves the success rate and accuracy of complex tasks through step-by-step reasoning and generation.

[0204] 11. GPT-4 (Generative Pre-trained Transformer 4):

[0205] The fourth generation of the Generative Pre-trained Transformer model, a large-scale language model developed by OpenAI, with powerful text generation and understanding capabilities.

[0206] 12. bge-large-zh:

[0207] A large-scale Chinese embedding model developed by the Beijing Academy of Artificial Intelligence (BAAI). It is part of the BGE (BAAI General Embedding) series of models. It maps any text input into a low-dimensional dense vector for various natural language processing tasks.

[0208] 13. Prompt engineering:

[0209] A method for optimizing the generation results of language models by designing and adjusting input prompts to guide the model to generate more expected outputs.

[0210] 14. Word segmentation:

[0211] Word segmentation is a basic task in natural language processing, which refers to the process of splitting a continuous text sequence into individual words or morphemes. In information retrieval, word segmentation is an important preprocessing step for building indexes and performing query matching.

[0212] 15. Hamiltonian:

[0213] In quantum mechanics, an operator that describes the total energy of a system. In quantum computing, it is often used to describe the evolution of a quantum system.

[0214] 16. Qubit:

[0215] The basic unit of quantum computing, similar to a bit in classical computing, but can be in a superposition state.

[0216] 17. Quantum Gate:

[0217] The basic unit for operating on qubits, similar to a logic gate in classical computing.

[0218] 18. Quantum Circuit:

[0219] A computational structure composed of quantum gates and qubits, used to implement quantum algorithms.

[0220] 19. Euclidean Distance:

[0221] A method for measuring the distance between two points in a vector space, used in this application to calculate vector similarity.

[0222] 20. Token:

[0223] The basic unit of text, which can be a word, sub-word, or character, used for text segmentation and representation in natural language processing tasks.

[0224] 21. Chunking:

[0225] The process of splitting long text into smaller, manageable fragments, which helps to improve text processing and retrieval effects.

[0226] 22. API (Application Programming Interface):

[0227] Application Programming Interface, which defines the methods and data structures for interaction between different software components. In this technical solution, the API mainly refers to the call interfaces of large language models and text embedding models, which may be implemented in the form of program function calls or HTTP requests, used to obtain the output results of the models.

[0228] 23. LaTeX:

[0229] A markup language and typesetting system for generating high-quality scientific and mathematical documents.

[0230] 24. MathML (Mathematical Markup Language):

[0231] An XML-based mathematical formula description language, used to display mathematical formulas on web pages.

[0232] 25. Chunk Index:

[0233] This term describes the process of dividing a document into small pieces for storage and indexing; in vector retrieval, these small pieces are converted into vectors and stored in a vector database.

[0234] 26. Full-text retrieval:

[0235] This term describes the process of returning the entire document rather than just the matching text fragments.

[0236] References in this specification to features, advantages, or similar language do not imply that all features and advantages achievable by this application should be included in or embodied in any single implementation thereof. On the contrary, language referring to features and advantages is understood to mean that a particular feature, advantage, or characteristic described in connection with an embodiment is included in at least one embodiment of this application. Thus, discussions of features, advantages, and similar language throughout this specification may, but do not necessarily, refer to the same embodiment.

[0237] Furthermore, the described features, advantages, and characteristics of this application may be combined in any suitable manner in one or more embodiments. Based on the description herein, those of ordinary skill in the relevant art will recognize that this application may be implemented without one or more specific features or advantages of a particular embodiment. In other instances, additional features and advantages may be realized in particular embodiments that are not presented in all embodiments of this application.

[0238] The embodiments of this application have been introduced in detail above. Specific examples have been used herein to elaborate on the principles and implementation manners of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application. At the same time, changes or deformations made by those skilled in the art based on the idea of this application, within the specific implementation manners and application scope of this application, all fall within the scope protected by this application. In summary, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for generating quantum computing programs based on retrieval-augmented generation technology, applied to a retrieval-augmented generation scheduler, characterized in that Including: Receiving the query content of the user; Invoking a large language model according to the query content to generate a query statement; Invoking a hybrid retrieval module and the large language model respectively according to the query statement to generate a quantum computing experiment scheme, wherein the hybrid retrieval module includes a vector retrieval module and a BM25 retrieval module; and Invoking the hybrid retrieval module and the large language model respectively according to the quantum computing experiment scheme to generate a quantum computing program corresponding to the quantum computing experiment scheme; Wherein, the hybrid retrieval module further includes a filtering module, and the step of invoking the hybrid retrieval module and the large language model respectively according to the query statement to generate a quantum computing experiment scheme includes: Invoking the vector retrieval module and the BM25 retrieval module, querying the quantum computing theory document library in the document library according to the query statement, and obtaining a document list of theoretical knowledge; Filtering the document list of theoretical knowledge through the filtering module to obtain a filtered document list of theoretical knowledge; and Invoking the large language model, and generating the quantum computing experiment scheme according to the filtered document list of theoretical knowledge; The step of invoking the hybrid retrieval module and the large language model respectively according to the quantum computing experiment scheme to generate a quantum computing program corresponding to the quantum computing experiment scheme includes: Invoking the vector retrieval module and the BM25 retrieval module, querying the quantum computing software package document library in the document library according to the quantum computing experiment scheme, and obtaining a document list of software toolkit knowledge; Filtering the document list of software toolkit knowledge through the filtering module to obtain a filtered document list of software toolkit knowledge; and Invoking the large language model, and generating the quantum computing program according to the quantum computing experiment scheme and the document list of software toolkit knowledge.

2. The method according to claim 1, wherein Both the step of filtering the document list of theoretical knowledge through the filtering module and the step of filtering the document list of software toolkit knowledge through the filtering module include: Determining the document score through the vector retrieval module; Determining the relevance score between the word segmentation of the query statement and the document through the BM25 retrieval module; Determining the total document score according to the document score and the relevance score; Calculating the comprehensive reference value of the document according to the token number of the document and the total document score; and Filtering the retrieved document list according to the comprehensive reference value of the document and a preset comprehensive reference value threshold to obtain a filtered document list.

3. The method according to claim 1, wherein It further includes: Invoking a front-end interface to display the quantum computing program, the document list of theoretical knowledge, and the document list of software toolkit knowledge.

4. The method according to claim 1, wherein The step of invoking a large language model according to the query content to generate a query statement includes: After generating the query statement, expanding the query statement by using a synonym table in multiple languages to obtain an expanded query statement, so that the BM25 retrieval module in the hybrid retrieval module performs retrieval according to the expanded query statement, wherein the synonym table in multiple languages can be updated.

5. The method according to claim 1, characterized in that, The document library is organized in a hierarchical and / or nested manner. The list of documents of theoretical knowledge or the list of documents of software toolkit knowledge obtained by querying includes the list of documents whose relevance to the query statement meets a preset threshold and the information of their parent nodes.

6. A quantum computing program generation system based on retrieval-augmented generation technology, characterized in that, Including: A retrieval enhancement generation scheduler for executing the method according to any one of claims 1 to 5; A hybrid retrieval module, including a vector retrieval module and a BM25 retrieval module, which is used to query the quantum computing theory document library in the document library according to the query statement input by the user under the scheduling of the retrieval enhancement generation scheduler, obtain the list of documents of theoretical knowledge, and query the quantum computing software package document library in the document library according to the generated quantum computing experiment plan, and obtain the list of documents of software toolkit knowledge; And A large language model, which is used to generate the quantum computing experiment plan according to the list of documents of theoretical knowledge under the scheduling of the retrieval enhancement generation scheduler, and generate the quantum computing program according to the quantum computing experiment plan and the list of documents of software toolkit knowledge.

7. The system according to claim 6, further comprising: A front-end interface for displaying the quantum computing program, the list of documents of theoretical knowledge, and the list of documents of software toolkit knowledge under the scheduling of the retrieval enhancement generation scheduler.

8. An electronic device, comprising a memory storing one or more programs and one or more processors, the one or more processors being electrically coupled to the memory and configured to execute the one or more programs to execute the method according to any one of claims 1 to 5.

9. A non-transitory computer-readable storage medium storing one or more programs, the one or more programs being configured to cause the execution of the method according to any one of claims 1 to 5 when executed by a processor.

Citation Information

Patent Citations

  • QP frame-based automatic code generator

    CN106569838A

  • Code generation method and device, storage medium and electronic equipment

    CN116166271A

  • Multi-document intelligent question and answer method and system based on large language model

    CN118394897A