Data question and answer method, system, equipment and computer program product

By rewriting user questions and combining large language models and database table views, a query language is built to generate answers, and the existing data question-and-answer system solves the problem of inefficient answers when facing complex questions, achieving higher accuracy and user experience.

CN119597868APending Publication Date: 2025-03-11CHINA MERCHANTS BANK
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411453513.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

Existing data question-and-answer systems are difficult to provide efficient answers when facing user complex questions, and their understanding of natural language is limited, so they cannot accurately analyze user intentions.

Method used

By receiving and rewriting user questions, combining pre-trained large language models and database table views, build query languages ​​and generate answers. This method includes rewriting user questions, retrieving related table data, constructing prompt words and generating query languages, and finally generating answers through a large language model.

Benefits of technology

It realizes more accurate identification of user intentions, improves the accuracy and flexibility of the Q&A system, provides a natural and smooth user experience, and improves application capabilities in professional fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119597868A_ABST
    Figure CN119597868A_ABST
Patent Text Reader

Abstract

The invention discloses a data question and answer method, system and device and a computer program product, and relates to the technical field of intelligent question and answer, and the method comprises the steps: receiving and rewriting a user question, and obtaining a rewritten user question; retrieving related table data in a database according to the rewritten user question to obtain a corresponding table view; constructing a first cue word in combination with the rewritten user question and the table view; obtaining a query language based on the first cue word through a large language model; querying through the database based on the query language to obtain query data, and constructing a second prompt word in combination with the user question; and finally, based on the second cue word, generating a corresponding answer through a large language model. According to the scheme, through user question rewriting, the user intention can be recognized more accurately; through data retrieval, model input is effectively reduced, and model accuracy is improved; meanwhile, based on the question answering system of the large language model, higher accuracy, flexibility, expansibility and user experience are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of intelligent question answering technology, and in particular to data question answering methods, systems, devices, and computer program products. Background Art

[0002] Currently, in data question answering systems, traditional question answering systems are mainly divided into rule-based question answering systems and machine learning-based question answering systems.

[0003] Rule-based question-answering systems usually rely on predefined rules and templates for question-answering, and the hardware requirements of rule-based question-answering systems are relatively low, and they only need to support basic servers and databases to run. Machine learning-based question-answering systems use natural language processing (NLP) and machine learning technologies for question-answering, and machine learning-based question-answering systems usually require higher hardware support, including high-performance servers and GPUs to support model training and reasoning.

[0004] Whether it is a rule-based question-answering system or a machine learning-based question-answering system, its ability to understand natural language is limited and it is often unable to accurately parse user intentions. In addition, a rule-based question-answering system relies on predefined rules and templates and is difficult to cope with diverse user question styles. The interactive interface and feedback mechanism of traditional question-answering systems are often rigid, making it difficult to provide a natural and smooth user experience. They are also not good at attribution analysis of data changes (increase / decrease) and lack professionalism.

[0005] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0006] The main purpose of this application is to provide a data question and answer method, system, device and computer program product, which aims to solve the technical problem of how a data question and answer system can provide efficient answers when facing complex questions from users.

[0007] To achieve the above objectives, this application proposes a data question-answering method, which includes:

[0008] Receive and rewrite the user's question to obtain the rewritten user's question;

[0009] According to the rewritten user question, relevant table data in the database is retrieved to obtain a table view corresponding to the relevant table data;

[0010] Combining the rewritten user question and the table view, constructing a first prompt word to obtain a query language corresponding to the first prompt word;

[0011] A second prompt word is constructed by combining the query data corresponding to the query language and the user question, and an answer corresponding to the user question is generated based on the second prompt word through a pre-trained large language model.

[0012] In one embodiment, the related table data includes a data table, table fields, and field values. The step of retrieving the related table data in a database according to the rewritten user question and obtaining a table view corresponding to the related table data includes:

[0013] According to the rewritten user question, using the sentence vector similarity score strategy, calculating the corresponding similarity score for the data table, the table field and the field value in the database;

[0014] Based on the similarity score, recall the data table, the table fields, and the field values ​​to obtain a recall result;

[0015] According to the recall result, a table view is constructed.

