Data analysis method and system based on retrieval enhancement generation, electronic equipment and program product

By introducing iterative, recursive and hybrid search modules into the search enhancement generation method, and combining with the classifier to classify user queries, the problems of low RAG recall and high resource consumption are solved, and an efficient and flexible query solution is achieved.

CN120336523APending Publication Date: 2025-07-18CHINA UNIONPAY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411998387.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

The existing search enhancement generation method (RAG) has insufficient recall rates, resulting in excessive resource consumption and low retrieval efficiency, making it difficult to provide flexible and efficient query solutions under limited computing resources.

Method used

Retrieval enhancement generation strategy based on iterative search module, recursive search module or mixed module is adopted, and user queries are classified in combination with a classifier, and adaptive processing methods are selected based on the classification results, including iterative search, recursive search or mixed search, and resource allocation and search process are optimized.

Benefits of technology

It improves the retrieval recall rate, reduces resource consumption, realizes efficient query under limited computing resources, and adapts to flexible processing of queries of different types of user.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120336523A_ABST
    Figure CN120336523A_ABST
Patent Text Reader

Abstract

The invention provides a data analysis method based on retrieval enhancement generation, and the method comprises the steps: classifying received user queries based on a first classification condition and a second classification condition, and forming classified user queries; adaptively processing the user query with a retrieval enhancement generation policy corresponding to the classified user query to generate a query result; outputting the query result to a user; wherein the first classification condition is related to the expression of the user query, and the second classification condition is related to the process of processing the user query; wherein the retrieval enhancement generation strategy comprises adopting an iterative retrieval module, adopting a recursive retrieval module or adopting the iterative retrieval module and the recursive retrieval module. A data analysis system, an electronic device, and a program product based on retrieval enhancement generation are also provided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of natural language processing, and more specifically, to technologies related to retrieval-augmented generation. Background Art

[0002] When conducting question answering in combination with large language models, retrieval-augmented generation (RAG) technology is generally used. An important part of RAG is the document retriever, which is responsible for retrieving relevant content from a large number of documents for the large model to generate answers. However, in current RAG methods, data flows unidirectionally, resulting in a low recall rate of the recall pipeline. Technical paths to improve the RAG recall rate include increasing the recall pipeline and adding a feedback mechanism, but this approach may increase resource consumption. For retrieval, it is expected to provide a more flexible, highly efficient, and fast querying retrieval solution with as little computing power resources as possible. Summary of the Invention

[0003] According to one aspect of the present application, there is provided a data analysis method based on retrieval-augmented generation, the method comprising: classifying a received user query based on a first classification condition and a second classification condition to form a classified user query; adaptively processing the user query with a retrieval-augmented generation strategy corresponding to the classified user query to generate a query result; outputting the query result to the user; wherein the first classification condition is related to the expression of the user query, and the second classification condition is related to the process of processing the user query; wherein the retrieval-augmented generation strategy includes using an iterative retrieval module, using a recursive retrieval module, or using any one of the two.

[0004] The provided data analysis method based on retrieval-augmented generation, optionally or as a supplement, classifying the received user query based on the first classification condition and the second classification condition includes classifying the user query into one of a first type of user query, a second type of user query, and a third type of user query by a classifier according to the first classification condition and the second classification condition; wherein the process of the first type of user query is simple; the second type of user query is clear but the process is complex; the third type of user query is fuzzy and the process is complex.

[0005] The provided data analysis method based on retrieval-augmented generation, optionally or as a supplement, the classifier includes a first classifier and a second classifier, the first classifier is used to classify the user query based on the first condition; the second classifier is used to classify the user query based on the second condition.

[0006] The provided data analysis method based on retrieval-augmented generation, optionally or as a supplement, the classifier is a language model-based classifier, and the classifier is pre-trained according to the following process: constructing a labeled data set, where the label indicates whether the data set is clearly expressed or ambiguously expressed and indicates whether the process of processing the corresponding user query of the data set is simple or complex; training the language model-based classifier with the constructed data set.

