Question and answer mode data retrieval and large model summarization method and device, equipment and medium
By obtaining natural language problems in the intelligent question-and-answer system and generating structured query statements, the problem of low accuracy of complex or specific domain problems is solved, and efficient resource utilization and user experience improvement is achieved.
Patent Information
- Application Number
- CN202510372120.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-27
- Publication Date
- 2025-06-17
AI Technical Summary
When existing intelligent question-and-answer systems deal with complex or specific domain problems, their accuracy is not high, and their model deployment is complex, resource utilization efficiency is low, and there is a lack of effective bottom-up strategies, which affects the user experience.
By obtaining the user's natural language problems, writing prompt words, determining the indicator scope and target indicators, generating structured query statements, and performing query operations on the database server. If the query fails, the search results are filtered from the preset knowledge base, and the results are filtered and sorted, and finally the query results or search results are input to the preset model for summary.
Without the need to conduct training and fine-tuning for specific scenarios, improve the accuracy of question-and-answer data retrieval and large-scale model summary, reduce the complexity of model deployment, improve resource utilization efficiency, and enhance the robustness of the system and user experience.
Smart Images

Figure CN120162425A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and particularly to a method, device, equipment and medium for question-and-answer data retrieval and large model summary. Background Art
[0002] In the current intelligent question-and-answer system, converting the user's natural language question into an executable SQL (Structured Query Language) is a key step in realizing data-driven answers. However, in the prior art, when dealing with complex questions or questions in specific fields, there are often problems with low accuracy, especially errors are likely to occur in aspects such as index selection and condition construction. In addition, due to the different data structures and business requirements of each application scenario, targeted training and fine-tuning of the model not only require a large amount of computing resources, but may also lead to a decline in the generalization ability of the model. At the same time, when an effective SQL cannot be generated, the system often lacks an effective fallback strategy, affecting the user experience.
[0003] As can be seen from the above, how to realize question-and-answer data retrieval and large model summary without training and fine-tuning for specific scenarios, reduce the complexity of model deployment, improve resource utilization efficiency and the accuracy of question-and-answer data retrieval and large model summary is an issue to be solved in this field. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a method, device, equipment and medium for question-and-answer data retrieval and large model summary, which can realize question-and-answer data retrieval and large model summary without training and fine-tuning for specific scenarios, reduce the complexity of model deployment, and improve resource utilization efficiency and the accuracy of question-and-answer data retrieval and large model summary. The specific solutions are as follows:
[0005] In the first aspect, the present application discloses a method for question-and-answer data retrieval and large model summary, including:
[0006] Obtain the user's natural language question, write a prompt word for the natural language question, use the prompt word to determine the index range, and determine the target index corresponding to the natural language question based on the index range;
[0007] Generate a structured query statement based on the natural language question and the target index, input the structured query statement into the database server, and execute a query operation;
[0008] If the query operation is successful, output the query result to complete the question-and-answer data retrieval, and then input the query result and the natural language question into a preset model for summary to obtain a first question-and-answer summary result;
[0009] If the query operation fails, the target metric is used as a retrieval keyword to screen out retrieval results from a preset knowledge base, and the retrieval results are filtered and sorted to obtain target retrieval results to complete Q&A data retrieval. Then, the target retrieval results and the natural language question are input into the preset model for summarization to obtain a second Q&A summary result.
[0010] Optionally, writing prompt words for the natural language question includes:
[0011] Determining a prompt word writing rule based on the user's natural language question and introducing a domain knowledge graph;
[0012] Encapsulating the writing rule and writing statements into a template, and using the natural language question to fill and adjust the template to generate prompt words.
[0013] Optionally, using the prompt words to determine an index range and determining a target metric corresponding to the natural language question based on the index range includes:
[0014] Using the prompt words to screen out a target data table related to the natural language question from a preset data table;
[0015] Determining an index range from the target data table, writing a target prompt word according to the index range and the natural language question, and using the target prompt word to determine the target metric corresponding to the natural language question.
[0016] Optionally, generating a structured query statement based on the natural language question and the target metric includes:
[0017] Writing a structured prompt word according to the user's natural language question; the structured prompt word includes a time rule, a region rule, a structured query statement generation rule, a background knowledge rule, statements and statement examples;
[0018] Based on the natural language question and the target metric, and using NL2SQL technology and the structured prompt word to generate one or more structured query statements.
[0019] Optionally, if the query operation fails, using the target metric as a retrieval keyword to screen out retrieval results from a preset knowledge base includes:
[0020] If the query operation fails, start a retry mechanism, record the current retry count, and jump to the process of generating a structured query statement to generate the next structured query statement;
[0021] If the query operation corresponding to the next structured query statement fails, determine whether the current retry count is greater than the preset retry count threshold;
[0022] If the current retry count is greater than the preset retry count threshold, use the target metric corresponding to the natural language question as a retrieval keyword to filter out retrieval results from a preset knowledge base.
[0023] Optionally, the step of using the target metric as a retrieval keyword to filter out retrieval results from a preset knowledge base includes:
[0024] Obtain special data related to each metric, use retrieval augmented generation technology to construct a special knowledge base, and copy the special data to the special knowledge base in a one-to-one replication form;
[0025] Obtain summary data related to the natural language questions of all users, use retrieval augmented generation technology to construct a summary knowledge base, and copy the summary data to the summary knowledge base in a one-to-one replication form; the preset knowledge base includes the special knowledge base and the summary knowledge base;
[0026] Input the target metric as a retrieval keyword into the special knowledge base for retrieval. If relevant data exists in the special knowledge base, output the retrieval results;
[0027] If no relevant data exists in the special knowledge base, input the target metric as a retrieval keyword into the summary knowledge base for retrieval. If relevant data exists in the summary knowledge base, output the retrieval results.
[0028] Optionally, the step of filtering and sorting the retrieval results includes:
[0029] Filter the retrieval results according to the time, location, and metric in the user's natural language question to obtain the filtered retrieval results;
[0030] Sort the filtered retrieval results according to a preset sorting rule; the sorting rule includes a timeliness rule, an importance rule, and a relevance rule.
[0031] In a second aspect, the present application discloses a question-and-answer type data retrieval and large model summarization device, including:
[0032] A metric determination module, configured to obtain a user's natural language question, write a prompt word for the natural language question, use the prompt word to determine a metric range, and determine a target metric corresponding to the natural language question based on the metric range;
[0033] A query module, configured to generate a structured query statement based on the natural language question and the target metric, input the structured query statement into a database server, and perform a query operation;
[0034] A first summarization module, configured to, if the query operation is successful, output the query result to complete the Q&A data retrieval, and then input the query result and the natural language question into a preset model for summarization to obtain a first Q&A summarization result;
[0035] A second summarization module, configured to, if the query operation fails, use the target metric as a retrieval keyword to screen out a retrieval result from a preset knowledge base, filter and sort the retrieval result to obtain a target retrieval result to complete the Q&A data retrieval, and then input the target retrieval result and the natural language question into the preset model for summarization to obtain a second Q&A summarization result.
[0036] In a third aspect, the present application discloses an electronic device, including:
[0037] A memory, configured to store a computer program;
[0038] A processor, configured to execute the computer program to implement the foregoing Q&A data retrieval and large model summarization method.
[0039] In a fourth aspect, the present application discloses a computer storage medium, configured to store a computer program; wherein, when the computer program is executed by a processor, the steps of the foregoing disclosed Q&A data retrieval and large model summarization method are implemented.
[0040] As can be seen, the present application provides a method for question-and-answer data retrieval and large model summarization, including obtaining a user's natural language question, writing a prompt for the natural language question, determining an index range using the prompt, and determining a target index corresponding to the natural language question based on the index range; generating a structured query statement based on the natural language question and the target index, inputting the structured query statement into a database server, and performing a query operation; if the query operation is successful, outputting the query result to complete the question-and-answer data retrieval, and then inputting the query result and the natural language question into a preset model for summarization to obtain a first question-and-answer summary result; if the query operation fails, using the target index as a retrieval keyword to screen out a retrieval result from a preset knowledge base, filtering and sorting the retrieval result to obtain a target retrieval result to complete the question-and-answer data retrieval, and then inputting the target retrieval result and the natural language question into the preset model for summarization to obtain a second question-and-answer summary result. The present application writes a prompt for the user's natural language question to determine the target index, generates a structured query statement based on the natural language question and the target index, and can improve the overall accuracy of the question-and-answer scenario when dealing with complex or specific domain problems. Inputting the structured query statement into the database server and performing the query operation, if the query operation is successful, outputting the query result to complete the question-and-answer data retrieval, and inputting the query result and the natural language question into the preset model for summarization to obtain a first question-and-answer summary result, using the native capabilities of the large model without the need for training and fine-tuning for specific scenarios, reducing the cost and complexity of model deployment. If the query operation fails, using the target index as a retrieval keyword to screen out a retrieval result from the preset knowledge base, filtering and sorting the retrieval result to obtain a target retrieval result to complete the question-and-answer data retrieval, and inputting the target retrieval result and the natural language question into the preset model for summarization to obtain a second question-and-answer summary result, which can reduce unnecessary computing power consumption, improve resource utilization efficiency, and use the preset knowledge base for further retrieval after the database server fails to ensure that the user's question can be reasonably answered, enhancing the robustness of the system and the user experience, and improving resource utilization efficiency and the accuracy of question-and-answer data retrieval and large model summarization. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on the provided drawings without creative efforts.
[0042] Figure 1Flowchart of a question-and-answer type data retrieval and large model summarization method disclosed in this application;
[0043] Figure 2 Specific flowchart of a question-and-answer type data retrieval and large model summarization disclosed in this application;
[0044] Figure 3 Schematic structural diagram of a question-and-answer type data retrieval and large model summarization device disclosed in this application;
[0045] Figure 4 Structural diagram of an electronic device provided by this application. Specific implementation manner
[0046] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0047] In the current intelligent question-and-answer system, converting the user's natural language question into an executable SQL is a key step to achieve data-driven answers. In the prior art, when dealing with complex questions or questions in specific fields, there are often problems with low accuracy, especially in terms of index selection and condition construction. In addition, due to the different data structures and business requirements of each application scenario, targeted training and fine-tuning of the model not only require a large amount of computing resources, but may also lead to a decline in the generalization ability of the model. At the same time, when an effective SQL cannot be generated, the system often lacks an effective fallback strategy, affecting the user experience. As can be seen from the above, how to achieve question-and-answer type data retrieval and large model summarization without targeted training and fine-tuning for specific scenarios, reduce the complexity of model deployment, improve resource utilization efficiency, and the accuracy of question-and-answer type data retrieval and large model summarization is a problem to be solved in this field.
[0048] See Figure 1 As shown, the embodiments of the present invention disclose a question-and-answer type data retrieval and large model summarization method, which may specifically include:
[0049] Step S11: Obtain the user's natural language question, write a prompt word for the natural language question, use the prompt word to determine the index range, and determine the target index corresponding to the natural language question based on the index range.
[0050] In this embodiment, a natural language question of a user is obtained, a prompting word writing rule is determined based on the natural language question of the user and by introducing a domain knowledge graph, the writing rule and writing statements are encapsulated into a template, and the natural language question is used to fill and adjust the template to generate a prompting word. The prompting word is used to screen out a target data table related to the natural language question from a preset data table, an index range is determined from the target data table, a target prompting word is written according to the index range and the natural language question, and the target index corresponding to the natural language question is determined by using the target prompting word.
[0051] Specifically, in a natural language question, a user usually asks for information about a certain or certain preset data tables. First, it is necessary to determine the preset data tables involved in the user's question. The process is as follows:
[0052] Write a Prompt: To determine the data tables involved in the user's question, first, a Prompt needs to be written. This Prompt includes all possible table creation statements, user questions, and table selection rules, etc. The table selection rules can be determined according to the keywords, phrases, or context in the user's question. Based on the written Prompt, this application uses the semantic understanding ability of a general large model to automatically select the target data table most relevant to the user's question. If the question only involves a single table, this step can be skipped. After determining the target data table involved in the natural language question of the user, it is necessary to further determine the indicators (i.e., columns in the target data table) involved in the natural language question, frame a possible indicator range according to the table selection result, and write a target Prompt again based on the natural language question of the user and the indicators within the indicator range. This target Prompt includes the selected indicators within the range, the natural language question, and the indicator selection rules, etc. Based on the written target Prompt, the semantic understanding ability of the general large model is used to automatically select the target indicator most relevant to the natural language question of the user.
[0053] In addition, this application adopts some optimization strategies to improve the writing efficiency and accuracy of the Prompt. For example, the method of templatization can be used to write the Prompt, encapsulating common table creation statements, table selection rules, SQL generation rules, etc. into a template, and filling and adjusting according to specific problems when needed.
[0054] Furthermore, in certain specific fields (such as medical, finance, etc.), the user's natural language questions may involve a large number of professional terms and domain knowledge. To handle these questions, this application introduces a domain knowledge graph into the technical solution. The domain knowledge graph is a structured knowledge representation method that can represent entities, attributes, and relationships in the domain in the form of a graph. By introducing the domain knowledge graph, more background knowledge and context information are provided for the technical solution, thereby improving the accuracy and efficiency of queries.
[0055] Step S12: Generate a structured query statement based on the natural language question and the target metric, input the structured query statement into the database server, and perform a query operation.
[0056] In this embodiment, a structured prompt word is written according to the user's natural language question; the structured prompt word includes time rules, region rules, structured query statement generation rules, background knowledge rules, statements, and statement examples; based on the natural language question and the target metric, and using NL2SQL technology and the structured prompt word, one or more structured query statements are generated, and the structured query statement is input into the database server, and a query operation is performed.
[0057] After this application determines the target data table and target metric involved in the user's natural language question, the next step is to generate an SQL query statement. The specific process is as follows:
[0058] Write a structured prompt word: To generate an SQL query statement, first, a structured prompt word containing SQL generation rules needs to be written. This structured prompt word includes SQL generation rules such as filtering time rules, filtering region rules, etc., as well as relevant background knowledge rules for selecting metrics, table creation statements, insert statement examples related to selecting metrics, and user questions.
[0059] Generate SQL: Based on the written structured prompt word, using the generation ability of a general large model, one or more SQL query statements are automatically generated, and these SQL query statements can accurately reflect the intention of the user's question.
[0060] After generating the SQL query statement, input the SQL query statement into the database server, and perform a query operation. The database server will return the query results, and these results will be used for subsequent analysis and summary.
[0061] Step S13: If the query operation is successful, output the query results to complete the question-and-answer data retrieval, and then input the query results and the natural language question into a preset model for summary to obtain a first question-and-answer summary result.
[0062] Step S14: If the query operation fails, use the target metric as the retrieval keyword to screen out retrieval results from the preset knowledge base, filter and sort the retrieval results to obtain the target retrieval results, so as to complete the question-and-answer data retrieval, and then input the target retrieval results and the natural language question into the preset model for summarization to obtain the second question-and-answer summary result.
[0063] In this embodiment, if the query operation fails, a retry mechanism is started, the current retry count is recorded, and the process jumps to the process of generating a structured query statement to generate the next structured query statement; if the query operation corresponding to the next structured query statement fails, it is determined whether the current retry count is greater than the preset retry count threshold; if the current retry count is greater than the preset retry count threshold, obtain the special data related to each metric, use the retrieval enhancement generation technology to construct a special knowledge base, and copy the special data to the special knowledge base in a one-to-one copy manner; obtain the summary data related to the natural language questions of all users, use the retrieval enhancement generation technology to construct a summary knowledge base, and copy the summary data to the summary knowledge base in a one-to-one copy manner; the preset knowledge base includes the special knowledge base and the summary knowledge base; input the target metric as the retrieval keyword into the special knowledge base for retrieval, if there is relevant data in the special knowledge base, output the retrieval result; if there is no relevant data in the special knowledge base, input the target metric as the retrieval keyword into the summary knowledge base for retrieval, if there is relevant data in the summary knowledge base, output the retrieval result, and then filter the retrieval result according to the time, location, and metric in the natural language question of the user to obtain the filtered retrieval result; sort the filtered retrieval result according to the preset sorting rules to obtain the target retrieval result, so as to complete the question-and-answer data retrieval; the sorting rules include the timeliness rule, the importance rule, and the relevance rule.
[0064] Specifically, input the SQL query statement into the database server and execute the query operation. The database server will return the query result. If the query operation fails (for example, due to a syntax error or a database connection problem), a retry mechanism is started. The retry mechanism can include adjusting the prompt words and regenerating the SQL query statement, modifying the database connection parameters, etc. In addition, a preset retry count threshold can be set to ensure that when the query still cannot be successfully completed after multiple attempts, other processing strategies can be switched in a timely manner.
[0065] If the current retry count is greater than the preset retry count threshold, it indicates that the SQL query statement cannot be successfully generated at this time or the query result does not meet the user's expectations. At this time, it is necessary to use the preset knowledge base for retrieval to provide an accurate answer to the user. The specific process is as follows:
[0066] (1) Construct a preset knowledge base. Construct a special knowledge base: For specific indicators, use retrieval-augmented generation technology to construct a special knowledge base, and copy the special data into the special knowledge base in a one-to-one replication form to ensure the pertinence and accuracy of retrieval results. At the same time, in order to support efficient retrieval operations, it is necessary to reasonably index and store the data in the knowledge base; Construct a summary knowledge base: In addition to the special knowledge base, a summary knowledge base containing all data can also be constructed. This knowledge base can be used as a fallback solution to provide additional retrieval opportunities when no matching data can be found in the special knowledge base.
[0067] (2) Knowledge base retrieval. After constructing the preset knowledge base, the next step is to implement the knowledge base retrieval function. Extract indicators: Extract the target indicators corresponding to the natural language question, and use these target indicators as retrieval keywords to search for relevant data in the preset knowledge base.
[0068] Give priority to retrieving the special knowledge base: Based on the extracted target indicators, give priority to retrieving in the special knowledge base. Since the special knowledge base only contains data related to the current indicator, the retrieval results are usually more accurate and targeted.
[0069] Secondly, retrieve the summary knowledge base: If no matching data can be found in the special knowledge base, then turn to the summary knowledge base for retrieval. Since the summary knowledge base contains all data, it can be used as a fallback solution to provide additional retrieval opportunities for users.
[0070] In addition, the retrieval threshold can also be adjusted: To improve the recall rate of retrieval, the retrieval threshold can be appropriately reduced. This means that during the retrieval process, the requirements for the matching degree will be relaxed to find more potentially relevant data. However, this will also increase the noise and redundancy of the retrieval results, so it is necessary to filter and sort the retrieval results in subsequent steps.
[0071] (3) Result filtering and sorting. After obtaining the relevant retrieval results, it is necessary to filter and sort the retrieval results to ensure that users obtain accurate and organized answers.
[0072] Filtering: According to the conditions such as time, location, and indicators in the user's natural language question, the retrieved results can be filtered. The filtering operation can remove data that is irrelevant to the question or does not meet the conditions, thereby improving the accuracy and relevance of the results.
[0073] Sorting: In order to make it easier for users to understand and accept the retrieval results, it is necessary to sort the filtered retrieval results. Sorting can be carried out according to factors such as the timeliness, importance, and relevance of the data. Through the sorting operation, the results can be presented to users more regularly and orderly.
[0074] Finally, the target retrieval results and the natural language question are input into a preset model for summarization to obtain the second Q&A-style summary result. To generate an accurate summary result, we need to provide the SQL statement, the target retrieval results, and the natural language question as input information to the preset model. These pieces of information can help the preset model understand the context and purpose of the query and generate an answer that meets the user's expectations (i.e., the second Q&A-style summary result). Based on the input information, the preset model can utilize its powerful semantic understanding and generation capabilities to automatically generate one or more summary results. These summary results should be able to accurately reflect the content of the query results and be presented to the user in a concise and clear manner.
[0075] The method for generating the first Q&A-style summary result is the same as that for generating the second Q&A-style summary result. At the same time, since the retrieval results may contain multiple relevant data points or information fragments, the preset model also needs to have the ability to integrate this information into a coherent and well-organized answer.
[0076] This application combines the NL2SQL step-by-step decomposition technology with the RAG (Retrieval Augmented Generation) technology to construct a Q&A-style data retrieval and large model summarization system, including an NL2SQL module, a RAG module, a model summarization module, and a user interface module. The specific process is as Figure 2 shown.
[0077] The NL2SQL module is used to generate an SQL query statement based on the user's natural language question and attempt to execute the query; it mainly includes a table selection step, an indicator determination step, an SQL generation step, a database query step, and a retry mechanism step;
[0078] The RAG module is used to retrieve relevant data from a preset knowledge base based on the question and perform filtering and sorting when the NL2SQL module's query fails; it mainly includes a data knowledge base construction step, a knowledge base retrieval step, and a retrieval result filtering and sorting step;
[0079] The model summarization module is used to input the output result of the NL2SQL module or the RAG module together with the user's natural language question into a preset model for summarization to obtain the first Q&A-style summary result or the second Q&A-style summary result;
[0080] The user interface module is used to receive the user's input natural language question and display the first Q&A-style summary result or the second Q&A-style summary result of the model summarization.
[0081] This application utilizes the native capabilities of general large models, eliminating the need for training and fine-tuning for specific scenarios, reducing the cost and complexity of model deployment, and significantly improving the overall accuracy in the question-answering scenario, especially when dealing with complex or domain-specific problems; without sacrificing model performance, it minimizes the computing power resources required for training and fine-tuning as much as possible, improving resource utilization efficiency; by combining the dual guarantees of NL2SQL and RAG, it significantly enhances the accuracy in the question-answering scenario, particularly more prominent when dealing with complex or domain-specific problems; through efficient step-by-step decomposition of NL2SQL and RAG fallback strategies, it reduces unnecessary computing power consumption, improves resource utilization efficiency, ensures that user questions can be reasonably responded to, and enhances the robustness and user experience of the system.
[0082] In this embodiment, a natural language question of a user is obtained, a prompt is written for the natural language question, an index range is determined by using the prompt, and a target index corresponding to the natural language question is determined based on the index range; a structured query statement is generated based on the natural language question and the target index, and the structured query statement is input into a database server and a query operation is executed; if the query operation is successful, the query result is output to complete the question-and-answer data retrieval, and then the query result and the natural language question are input into a preset model for summarization to obtain a first question-and-answer summary result; if the query operation fails, the target index is used as a retrieval keyword to screen out retrieval results from a preset knowledge base, and the retrieval results are filtered and sorted to obtain target retrieval results to complete the question-and-answer data retrieval, and then the target retrieval results and the natural language question are input into the preset model for summarization to obtain a second question-and-answer summary result. In this application, a prompt is written for the natural language question of the user, so as to determine the target index, and a structured query statement is generated based on the natural language question and the target index, which can improve the overall accuracy of the question number scenario when dealing with complex or specific domain problems. The structured query statement is input into the database server and a query operation is executed. If the query operation is successful, the query result is output to complete the question-and-answer data retrieval. The query result and the natural language question are input into the preset model for summarization to obtain a first question-and-answer summary result. By using the native capabilities of the large model, there is no need to perform training and fine-tuning for specific scenarios, which reduces the cost and complexity of model deployment. If the query operation fails, the target index is used as a retrieval keyword to screen out retrieval results from the preset knowledge base, the retrieval results are filtered and sorted to obtain target retrieval results, the question-and-answer data retrieval is completed, and the target retrieval results and the natural language question are input into the preset model for summarization to obtain a second question-and-answer summary result, which can reduce unnecessary computing power consumption, improve resource utilization efficiency, and use the preset knowledge base for further retrieval after the database server fails to ensure that the user's question can be reasonably responded to, enhance the robustness of the system and the user experience, and improve resource utilization efficiency and the accuracy of question-and-answer data retrieval and large model summarization.
[0083] See Figure 3 As shown, an embodiment of the present invention discloses a question-and-answer data retrieval and large model summarization device, which may specifically include:
[0084] An index determination module 11, configured to obtain a natural language question of a user, write a prompt for the natural language question, determine an index range by using the prompt, and determine a target index corresponding to the natural language question based on the index range;
[0085] A query module 12, configured to generate a structured query statement based on the natural language question and the target metric, input the structured query statement into a database server, and perform a query operation;
[0086] A first summary module 13, configured to, if the query operation is successful, output a query result to complete question-and-answer data retrieval, and then input the query result and the natural language question into a preset model for summarization to obtain a first question-and-answer summary result;
[0087] A second summary module 14, configured to, if the query operation fails, use the target metric as a retrieval keyword to screen out a retrieval result from a preset knowledge base, filter and sort the retrieval result to obtain a target retrieval result to complete question-and-answer data retrieval, and then input the target retrieval result and the natural language question into the preset model for summarization to obtain a second question-and-answer summary result.
[0088] In this embodiment, a natural language question of a user is obtained, a prompt is written for the natural language question, an index range is determined by using the prompt, and a target index corresponding to the natural language question is determined based on the index range; a structured query statement is generated based on the natural language question and the target index, and the structured query statement is input into a database server and a query operation is executed; if the query operation is successful, a query result is output to complete question-and-answer data retrieval, and then the query result and the natural language question are input into a preset model for summarization to obtain a first question-and-answer summary result; if the query operation fails, the target index is used as a retrieval keyword to screen out a retrieval result from a preset knowledge base, and the retrieval result is filtered and sorted to obtain a target retrieval result to complete question-and-answer data retrieval, and then the target retrieval result and the natural language question are input into the preset model for summarization to obtain a second question-and-answer summary result. In this application, a prompt is written for the natural language question of the user, so as to determine the target index, and a structured query statement is generated based on the natural language question and the target index, which can improve the overall accuracy of the question-answering scenario when dealing with complex or specific domain problems. The structured query statement is input into the database server and the query operation is executed. If the query operation is successful, the query result is output to complete question-and-answer data retrieval. The query result and the natural language question are input into the preset model for summarization to obtain a first question-and-answer summary result. By using the native capabilities of the large model, there is no need to perform training and fine-tuning for specific scenarios, which reduces the cost and complexity of model deployment. If the query operation fails, the target index is used as a retrieval keyword to screen out a retrieval result from the preset knowledge base, the retrieval result is filtered and sorted to obtain a target retrieval result to complete question-and-answer data retrieval, and the target retrieval result and the natural language question are input into the preset model for summarization to obtain a second question-and-answer summary result, which can reduce unnecessary computing power consumption, improve resource utilization efficiency, and use the preset knowledge base for further retrieval after the database server fails to ensure that the user's question can be reasonably responded to, improve the robustness of the system and the user experience, and improve resource utilization efficiency and the accuracy of question-and-answer data retrieval and large model summarization.
[0089] In some specific embodiments, the index determination module 11 may specifically include:
[0090] A rule determination module, configured to determine a prompt writing rule based on the natural language question of the user and by introducing a domain knowledge graph;
[0091] A prompt generation module, configured to encapsulate the writing rule and the writing statement into a template, and fill and adjust the template by using the natural language question to generate a prompt.
[0092] In some specific embodiments, the index determination module 11 may specifically include:
[0093] A target data table screening module, configured to use a prompt word to screen out a target data table related to the natural language question from a preset data table;
[0094] A target index determination module, configured to determine an index range from the target data table, write a target prompt word according to the index range and the natural language question, and use the target prompt word to determine a target index corresponding to the natural language question.
[0095] In some specific embodiments, the query module 12 may specifically include:
[0096] A rule generation module, configured to write a structured prompt word according to the user's natural language question; the structured prompt word includes a time rule, a region rule, a structured query statement generation rule, a background knowledge rule, a statement, and a statement example;
[0097] A structured query statement generation module, configured to generate one or more structured query statements based on the natural language question and the target index, and using NL2SQL technology and the structured prompt word.
[0098] In some specific embodiments, the second summary module 14 may specifically include:
[0099] A retry mechanism activation module, configured to activate a retry mechanism if a query operation fails, record the current retry count, and jump to the process of generating a structured query statement to generate the next structured query statement;
[0100] A judgment module, configured to judge whether the current retry count is greater than a preset retry count threshold if the query operation corresponding to the next structured query statement fails;
[0101] A first retrieval module, configured to use the target index corresponding to the natural language question as a retrieval keyword to screen out retrieval results from a preset knowledge base if the current retry count is greater than the preset retry count threshold.
[0102] In some specific embodiments, the second summary module 14 may specifically include:
[0103] A special knowledge base construction module, configured to obtain special data related to each index, use retrieval augmentation generation technology to construct a special knowledge base, and copy the special data to the special knowledge base in a one-to-one replication form;
[0104] The summary knowledge base construction module is used to obtain summary data related to the natural language questions of all users, construct a summary knowledge base by using retrieval-augmented generation technology, and copy the summary data into the summary knowledge base in a one-to-one replication form; the preset knowledge base includes the special knowledge base and the summary knowledge base;
[0105] The second retrieval module is used to input the target indicator as a retrieval keyword into the special knowledge base for retrieval. If there is relevant data in the special knowledge base, the retrieval result is output;
[0106] The third retrieval module is used to, if there is no relevant data in the special knowledge base, input the target indicator as a retrieval keyword into the summary knowledge base for retrieval. If there is relevant data in the summary knowledge base, the retrieval result is output.
[0107] In some specific embodiments, the second summarization module 14 may specifically include:
[0108] The filtering module is used to filter the retrieval result according to the time, location, and indicator in the natural language question of the user to obtain the filtered retrieval result;
[0109] The sorting module is used to sort the filtered retrieval result according to a preset sorting rule; the sorting rule includes a timeliness rule, an importance rule, and a relevance rule.
[0110] Figure 4 This is a schematic structural diagram of an electronic device provided by 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. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the question-answering data retrieval and large model summarization method executed by the electronic device disclosed in any of the foregoing embodiments.
[0111] 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 external devices, and the communication protocol it follows is any communication protocol applicable to the technical solution of the present application, and specific limitations are not imposed on it here; the input / output interface 25 is used to obtain external input data or output data to the outside, and its specific interface type can be selected according to specific application needs, and specific limitations are not made here.
[0112] In addition, as a carrier for storing resources, the memory 22 can be a read-only memory, a random access memory, a magnetic disk, an optical disk, etc. The resources stored thereon include an operating system 221, a computer program 222, data 223, etc. The storage method can be transient storage or permanent storage.
[0113] Among them, the operating system 221 is used to manage and control each hardware device on the electronic device 20 and the computer program 222, so as to enable the processor 21 to perform operations and processing on the data 223 in the memory 22. It can be Windows, Unix, Linux, etc. In addition to the computer program that can be used to complete the question-and-answer data retrieval and large model summarization method executed by the electronic device 20 disclosed in any of the foregoing embodiments, the computer program 222 can further include computer programs that can be used to complete other specific tasks. In addition to the data that can include the data transmitted by external devices received by the question-and-answer data retrieval and large model summarization device, the data 223 can also include the data collected by its own input / output interface 25, etc.
[0114] The steps of the method or algorithm described in combination with the embodiments disclosed in this article can be implemented directly by hardware, a software module executed by a processor, or a combination of the two. The software module can be placed in a random access memory (RAM), memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.
[0115] Furthermore, the embodiments of the present application also disclose a computer-readable storage medium. When the computer program stored in the storage medium is loaded and executed by a processor, the steps of the question-and-answer data retrieval and large model summarization method disclosed in any of the foregoing embodiments are implemented.
[0116] Finally, it should also be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of another identical element in the process, method, article or device including the element.
[0117] The above has introduced in detail a method, apparatus, device, and storage medium for question-and-answer data retrieval and large model summary provided by the present invention. Specific examples are used in this article to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.
Claims
1. A question-answering data retrieval and large model summarization method, characterized in that: include: Acquire a natural language question of a user, write prompt words for the natural language question, use the prompt words to determine an indicator range, and determine a target indicator corresponding to the natural language question based on the indicator range; Generate a structured query statement based on the natural language question and the target indicator, input the structured query statement into a database server, and perform a query operation; If the query operation is successful, the query result is output to complete the question-answering data retrieval, and then the query result and the natural language question are input into a preset model for summarization to obtain a first question-answering summary result; If the query operation fails, the target indicator is used as a search keyword to filter out search results from a preset knowledge base, and the search results are filtered and sorted to obtain target search results to complete question-and-answer data retrieval, and then the target search results and the natural language questions are input into the preset model for summary to obtain a second question-and-answer summary result.
2. The question-answer data retrieval and large model summarization method according to claim 1, characterized in that: The step of writing prompt words for the natural language question includes: Determine the prompt word writing rules based on the user's natural language questions and introduce domain knowledge graphs; The writing rules and writing sentences are encapsulated as a template, and the template is filled and adjusted using the natural language question to generate prompt words.
3. The question-answer data retrieval and large model summarization method according to claim 1, characterized in that: The step of determining an indicator range by using the prompt word and determining a target indicator corresponding to the natural language question based on the indicator range includes: Using the prompt words, a target data table related to the natural language question is selected from the preset data tables; An indicator range is determined from the target data table, a target prompt word is written according to the indicator range and the natural language question, and a target indicator corresponding to the natural language question is determined using the target prompt word.
4. The question-answer data retrieval and large model summarization method according to claim 1, characterized in that: The generating of a structured query statement based on the natural language question and the target indicator includes: Compile structured prompt words according to the user's natural language questions; the structured prompt words include time rules, region rules, structured query statement generation rules, background knowledge rules, statements and statement examples; Based on the natural language question and the target indicator, one or more structured query statements are generated by using NL2SQL technology and the structured prompt words.
5. The question-answer data retrieval and large model summarization method according to claim 1, characterized in that: If the query operation fails, the target indicator is used as a search keyword to filter out search results from a preset knowledge base, including: If the query operation fails, the retry mechanism is started, the current number of retries is recorded, and the process of generating structured query statements is jumped to generate the next structured query statement; If the query operation corresponding to the next structured query statement fails, determining whether the current number of retries is greater than a preset number of retries threshold; If the current number of retries is greater than a preset retry number threshold, the target indicator corresponding to the natural language question is used as a search keyword to filter out search results from a preset knowledge base.
6. The question-answer data retrieval and large model summarization method according to claim 1, characterized in that: The step of using the target indicator as a search keyword to filter out search results from a preset knowledge base includes: Acquire special data related to each indicator, build a special knowledge base using search enhancement generation technology, and copy the special data to the special knowledge base in a one-to-one copy form; Obtaining summary data related to natural language questions of all users, constructing a summary knowledge base using retrieval enhancement generation technology, and copying the summary data to the summary knowledge base in a one-to-one copy form; the preset knowledge base includes the special knowledge base and the summary knowledge base; Input the target indicator as a search keyword into the special knowledge base for searching, and if relevant data exists in the special knowledge base, output the search result; If there is no relevant data in the special knowledge base, the target indicator is input as a search keyword into the summary knowledge base for retrieval. If there is relevant data in the summary knowledge base, the retrieval result is output.
7. The question-answer data retrieval and large model summarization method according to any one of claims 1 to 6, characterized in that: The filtering and sorting of the search results includes: Filtering the search results according to the time, place and index in the user's natural language question to obtain the filtered search results; The filtered search results are sorted according to preset sorting rules; the sorting rules include timeliness rules, importance rules and relevance rules.
8. A question-answering data retrieval and large model summarization device, characterized in that: include: An indicator determination module, used to obtain a natural language question of a user, write prompt words for the natural language question, determine an indicator range using the prompt words, and determine a target indicator corresponding to the natural language question based on the indicator range; A query module, used to generate a structured query statement based on the natural language question and the target indicator, input the structured query statement into a database server, and perform a query operation; A first summarizing module is used to output the query result if the query operation is successful, so as to complete the question-answering data retrieval, and then input the query result and the natural language question into a preset model for summarization, so as to obtain a first question-answering summary result; The second summary module is used to use the target indicator as a search keyword to filter out search results from a preset knowledge base if the query operation fails, and filter and sort the search results to obtain target search results to complete question-and-answer data retrieval, and then input the target search results and the natural language questions into the preset model for summary to obtain a second question-and-answer summary 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 question-and-answer data retrieval and large model summarization method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein, when the computer program is executed by a processor, it implements the question-and-answer data retrieval and large model summarization method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Large language model reasoning method and system based on multi-level knowledge retrieval enhancement
CN118036753A
Knowledge retrieval enhancement generation method and system based on large language model
CN118394890A
Real-time interactive question answering system, method and equipment integrating vectorization retrieval and large model technology
CN118885559A
Database AI question answering system and method based on large language model and retrieval enhancement
CN118981522A
Method for correcting nonstandard SQL (Structured Query Language) statement based on large language model
CN119003563A
Cited By
Intelligent number asking method and related device
CN121144464A
Question and answer method, device and equipment based on large language model and storage medium
CN121256003A
Multi-source information processing method, system and equipment based on dynamic perception and intelligent response and medium
CN121456227A
Power data intelligent question and answer method and device based on efficient fine tuning and tool calling
CN121996755A