[0016] In one embodiment, the step of calculating the corresponding similarity scores for the data table, the table fields, and the field values ​​in the database using the sentence vector similarity score strategy according to the rewritten user question includes:

[0017] Using a pre-trained embedding model, the rewritten user question is converted into a first vector, and the data table, the table field, and the field value are converted into a second vector;

[0018] A similarity score between the first vector and the second vector is calculated.

[0019] In one embodiment, the step of recalling the data table, the table fields, and the field values ​​based on the similarity score to obtain the recall result includes:

[0020] sorting the similarity scores in reverse order to form a sorted list;

[0021] The data table, table field and field value corresponding to the preset similarity score are selected from the sorted list as the recall result.

[0022] In one embodiment, the step of combining the rewritten user question and the table view to construct a first prompt word to obtain a query language corresponding to the first prompt word includes:

[0023] Combine the rewritten user question with the table view to construct the first prompt word;

[0024] The first prompt word is input into a pre-trained large language model to obtain a query language corresponding to the first prompt word.

[0025] In one embodiment, the step of combining the query data corresponding to the query language and the user question to construct a second prompt word, and generating an answer corresponding to the user question based on the second prompt word by using a pre-trained large language model includes:

[0026] Perform a query in the database according to the query language corresponding to the first prompt word to obtain corresponding query data;

[0027] Combining the query data with the user question, constructing a second prompt word;

[0028] The second prompt word is input into the pre-trained large language model to generate an answer corresponding to the user question.

[0029] In one embodiment, before the step of performing a query in the database according to the query language corresponding to the first prompt word to obtain the corresponding query data, the step further includes:

[0030] Adjusting the query language corresponding to the first prompt word to obtain an adjusted query language;

[0031] Perform a validity check on the adjusted query language and obtain the check result;

[0032] If the verification result is that the query language passes the legal verification, the following steps are performed: querying in the database according to the query language corresponding to the first prompt word to obtain corresponding query data;

[0033] If the verification result is that the query language fails the legal verification, a violation reason is generated, and the violation reason and the user question are displayed to the user through a pre-trained large language model.

[0034] In addition, to achieve the above purpose, the present application also proposes a data question answering system, the system comprising:

[0035] A rewriting module, used for receiving and rewriting user questions to obtain rewritten user questions;

[0036] A retrieval module, used to retrieve relevant table data in a database according to the rewritten user question, and obtain a table view corresponding to the relevant table data;

[0037] A construction module, configured to construct a first prompt word by combining the rewritten user question and the table view to obtain a query language corresponding to the first prompt word;

[0038] A generation module is used to construct a second prompt word in combination with the query data corresponding to the query language and the user question, and generate an answer corresponding to the user question based on the second prompt word through a pre-trained large language model.

[0039] In addition, to achieve the above-mentioned purpose, the present application also proposes a data question and answer device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the data question and answer method described above.

[0040] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the data question and answer method described above.

[0041] The embodiment of the present application provides a data question-and-answer method, system, device, and computer program product, the method comprising receiving and rewriting a user question to obtain a rewritten user question; searching for relevant table data in a database according to the rewritten user question to obtain a table view corresponding to the relevant table data; constructing a first prompt word in combination with the rewritten user question and the table view to obtain a query language corresponding to the first prompt word; constructing a second prompt word in combination with the query data corresponding to the query language and the user question, and generating an answer corresponding to the user question based on the second prompt word through a pre-trained large language model. This solution can more accurately identify user intent by rewriting user questions; effectively reduce model input and improve model accuracy through data retrieval; and at the same time, the question-and-answer system based on the large language model achieves higher accuracy, flexibility, scalability, and user experience, and improves application capabilities in professional fields. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0043] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0044] Figure 1 A flowchart of the first embodiment of the data question and answer method of this application;

[0045] Figure 2 A schematic diagram of a code for constructing a table view based on a table field recall result provided in the first embodiment of the present application;

[0046] Figure 3 A schematic diagram of a table field search process provided in Example 1 of the present application;

[0047] Figure 4 A schematic diagram of constructing a first prompt word by combining a rewritten user question and a table view provided in the first embodiment of the present application;

