Quantum computing program generation method and system based on retrieval enhancement generation technology

Through mixed search technology and two-stage generation strategy, the problem of insufficient retrieval accuracy and reasoning capabilities of large language models in quantum computing program generation is solved, and efficient and accurate quantum computing program generation is achieved, which lowers the programming threshold and accelerates the quantum Algorithm development.

CN119293140AActive Publication Date: 2025-01-10BEIJING ACAD OF QUANTUM INFORMATION SCI +1

Patent Information

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

AI Technical Summary

Technical Problem

When generating quantum computing programs, existing large language models face problems such as insufficient retrieval accuracy, insufficient complex reasoning capabilities, insufficient knowledge integration and inefficient computing efficiency, making it difficult to generate high-quality, interpretable quantum computing programs.

Method used

Using a hybrid search technology of embedded vectors and BM25 algorithms, combining block indexes and full-text search, through a two-stage search generation strategy, the abstract quantum algorithm ideas are created, and the specific code implementation is generated, using large language models and quantum computing software. Toolkit knowledge to improve the accuracy and efficiency of generation.

Benefits of technology

It improves the accuracy and usability of quantum computing program generation, lowers the programming threshold, accelerates the research and development of quantum algorithms, and provides high-quality and interpretable program generation tools.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119293140A_ABST
    Figure CN119293140A_ABST
Patent Text Reader

Abstract

The invention relates to a quantum computing program generation method and system based on a retrieval enhancement generation technology, the method is applied to a retrieval enhancement generation scheduler, and the method comprises the following steps: receiving query content of a user; calling a large language model to generate a query statement according to the query content; according to the query statement, a hybrid retrieval module and the large language model are called to generate a quantum computing experiment scheme, and the hybrid retrieval module comprises a vector retrieval module and a BM25 retrieval module; and calling the hybrid retrieval module and the large language model according to the quantum calculation experiment scheme, and generating a quantum calculation program corresponding to the quantum calculation experiment scheme. According to the scheme, on one hand, an improved retrieval and filtering mechanism is introduced, and the accuracy of knowledge matching is improved; on the other hand, the thinking process of the human is simulated, an abstract quantum algorithm thought is generated firstly, then specific codes are generated for implementation, and the generation success rate and usability of the complex quantum algorithm are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of retrieval enhancement generation technology, and in particular to a quantum computing program generation method and system based on retrieval enhancement 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 based on 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. For general large language models, it is difficult to accurately understand and generate quantum computing programs that meet the requirements. In addition, the knowledge in the field of quantum computing is updated quickly, and how to make large language models quickly adapt to new knowledge is also a major problem. In order to solve the above problems, researchers have proposed a series of improvement plans. Among them, Facebook proposed the Retrieval Augmented Generation (RAG) technology in 2020, which combines information retrieval with large language models to enable the model to 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 performance of models in specific fields. Some typical improvements include: using more accurate retrieval algorithms to screen relevant knowledge, introducing thought chains and multi-round interaction mechanisms to guide the generation process, using domain ontology and rule systems to assist semantic understanding, etc. 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 it 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-training large-scale language models:

[0005] Models such as GPT-4, while having strong general reasoning capabilities, still lack the depth and accuracy of knowledge in specialized fields such as quantum computing. They have difficulty adapting to rapidly iterating expertise and perform poorly when dealing with tasks that require deep domain understanding.

[0006] 2. Fine-tuning in specific areas:

[0007] Fine-tuning a pre-trained model with domain-specific data can improve the model's performance on specific tasks. However, this approach may lead to catastrophic forgetting, affecting the model's performance in other areas. At the same time, the fine-tuning process requires a large amount of high-quality domain data and computing resources, which is difficult to adapt to the rapid development of the quantum computing field and the rapid iteration of related code bases.

[0008] 3. Template-based code generation:

[0009] Through predefined code templates and rules, program code can be generated according to given specifications. This approach is efficient when dealing with structured and predefined tasks, but lacks the flexibility to deal with novel problems. In the rapidly evolving field of quantum computing, it is costly to maintain and update rule bases and template collections, 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 limitations to varying degrees 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 discovered that the basic form of RAG technology has the following technical problems when applied to highly specialized fields such as quantum computing program generation:

[0012] 1. Insufficient retrieval accuracy:

[0013] Main problem: Vector search methods are not very accurate for specialized vocabulary and concepts in the field of quantum computing.

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