[0007] The provided data analysis method based on retrieval-augmented generation, optionally or as a supplement, adaptively processes the user query with a retrieval-augmented generation strategy corresponding to the classified user query, including: when the classified user query is the first type of user query, searching the knowledge base with the iterative retrieval module, where, during the search process, more context information is provided through retrieval iteration; when the classified user query is the second type of user query, searching the knowledge base with the recursive retrieval module, where, during the search within the set number of recursive rounds, a new query is generated with the previous search results for searching, thereby performing feedback-based search; when the classified user query is the third type of user query, the hybrid module performs the retrieval, and the hybrid module is based on the iterative retrieval module and the recursive retrieval module.

[0008] The provided data analysis method based on retrieval-augmented generation, optionally or as a supplement, when the user query involves data analysis, adaptively processing the user query with a retrieval-augmented generation strategy corresponding to the classified user query further includes calling a database to perform a query.

[0009] According to another aspect of the present application, there is also provided a data analysis system based on retrieval-augmented generation, the system includes: a classifier that classifies the received user query based on the first classification condition and the second classification condition; a retrieval module that adaptively processes the user query with a retrieval-augmented generation module corresponding to the classified user query to generate a query result; an output module that outputs the query result to the user; where the first classification condition is related to the expression of the user query, and the second classification condition is related to the process of processing the user query; where the retrieval module includes an iterative retrieval module and a recursive retrieval module.

[0010] According to still another aspect of the present application, there is also provided an electronic device, which includes a memory and a processor, and the memory stores program instructions, and when the processor executes these program instructions, it can implement any one of the methods described above.

[0011] There is also provided a program product, which stores program instructions, and when these program instructions are executed, it can implement any one of the methods described above. Brief Description of the Drawings

[0012] Referring to the following detailed description of the specific embodiments in conjunction with the accompanying drawings, the present application will be more fully understood. The same reference numerals in the drawings refer to the same elements, where:

[0013] Figure 1 is a schematic structural diagram of a device 1 capable of executing a data analysis method based on retrieval-augmented generation according to an example of the present application;

[0014] Figure 2 is a flowchart of a data analysis method based on retrieval-augmented generation according to some embodiments of the present application;

[0015] Figure 3 is a process schematic of a data analysis method based on retrieval-augmented generation according to some specific embodiments of the present application;

[0016] Figure 4 is a structural diagram of a data analysis system based on retrieval-augmented generation according to some embodiments of the present application. Detailed Description of the Embodiments

[0017] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will describe the embodiments of the present application clearly and completely in conjunction with the accompanying drawings. It should be noted that the described embodiments are only some of the embodiments of the technical solutions of the present application, not all. All other embodiments obtained by those of ordinary skill in the art based on the embodiments described in this application document without creative efforts are covered by the protection scope of the present application.

[0018] Figure 1 is a schematic structural diagram of a device 1 capable of executing a data analysis method based on retrieval-augmented generation according to an example of the present application. As Figure 1 shown, the device includes a memory 10 and a processor 12. The memory 10 is used to store program instructions for the operation of the device. The processor 12 can execute these instructions and at least implement the data analysis method based on retrieval-augmented generation to be described below during the execution of these program instructions. As an example, Figure 1 the device 1 shown can be an electronic device such as a smart phone, a tablet computer, a laptop computer, or a desktop computer.

[0019] In some examples, device 1 receives user input through an input component. The input component can be one or a combination of input components such as a voice input component like a microphone, a video input component like a camera, a text input component like a keyboard, a mouse, or a touch screen. In some cases, the memory 10 of device 1 stores knowledge and / or data for responding to user input. At this time, the memory 10 can include two types. One is a memory for storing knowledge and data information, and the other is a memory for storing program instructions. In more cases, the knowledge base and the database that device 1 interacts with during the execution of the illustrated retrieval-enhanced generation-based data analysis method are set in other devices or in the cloud that are communicatively connected to device 1, and device 1 interacts with them through a network. For example, in Figure 1 a knowledge base 20 and a database 22 communicatively connected to device 1 are shown.