[0048] Figure 5 A schematic diagram of a query language generated based on a first prompt word provided in the first embodiment of the present application;

[0049] Figure 6 A flowchart diagram of the second embodiment of the data question and answer method of this application;

[0050] Figure 7 A brief flowchart of the first embodiment of the present invention is provided;

[0051] Figure 8 This is a schematic diagram of the module structure of the data question and answer system according to an embodiment of the present application.

[0052] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0053] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0054] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0055] The main solution of the embodiment of the present application is: receiving and rewriting the user question to obtain the rewritten user question; according to the rewritten user question, retrieving the relevant table data in the database, and obtaining the table view corresponding to the relevant table data; combining the rewritten user question and the table view to construct a first prompt word to obtain the query language corresponding to the first prompt word; combining the query data corresponding to the query language and the user question to construct a second prompt word, and generating the answer corresponding to the user question based on the second prompt word through a pre-trained large language model.

[0056] Since both rule-based and machine learning-based question-answering systems have limited understanding of natural language, they are often unable to accurately parse user intent. Rule-based question-answering systems rely on predefined rules and templates, making it difficult to cope with diverse user question styles. The interactive interface and feedback mechanism of traditional question-answering systems are often rigid, making it difficult to provide a natural and smooth user experience. They are also not good at attribution analysis of data changes (increase / decrease) and lack professionalism.

[0057] This application provides a solution. By rewriting and parsing user questions, the system can more accurately identify the user's actual needs. Using techniques such as sentence vector similarity, you can find the tables and fields most relevant to the user's questions, thereby improving the relevance and quality of the search results. Based on the natural language understanding ability, powerful learning and adaptability of the large language model, the system can understand the user's intentions, improve the accuracy, flexibility and adaptability of the question-answering system, and achieve natural conversational interaction to enhance user experience; input the results of data changes and influencing factors into the large language model, use the model's reasoning ability to complete attribution analysis, and provide users with more professional and in-depth analysis results.

[0058] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, etc. The following takes a mobile phone as an example to illustrate this embodiment and the following embodiments.

[0059] Based on this, the present application embodiment provides a data question and answer method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the data question and answer method of this application.

[0060] In this embodiment, the data question and answer method includes steps S10 to S40:

[0061] Step S10, receiving and rewriting the user question to obtain the rewritten user question;

[0062] Optionally, the data question and answer system first receives questions or requests raised by the user in natural language, and determines whether the question entered by the user is vague or incomplete. If so, the data question and answer system adds some default information to the user's question to clarify the question. For example, the user enters "How are sales recently?" After receiving the question entered by the user, the data question and answer system rewrites it to "How were sales in the past week?"

[0063] It is determined whether the question input by the user contains the abbreviation or alias of the product. If so, the data question answering system converts the user's question into a standard name stored in the database.

[0064] Similarly, it is determined whether the question input by the user contains the company's abbreviation or alias. If so, the data question answering system converts the user's question into the official full name stored in the database.

[0065] Through the above steps, the received user questions are rewritten, and the data question answering system obtains a user question that is more standardized, clear and in line with the database structure, and can better prepare user questions, laying a solid foundation for subsequent data retrieval, logic construction and answer generation.

[0066] Step S20, searching for relevant table data in a database according to the rewritten user question, and obtaining a table view corresponding to the relevant table data;

[0067] It should be noted that, in this embodiment, the relevant table data includes a data table, table fields, and field values.

[0068] It is worth noting that due to the large number of data tables in the database, if they are all input into the large language model, it will increase resource usage and reduce the accuracy of Text2SQL (converting user questions into SQL query language).

[0069] Therefore, this embodiment searches the data table according to the rewritten user questions to solve the above problems; since there are too many fields in some tables, the table fields are searched according to the rewritten user questions to remove the relevant management fields; since there are too many field values, if all field values ​​are enumerated and input into the large language model, the efficiency will be reduced. Therefore, this embodiment searches the field values, such as the product name and risk exposure type fields have more values, and confirms the product name involved according to the rewritten user questions.

[0070] In a feasible implementation, step S20 may include steps S21 to S23:

[0071] Step S21, according to the rewritten user question, using the sentence vector similarity score strategy, calculate the corresponding similarity score for the data table, the table field and the field value in the database;