[0015] 2. Insufficient complex reasoning ability:

[0016] Main problem: For quantum computing program generation tasks that require multi-step reasoning, direct generation is not very complete.

[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 theoretical knowledge of quantum computing and practical programming implementation.

[0020] Technical impact: This results in the generated program being correct in theory but having problems in actual implementation, reducing the practicality of the system.

[0021] 4. Low computational efficiency:

[0022] Main problem: including a lot of potentially relevant but actually unnecessary information in the context.

[0023] Technical impact: This will significantly increase the computational cost and reduce the processing efficiency of the model, especially in scenarios that require real-time response. Longer contexts currently also affect the performance of LLM and cause reasoning errors or hallucinations.

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

[0025] According to a first aspect of the present application, a quantum computing program generation method based on retrieval enhancement generation technology is provided, which is applied to a retrieval enhancement generation scheduler, and is characterized by comprising:

[0026] Receive user query content;

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

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

[0029] According to the quantum computing experimental scheme, the hybrid retrieval module and the large language model are respectively called to generate a quantum computing program corresponding to the quantum computing experimental scheme.

[0030] According to a second aspect of the present application, a quantum computing program generation system based on retrieval enhancement generation technology is provided, characterized in that it includes:

[0031] Retrieve an enhanced 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, is used to query a quantum computing theory document library in a document library according to a query statement input by a user under the scheduling of the retrieval enhancement generation scheduler to obtain a document list of theoretical knowledge, and query a quantum computing software package document library in a document library according to a generated quantum computing experimental scheme to obtain a document list of software toolkit knowledge; and

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

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

[0035] Processor; and

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

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

[0038] According to the quantum computing program generation method and system based on retrieval-enhanced generation technology provided by 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 to first generate abstract quantum algorithm ideas and then generate specific code implementations, thereby improving the generation success rate and availability of complex quantum algorithms. Therefore, the solution of this 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 high-quality, explainable quantum computing program generation tools, which is of great significance for lowering the threshold of quantum programming and accelerating the 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 drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without exceeding the scope of protection required by the present application.

[0040] Figure 1 It 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.

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

[0042] Figure 3 This 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 enhanced 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 enhanced generation technology according to another embodiment of the present application.

[0045] Figure 6 It is a structural diagram of an electronic device provided by this application. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

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

[0048] First, this application adopts a hybrid retrieval technology of embedded vectors and BM25 algorithms, and adopts the method of "combining chunk indexing (ChunkIndexing) with full-text retrieval (Full-text Retrieval)" to obtain relevant documents. Specifically, the chunked text blocks are used as the storage and query objects of the vector database, and the vector similarity is used to capture the semantic relevance; at the same time, document segmentation is used as the retrieval unit of BM25, and keyword matching is used to improve the recall rate. On the basis of vector retrieval and BM25 retrieval, the system always returns a whole section of the document with more complete semantics to provide more comprehensive contextual information. In addition, this application also combines an adaptive result filtering mechanism to dynamically adjust the number and order of returned results according to the query statement and document relevance, ensuring the high relevance of the retrieval results. While ensuring effective retrieval, the amount of context introduced is also controlled to avoid the problem of information overload or the introduction of irrelevant information.

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

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

[0051] (1) Front-end interface: used 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) interface: Provides the text response of 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 for a professional field, collectively referred to as a "large language model" in this application.

[0055] (5) Text Embedding Model interface: The embedding vector of a text block is given by calling an external text embedding model API. The external model can be a general text embedding model or a model that has been fine-tuned for a professional field.

[0056] (6) Hybrid retrieval module: including a vector retrieval module and a BM25 retrieval module, using a vector database and a BM25 document query module for hybrid retrieval, and optionally filtering the retrieval results according to the retrieval score;

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

[0058] (8) BM25 document query module: uses the BM25 algorithm to implement keyword-based retrieval;

[0059] (9) Document library: It consists of two parts, storing theoretical knowledge related to quantum computing and specific quantum computing software toolkits, namely, the quantum computing theory document library and the quantum computing software package document library.

[0060] exist Figure 1 On the basis of the system shown, the data flow and processing process of the system roughly include 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 in real time the changes in the computational theory document library and the quantum computing software package document library in the quantum document library.

[0063] (2) When a document change is detected, the system triggers the update process:

[0064] For newly added documents, they are vectorized through the Embedding interface after block processing and stored in the vector database. 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 the content of the document library is vectorized and stored in the vector database during the document update process; on the other hand, the vector database (actually the entire hybrid retrieval module) acts as the index of the document library, matching the corresponding documents in the document library according to a set of query statements.

[0065] For updated documents, re-block and vectorize them, 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 update logs, including update time, number of updated documents, and other information, to facilitate system maintenance and performance optimization.

[0069] According to one embodiment, Figure 2 As shown in FIG. 1 , the user query response process includes:

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

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

[0072] (3) Call LLM to generate a query statement suitable for retrieval;

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

[0074] (5) Guide LLM to generate quantum computing experimental plans;

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

[0076] (7) Guide LLM to generate specific executable quantum computing programs;

[0077] (8) The RAG scheduler returns the generated program and related reference content (i.e., the document lists of the two query results) to the user interface and displays them to the user.

[0078] exist Figure 1 Among the components of the system shown, the roles of the RAG scheduler, hybrid retrieval module, document library and 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 to schedule each module, and using the prompt word engineering method to obtain multiple expected outputs from the LLM. Its main functions and workflow are as follows:

[0080] (1) Receive user inquiries:

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

[0082] (2) Query statement generation:

[0083] The RAG scheduler calls the LLM interface to convert the user's question into a maximum of N optimized query statements based on the conversation context. That is, the RAG scheduler generates query statements using LLM through prompt word engineering.

[0084] (3) First stage search (theoretical knowledge):

[0085] The RAG scheduler calls the hybrid retrieval module to trigger the vector database and BM25 module, and performs parallel queries in the quantum computing theory document library according to the query statement, and 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 document list of relevant theoretical knowledge.

[0087] (4) First stage generation (experimental plan):

[0088] The RAG scheduler calls the LLM interface and gives the dialogue context and the query results based on theoretical knowledge (including the list of theoretical knowledge documents) in the prompt information;

[0089] The LLM interface returns the generated abstract quantum computing experiment plan.

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

[0091] The RAG scheduler calls the hybrid retrieval module to trigger the vector database and BM25 module, and performs parallel queries in the quantum computing software package document library according to the experimental plan 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 document list of related software toolkit knowledge.

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

[0094] The RAG scheduler calls the LLM interface and provides the conversation context, quantum computing experiment plan, and related software toolkit query results (including a document list of software toolkit knowledge) in the prompt information;

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

[0096] (7) Result returned:

[0097] The generated quantum computing program and the reference documents retrieved twice (including a list of theoretical knowledge documents and a 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 entire process and handle possible abnormal situations (such as retrieval failure, generation errors, etc.).

[0100] Implement appropriate recovery measures or provide alternatives.

[0101] (9) Resource Management:

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

[0103] Dynamically adjust task priorities and resource allocation based on system load.

[0104] According to some embodiments, in the above-mentioned first and second stage hybrid retrieval (especially when performing BM25 retrieval), a replaceable synonym table in multiple languages ​​(for example, a Chinese and English synonym table) 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 synonym table 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 search:

[0107] Using pre-computed document vectors, find the chunk of text that is most similar to the query vector in vector space.

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

[0109] According to a specific embodiment, the formula score_vector=(1 / (L2_dist+c)-1) / sqrt(n_query) is used to obtain the original vector score of the text block, wherein score_vector represents the text block vector score, L2_dist represents the 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 search:

[0111] · Segment the query;

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

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

[0114] (3) Combine and filter to obtain the final search results:

[0115] The text block scores of vector retrieval are classified and counted by document, and the score of bm25 is added to obtain the total score of the document:

[0116] final_score=Σscore_vector+α*score_bm25

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

[0118] · Calculate the comprehensive reference value of the document based on 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. Under the same final_score, the longer the document, the lower the value.

[0121] According to a specific embodiment, the documents that meet the conditions are filtered according to the comprehensive reference value threshold value_thresh, and are sorted from large to small according to value, and the first n documents are taken as the final search results and the total token of these n documents is not greater than a given token_limit.

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

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

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

[0125] (1) Quantum computing theory knowledge base

[0126] The quantum computing theory knowledge base can cover the foundations of quantum mechanics, basic concepts of quantum computing, quantum simulation methods of physical systems, quantum machine learning algorithms and principles, 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 an audit mechanism.

[0127] (2) Quantum Computing Software Toolkit Documentation Library

[0128] The Quantum Computing Software Toolkit Documentation Library contains official documentation, tutorials, sample codes, etc. for a specified quantum computing software toolkit (such as Qiskit or PyQuafu). It is organized by software toolkit category, providing quick start, advanced usage, API documentation, etc. The documentation should be kept in sync with the main version of the software toolkit.

[0129] According to some embodiments, the organizational structure of the above-mentioned document library can be organized in a hierarchical / nested manner, for example, setting top-level classification, secondary classification, tertiary classification and other levels, and returning the documents most relevant to the query and their parent node information during retrieval. For example, the document list of theoretical knowledge or the document list of software toolkit knowledge obtained by the query includes a document list and its parent node information whose relevance to the query statement meets a preset threshold, so as to help the language model more comprehensively understand the position and connection of the queried knowledge point in the entire quantum computing field.

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

[0131] (1) Dialog window:

[0132] ·Textual description of quantum computing experimental scheme and related formulas;

[0133] Executable quantum computing program code;

[0134] A list of relevant references.

[0135] (2) Query input box: Users enter questions related to quantum computing.

[0136] According to some embodiments, the above-mentioned front-end interface design can support more complete interactive functions, such as supporting formatted display of formulas and codes to improve readability; providing visualization of quantum circuit diagrams to help users understand the generated quantum computing programs; introducing the functions of deleting dialogue content and modifying query statements to facilitate users to adjust and optimize queries, etc.

[0137] Based on the above description of the application scheme, in order to better illustrate the workflow of the application, the following takes a specific application scenario as an example to explain the general workflow of the application:

[0138] User query: "How to use the quantum approximate optimization algorithm (QAOA) to solve the Max-cut problem?"

[0139] (1) First stage search query:

[0140] Systematic hybrid retrieval of theoretical knowledge on quantum computing, especially on QAOA and Max-cut problems.

[0141] Generate an experimental plan that includes the mapping of the problem to the Hamiltonian expression of the quantum system and the QAOA evolution expression.

[0142] (2) Second stage search query:

[0143] Based on the generated experimental plan, the system hybrid searches for the implementation of QAOA in Qiskit.

[0144] Generate Python code to implement 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 enhancement generation technology performed by a RAG scheduler is provided, such as Figure 4 As shown, the method includes:

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

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

[0148] Step S403, calling 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

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

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

[0151] After generating the query statement, the query statement is expanded 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, wherein the synonym tables in multiple languages ​​can be updated.

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

[0153] Calling 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;

[0154] Filtering the theoretical knowledge document list by the filtering module to obtain a filtered theoretical knowledge document list; and

[0155] The large language model is called 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] Calling 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 plan, and obtaining a document list of software toolkit knowledge;

[0158] Filtering the software toolkit knowledge document list by the filtering module to obtain a filtered software toolkit knowledge document list; and

[0159] The large language model is called to generate the quantum computing program according to the quantum computing experimental plan and the document list of the software toolkit knowledge.

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

[0161] Determining a document score by means of the vector retrieval module;

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

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

[0164] Calculating a comprehensive reference value of the document according to the number of tokens in the document and the total score of the document; and

[0165] The document list obtained by retrieval is filtered 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, a method for generating a quantum computing program based on a retrieval enhancement generation technique performed by a RAG scheduler is also provided, such as Figure 5 As shown. Figure 4 compared to, Figure 5 Steps S501 to S504 are Figure 4 Steps S401 to S404 are similar, except that: Figure 5 The method also includes:

[0167] Step S505, calling 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] The quantum computing program generation method and system based on the retrieval enhancement generation technology provided by this application can bring the following technical effects:

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

[0170] Secondly, enhance complex reasoning capabilities: adopt a two-step generation strategy, first generate an experimental plan that combines natural language and mathematical expressions, and then generate the corresponding quantum program. This method uses the principle of thought chain to improve the success rate and accuracy of generating complex quantum computing programs. This overcomes the problem that the single-step direct generation method is not effective when it comes to complex reasoning, and improves the quality and usability of the generated program;

[0171] Furthermore, the knowledge integration capability is enhanced: by adopting a two-step search strategy, the complex quantum computing program generation task is decomposed into two steps: quantum experimental scheme construction and program implementation. This application can more effectively retrieve and integrate quantum computing theoretical knowledge and practical programming related knowledge. This overcomes the problem of the traditional method having a large span between theory and practice, and improves the accuracy and practicality of the generated results;