[0020] It should be noted that for the sake of brevity, Figure 1 only the components in device 1 that are required to implement the method to be described below in this application are schematically shown, and this should not be construed as limiting the structure of the devices for implementing the various embodiments of this application.

[0021] Figure 2 is a flowchart of a retrieval-enhanced generation-based data analysis method according to some embodiments of this application. This method can be executed, for example, by a device 1 such as Figure 1 shown. The device 1 is, for example, a smart phone. The user inputs the information they want to query through device 1, and this input can be voice input or text input, etc. The device 1 that receives the user input can execute the method according to the examples of this application to quickly and accurately form a response, and then output it to the user through device 1, for example.

[0022] As Figure 2As shown, in step S200, based on the first classification condition and the second classification condition, the received user query is classified to form a classified user query. As an example, the first classification condition may be related to the expression of the user query, and the second classification condition is related to the process of processing the user query. The first classification condition related to the expression of the user query is, for example, classified according to the expression clarity, and the clarity may be semantic clarity. For example, based on the expression input by the user, if it is possible to clearly determine what to query without interaction, the user query is considered clear; conversely, based on the expression input by the user, if one or more interactions are required to determine what the user is querying, the user query is considered fuzzy. The second classification condition may be related to the process of processing the user query. For example, the user query is classified as simple or complex in the process according to whether the process of processing the user query is simple or complex. The division between simple and complex processes is relative. By way of example and not limitation, the retrieval process for implementing the user query with only one retrieval time can be regarded as a simple question, and the rest are regarded as complex questions. The retrieval times here include the processes of performing retrieval and forming answers. As an alternative, in some examples, the retrieval times not exceeding two can also be regarded as simple questions. According to the embodiments of the present application, in the classification process based on the first classification condition and the second classification condition, the two conditions are considered in combination, and accordingly, the user query can be classified as: clear / fuzzy and simple (that is, simple whether it is clear or fuzzy), clear but complex, fuzzy and complex.

[0023] In step S202, the user query is adaptively processed with a retrieval enhancement generation strategy corresponding to the classified user query to generate a query result. According to the example of the present application, different retrieval enhancement generation strategies are set to process the user query. The retrieval enhancement generation strategies include an iterative retrieval module, a recursive retrieval module, and a retrieval module based on iteration and recursion. Exemplarily, the iterative retrieval module is a module based on an iterative algorithm; the recursive retrieval mode is a module based on a recursive algorithm; and the retrieval module based on iteration and recursion is a module based on both iterative and recursive algorithms, which is called a hybrid module in some examples herein. According to the embodiments of the present application, after receiving the classified user query, the user query is adaptively processed according to the classification and the corresponding strategy.

[0024] In step S204, the query result is output to the user. As an example, the big data language model combines the user query result and the user query to form a final query result and output it. Specifically, the final result is converted into a suitable manner to be presented to the user so that the user can know. The output manner can be output through a display screen or output through voice.

[0025] According to an embodiment of the present application, after receiving a user query, it is first classified to facilitate subsequent targeted processing of various user queries. When processing user queries, different types of user queries are processed separately in a manner such as iterative, recursive, or a combination of the two. Compared with conventional RAG retrieval, the allocation of retrieval resources is more reasonable and the retrieval process is more efficient.