[0072] It should be noted that the sentence vector similarity score strategy is a natural language processing-based technique for quantifying the semantic similarity between two text fragments. This strategy can convert text into numerical vectors that capture the semantic information of words or sentences.

[0073] In another feasible implementation, step S21 may further include steps A1 to A2:

[0074] Step A1, using a pre-trained embedding model to convert the rewritten user question into a first vector, and converting the data table, the table field and the field value into a second vector;

[0075] It should be noted that the embedding models are trained based on large-scale text data and can capture the contextual information of the text well.

[0076] Specifically, the data question answering system passes the rewritten user question as input to the selected pre-trained embedded model. The pre-trained embedded model outputs a corresponding fixed-dimensional vector according to the rewritten user question, which is represented by a first vector in this embodiment, and the first vector encodes the main semantic information of the rewritten user question.

[0077] At the same time, for each data table, table field and field value in the database, they are respectively passed as input to the selected pre-trained embedding model. Each element is converted into a corresponding vector representation, which is represented by the second vector in this embodiment.

[0078] Step A2: Calculate the similarity score between the first vector and the second vector.

[0079] It should be noted that methods for calculating similarity scores include but are not limited to cosine similarity, Euclidean distance, and corresponding matrix methods.

[0080] The method for calculating the similarity score is to use one or more vector similarity measurement methods to calculate the similarity between the first vector and each second vector, that is, to calculate the similarity score between the rewritten user question and each data table, table field and field value in the database.

[0081] Step S22, based on the similarity score, recall the data table, the table fields and the field values ​​to obtain a recall result;

[0082] It should be noted that the recall result refers to the selection of the most relevant set of data from the candidate set based on the sentence vector similarity. In this embodiment, the recall result refers to the selection of the N with the highest scores (TPON) as the final set displayed to the user based on the similarity scores between the rewritten user question (which can be represented by a query) and the data tables, table fields, and field values ​​in the database.

[0083] In another feasible implementation, step S22 may further include steps B1 to B2:

[0084] Step B1, sorting the similarity scores in reverse order to form a sorted list;

[0085] Specifically, in step S21, the similarity scores between the query and each data table, table field and field value in the database have been calculated. All these similarity scores and corresponding items, namely data tables, table fields and field values, are put into a pre-created list.

[0086] And use the sorting function to sort this list in reverse order according to the similarity score, and the items with the highest similarity score will be placed at the front of the list.

[0087] Step B2, selecting data tables, table fields and field values ​​corresponding to preset similarity scores from the sorted list as recall results.

[0088] Specifically, a preset similarity score threshold is determined as a threshold for selecting N items.

[0089] Traverse the sorted list and select N items whose similarity scores are higher than the preset similarity score threshold. The selected items are used as recall results. These items are considered to be the most relevant content to the user's query.

[0090] Step S23: construct a table view according to the recall result.

[0091] Optionally, rebuild the table view based on the recalled results.

[0092] For example, through table field search, you can recall the fields related to the user's question. Through field value search, you can recall the field values ​​related to the question. For example, if you ask "Beijing Branch's xxxx", the Beijing Branch in the branch name will be recalled. Through table recall, you can recall tables related to the question, such as RWA detail tables and organization tables. The specific code diagram for building a table view based on the table field recall results is as follows: Figure 2 shown.

[0093] The following uses the rewritten user question: Risk-weighted assets of various products of a branch, and retrieves table fields as an example to explain the above step S20. Figure 3 , Figure 3 This is a flowchart for table field retrieval, specifically:

[0094] First, the rewritten user question is input into the pre-trained embedding model, and the pre-trained embedding model obtains the corresponding vector v(0). The table fields in the database are searched, and the corresponding embedding vectors v1-vn are obtained for each field in the table.

[0095] Calculate v(0)@{v1,..,vn} to get the similarity score between v(0) and each field vector, where @ is matrix multiplication. After obtaining the similarity score, sort the similarity scores in reverse order and extract the topN (taking N=4 as an example) according to the preset similarity score threshold. Extract the four sets of table fields that meet the preset similarity score threshold as the recalled fields and use them to rebuild the table view.

