Data query method and device, equipment and storage medium
By performing tree structure transformation on the original query and parallel document retrieval in the document database, combining the reciprocal sorting fusion algorithm and answer integration of large language models, the problem of poor correlation between answer content and documents in the existing RAG system is solved, and the relevance of answers and systematic interpretability are improved.
Patent Information
- Application Number
- CN202510238507.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-03
- Publication Date
- 2025-06-06
AI Technical Summary
Existing query solutions based on RAG systems are difficult to reliably associate the generated answer content with specific retrieved documents, affecting the credibility and interpretability of the system. Especially when dealing with large amounts of documents and multi-angle information queries, it is easy to have problems such as insufficient coverage of query intentions and single ranking of search results.
By obtaining the original query and converting the tree structure based on the large language model, multiple subqueries are generated; subqueries are searched in parallel in the document database, and document sorting is used using the reciprocal sorting fusion algorithm; finally, answers are integrated based on the document sorting results and the large language model to determine the target answer corresponding to the original query.
It effectively improves the relevance and accuracy of generated answers, improves the reasoning ability and interpretability of the generation system, and thus enhances the user experience.
Smart Images

Figure CN120104785A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data query method, device, equipment and storage medium. Background Art
[0002] The current query solution based on the RAG (Retrieval-Augmented Generation) system still has certain limitations. It is difficult to reliably associate the generated answer content with specific retrieved documents, which affects the credibility and explainability of the system. And when processing a large number of documents, especially when the user query involves multi-angle information, the solution is also prone to insufficient query intent coverage and single ranking of retrieval results, resulting in inaccurate generated answer content and affecting user experience. Summary of the invention
[0003] In view of this, the purpose of the present invention is to provide a data query method, device, equipment and storage medium, which can effectively improve the relevance and accuracy of the generated answers, and enhance the reasoning ability and interpretability of the retrieval enhancement generation system, thereby improving the user experience. The specific scheme is as follows:
[0004] In a first aspect, the present application provides a data query method, which is applied to a retrieval enhancement generation system, comprising:
[0005] Obtaining an original query, and performing tree structure conversion on the original query based on a large language model to obtain a conversion result;
[0006] Performing document retrieval for each subquery in the conversion result based on the document database, and sorting the documents using the document retrieval results corresponding to each subquery and the inverse sorting fusion algorithm to obtain a document sorting result;
[0007] Answer integration is performed based on the document ranking result, the conversion result, and the large language model to determine a target answer corresponding to the original query.
[0008] Optionally, the performing tree structure conversion on the original query based on the large language model to obtain a conversion result includes:
[0009] Based on the large language model, the reasoning steps and multi-angle requirements in the original query are identified to complete the corresponding multi-hop intent recognition operation and obtain the multi-hop intent recognition result;
[0010] A tree structure is constructed for the original query based on the multi-hop intent recognition result and a preset tree structure template to determine a target query tree; the target query tree includes multiple sub-queries.
[0011] Optionally, performing document retrieval on each subquery in the conversion result based on a document database includes:
[0012] Obtain identification information corresponding to each of the sub-queries;
[0013] Clustering the retrieval intent of each sub-query in the conversion result, and configuring the retrieval channel based on the number of retrieval intents in the clustering result to obtain a retrieval channel configuration result;
[0014] Based on the preset hybrid retrieval strategy, the clustering results and the retrieval channel configuration results, parallel document retrieval is performed on each of the sub-queries in the document database, and the corresponding document retrieval result binding operation is triggered using the identification information corresponding to each of the sub-queries to obtain the document retrieval results corresponding to each of the sub-queries.
[0015] Optionally, the document sorting is performed using the document retrieval results corresponding to each of the sub-queries and a reciprocal sorting fusion algorithm to obtain a document sorting result, including:
[0016] Determining a ranking value of each document in the document retrieval result based on a smoothing constant;
[0017] Counting the ranking values of the documents to obtain target ranking values corresponding to the documents;
[0018] The documents are sorted in a descending order based on the target sorting value to obtain a document sorting result.
[0019] Optionally, integrating the answers based on the document ranking results, the conversion results and the large language model includes:
[0020] Performing contradictory information identification based on the document retrieval results corresponding to each of the sub-queries to obtain corresponding contradictory information identification results;
[0021] By inputting the document ranking result, the original query and the conversion result into the large language model, answer integration is performed in a recursive form and a multi-granularity fusion strategy, and a target answer and a traceability chain for tracing the generation stage of the target answer are determined;
[0022] The conflicting information identification result is used to determine the warning information corresponding to the target answer.
[0023] Optionally, the step of inputting the document ranking result, the original query, and the conversion result into the large language model to integrate the answers in a recursive form and a multi-granularity fusion strategy includes:
[0024] By inputting the document ranking result, the original query and the conversion result into the large language model, first answer information of each sub-query is obtained based on the multi-granularity fusion strategy;
[0025] By integrating the first answer information corresponding to each of the sub-queries, a corresponding parent node reconstruction operation is completed, and a current parent query is determined;
[0026] Determine second answer information corresponding to each current parent query based on the current parent query, the document ranking result, the original query, the multi-granularity fusion strategy, and the large language model;
[0027] Perform corresponding parent node reconstruction operation by integrating the second answer information to determine the current parent query;
[0028] Redirect to the step of determining the second answer information corresponding to each current parent query based on the current parent query, the document ranking result, the original query, the multi-granularity fusion strategy and the large language model, until reaching the root node in the conversion result, and determining the target answer based on the document ranking result and the large language model.
[0029] In a second aspect, the present application provides a data query device, which is applied to a retrieval enhancement generation system, comprising:
[0030] A query conversion module, used to obtain an original query and perform tree structure conversion on the original query based on a large language model to obtain a conversion result;
[0031] A document sorting module, used to perform document retrieval for each sub-query in the conversion result based on a document database, and to sort the documents using the document retrieval results corresponding to each sub-query and a reciprocal sorting fusion algorithm to obtain a document sorting result;
[0032] An answer determination module is used to integrate answers based on the document ranking results, the conversion results and the large language model to determine a target answer corresponding to the original query.
[0033] Optionally, the document sorting module includes:
[0034] A ranking value determining unit, used to determine the ranking value of each document in the document retrieval result based on a smoothing constant;
[0035] A ranking value counting unit, used for counting the ranking value of each of the documents to obtain a target ranking value corresponding to each of the documents;
[0036] The document sorting unit is used to sort each of the documents in a descending order based on the target sorting value to obtain a document sorting result.
[0037] In a third aspect, the present application provides an electronic device, including:
[0038] Memory, used to store computer programs;
[0039] The processor is used to execute the computer program to implement the steps of the aforementioned data query method.
[0040] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, which implements the steps of the aforementioned data query method when executed by a processor.
[0041] It can be seen that in this application, the original query is obtained through the retrieval enhancement generation system, and the original query is converted into a tree structure based on the large language model to obtain the conversion result; the document retrieval is performed on each subquery in the conversion result based on the document database, and the document retrieval results corresponding to each subquery and the reciprocal sorting fusion algorithm are used to sort the documents to obtain the document sorting result; the answer is integrated based on the document sorting result, the conversion result and the large language model to determine the target answer corresponding to the original query. That is, this application uses the retrieval enhancement generation system to first use the large language model to perform a tree conversion on the original query, and then retrieves each subquery in the conversion result in the document database, and sorts the documents using the reciprocal sorting fusion algorithm and the document retrieval result to obtain the document sorting result. Finally, the document sorting result and the large language model are used to determine the target answer corresponding to the original query. In this way, the relevance and accuracy of the generated answers can be effectively improved, and the reasoning ability and interpretability of the retrieval enhancement generation system can be improved, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0043] Figure 1 A flow chart of a data query method provided for this application;
[0044] Figure 2 A specific data query flow diagram provided for this application;
[0045] Figure 3 A schematic diagram of the structure of a data query device provided by this application;
[0046] Figure 4 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] The current query scheme based on the RAG system still has certain limitations. It is difficult to reliably associate the generated answer content with specific retrieved documents, which affects the credibility and interpretability of the system. And when processing a large number of documents, especially when the user query involves multi-angle information, the scheme is also prone to insufficient query intent coverage and single ranking of retrieval results, resulting in the generated answer content being inaccurate, affecting the user experience. To this end, the present application provides a data query scheme that can effectively improve the relevance and accuracy of the generated answers, and enhance the reasoning ability and interpretability of the retrieval enhancement generation system, thereby improving the user experience.
[0049] See also Figure 1 As shown, an embodiment of the present invention discloses a data query method, which is applied to a retrieval enhancement generation system, comprising:
[0050] Step S11: obtain an original query, and perform tree structure conversion on the original query based on a large language model to obtain a conversion result.
[0051] Specifically, in this embodiment, after receiving the original query sent by the user, the reasoning steps and multi-angle requirements in the original query are identified based on the large language model to complete the corresponding multi-hop intent recognition operation and obtain the multi-hop intent recognition result; the tree structure of the original query is constructed based on the multi-hop intent recognition result and the preset tree structure template to determine the target query tree; the target query tree includes multiple sub-queries. Among them, the preset tree structure template can be configured in advance based on actual needs, that is, when the original query of the user is received, the reasoning steps and multi-angle requirements of the original query are first detected using the large language model to optimize the query. In this process, the original query will be converted into a tree structure, in which the root node is the optimized query of the original query, and the leaf node represents the decomposed multiple sub-queries. These sub-queries are specific splits of the parent node query problem, which are parallel to each other, and each sub-query has a logical dependency relationship with the parent query. In this way, it is ensured that complex problems (queries involving multi-angle information and / or multi-hop queries) can be effectively decomposed into a series of small problems that are easy to handle.
[0052] At the same time, during the conversion process, for each sub-query, a large language model will be used to generate multiple extended queries to capture different aspects of user intent from multiple angles and improve the breadth of retrieval.
[0053] Step S12: performing document retrieval on each sub-query in the conversion result based on the document database, and sorting the documents using the document retrieval results corresponding to each sub-query and the inverse sorting fusion algorithm to obtain a document sorting result.
[0054] In this embodiment, after the original query is converted, each sub-query retrieves documents in the document database in parallel. That is, first, the identification information corresponding to each of the sub-queries is obtained; then, the sub-queries in the conversion result are clustered according to the search intent, and the search channel is configured based on the number of search intents in the clustering result to obtain the search channel configuration result; then, based on the preset hybrid search strategy, the clustering result and the search channel configuration result, each of the sub-queries is searched in parallel in the document database, and the identification information corresponding to each of the sub-queries is used to trigger the corresponding document search result binding operation to obtain the document search results corresponding to each of the sub-queries. In other words, this embodiment will detect the search intent of the query during the search, and configure a dedicated search channel for each intent to improve the accuracy and efficiency of the query and avoid query confusion. And after the document is found, it is bound to the identification information of the corresponding sub-query, thereby enhancing the document relevance.
[0055] Further, combined with Figure 2As shown, after completing the document retrieval of the subquery, this embodiment uses the reciprocal ranking fusion algorithm to re-rank the retrieved documents. That is, first, the ranking value of each document in the document retrieval result is determined based on the smoothing constant; then, the ranking value of each document is counted to obtain the target ranking value corresponding to each document; then, the documents are sorted from large to small based on the target ranking value to obtain the document ranking result. Among them, the calculation formula of the ranking value score is:
[0056] ;
[0057] In the formula, r is the ranking of the document in the document retrieval results; k is a smoothing constant. For each document, the inverse ranking scores (i.e., ranking values) obtained from each document retrieval result are added together to generate a combined score for each document, i.e., the target ranking value. Each document is then ranked and sorted based on the combined score.
[0058] Step S13: integrating answers based on the document ranking results, the conversion results and the large language model to determine a target answer corresponding to the original query.
[0059] In this embodiment, after obtaining the document ranking results, it is necessary to combine the conversion results and the large language model to integrate the answers. First, based on the document retrieval results corresponding to each of the sub-queries, contradictory information is identified to obtain the corresponding contradictory information identification results; then, by inputting the document ranking results, the original query and the conversion results into the large language model, the answers are integrated in a recursive form and a multi-granularity fusion strategy, and the target answer and the traceability chain used to trace the generation stage of the target answer are determined; then, the contradictory information identification results are used to determine the warning information corresponding to the target answer. That is, in the process of answer integration, the contradictory information in the document will be identified, and when determining the answer, the warning information is determined based on the contradictory information identification results for the user to view. Among them, the contradictory information is different records for the same thing or event in different documents. For example, the retrieved document 1 records that Company A was established in 2000, while the retrieved document 2 records that Company A was established in 2005. In addition, multi-granularity fusion is performed when integrating answers, and the choice of granularity can be determined by analyzing the intent of the query. For example, the granularity can include paragraph level, term level, and chapter level. In addition, the fusion of each granularity can select the corresponding fusion operator, and the fusion of each granularity is performed first, and then gradually integrated to obtain the integrated answer information.
[0060] In addition, a granular feature library can be established to record the best fusion mode for queries in different fields, so as to provide reliable fusion mode selection suggestions for subsequent new queries. Specifically, the granular feature library can include features such as the semantics, structure, context, data source type, and processing technology of the query. Then, it is necessary to record the best fusion mode for these queries and evaluate the performance indicators of the fusion mode, such as accuracy and response time. In addition, the feature library can be constructed using a structured database, such as a relational database or a non-relational database, based on the type of features and the complexity of the query. Then, a matching and recommendation mechanism needs to be designed. When a new query comes in, its features are extracted, and the similarity is matched with the records in the feature library to find the most similar cases and recommend the corresponding fusion mode.
[0061] It is further necessary to understand that, regarding answer integration, in this embodiment, the document ranking result, the original query and the conversion result are input into the large language model to obtain the first answer information of each sub-query based on the multi-granularity fusion strategy; the first answer information corresponding to each sub-query is integrated to complete the corresponding parent node reconstruction operation and determine the current parent query; the second answer information corresponding to each current parent query is determined based on the current parent query, the document ranking result, the original query, the multi-granularity fusion strategy and the large language model; the corresponding parent node reconstruction operation is performed by integrating the second answer information to determine the current parent query; and the step of determining the second answer information corresponding to each current parent query based on the current parent query, the document ranking result, the original query, the multi-granularity fusion strategy and the large language model is jumped again until the root node in the conversion result is reached, and the target answer is determined based on the document ranking result and the large language model. That is, then, this embodiment integrates the sub-queries and the answer information of the sub-queries to construct the query of its parent node and the answer information of the parent query, and this process is repeated until the entire query tree is traversed and the final target answer is generated at the root node. It can be understood that the contradictory information between the child nodes can also be integrated step by step following the recursive construction of the parent node, and finally the warning information is obtained.
[0062] In a specific implementation, the user inputs the original query content, for example: "What is the total sales revenue of Company X in Location B and Location S in December 2024?". Afterwards, the original query is processed by constructing a prompt word template and using a large language model to generate a sub-query with a tree structure. This step ensures that each generated sub-query is a simplified query, that is, the query can retrieve relevant documents in one document, and the RAG system can give an accurate answer based on the retrieved documents. If a query is still a more complex question, the query node will continue to be decomposed into multiple simpler sub-queries until all sub-queries meet the above conditions. If the original query is originally a simple question, the output contains only one root node, which is the optimized query. For example, the following query structure tree may be generated:
[0063] Root Node: <a1>and <a2>What is the sum of them? "
[0064] Subquery Q1: "What is the sales revenue of Company X in Location B in December 2024?"
[0065] Subquery Q2: "What is the sales revenue of Company X in S in December 2024?"
[0066] Among them, A1 and A2 are input labels, which are the generated contents of Q1 and Q2 subqueries.
[0067] For each subquery, a large language model can be used to generate multiple expanded queries, for example:
[0068] Subquery Q1 can be expanded to:
[0069] "What is the sales revenue of Company X in Location B in December 2024?"
[0070] "What are the sales figures for Company X in Location B in December 2024?"
[0071] Subquery Q2 is expanded to:
[0072] "What is the sales revenue of Company X in S in December 2024?"
[0073] "What are the sales figures of Company X in Location S in December 2024?"
[0074] Each expanded query is then encoded into a 768-dimensional vector using the bce-embedding-base_v1 model, and vector retrieval is performed in the document database. The bce-reranker-base_v1 model is used to perform a preliminary relevance ranking of the retrieval results for each query. After that, the inverse ranking fusion algorithm is used to perform a final ranking on each preliminary ranking result to generate a fused ranking document. The fused and ranked retrieval documents, the generated query, and the original query are input into the large language model to generate the answer to the subquery. The generated answer needs to correspond to the input label in the parent node query of the query, that is, the generated answer needs to be semantically coherent after being inserted into the parent query. For example, in this example, the output of subquery Q1 may be "1 million". The output of subquery Q2 may be "2 million".
[0075] After the content of the subquery is generated, the subquery content is fused to generate a new parent node query. For example, in this example, the output of the subquery replaces the input label of the parent query, and the fused query is: "What is the sum of 1 million and 2 million?". Then, the query continues the retrieval generation process in the previous step. This process is repeated until the entire query tree is traversed and the final answer is generated at the root node. In this way, by optimizing the original query and generating a query tree, complex problems can be structured. This is conducive to improving the reasoning ability of large language models and reducing the occurrence of hallucinations. On the other hand, by generating subqueries to achieve a one-to-one mapping between queries and retrieval documents, the accuracy of answers to multi-hop query questions can be improved.
[0076] It can be seen that in the embodiment of the present application, the original query is obtained through the retrieval enhancement generation system, and the original query is converted into a tree structure based on the large language model to obtain the conversion result; the document retrieval is performed on each subquery in the conversion result based on the document database, and the document is sorted using the document retrieval results corresponding to each subquery and the reciprocal sorting fusion algorithm to obtain the document sorting result; the answer is integrated based on the document sorting result, the conversion result and the large language model to determine the target answer corresponding to the original query. That is, the present application first uses the large language model to perform a tree conversion on the original query through the retrieval enhancement generation system, and then retrieves each subquery in the conversion result in the document database, and sorts the document using the reciprocal sorting fusion algorithm and the document retrieval result to obtain the document sorting result. Finally, the document sorting result and the large language model are used to determine the target answer corresponding to the original query. In this way, the relevance and accuracy of the generated answers can be effectively improved, and the reasoning ability and interpretability of the retrieval enhancement generation system can be improved, thereby improving the user experience.
[0077] See also Figure 3 As shown, the embodiment of the present application also discloses a data query device, which is applied to the retrieval enhancement generation system, including:
[0078] A query conversion module 11 is used to obtain an original query and perform tree structure conversion on the original query based on a large language model to obtain a conversion result;
[0079] A document sorting module 12, configured to perform document retrieval for each sub-query in the conversion result based on a document database, and to sort the documents using the document retrieval results corresponding to each sub-query and a reciprocal sorting fusion algorithm to obtain a document sorting result;
[0080] The answer determination module 13 is used to integrate answers based on the document ranking result, the conversion result and the large language model to determine a target answer corresponding to the original query.
[0081] Among them, for more specific working processes of the above-mentioned modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0082] It can be seen from this that, that is, this application uses a retrieval enhancement generation system to first use a large language model to perform a tree transformation on the original query, and then retrieve each subquery in the transformation result in the document database, and use the inverse sorting fusion algorithm and the document retrieval result to sort the documents to obtain the document sorting result. Finally, the document sorting result and the large language model are used to determine the target answer corresponding to the original query. In this way, the relevance and accuracy of the generated answers can be effectively improved, and the reasoning ability and interpretability of the retrieval enhancement generation system can be improved, thereby improving the user experience.
[0083] In some specific embodiments, the query conversion module 11 may specifically include:
[0084] A multi-hop intent recognition unit, used to recognize the reasoning steps and multi-angle requirements in the original query based on the large language model, so as to complete the corresponding multi-hop intent recognition operation and obtain the multi-hop intent recognition result;
[0085] A query tree construction unit is used to construct a tree structure for the original query based on the multi-hop intent recognition result and a preset tree structure template to determine a target query tree; the target query tree includes multiple sub-queries.
[0086] In some specific embodiments, the document sorting module 12 may specifically include:
[0087] An identification acquisition unit, used to acquire identification information corresponding to each of the sub-queries;
[0088] A search channel configuration unit, used to cluster the search intents of the sub-queries in the conversion result, and configure the search channels based on the number of search intents in the clustering result to obtain a search channel configuration result;
[0089] A document retrieval unit is used to perform parallel document retrieval on each of the sub-queries in a document database based on a preset hybrid retrieval strategy, the clustering results, and the retrieval channel configuration results, and use the identification information corresponding to each of the sub-queries to trigger a corresponding document retrieval result binding operation to obtain document retrieval results corresponding to each of the sub-queries.
[0090] In some specific embodiments, the answer determination module 13 may specifically include:
[0091] A contradictory information identification unit, used to identify contradictory information based on the document retrieval results corresponding to each of the sub-queries, so as to obtain a corresponding contradictory information identification result;
[0092] An answer integration unit, configured to integrate the answers in a recursive manner and with a multi-granularity fusion strategy by inputting the document ranking result, the original query, and the conversion result into the large language model, and to determine a target answer and a traceability chain for tracing the generation stage of the target answer;
[0093] The warning information determining unit is used to determine the warning information corresponding to the target answer by using the conflict information identification result.
[0094] In some specific embodiments, the answer integration unit may specifically include:
[0095] A first answer information determination subunit, configured to obtain first answer information of each sub-query based on the multi-granularity fusion strategy by inputting the document ranking result, the original query and the conversion result into the large language model;
[0096] A first answer information integration subunit, used to complete the corresponding parent node reconstruction operation and determine the current parent query by integrating the first answer information corresponding to each of the sub-queries;
[0097] A second answer information determination subunit, configured to determine second answer information corresponding to each current parent query based on the current parent query, the document ranking result, the original query, the multi-granularity fusion strategy, and the large language model;
[0098] A second answer information integration subunit, configured to perform a corresponding parent node reconstruction operation by integrating the second answer information to determine a current parent query;
[0099] The answer determination subunit is used to jump back to the step of determining the second answer information corresponding to each current parent query based on the current parent query, the document ranking result, the original query, the multi-granularity fusion strategy and the large language model, until reaching the root node in the conversion result, and determining the target answer based on the document ranking result and the large language model.
[0100] Furthermore, the present application also discloses an electronic device. Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0101] Figure 4 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the data query method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0102] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0103] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0104] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, and can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the data query method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0105] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned disclosed data query method. The specific steps of the method can refer to the corresponding contents disclosed in the aforementioned embodiments, and will not be repeated here.
[0106] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0107] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0108] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0109] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0110] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article 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 of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data query method, characterized in that: Applied to retrieval enhancement generation system, including: Obtaining an original query, and performing tree structure conversion on the original query based on a large language model to obtain a conversion result; Performing document retrieval for each subquery in the conversion result based on the document database, and sorting the documents using the document retrieval results corresponding to each subquery and the inverse sorting fusion algorithm to obtain a document sorting result; Answer integration is performed based on the document ranking result, the conversion result, and the large language model to determine a target answer corresponding to the original query.
2. The data query method according to claim 1, characterized in that: The converting the original query into a tree structure based on the large language model to obtain a conversion result includes: Based on the large language model, the reasoning steps and multi-angle requirements in the original query are identified to complete the corresponding multi-hop intent recognition operation and obtain the multi-hop intent recognition result; A tree structure is constructed for the original query based on the multi-hop intent recognition result and a preset tree structure template to determine a target query tree; the target query tree includes multiple sub-queries.
3. The data query method according to claim 1, characterized in that: The performing document retrieval on each sub-query in the conversion result based on the document database includes: Obtain identification information corresponding to each of the sub-queries; Clustering the retrieval intent of each sub-query in the conversion result, and configuring the retrieval channel based on the number of retrieval intents in the clustering result to obtain a retrieval channel configuration result; Based on the preset hybrid retrieval strategy, the clustering results and the retrieval channel configuration results, parallel document retrieval is performed on each of the sub-queries in the document database, and the corresponding document retrieval result binding operation is triggered using the identification information corresponding to each of the sub-queries to obtain the document retrieval results corresponding to each of the sub-queries.
4. The data query method according to any one of claims 1 to 3, characterized in that: The document sorting is performed using the document retrieval results corresponding to each of the sub-queries and a reciprocal sorting fusion algorithm to obtain a document sorting result, including: Determining a ranking value of each document in the document retrieval result based on a smoothing constant; Counting the ranking values of the documents to obtain target ranking values corresponding to the documents; The documents are sorted in a descending order based on the target sorting value to obtain a document sorting result.
5. The data query method according to claim 3, characterized in that: The answer integration based on the document ranking result, the conversion result and the large language model includes: Performing contradictory information identification based on the document retrieval results corresponding to each of the sub-queries to obtain corresponding contradictory information identification results; By inputting the document ranking result, the original query and the conversion result into the large language model, answer integration is performed in a recursive form and a multi-granularity fusion strategy, and a target answer and a traceability chain for tracing the generation stage of the target answer are determined; The conflicting information identification result is used to determine the warning information corresponding to the target answer.
6. The data query method according to claim 5, characterized in that: The document ranking result, the original query and the conversion result are input into the large language model to integrate the answers in a recursive form and a multi-granularity fusion strategy, including: By inputting the document ranking result, the original query and the conversion result into the large language model, first answer information of each sub-query is obtained based on the multi-granularity fusion strategy; By integrating the first answer information corresponding to each of the sub-queries, a corresponding parent node reconstruction operation is completed, and a current parent query is determined; Determine second answer information corresponding to each current parent query based on the current parent query, the document ranking result, the original query, the multi-granularity fusion strategy, and the large language model; Perform corresponding parent node reconstruction operation by integrating the second answer information to determine the current parent query; Redirect to the step of determining the second answer information corresponding to each current parent query based on the current parent query, the document ranking result, the original query, the multi-granularity fusion strategy and the large language model, until reaching the root node in the conversion result, and determining the target answer based on the document ranking result and the large language model.
7. A data query device, characterized in that: Applied to retrieval enhancement generation system, including: A query conversion module, used to obtain an original query and perform tree structure conversion on the original query based on a large language model to obtain a conversion result; A document sorting module, used to perform document retrieval for each sub-query in the conversion result based on a document database, and to sort the documents using the document retrieval results corresponding to each sub-query and a reciprocal sorting fusion algorithm to obtain a document sorting result; An answer determination module is used to integrate answers based on the document ranking results, the conversion results and the large language model to determine a target answer corresponding to the original query.
8. The data query device according to claim 7, characterized in that: The document sorting module comprises: A ranking value determining unit, used to determine the ranking value of each document in the document retrieval result based on a smoothing constant; A ranking value counting unit, used for counting the ranking value of each of the documents to obtain a target ranking value corresponding to each of the documents; The document sorting unit is used to sort each of the documents in a descending order based on the target sorting value to obtain a document sorting result.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the data query method according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed by a processor, implements the data query method according to any one of claims 1 to 6.