[0026] Figure 3 is a process schematic of a data analysis method based on retrieval-augmented generation according to some specific embodiments of the present application. As Figure 3 shown, a user query is received in step S300. In step S302, the user query is classified by a classifier. As an example, the classifier is pre-trained. In this example, the first classifier of the pre-trained classifier classifies whether the user query is clearly expressed or vaguely expressed, and the second classifier of the pre-trained classifier classifies whether the process of the user query is simple or complex. Thus, after being processed by the first classifier, a clear or vague label is attached to the user query, and after being processed by the second classifier, a label indicating whether the process is simple or complex is attached to the user query. Furthermore, for a user query labeled as having a simple process, according to the example of the present application, regardless of whether the label of the first classifier is simple or complex, it can be classified as the first type of user query, that is, a user query with a simple process; if the label of the first classifier of the user query is that the user query is clear but the label of the second classifier is that the process is complex, then the user query is classified as the second type of user query; if the label of the first classifier of the user query is that the user query is vague and the label of the second classifier is that the process is complex, then the user query is classified as the third type of user query.

[0027] The classifier is, for example, a pre-trained language model-based classifier, such as a Bidirectional Encoder Representations from Transformers (BERT) model. For the training of the classifier, according to the examples of this application, a dataset required for training the classifier can be first constructed, which includes user input questions (i.e., user queries), and also includes labels indicating whether the user queries are clearly expressed or vaguely expressed, and whether the processes are simple or complex. As an example, for the classification of clear or vague expressions, it mainly refers to whether there are ambiguous terms in the user input, and manual combination with a large model can be used for label annotation. The simplicity or complexity of the process is determined according to the number of retrieval times, or, if necessary, manual combination with a large model can also be used for annotation. The labeled training dataset can include two parts: questions and labels. The questions are the main body of the user queries, and the labels are used to indicate whether the question is clearly expressed or vaguely expressed, and whether the question is a simple or complex process. When constructing the data training set, the method of expanding with similar questions can be used for dataset expansion. The classifier is trained with the established labeled dataset. As an example, the established labeled dataset is used to train the first classifier and the second classifier respectively. The first classifier is used to classify the user query as clearly expressed or vaguely expressed; the second classifier is used to classify the user query as a simple or complex process. During the training process, the cross-entropy loss function and the number of iterations that perform best on the validation dataset can be adopted.

[0028] In step S304, according to the classification, retrieval is performed using the retrieval module corresponding to the classification. Specifically, when the user query is a first type of user query, it is processed by the iterative retrieval module, as shown in step S304a. When the user query is a second type of user query, it is processed by the recursive retrieval module, as shown in step S304b. When the user query is a third type of user query, retrieval is performed by the hybrid retrieval module. Specifically, the hybrid retrieval module can reuse the iterative retrieval module and the recursive retrieval module in this application. First, it is processed by the iterative retrieval module, and then the recursive retrieval module uses the output of the iterative retrieval module as the query input for processing, as shown in step S304c.

[0029] In step S304a, the iterative retrieval module repeatedly searches the knowledge base. During the search process, more context information is provided through retrieval iteration. Briefly, iterative retrieval is a process of repeatedly searching the knowledge base based on the initial user query and the currently generated text. Through multiple retrieval iterations, more context references are provided, thereby enhancing the accuracy of subsequent answer generation. For example, setting the number of iteration rounds as k, the iterative retrieval process is as follows:

[0030] Assume the user's question is Q, the initial retrieval result is R0 = retrieve(Q), the answer obtained from the initial retrieval is A0 = generate(R0), and the context is updated to C1 =

[0031] combine(Q, A0). Similarly, in the i-th iteration, R i-1 = retrieve(C i-1 ),

[0032] A i-1 = generate(R i-1 ), C i = combine(C i-1 , A i-1 ). The final answer is A k = generate(R k ).

[0033] In step S304b, the recursive retrieval module retrieves from the knowledge base. During the search within the set number of recursive rounds, the previous search results are used as feedback to generate a new query and search again. In this way, a multi-round search based on feedback is formed. Briefly, setting the number of recursive rounds to k, the recursive retrieval process is as follows: Recursive retrieval can optimize the query through feedback based on the prior search results and search again. After multiple rounds like this, the most relevant information is gradually found, thereby obtaining comprehensive search results. Thus, more accurate and comprehensive retrieval results can be given for user queries with unclear expressions or high professionalism and complexity.