[0096] Similarly, the correlation between the vector of each field value and the user question vector can be calculated, and the top 3 can be recalled. At this time, the simplified table view of each table can be determined. Then the correlation between the user question vector and each simplified table view vector is calculated, and the top 3 or table views with a correlation exceeding 0.6 are recalled.

[0097] Through the above steps, retrieval technology is used for data table retrieval, table field retrieval, and field value retrieval. The present invention uses sentence vector similarity scores to measure the relevance between the query and candidate tables, fields, and field values, and recalls the TopN (determined according to the specific scenario) candidate sets to construct a table structure, which can reduce model input, improve model accuracy, and effectively use semantic similarity to identify and display the data most relevant to the user query, thereby improving user experience.

[0098] Step S30, combining the rewritten user question and the table view, constructing a first prompt word, and obtaining a query language corresponding to the first prompt word;

[0099] It should be noted that the query language corresponding to the first prompt word (LLM SQL, Large Language Model, Structured Query Language) refers to a technology for generating or understanding SQL queries based on the first prompt word by utilizing a large language model.

[0100] In a feasible embodiment, step S30 includes steps C1 to C2:

[0101] Step C1, combining the rewritten user question with the table view to construct a first prompt word;

[0102] Specifically, the rewritten user question is combined with the table view to generate a complete first prompt word (Prompt1). This Prompt1 contains the data table, table fields, field values ​​and context related to the rewritten user question recorded in the table view, so that the large language model can understand the user's query requirements.

[0103] Step C2: input the first prompt word into a pre-trained large language model to obtain a query language corresponding to the first prompt word.

[0104] Specifically, the generated first prompt word is input into the pre-trained large language model. The pre-trained large language model generates a corresponding SQL query language according to the input first prompt word. In this embodiment, LLM SQL is used to represent the SQL query statement generated or understood by the pre-trained large language model. The generated query language can be a complete SQL query statement, or a series of query steps or pseudocode.

[0105] Please refer to Figure 4 , Figure 4 A diagram for constructing the first prompt word by combining the rewritten user question and the table view. Figure 4 It can be seen that the diagram is based on a user's request to query the risk-weighted assets of all products of the Beijing branch on June 30, 2024. RWA_DETAIL (Risk-Weighted Assets Detail) contains fields such as product name, risk-weighted assets (rwa) and risk weight (rw), while ORG_TREE (Organization Tree) stores the information of the organization tree structure, including organization ID, branch ID and branch name. Combined with the above rewritten user question and the table field content, the first prompt word is formed.

[0106] Input Prompt1 into the pre-trained large language model to obtain the corresponding query language, such as Figure 5 As shown, Figure 5 A schematic diagram of a query language generated based on a first prompt word.

[0107] Step S40, constructing a second prompt word in combination with the query data corresponding to the query language and the user question, and generating an answer corresponding to the user question based on the second prompt word through a pre-trained large language model.

[0108] This embodiment combines a large language model and SQL technology to generate answers corresponding to user questions, so as to provide complex and efficient solutions to users.

[0109] In a feasible implementation, step S40 may include steps S41 to S43:

[0110] Step S41, querying in the database according to the query language corresponding to the first prompt word to obtain corresponding query data;

[0111] Optionally, after obtaining the query language corresponding to the first prompt word through step S30, the query language corresponding to the first prompt word is input into a target database, and the query language corresponding to the first prompt word is executed in the target database to obtain required query data.

[0112] Step S42, combining the query data with the user question to construct a second prompt word;

[0113] Optionally, after obtaining the query data required by the query language corresponding to the first prompt word, it is organized into an easy-to-understand form, and combined with the user's question and query data to form a second prompt word, which is a new prompt word and is used for the next step of the pre-trained large language model to generate an answer.

[0114] Step S43: input the second prompt word into the pre-trained large language model to generate an answer corresponding to the user question.

[0115] Optionally, use a pre-trained large language model suitable for natural language generation tasks, such as the GPT series, BERT, etc. Input the second prompt word constructed in the previous step into the selected pre-trained large language model. The pre-trained large language model will generate a logical answer corresponding to the user's question based on the provided second prompt word.