[0172] Finally, improve computing efficiency and resource utilization: By intelligently filtering and optimizing the search results through the query result filtering module, this 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 increasing computing costs and reducing model efficiency by introducing a large amount of irrelevant information in traditional RAG technology.

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

[0174] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0175] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0176] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the units, which is only a logical function division. There may be other division methods in actual implementation, such as 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 mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be electrical connection or other forms.

[0177] See also Figure 6 , Figure 6 A wireless communication device is provided, comprising 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 following Figure 4 and Figure 5 The method and refinement scheme shown.

[0178] It should be understood that the above device embodiments are only illustrative, and the device disclosed in the present invention can also be implemented in other ways. For example, the division of 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 can be integrated into another system, or some features can be ignored or not executed.

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

[0180] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. If not otherwise specified, the processor or chip may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. If not otherwise specified, the on-chip cache, the off-chip memory, and the memory may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.

[0181] If the 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 this 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, which is stored in a memory and includes several instructions for a computer electronic device (which can be a personal computer, a server or a network electronic device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.

[0182] The present application also provides 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 execute the following Figure 4and Figure 5 The method and refinement scheme shown.

[0183] Terminology explanation:

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

[0185] Retrieval-augmented generation technology improves the accuracy and relevance of generated content by combining information retrieval and generation models.

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

[0187] A large language model refers to a natural language processing model trained with large-scale data, such as GPT-4, which has powerful text generation and comprehension capabilities.

[0188] 3. BM25 algorithm:

[0189] BM25 is a document retrieval algorithm based on a probability model. It takes into account factors such as term frequency (TF), inverse document frequency (IDF) and document length to calculate the relevance score between the query and the document. The core idea is that for a given query, documents containing the query terms are more relevant than those not containing them. At the same time, the higher the term frequency and the shorter the document, the greater the relevance.

[0190] 4. Vector search:

[0191] The retrieval method based on the vector space model retrieves relevant documents by calculating the similarity between the query vector and the 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 vector representations of documents and support efficient vector retrieval.

[0194] 6. Text Embedding Model:

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

[0196] 7. Qiskit:

[0197] An open source quantum computing software development framework developed by IBM that 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 Science, 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 generative strategy that improves success and accuracy on complex tasks through step-by-step reasoning and generation.

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

[0205] Generative Pre-trained Transformer 4th generation model, a large-scale language model developed by OpenAI with strong text generation and understanding capabilities.

[0206] 12. bge-large-zh:

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

[0208] 13. Prompt word project:

[0209] A method for optimizing the results of language model generation, by designing and adjusting input prompt words to guide the model to generate output that is more in line with the expected output.

[0210] 14. Participle:

[0211] Word segmentation is a basic task in natural language processing, which refers to the process of dividing a continuous text sequence into individual words or morphemes. In information retrieval, word segmentation is an important pre-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. Quantum bit (Qubit):

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

[0216] 17. Quantum Gate:

[0217] The basic unit for operating on quantum bits is similar to the logic gates in classical computing.

[0218] 18. Quantum Circuit:

[0219] A computing structure consisting of quantum gates and qubits used to implement quantum algorithms.

[0220] 19. Euclidean Distance:

[0221] A method of 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, subword or character, is used for text segmentation and representation in natural language processing tasks.

[0224] 21. Chunking:

[0225] The process of breaking up long text into smaller, manageable segments helps improve text processing and retrieval.

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

[0227] Application programming interface defines the methods and data structures for interaction between different software components. In this technical solution, API mainly refers to the calling interface of large language model and text embedding model, which may be implemented in the form of program function call or HTTP request to obtain the output results of the model.

[0228] 23. LaTeX:

[0229] A markup language and typesetting system for producing high-quality scientific, technical, 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. Block index:

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

[0234] 26. Full-text search:

[0235] This term describes the process of returning complete documents, rather than just matching text fragments.

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

[0237] In addition, the features, advantages and characteristics of the present application can be combined in any suitable manner in one or more embodiments. According to the description herein, those of ordinary skill in the relevant art will recognize that the present application can be implemented without one or more specific features or advantages of a particular embodiment. In other cases, in a specific embodiment not presented in all embodiments of the present application, additional features and advantages can be realized.

[0238] The embodiments of the present application are described in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and its core idea of ​​the present application. At the same time, changes or deformations made by those skilled in the art based on the ideas of the present application, the specific implementation methods and the scope of application of the present application, all belong to the scope of protection of the present application. In summary, the content of this specification should not be construed as a limitation on the present application.

Claims

1. A quantum computing program generation method based on retrieval enhancement generation technology, applied to retrieval enhancement generation scheduler, characterized in that: include: Receive user query content; Calling a large language model to generate a query statement according to the query content; According to the query statement, respectively calling a hybrid retrieval module and the large language model to generate a quantum computing experiment plan, wherein the hybrid retrieval module includes a vector retrieval module and a BM25 retrieval module; and According to the quantum computing experimental scheme, the hybrid retrieval module and the large language model are respectively called to generate a quantum computing program corresponding to the quantum computing experimental scheme.

2. The method according to claim 1, characterized in that The hybrid retrieval module further includes a filtering module, and the generating of a quantum computing experimental scheme by respectively calling the hybrid retrieval module and the large language model according to the query statement includes: Calling 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 theoretical knowledge document list by the filtering module to obtain a filtered theoretical knowledge document list; and The large language model is called to generate the quantum computing experiment plan according to the filtered document list of theoretical knowledge.

3. The method according to claim 1, characterized in that The hybrid retrieval module further includes a filtering module, which calls the hybrid retrieval module and the large language model respectively according to the quantum computing experimental scheme to generate a quantum computing program corresponding to the quantum computing experimental scheme, including: Calling 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 plan, and obtaining a document list of software toolkit knowledge; Filtering the software toolkit knowledge document list by the filtering module to obtain a filtered software toolkit knowledge document list; and The large language model is called to generate the quantum computing program according to the quantum computing experimental plan and the document list of the software toolkit knowledge.

4. The method according to claim 2 or 3, characterized in that The filtering of the document list of the theoretical knowledge by the filtering module and the filtering of the document list of the software toolkit knowledge by the filtering module both include: Determining a document score by means of the vector retrieval module; Determining the relevance score between the word segmentation of the query statement and the document through the BM25 retrieval module; Determine a total score of the document according to the document score and the relevance score; Calculating a comprehensive reference value of the document according to the number of tokens in the document and the total score of the document; and The document list obtained by retrieval is filtered according to the comprehensive reference value of the document and a preset comprehensive reference value threshold to obtain a filtered document list.

5. The method according to claim 1, characterized in that Also includes: The front-end interface is called to display the quantum computing program, the document list of the theoretical knowledge and the document list of the software toolkit knowledge.

6. The method according to any one of claims 1 to 3, characterized in that: The calling of the large language model to generate a query statement according to the query content includes: After generating the query statement, the query statement is expanded 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, wherein the synonym tables in multiple languages ​​can be updated.

7. The method according to claim 2 or 3, characterized in that: The document library is organized in a hierarchical and / or nested manner, and the document list of theoretical knowledge or the document list of software toolkit knowledge obtained by query includes the document list whose relevance to the query statement meets a preset threshold and information of its parent node.

8. A quantum computing program generation system based on retrieval-enhanced generation technology, characterized in that: include: Retrieve an enhanced generation scheduler for executing the method according to any one of claims 1 to 7; A hybrid retrieval module, including a vector retrieval module and a BM25 retrieval module, 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 to obtain a document list of theoretical knowledge, and query the quantum computing software package document library in the document library according to the generated quantum computing experimental plan to obtain a document list of software toolkit knowledge; as well as A large language model is used to generate the quantum computing experimental plan according to the document list of the theoretical knowledge under the scheduling of the retrieval enhanced generation scheduler, and to generate the quantum computing program according to the document list of the quantum computing experimental plan and the software toolkit knowledge.

9. The system of claim 8, further comprising: A front-end interface is used to display the quantum computing program, the document list of the theoretical knowledge and the document list of the software toolkit knowledge under the scheduling of the retrieval enhancement generation scheduler.

10. 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 perform the method as claimed in any one of claims 1 to 7.

11. A non-transitory computer-readable storage medium storing one or more programs, the one or more programs being configured to, when executed by a processor, cause the method of any one of claims 1 to 7 to be performed.

Citation Information

Patent Citations

  • QP frame-based automatic code generator

    CN106569838A

  • Test case generation method based on quantum program language grammar rule

    CN115344476A

  • 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

  • Generating a semantic search engine results page

    WO2024163599A1

Cited By

  • Traditional Chinese medicine prescription generation method and system based on knowledge graph retrieval enhancement

    CN119479985A