[0034] Assume the user's question is Q, the initial retrieval result is R0 = retrieve(Q), the initial answer is A0 = generate(R0), and the new query Q1 = generate_query(A0). Similarly, in the i-th retrieval, R i-1 = retrieve(Q i-1 ), the updated answer is A i-1 =

[0035] generate(R i-1 ), and the updated context Q1 = generate_query(A i-1 ). The final answer is A k = generate(R k ).

[0036] In step S304c, the hybrid module retrieves the knowledge base. According to the example of the present application, the hybrid module first retrieves by the iterative retrieval module and then by the recursive retrieval module. In this process, the user query is processed by the iterative retrieval module, and the processing result can be used as a new query and input into the recursive retrieval module for processing by the recursive retrieval module.

[0037] According to an embodiment of the present application, if the user query also involves data analysis, then according to the example of the present application, based on the SQL statement generated when querying the database during the retrieval process, the database is called and the statement is executed to obtain the query result from the database. The process of querying the database may occur in any one of steps S304a, S304b, and S304c.

[0038] In step S306, the large language model generates a reply for answering the user query based on the retrieval result. Specifically, the reply is generated by combining the user query and the retrieval result and presented to the user.

[0039] As described above in connection with Figure 2 and Figure 3 any example of the data analysis method based on retrieval-augmented generation can be executed by an electronic device such as Figure 1 shown. For example, the data analysis method based on retrieval-augmented generation is implemented as program instructions, and these program instructions are stored in the memory 10 of the electronic device 1 and executed by the processor 12 to implement the embodiments described above in connection with Figure 2 and Figure 3 described.

[0040] During the process of executing the data analysis method based on retrieval-augmented generation described in the present application, if the user query classifier confirms that the problem is very simple and does not require retrieval through RAG, the large language model directly processes the user query to form a reply to the user query.

[0041] Figure 4 is a structural diagram of a data analysis system based on retrieval-augmented generation according to some embodiments of the present application. As Figure 4As shown, the system includes a classifier 40, a retrieval module 42, and an output module 44. The classifier 40 classifies the received user query based on a first classification condition and a second classification condition. The retrieval module 42 adaptively processes the user query with a retrieval enhancement generation module corresponding to the classified user query to generate a query result. The output module 44 outputs the query result to the user. Specifically, the output module 44 is configured to combine the query result with the user query based on a large language model to form a final query result and output it. As an example, the first classification condition is related to the expression of the user query, and the second classification condition is related to the process of processing the user query; the retrieval module includes an iterative retrieval module 420 and a recursive retrieval module 421. As an example, the classifier 40 is configured to classify the received user query based on the first classification condition and the second classification condition through the following process. Specifically, the classifier 40 classifies the user query into one of a first type of user query, a second type of user query, and a third type of user query according to the first classification condition and the second classification condition. Further, the classifier 40 includes a first classifier and a second classifier. The first classifier is used to classify the user query based on the first classification condition; the second classifier is used to classify the user query based on the second classification condition.

[0042] As an example, the retrieval module 42 is configured to process the user query through the following process. Specifically, when the classified user query is a first type of user query, the iterative retrieval module is used to search the knowledge base. Among them, in the iterative search process, more context information is provided through retrieval iteration; when the classified user query is a second type of user query, the recursive retrieval module is used to search the knowledge base. Among them, in the process of searching within the set number of recursive rounds, the previous search result is used as feedback to generate a new query and search again, so as to achieve a comprehensive search after multiple rounds; when the classified user query is a third type of user query, the hybrid module is used for retrieval, and the hybrid module is based on the iterative retrieval module and the recursive retrieval module.

[0043] The retrieval module 42 is also configured to adaptively process the user query with a retrieval enhancement generation strategy corresponding to the classified user query when the user query involves data analysis, including calling a database for query.