[0116] The above-mentioned embodiment method includes receiving and rewriting the user question to obtain the rewritten user question; according to the rewritten user question, searching the relevant table data in the database to obtain the table view corresponding to the relevant table data; combining the rewritten user question and the table view to construct a first prompt word, and obtaining the query language corresponding to the first prompt word through the large language model according to the first prompt word; querying in the database through the query language to obtain query data, and constructing a second prompt word according to the query data and the user question; generating the answer corresponding to the user question based on the second prompt word through the pre-trained large language model. This solution can more accurately identify the user's intention by rewriting the user question; effectively reduce the model input and improve the model accuracy through data retrieval; at the same time, the question-answering system based on the large language model achieves higher accuracy, flexibility, scalability and user experience, and improves the application ability in professional fields.

[0117] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 6 , before step S41, steps S410 to S413 are also included:

[0118] Step S410, adjusting the query language corresponding to the first prompt word to obtain an adjusted query language;

[0119] Optionally, when faced with complex query languages, in this embodiment, the query languages ​​are adjusted according to the business scenario. For example, the average risk weight of the query language can be calculated using the following formula:

[0120] Average risk weight = SUM(RWA) / SUM(EAD)

[0121] In the formula, RWA (Risk-Weighted Assets) stands for risk-weighted assets, which refers to the total assets weighted according to the risk level of the assets. EAD (Exposure at Default) stands for exposure at default, which refers to the maximum amount of loss that may be suffered when the debtor defaults.

[0122] Step S411, performing a validity check on the adjusted query language and obtaining a check result;

[0123] Optionally, the adjusted query language is subjected to a legality check, including but not limited to syntax and security checks. If the query language contains operations such as addition, deletion, and modification that change database results and content, they will be considered unsafe operations, indicating that the query language has failed the legality check.

[0124] Step S412, if the verification result is that the query language passes the legal verification, then the steps of: querying in the database according to the query language corresponding to the first prompt word to obtain corresponding query data;

[0125] Optionally, after the adjusted query language is subjected to a legality verification process, if the verification result is that the adjusted query language passes the legality verification, the adjusted query language is input into the target database, the verified query language is executed in the target database, and corresponding query data is obtained.

[0126] Step S413: If the verification result is that the query language fails the legal verification, a violation reason is generated, and the violation reason and the user question are displayed to the user through a pre-trained large language model.

[0127] Optionally, after the adjusted query language is checked for legality, if the check result is that the adjusted query language is illegal, a reason for the violation is generated, such as a syntax error, a non-existent field, a logical error, etc.

[0128] Then, the violation reason and the user question are sent to the pre-trained large language model to generate the corresponding prompt result, and the prompt result is displayed to the user through the interactive interface to inform the user that the input question is illegal and the reason for the illegality.

[0129] Through the above-mentioned embodiment method, by evaluating the risk weight of the query language, potential high-risk operations can be identified, such as operations that may cause a large amount of data leakage or system performance degradation. And regardless of whether the query language is legal, the user can get clear feedback and corresponding explanations. This not only improves the user experience, but also ensures the accuracy and reliability of data processing. Not only improves the user experience, but also ensures the accuracy and reliability of data processing.

[0130] For example, to help understand the implementation process of the data question and answer method obtained by combining this embodiment with the above-mentioned embodiment 1, please refer to Figure 7 , Figure 7 A brief flowchart of a data question-answering method is provided, specifically:

[0131] The method of this embodiment is applied to a data question answering system, which mainly includes SQL generation and answer acceptance. The functional modules and descriptions of the SQL generation part are shown in Table 1 below:

[0132]

[0133]

[0134] Table 1

[0135] The functional modules and descriptions of the answer generation part are shown in Table 2:

[0136]

[0137] Table 2

[0138] Combination Figure 7 As can be seen from Table 1 and Table 2, when the data question answering system receives a user question, it rewrites the user question, such as adding a query date (the default is the end of the previous month) to obtain the rewritten user question.