[0044] Combine Figure 4 The described data analysis system based on retrieval enhancement generation can be used to execute according to Figure 2 or Figure 3The described retrieval-augmented generation-based data analysis method. For example, the classifier 40 executes steps S200 and S302 to assign the user query, the retrieval module 42 executes steps S202 and S304, and the output module 204 executes steps S204 and S306. During the execution of step S304 by the retrieval module 42, if the user query is labeled as a third type of user query, it is first processed by the iterative retrieval module, and the processing result of the iterative retrieval module is used as the input of the recursive retrieval module, which is further processed by the recursive retrieval module.

[0045] Figure 4 The shown retrieval-augmented generation-based data analysis system can be implemented in Figure 1 the electronic device 1. By way of example and not limitation, both the classifier 40 and the retrieval module 42 can be set in the electronic device 1 in software, for example, implemented as program instructions stored in the memory 10 and executed by the processor 12 to implement the functions of the retrieval-augmented generation-based data analysis system according to the examples of the present application.

[0046] In a specific example, the user input received (S300) is "Query the online consumption income last week". The classifier 40 labels (S302) this user input as the user query; since the expression "last week" is unclear, it is labeled as a fuzzy user query by the classifier 40, specifically by the first classifier. Since the number of retrievals required for this user query by the classifier 40 is two, it is labeled as a simple user query, specifically labeled by the second classifier. Based on the fuzzy and simple labels, it is determined that this user query is classified as a first type of query. Thus, the retrieval module 42 adaptively uses the iterative retrieval module to retrieve and process this user query (S304a). During the iterative retrieval process, the initial query question is "Query the online consumption income last week". During the initial retrieval process, the specific event represented by "last week" is determined according to the current event, and then the initial answer "The current date is September 30, 2024, and last week was from September 23, 2024, to September 29, 2024" is obtained, thereby obtaining more context information. The iterative retrieval module combines the initial answer with the original question, that is, the initial query question, to form a new query text. Accordingly, the question for the second query is "Query the online consumption income last week, where last week refers to from September 23, 2024, to September 29, 2024", and the second retrieval generates a SQL statement for searching the database based on the new text generated by the second query, that is, the question for the second query. This SQL statement is, for example:

[0047] SELECT SUM(amount)AS online_income

[0048] FROM transactions

[0049] WHERE trans_date BETWEEN '2024-09-23' AND '2024-09-29'

[0050] AND trans_type = 'online';

[0051] Use the above SQL statement to search in the database to obtain the query result. For this example, based on this query result, the final display result can be formed and output by the output module 44 (S306). Specifically, the output module 44 combines the user query and the search result to form the output, such as: According to the query, the online consumption income last week (from September 23, 2024 to September 29, 2024) was 12,345 yuan.

[0052] In yet another specific example, the received (S300) user input is "Predict the number of active merchants in the Shanghai area in the fourth quarter. Here, active merchants refer to those with a total monthly transaction volume of no less than 500 transactions". For this user input which is the user query, the first classifier of classifier 40 determines (S302) that the user query is clear and labels it with the tag of clear user query. The second classifier determines that the user query requires more than two retrievals and labels it with the tag of complex user query. Thus, it can be determined that this user query is a second-type user query, and the retrieval module 42 accordingly determines to process (S304) this user query through the recursive retrieval module. During the retrieval process within the set number of recursive rounds, the initial query question is "Predict the number of active merchants in the Shanghai area in the fourth quarter. Here, active merchants refer to those with a total monthly transaction volume of no less than 500 transactions". The initial retrieval is to query the historical transaction data of merchants in the Shanghai area (the fourth quarter of last year, the first, second, and third quarters of this year), which involves data querying. The retrieval module generates an SQL statement for querying the database. Query the result from the database with the SQL statement, and obtain the number of transactions of each merchant in the Shanghai area from October 2023 to September 2024. Generate a new query from this result. Enter the second retrieval with this new query. During this retrieval process, based on the result obtained from the first query, predict the number of transactions of each merchant in the Shanghai area in the fourth quarter. The answer for the second retrieval is the result of predicting the number of transactions of each merchant in the Shanghai area from October 2024 to December 2024. The recursive retrieval module enters the third query "The number of transactions of each merchant in the Shanghai area from October 2023 to September 2024 (query result), and the number of transactions of each merchant in the Shanghai area from October 2024 to December 2024 has been predicted (prediction result). Please predict the number of active merchants in the Shanghai area in the fourth quarter". The third retrieval is "Query the number of merchants with a total monthly transaction volume of no less than 500 transactions in the prediction result of the number of transactions of each merchant in the Shanghai area from October 2024 to December 2024. The query result is XX". The retrieval answer for the third retrieval, which is the final answer for this example, is "Predict that the number of active merchants in the Shanghai area in the fourth quarter is XX".