[0139] According to the rewritten user questions, the similarity scores of the data tables, table fields, field values ​​and the rewritten user questions in each table view are calculated, and the calculated similarity scores are sorted in descending order. At the same time, a threshold of the similarity score is set, for example, the threshold is 0.6, and then the corresponding data tables, table fields and field values ​​with similarity scores exceeding 0.6 are extracted from all the calculated similarity scores to recall the results and build a table view.

[0140] Subsequently, the first prompt word is constructed by combining the rewritten user question and the table view, and the first prompt word is passed as input to the pre-trained large language model to generate the query language. The query language is then adjusted according to the business scenario, such as the average risk weight calculation. It is worth noting that AVG (arithmetic mean) is not used in the average risk weight calculation, but SUM (RWA) / SUM (EAD).

[0141] Next, the adjusted query language is checked for legality. If the adjusted query language is illegal, the illegal reason of the adjusted query language is combined with the user's question to construct a corresponding prompt word result and the prompt result is input into the pre-trained large language model to generate a corresponding answer to inform the user that the question he entered is illegal and the reason for the illegality. If the adjusted query language is qualified, the database is queried to obtain query data, and the corresponding prompt word is constructed in combination with the query data and the user's question, which is expressed as the second prompt word below. Among them, the query data includes but is not limited to the calculation results of the average risk weight, other important data related to the calculation, such as total risk-weighted assets (RWA) and total default exposure (EAD), the time range of the query, institutional information, and contextual information, etc.

[0142] Finally, the second prompt word is input into the pre-trained large language model to generate the answer corresponding to the user's question, and the answer is displayed to the user through the interactive interface.

[0143] The data question and answer system in the capital management field based on the large language model in the embodiment of the present application significantly improves the natural language understanding ability, allowing the system to more accurately parse and understand complex questions from users. Compared with traditional rule-based and machine learning systems, the present invention has higher flexibility and adaptability, and can cope with diverse user needs and questioning styles. In addition, in terms of user experience, the present invention achieves a more natural and smooth conversational interaction, significantly improving user satisfaction and usage experience. In terms of professionalism, the present invention can use the reasoning ability of the large language model to perform complex data change attribution analysis, provide more professional and in-depth analysis results, and comprehensively optimize the data question and answer system in the capital management field.

[0144] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the data question and answer method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0145] This application also provides a data question-answering system, please refer to Figure 8 , the data question answering system comprises:

[0146] A rewriting module 10, used for receiving and rewriting a user question to obtain a rewritten user question;

[0147] A retrieval module 20, configured to retrieve relevant table data in a database according to the rewritten user question, and obtain a table view corresponding to the relevant table data;

[0148] A construction module 30, configured to construct a first prompt word by combining the rewritten user question and the table view to obtain a query language corresponding to the first prompt word;

[0149] The generation module 40 is used to construct a second prompt word in combination with the query data corresponding to the query language and the user question, and generate an answer corresponding to the user question based on the second prompt word through a pre-trained large language model.

[0150] The data question and answer system provided by the present application adopts the data question and answer method in the above embodiment, which can solve the technical problem of how the data question and answer system can provide efficient answers when facing complex user questions. Compared with the prior art, the beneficial effects of the data question and answer system provided by the present application are the same as the beneficial effects of the data question and answer method provided by the above embodiment, and other technical features of the data question and answer system are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0151] The present application provides a data question and answer device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the data question and answer method in the above-mentioned embodiment one.

[0152] The data question and answer device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), etc., and fixed terminals such as digital TVs, desktop computers, etc. The data question and answer device is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0153] The data question and answer device may include a processing system (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage system into a random access memory (RAM). In the RAM, various programs and data required for the operation of the data question and answer device are also stored. The processing system, ROM, and RAM are connected to each other through a bus. An input / output (I / O) interface is also connected to the bus. Typically, the following systems can be connected to the I / O interface: an input system including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output system including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage system including, for example, a tape, a hard disk, etc.; and a communication system. The communication system may allow the data question and answer device to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a data question and answer device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have alternatively.

[0154] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication system, or installed from a storage system, or installed from a ROM. When the computer program is executed by a processing system, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0155] The data question and answer device provided by this application adopts the data question and answer method in the above embodiment, which can solve the technical problem of how the data question and answer system can provide efficient answers when facing complex user questions. Compared with the prior art, the beneficial effects of the data question and answer device provided by this application are the same as the beneficial effects of the data question and answer method provided by the above embodiment, and the other technical features in the data question and answer device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0156] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0157] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0158] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0159] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0160] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned data question and answer method when executed by a processor.

[0161] The computer program product provided by this application can solve the technical problem of how the data question-answering system can provide efficient answers to complex user questions. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as the beneficial effects of the data question-answering method provided by the above embodiment, which will not be repeated here.

[0162] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A data question-answering method, characterized in that: The method comprises: Receive and rewrite the user's question to obtain the rewritten user's question; According to the rewritten user question, relevant table data in the database is retrieved to obtain a table view corresponding to the relevant table data; Constructing a first prompt word in combination with the rewritten user question and the table view to obtain a query language corresponding to the first prompt word; A second prompt word is constructed by combining the query data corresponding to the query language and the user question, and an answer corresponding to the user question is generated based on the second prompt word through a pre-trained large language model.

2. The method according to claim 1, characterized in that The related table data includes a data table, table fields and field values. The step of retrieving the related table data in a database according to the rewritten user question and obtaining a table view corresponding to the related table data includes: According to the rewritten user question, using the sentence vector similarity score strategy, calculating the corresponding similarity score for the data table, the table field and the field value in the database; Based on the similarity score, recall the data table, the table fields, and the field values ​​to obtain a recall result; According to the recall result, a table view is constructed.

3. The method according to claim 2, characterized in that The step of calculating the corresponding similarity scores for the data table, the table fields, and the field values ​​in the database using the sentence vector similarity score strategy according to the rewritten user question includes: Using a pre-trained embedding model, the rewritten user question is converted into a first vector, and the data table, the table field, and the field value are converted into a second vector; A similarity score between the first vector and the second vector is calculated.

4. The method according to any one of claims 2 to 3, characterized in that The step of recalling the data table, the table fields, and the field values ​​based on the similarity scores to obtain the recall result comprises: sorting the similarity scores in reverse order to form a sorted list; The data table, table field and field value corresponding to the preset similarity score are selected from the sorted list as the recall result.

5. The method according to claim 1, characterized in that The step of combining the rewritten user question and the table view to construct a first prompt word to obtain a query language corresponding to the first prompt word includes: Combine the rewritten user question with the table view to construct the first prompt word; The first prompt word is input into a pre-trained large language model to obtain a query language corresponding to the first prompt word.

6. The method according to claim 5, characterized in that The step of combining the query data corresponding to the query language and the user question to construct a second prompt word, and generating an answer corresponding to the user question based on the second prompt word by using a pre-trained large language model comprises: Perform a query in the database according to the query language corresponding to the first prompt word to obtain corresponding query data; Combining the query data with the user question, constructing a second prompt word; The second prompt word is input into the pre-trained large language model to generate an answer corresponding to the user question.

7. The method according to claim 6, characterized in that Before the step of performing a query in the database according to the query language corresponding to the first prompt word to obtain the corresponding query data, the step further includes: Adjusting the query language corresponding to the first prompt word to obtain an adjusted query language; Perform a validity check on the adjusted query language and obtain the check result; If the verification result is that the query language passes the legal verification, the following steps are performed: querying in the database according to the query language corresponding to the first prompt word to obtain corresponding query data; If the verification result is that the query language fails the legal verification, a violation reason is generated, and the violation reason and the user question are displayed to the user through a pre-trained large language model.

8. A data question answering system, characterized in that: The system comprises: A rewriting module, used for receiving and rewriting user questions to obtain rewritten user questions; A retrieval module, used to retrieve relevant table data in a database according to the rewritten user question, and obtain a table view corresponding to the relevant table data; A construction module, combining the rewritten user question and the table view to construct a first prompt word, so as to obtain a query language corresponding to the first prompt word; A generation module is used to construct a second prompt word in combination with the query data corresponding to the query language and the user question, and generate an answer corresponding to the user question based on the second prompt word through a pre-trained large language model.

9. A data question and answer device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the data question-answering method according to any one of claims 1 to 7.

10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the data questioning and answering method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Structured query statement generation method and system

    CN120780730A