[0053] In another specific example, the user query is "Predict the number of active merchants in the Shanghai area in the next quarter". Since the next quarter and the number of active merchants are not specified in the user query, it is labeled as ambiguous by classifier 40. The classifier also determines that this question requires more than two retrievals and labels it as complex. This question is both ambiguous and complex and is classified as a third-type user query, which is processed by the hybrid retrieval module. That is, first, it is processed by the iterative retrieval module, and the processing result is used as a new query input to the recursive retrieval module, which is then processed by the recursive retrieval module to obtain the retrieval result, and finally, it is output by the output module.

[0054] Execute the data analysis method based on retrieval-augmented generation according to the embodiments of the present application or adopt the data analysis system based on retrieval-augmented generation according to the embodiments of the present application. The trained classification module classifies user queries into different user query models according to whether the expression is clear or not and whether the processing process is simple or not. For example, the three examples listed above are respectively classified into different user query types by the classifier. Subsequently, the RAG retrieval part adaptively adopts different search strategies to process different user queries based on the classification, so as to reasonably allocate resources. For example, for simple user queries, an iterative search strategy with less resource consumption is adopted; for those classified as moderately complex (i.e., the second type of user query), a recursive search strategy is adopted; for the most complex ones (i.e., the third type of user query), an iterative search is first performed and then a recursive query is carried out. In this way, the search resources are configured in a hierarchical manner based on the classification of user queries, avoiding the situation where the entire RAG search module is put into operation regardless of the difficulty of all searches, thus greatly saving resources.

[0055] The present application also provides an electronic device, which includes a memory and a processor. The memory includes program instructions, and when the processor processes these program instructions, it can implement the embodiments described above in conjunction with the accompanying drawings. This electronic device is, for example, the electronic device 1 described above in conjunction with Figure 1 description.

[0056] The present application also provides a program product, which includes program instructions that can implement the embodiments described above in conjunction with the accompanying drawings when these program instructions are executed.

[0057] The technical features in the embodiments of the present application can be combined with each other without departing from the spirit of the present application and without conflict with each other to form new embodiments. Although specific embodiments of the present application have been shown and described in detail to illustrate the principles of the present application, it should be understood that the present application can be implemented in other ways without departing from such principles.

Claims

1. A data analysis method based on retrieval-augmented generation, characterized in that, The method includes: Classifying the received user query based on a first classification condition and a second classification condition to form a classified user query; Adaptively processing the user query with a retrieval enhancement generation strategy corresponding to the classified user query to generate a query result; Outputting the query result to the user; wherein, the first classification condition is related to the expression of the user query, and the second classification condition is related to the process of processing the user query; wherein, the retrieval enhancement generation strategy includes using an iterative retrieval module, or using a recursive retrieval module, or using both the iterative retrieval module and the recursive retrieval module.

2. The method according to claim 1, wherein Classifying the received user query based on a first classification condition and a second classification condition includes The classifier classifies the user query into one of a first type of user query, a second type of user query, and a third type of user query according to the first classification condition and the second classification condition; wherein, the process of the first type of user query is simple; the second type of user query is clear but the process is complex; the third type of user query is fuzzy and the process is complex.

3. The method according to claim 2, wherein The classifier includes a first classifier and a second classifier. The first classifier is used to classify the user query based on the first condition; the second classifier is used to classify the user query based on the second condition.

4. The method according to claim 2, wherein The classifier is a classifier based on a language model, and the classifier is pre-trained according to the following process: Construct a labeled data set, where the label indicates whether the data set is clearly expressed or vaguely expressed and indicates whether the process of processing the user query corresponding to the data set is simple or complex; Training the classifier based on the language model with the constructed data set.

5. The method according to claim 2, characterized in that, Adaptively processing the user query with a retrieval enhancement generation strategy corresponding to the classified user query includes: When the classified user query is the first type of user query, searching the knowledge base with the iterative retrieval module, wherein, during the search process, more context information is provided through retrieval iteration; When the classified user query is the second type of user query, searching the knowledge base with the recursive retrieval module, wherein, during the search within the set number of recursive rounds, a new query is generated with the previous search result for searching, thereby performing feedback-based search; When the classified user query is the third type of user query, the hybrid module performs retrieval, and the hybrid module is based on the iterative retrieval module and the recursive retrieval module.

6. The method according to claim 5, characterized in that, When the user query involves data analysis, adaptively processing the user query with a retrieval enhancement generation strategy corresponding to the classified user query further includes calling a database for query.

7. The method according to any one of claims 1 to 6, characterized in that, Outputting the query result to the user includes: Combining the query result with the user query by a large language model to form a final query result and outputting it.

8. A data analysis system based on retrieval-augmented generation, characterized in that, The system includes: A classifier that classifies the received user query based on a first classification condition and a second classification condition; A retrieval module that adaptively processes the user query with a retrieval enhancement generation module corresponding to the classified user query to generate a query result; An output module that outputs the query result to the user; Among them, the first classification condition is related to the expression of the user query, and the second classification condition is related to the process of processing the user query; Among them, the retrieval module includes an iterative retrieval module and a recursive retrieval module.

9. The system according to claim 8, characterized in that, The classifier is configured to classify the received user query based on the first classification condition and the second classification condition through the following process, including: The classifier classifies the user query into one of the first type of user query, the second type of user query, and the third type of user query according to the first classification condition and the second classification condition; Among them, the process of the first type of user query is simple; the second type of user query is clear but the process is complex; the third type of user query is fuzzy and the process is complex.

10. The system according to claim 9, wherein The classifier includes a first classifier and a second classifier. The first classifier is used to classify the user query based on the first classification condition; the second classifier is used to classify the user query based on the second classification condition.

11. The system according to claim 9, wherein The retrieval module is configured to process the user query through the following process: When the classified user query is the first type of user query, the iterative retrieval module is used to search the knowledge base. Among them, during the search process, more context information is provided through iterative retrieval; When the classified user query is the second type of user query, the recursive retrieval module is used to search the knowledge base. Among them, during the search within the set number of recursive rounds, a new query is generated based on the previous search results for searching, thereby performing feedback-based search; When the classified user query is the third type of user query, the hybrid module is used for retrieval. The hybrid module is based on the iterative retrieval module and the recursive retrieval module.

12. The system according to claim 11, wherein The retrieval module is also configured to call the database for query when the user query involves data analysis.

13. The system according to claim 8, wherein The output module is configured to combine the query result with the user query based on a large language model to form a final query result and output it.

14. An electronic device, characterized in that, The device includes: A memory for storing program instructions; A processor configured to execute the program instructions and implement the method according to any one of claims 1 to 7 during the execution process; An output component configured to output a query result for the user query.

15. The electronic device according to claim 14, wherein, The electronic device includes a communication module for the electronic device to communicate with a knowledge base and a database disposed outside the electronic device.

16. A program product, characterized in that, Including program instructions that can implement the method according to any one of claims 1 to 7 when executed.