Answer acquisition method and related equipment

By standardizing the initial problem and semantic understanding, combining preset statement conversion model and SQL decoder, accurate SQL statements are generated to improve the accuracy of the answers, and the problem of low answer accuracy in the prior art is solved.

CN119739742APending Publication Date: 2025-04-01CHINA MERCHANTS BANK
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411704607.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

In the prior art, the answer acquisition device may have ambiguity in the semantic comprehension results due to the limitations of the semantic comprehension capabilities, resulting in a low accuracy of the answer.

Method used

Propose a method for obtaining answers, obtaining the initial question, and standardizing it, and determining the target question and target semantics. Then, select the tabular data and key fields with the highest correlation with the target semantics, use the preset statement conversion model to deal with the target problem, and generate the initial SQL statement. Finally, based on the preset SQL decoder, standardizes the initial SQL statement, generates the target SQL statement and finds its corresponding answer.

Benefits of technology

By improving the accuracy of semantic understanding and standardized processing of SQL statements, the accuracy of the answer is significantly improved, and the problem of possible ambiguity in semantic understanding results is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119739742A_ABST
    Figure CN119739742A_ABST
Patent Text Reader

Abstract

The present application discloses an answer acquisition method and related equipment, which relates to the field of artificial intelligence technology, including: obtaining a query answer instruction, responding to the query answer instruction, obtaining an initial question, standardizing the initial question, obtaining a target question, and determining the target semantics corresponding to the target question, selecting the table data and key fields with the highest correlation with the target semantics, based on the table data and the key fields, using a preset statement conversion model, processing the target question, obtaining an initial SQL statement, standardizing the initial SQL statement based on a preset SQL decoder, obtaining a target SQL statement, searching for an answer corresponding to the target SQL statement, and obtaining a target answer. The present application obtains an initial SQL statement with a more accurate semantic result for a large language model, and standardizes the initial SQL statement, thereby improving the accuracy of the answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to an answer acquisition method and related equipment. Background Art

[0002] With the rapid development of technology, how to accurately answer users' questions in user question-and-answer scenarios has become more important.

[0003] In the related art, the answer acquisition device performs semantic understanding on the question raised by the user, searches for the target answer associated with the question raised by the user from the answer library based on the semantic understanding result, and finally sends the answer to the user.

[0004] In the actual answer acquisition process, due to the limitation of semantic understanding ability, the semantic understanding results may be ambiguous, which leads to lower accuracy of the answer.

[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 an answer acquisition method and related equipment, aiming to solve the technical problem that due to the limitation of semantic understanding ability, the semantic understanding results may be ambiguous, which leads to low answer accuracy.

[0007] To achieve the above purpose, the present application proposes a method for obtaining an answer, which includes:

[0008] Obtaining a query answer instruction, and obtaining an initial question in response to the query answer instruction;

[0009] Standardizing the initial question to obtain a target question, and determining a target semantics corresponding to the target question;

[0010] Selecting the table data and key fields with the highest semantic relevance to the target, and processing the target problem based on the table data and the key fields using a preset statement conversion model to obtain an initial SQL statement, wherein the preset statement conversion model is a trained statement conversion model;

[0011] Based on a preset SQL decoder, the initial SQL statement is standardized to obtain a target SQL statement, and an answer corresponding to the target SQL statement is searched to obtain a target answer.

[0012] In one embodiment, the steps of normalizing the initial question to obtain a target question and determining a target semantics corresponding to the target question include:

[0013] Obtain a question template library, and determine semantic information corresponding to each question template in the question template library to obtain multiple groups of question template semantics;

[0014] Determine a first semantics corresponding to the initial question, and calculate a semantic similarity value between the first semantics and any one of the multiple groups of question template semantics based on a preset semantic similarity calculation method to obtain multiple groups of semantic similarity values;

[0015] A maximum value among the multiple groups of semantic similarity values ​​is obtained, a question template corresponding to the maximum value is set as a target question template, and based on the target question template, the target question is determined, and a target semantics corresponding to the target question is determined.

[0016] In one embodiment, the step of performing standardization processing on the initial SQL statement based on a preset SQL decoder to obtain a target SQL statement further includes:

[0017] Obtain a preset SQL template library, and map the initial SQL statement based on the preset SQL template library to obtain a first SQL statement;

[0018] Based on the target semantics, the first SQL statement is processed using a preset SQL decoder to obtain a target SQL statement.

[0019] In one embodiment, the step of processing the first SQL statement based on the target semantics using a preset SQL decoder to obtain a target SQL statement further includes:

[0020] Based on the target semantics, using a preset SQL decoder, processing the first SQL statement to obtain a second SQL statement;

[0021] Obtain a preset SQL statement standard library, and perform statement standardization verification on the second SQL statement based on the preset SQL statement standard library to obtain a verification result;

[0022] If the verification result is a verification failure, the second SQL statement is saved in an SQL statement training library, wherein the SQL statements in the SQL statement training library are used to generate standard SQL statements in a preset SQL statement standard library;

[0023] If the verification result is successful, the second SQL statement is set as the target SQL statement.

[0024] In one embodiment, the step of searching for an answer corresponding to the target SQL statement to obtain a target answer further includes:

[0025] Based on the ORM tool, load the answer template library and the answer database, determine the target answer template corresponding to the target SQL statement in the answer template library, and determine the initial data corresponding to the target SQL statement in the answer database;

[0026] Convert the initial data into JSON format to obtain target data;

[0027] A target answer is obtained based on the target answer template and the target data.

[0028] In one embodiment, before the step of using the preset sentence to convert the model, the method further includes:

[0029] Obtaining a sample statement and a current statement conversion model, wherein a statement conversion result corresponding to the sample statement is a third SQL statement;

[0030] Based on the current statement conversion model, the sample statement is converted to obtain a fourth SQL statement;

[0031] Determine whether the third SQL statement is the same as the fourth SQL statement, and if not, adjust the parameters of the current statement conversion model;

[0032] Based on the adjusted current statement conversion model, returning to the current statement conversion model, performing statement conversion on the sample statement to obtain a fourth SQL statement, until the third SQL statement is the same as the fourth SQL statement, and obtaining a preset statement conversion model.

[0033] In addition, to achieve the above purpose, the present application also proposes an answer acquisition device, the answer acquisition device comprising:

[0034] An acquisition module, the acquisition module is used to acquire a query answer instruction, and acquire an initial question in response to the query answer instruction;

[0035] A determination module, the determination module is used to perform standardization processing on the initial question, obtain a target question, and determine a target semantics corresponding to the target question;

[0036] A selection module, the selection module is used to select the table data and key fields with the highest semantic relevance to the target, and based on the table data and the key fields, use a preset statement conversion model to process the target problem and obtain an initial SQL statement, wherein the preset statement conversion model is a trained statement conversion model;

[0037] The processing module is used to perform standardization processing on the initial SQL statement based on a preset SQL decoder to obtain a target SQL statement, find an answer corresponding to the target SQL statement, and obtain a target answer.

[0038] In one embodiment, the determining module includes:

[0039] A first acquisition unit is used to acquire a question template library, and determine semantic information corresponding to each question template in the question template library to obtain multiple groups of question template semantics;

[0040] A determination unit, configured to determine a first semantic meaning corresponding to the initial question, and calculate a semantic similarity value between the first semantic meaning and any one of the multiple sets of question template semantic meanings based on a preset semantic similarity calculation method, to obtain multiple sets of semantic similarity values;

[0041] The first setting unit is used to obtain the maximum value among the multiple groups of semantic similarity values, set the question template corresponding to the maximum value as the target question template, determine the target question based on the target question template, and determine the target semantics corresponding to the target question.

[0042] In one embodiment, the processing module includes:

[0043] A second acquisition unit is used to acquire a preset SQL template library, and map the initial SQL statement based on the preset SQL template library to obtain a first SQL statement;

[0044] The first processing unit is used to process the first SQL statement based on the target semantics using a preset SQL decoder to obtain a target SQL statement.

[0045] In one embodiment, the processing module further includes:

[0046] A second processing unit, configured to process the first SQL statement based on the target semantics using a preset SQL decoder to obtain a second SQL statement;

[0047] A third acquisition unit is used to acquire a preset SQL statement standard library, and perform statement standardization verification on the second SQL statement based on the preset SQL statement standard library to obtain a verification result;

[0048] A saving unit, if the verification result is a verification failure, saves the second SQL statement into a SQL statement training library, wherein the SQL statements in the SQL statement training library are used to generate standard SQL statements in a preset SQL statement standard library;

[0049] The second setting unit sets the second SQL statement as a target SQL statement if the verification result is successful.

[0050] In one embodiment, the processing module further includes:

[0051] A loading unit, based on an ORM tool, loads an answer template library and an answer database, determines a target answer template in the answer template library corresponding to the target SQL statement, and determines initial data in the answer database corresponding to the target SQL statement;

[0052] A format conversion unit, used for converting the initial data into JSON format to obtain target data;

[0053] A target answer is obtained based on the target answer template and the target data.

[0054] In one embodiment, the selection module includes:

[0055] A fourth acquisition unit is used to acquire a sample statement and a current statement conversion model, wherein the statement conversion result corresponding to the sample statement is a third SQL statement;

[0056] A conversion unit, configured to perform statement conversion on the sample statement based on a current statement conversion model to obtain a fourth SQL statement;

[0057] A judging unit, configured to judge whether the third SQL statement is the same as the fourth SQL statement, and if they are not the same, adjust the parameters of the current statement conversion model;

[0058] The training unit is used to return to the current statement conversion model based on the adjusted current statement conversion model, perform statement conversion on the sample statement, and obtain a fourth SQL statement, until the third SQL statement is the same as the fourth SQL statement, and obtain a preset statement conversion model.

[0059] In addition, to achieve the above-mentioned purpose, the present application also proposes an answer acquisition 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 answer acquisition method described above.

[0060] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the answer acquisition method described above are implemented.

[0061] 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, the steps of the answer acquisition method described above are implemented.

[0062] One or more technical solutions proposed in this application have at least the following technical effects:

[0063] The present application proposes an answer acquisition method and related equipment. In the related technology, due to the limitation of semantic understanding ability, the semantic understanding result may be ambiguous, which leads to low accuracy of the answer. In the present application, first, a query answer instruction is obtained, and in response to the query answer instruction, an initial question is obtained. Then, the initial question is standardized to obtain a target question, and the target semantics corresponding to the target question is determined. Further, the table data and key fields with the highest correlation with the target semantics are selected, and based on the table data and the key fields, a preset statement conversion model is used to process the target question to obtain an initial SQL statement, wherein the preset statement conversion model is a trained statement conversion model. Finally, based on a preset SQL decoder, the initial SQL statement is standardized to obtain a target SQL statement, and the answer corresponding to the target SQL statement is searched to obtain the target answer.

[0064] It can be understood that, first, a preset large language model is used to obtain an initial SQL statement with higher accuracy, and then the initial SQL statement is standardized to obtain a target SQL statement with higher accuracy. Based on the target SQL statement with higher accuracy, the answer corresponding to the target SQL statement is searched, and then a target answer with higher accuracy is obtained, thereby improving the accuracy of the answer. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] 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.

[0066] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0067] Figure 1 A flowchart of the first embodiment of the method for obtaining the answer of this application;

[0068] Figure 2 A schematic diagram of the answer acquisition process provided in Example 1 of the answer acquisition method of this application;

[0069] Figure 3 A flowchart of the second embodiment of the method for obtaining the answer of this application is provided;

[0070] Figure 4 This is a schematic diagram of the module structure of the answer acquisition device in the embodiment of the present application;

[0071] Figure 5 Schematic diagram of the device structure of the hardware operating environment involved in the answer acquisition method in the embodiment of the present application.

[0072] 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

[0073] 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.

[0074] 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.

[0075] The main solutions of the embodiments of this application are:

[0076] In this embodiment, for ease of description, the following description is made with the identification answer acquisition device as the execution subject.

[0077] Since existing technologies are limited by their semantic understanding capabilities, the semantic understanding results may be ambiguous, resulting in lower accuracy of answers.

[0078] The present application provides a solution to obtain a query answer instruction, obtain an initial question in response to the query answer instruction, standardize the initial question, obtain a target question, and determine the target semantics corresponding to the target question, select the table data and key fields with the highest correlation with the target semantics, and use a preset statement conversion model based on the table data and the key fields to process the target question and obtain an initial SQL statement, standardize the initial SQL statement based on a preset SQL decoder, obtain a target SQL statement, find the answer corresponding to the target SQL statement, and obtain the target answer. The present application obtains an initial SQL statement with a more accurate semantic result for a large language model, and standardizes the initial SQL statement, thereby improving the accuracy of the answer.

[0079] 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, an answer acquisition device, etc. The following takes the answer acquisition device as an example to illustrate this embodiment and the following embodiments.

[0080] Based on this, the present application embodiment provides a method for obtaining an answer, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the answer acquisition method of this application.

[0081] In this embodiment, the answer acquisition method includes steps S100 to S400:

[0082] Step S100, obtaining a query answer instruction, and obtaining an initial question in response to the query answer instruction;

[0083] It is understood that when the answer acquisition device receives a query request, it needs to respond to the request. The response may include acknowledging receipt of the request, requesting more information (if necessary), or directly providing an answer.

[0084] After responding, the answer acquisition device extracts or recognizes the question asked by the user. This initial question is called the "initial question". The system analyzes this question to understand the intent and context of the question and provide an accurate answer.

[0085] Step S200, standardizing the initial question to obtain a target question, and determining a target semantics corresponding to the target question;

[0086] It should be noted that the initial question is a question asked by the user, usually in natural language. It may be unstructured, complex, and contain many details.

[0087] It should be noted that standardization refers to converting the initial problem into a structured and standardized form so that the computer system can understand and process it more easily. This process includes but is not limited to removing irrelevant information, filling in missing data, and converting the problem statement to conform to a predefined format or template.

[0088] It should be noted that the target problem is a problem that has been standardized and can be directly used for solving or further analysis.

[0089] In addition, it should be noted that the target semantics is the meaning of the target question at the semantic level, that is, the specific intention or information it expresses.

[0090] Understandably, determining the target semantics means understanding not only the literal statement of the problem but also the meaning and context behind it, which is crucial to solving the problem correctly.

[0091] Specifically, the step of performing standardization processing on the initial question to obtain the target question, and determining the target semantics corresponding to the target question also includes steps S210 to S240:

[0092] Step S210, obtaining a question template library, and determining semantic information corresponding to each question template in the question template library, to obtain multiple groups of question template semantics;

[0093] It is understandable that in the answer acquisition device based on the template method, a question template library needs to be built first. This template library contains predefined question templates, which are used to match the natural language questions raised by users. Question templates are usually summarized based on the history of previous questions and answers. They can cover different types of questions and can convert these questions into structured queries.

[0094] Each question template corresponds to specific semantic information, which describes the type and intent of the question represented by the template. For example, one template may be used to ask about a person's birthday, and another template may be used to ask about the director of a movie. Determining this semantic information is a key step in mapping natural language questions to structured queries.

[0095] It should be noted that in the process of answer acquisition, there may be many different types of questions, so multiple sets of question templates are needed to cover these different question types. Each set of question templates corresponds to a set of questions with similar semantic features. In this way, the answer acquisition device can handle a variety of different queries and convert them into structured queries that the knowledge graph can understand.

[0096] In this embodiment, through the intention recognition, entity linking, relation detection, and query construction of natural language questions, the answer acquisition device can convert the user's question into a structured query that can be processed by the knowledge graph, thereby retrieving the correct answer. The advantage of this method is that it can handle a large number of predefined question types, but the challenge lies in how to accurately match the question template and extract the correct semantic information.

[0097] Step S220, determining a first semantics corresponding to the initial question, and calculating a semantic similarity value between the first semantics and any one of the multiple sets of question template semantics based on a preset semantic similarity calculation method to obtain multiple sets of semantic similarity values;

[0098] It should be noted that the first semantics is the semantic representation obtained after semantic analysis of the initial question. This may be a vector, a semantic label or a structured representation that captures the core intent and key information of the question.

[0099] It should also be noted that question template semantics refers to the semantic representation corresponding to each question template, which are pre-defined and used to match user questions.

[0100] In this embodiment, the answer acquisition device compares the semantic representation of the user's initial question (first semantics) with the semantic representation of each question template to calculate the similarity value between them. This value is usually a value between 0 and 1, indicating the similarity between the two semantic representations, and the closer the value is to 1, the more similar they are.

[0101] This step involves choosing or designing a method to calculate the similarity between two semantic representations. This can be a machine learning based approach, such as using a neural network model to assess semantic similarity, or a traditional feature-based approach, such as cosine similarity, Jaccard similarity, etc.

[0102] It is understandable that since there may be multiple question templates, the answer acquisition device calculates the similarity value between the first semantics of the initial question and the semantics of each template, thereby obtaining multiple sets of similarity values. These values ​​can help the system determine which question template is closest to the user's initial question, thereby selecting the most appropriate template to generate an answer or further processing. This process is a key step in question-answering systems and information retrieval systems, matching the initial question with a pre-defined question template to provide an accurate answer or response. The effectiveness of this method depends on the accuracy of the semantic representation and the rationality of the similarity calculation method.

[0103] Step S230, obtaining the maximum value among the multiple groups of semantic similarity values, setting the question template corresponding to the maximum value as the target question template, determining the target question based on the target question template, and determining the target semantics corresponding to the target question.

[0104] In this embodiment, the answer acquisition device first calculates the semantic similarity between the natural language question (initial question) raised by the user and the predefined multiple question templates. These similarity values ​​are obtained by a preset semantic similarity calculation method, which may be based on a vector space model, a machine learning model or other semantic analysis technology.

[0105] Among these calculated similarity values, the answer acquisition device finds a value with the highest similarity, that is, the maximum value. This maximum value indicates that the semantic similarity between the user question and a certain question template is the highest.

[0106] The answer acquisition device determines the question template corresponding to the maximum similarity value as the target question template, which means that this template is the closest to the user's question in semantics among all predefined templates.

[0107] After determining the target question template, the answer acquisition device will use this template to construct or reconstruct the user's question to form a target question. The target question is a standardized or structured version of the user's original question, which follows the format and structure of the target question template while retaining the core intent and key information of the user's question.

[0108] Finally, the answer acquisition device determines the target semantics corresponding to the target question. This step involves in-depth semantic analysis of the target question to extract its core intent and key information. The target semantics is a semantic representation of the target question, which can be used to guide subsequent processing, such as querying the knowledge base, retrieving information, or generating answers.

[0109] In this embodiment, by selecting the most similar question template and constructing the target question, the answer acquisition device can more accurately understand and respond to the user's needs. This method relies on high-quality question templates and accurate semantic analysis technology to ensure the accuracy and effectiveness of the conversion.

[0110] Step S300, selecting the table data and key fields with the highest semantic relevance to the target, and based on the table data and the key fields, using a preset statement conversion model to process the target problem to obtain an initial SQL statement, wherein the preset statement conversion model is a trained statement conversion model;

[0111] After determining the target semantics corresponding to the target question, the answer acquisition device needs to select the table data and key fields that are most relevant to this semantics from the database. This usually involves semantic analysis and entity recognition technology to determine the key information in the question (such as name, place, date, etc.) and their corresponding database fields.

[0112] Once the relevant tables and fields are identified, the answer acquisition device uses this information to build a preliminary query framework. This framework will guide how to retrieve information from the database to answer the target question.

[0113] Based on the preliminary query framework, the answer acquisition device uses a preset statement conversion model to convert the target question into an SQL statement. This model is a trained machine learning model that can understand the structure and semantics of natural language questions and map them to corresponding database query statements.

[0114] It should be noted that the preset statement conversion model can analyze the target question, identify key information, and generate an SQL statement based on this information. This process may involve parsing the keywords, phrases, and sentence structures in the question and converting them into the corresponding parts of the SQL query, such as SELECT, FROM, WHERE clauses, etc.

[0115] After the above processing, the answer acquisition device will generate an initial SQL statement. This statement is designed according to the target question and database structure, and is used to retrieve data from the database that can answer the target question.

[0116] It should also be noted that the preset statement conversion model is trained with a large amount of data and can understand and process a variety of natural language questions and accurately convert them into SQL statements. This model may use deep learning techniques such as recurrent neural networks (RNN), long short-term memory networks (LSTM) or Transformer models to improve the accuracy and robustness of the conversion.

[0117] In this embodiment, the user's natural language question is automatically converted into a database query statement so that the answer can be directly retrieved from the database. This method can effectively improve the efficiency of database query and user experience, especially in complex database query and analysis tasks.

[0118] Step S400: Based on a preset SQL decoder, the initial SQL statement is standardized to obtain a target SQL statement, and an answer corresponding to the target SQL statement is searched to obtain a target answer.

[0119] It should be noted that the SQL decoder is a preset tool or module, and its function is to understand and process SQL statements, ensure that these statements comply with the query language specifications of the database, and can be correctly executed by the database management system (DBMS).

[0120] refer to Figure 2 After the initial SQL statement is standardized using the preset SQL decoder, the SQL decoder will output a target SQL statement. This target SQL statement is an optimized and standardized version that can be correctly understood and executed by the database management system.

[0121] Once the target SQL statement is in place, the answer acquisition device executes the statement in the database. This process involves querying the database to retrieve data records that match the target SQL statement.

[0122] After the answer acquisition device executes the target SQL statement, the database returns the query results, which are the target answers. These answers may be one or more rows of data, depending on the nature of the query and the data in the database.

[0123] The goal of the entire process is to ensure that the conversion from natural language questions to database queries is not only accurate, but also produces valid query results. The SQL decoder plays a key role in this process, ensuring the correctness and executableness of the query statement, so that the answers retrieved from the database are both accurate and reliable. This approach improves the efficiency and accuracy of automatically retrieving information from the database, especially in situations where a large number of complex queries need to be processed.

[0124] Specifically, the step of performing standardization processing on the initial SQL statement based on a preset SQL decoder to obtain a target SQL statement further includes steps S410 to S420:

[0125] Step S410, obtaining a preset SQL template library, and mapping the initial SQL statement based on the preset SQL template library to obtain a first SQL statement;

[0126] It should be noted that the SQL template library is a set of predefined SQL statement templates that cover common query types and structures. Each template is designed to match a specific type of query requirement, such as querying a specific field, performing aggregation operations, or performing conditional filtering.

[0127] The answer acquisition device will use this preset SQL template library to generate or optimize SQL statements. The template library provides a fast and standardized way to build SQL statements, ensuring that they comply with the specifications of the database query language.

[0128] It is understandable that the initial SQL statement may be automatically generated by a natural language processing system based on a user question, and it may not be complete or accurate. The mapping process involves comparing this initial SQL statement with a preset SQL template to find the best matching template.

[0129] Among them, mapping may include semantic matching, template selection and parameter filling.

[0130] After mapping and filling, the answer acquisition device will obtain the first SQL statement. This statement is an optimized version based on the preset template, which is more standardized and accurate, and can be correctly understood and executed by the database management system.

[0131] The purpose of the whole process is to convert natural language questions or initially generated SQL statements into a structured, standardized SQL query statement so that accurate information can be retrieved from the database. Using a preset SQL template library can improve the efficiency and accuracy of this conversion process, ensuring that the generated SQL statement not only conforms to the database query language specifications, but also accurately reflects the user's query needs.

[0132] Step S420: Based on the target semantics, use a preset SQL decoder to process the first SQL statement to obtain a target SQL statement.

[0133] It should be noted that target semantics refers to the semantic information extracted from the user's question, which represents the core intent and key content of the question. This semantic information is obtained by the natural language processing system after analyzing the user's question and is used to guide the generation of SQL statements.

[0134] The purpose of the entire process is to ensure that the conversion from natural language questions to database queries is not only accurate, but also able to produce valid query results. The SQL decoder plays a key role in this process, ensuring the correctness and executableness of the query statement, so that the answers retrieved from the database are both accurate and reliable. This method improves the efficiency and accuracy of automatically retrieving information from the database, especially in situations where a large number of complex queries need to be processed.

[0135] Specifically, the step of processing the first SQL statement based on the target semantics using a preset SQL decoder to obtain a target SQL statement further includes steps S421 to S424:

[0136] Step S421, based on the target semantics, using a preset SQL decoder, processing the first SQL statement to obtain a second SQL statement;

[0137] It should be noted that the first SQL statement refers to an SQL statement initially generated based on the target semantics, which may not be perfect and may contain syntax errors, inaccurate query conditions, or SQL dialects that do not conform to a specific database.

[0138] After being processed by the SQL decoder, the second SQL statement is obtained. This statement is an optimized and standardized version that can be correctly understood and executed by the database management system and more accurately reflects the user's query intention.

[0139] Step S422, obtaining a preset SQL statement standard library, and performing statement standardization verification on the second SQL statement based on the preset SQL statement standard library to obtain a verification result;

[0140] It should be noted that the preset SQL statement standard library is a set of predefined SQL statement templates that follow the standard specifications of the SQL language. They are used as a reference to ensure that the generated SQL statements are correct in syntax and structure. This standard library may contain different types of SQL statement templates, such as SELECT, INSERT, UPDATE, and DELETE.

[0141] Using this preset standard library, the answer acquisition device can check whether the second SQL statement complies with the standard specification of the SQL language by comparing it with the template. This process may involve syntax checking, structure verification and semantic analysis to ensure the correctness of the SQL statement.

[0142] After verification, the answer acquisition device will obtain a verification result. This result indicates whether the second SQL statement has passed the standardization verification, as well as any problems or errors found. If the SQL statement passes the verification, it is considered standardized and executable. If the verification fails, the system may provide an error message indicating the problems that need to be corrected so that the SQL statement can be adjusted and optimized.

[0143] The purpose of this process is to ensure that the SQL statement is correct and standardized before execution, thereby reducing execution errors and improving the reliability of database operations. Using a preset SQL statement standard library and SQL validator is an important step to ensure the quality of SQL statements.

[0144] Step S423: if the verification result is a verification failure, the second SQL statement is saved in a SQL statement training library, wherein the SQL statements in the SQL statement training library are used to generate standard SQL statements in a preset SQL statement standard library;

[0145] After the second SQL statement is standardized and verified, if the verification result shows that the statement fails the verification, that is, there is a syntax error, a structural problem, or it does not meet the standard specification of the SQL language, then further measures need to be taken, and the second SQL statement is saved in the SQL statement training library:

[0146] It should be noted that the SQL statement training library is a database that stores SQL statements that have failed verification. These statements are saved for subsequent analysis and learning in order to improve the SQL statement generation model and generate new standard SQL statements. Saving failed SQL statements in the training library can provide developers or machine learning models with actual, unverified statement samples, which can be used to analyze error types, understand common problems, and adjust SQL statement generation strategies accordingly. By analyzing the statements in the SQL statement training library, developers can identify common error patterns and problems, thereby creating or updating templates in the preset SQL statement standard library.

[0147] Additionally, machine learning models can be trained and optimized using this data to improve their ability to generate correct SQL statements. For example, through supervised learning, the model can learn how to recognize correct structure and syntax from incorrect examples.

[0148] In addition, these failed SQL statements can also be used to test and verify new SQL statement generation models to ensure that they can handle various complex and abnormal situations.

[0149] The purpose of the entire process is to form a continuous improvement cycle to improve the accuracy and reliability of SQL statement generation by analyzing failed SQL statements. This will not only help reduce future validation failures, but also enhance the system's ability to handle complex and non-standard queries.

[0150] Step S424: If the verification result is successful, the second SQL statement is set as the target SQL statement.

[0151] The successful verification indicates that the second SQL statement is correct in format and logic and complies with the standard specification of the SQL language, so the second SQL statement is set as the target SQL statement:

[0152] It is understandable that if the second SQL statement passes the verification, the answer acquisition device sets it as the target SQL statement. The target SQL statement refers to the SQL query statement that is ultimately used for execution, which is obtained from the user's question after a series of steps such as semantic analysis, template matching, statement generation and verification.

[0153] It can also be understood that setting the second SQL statement as the target SQL statement means that this statement is ready to be sent to the database for execution to retrieve or operate data.

[0154] Specifically, the step of searching for an answer corresponding to the target SQL statement to obtain a target answer further includes steps S430 to S450:

[0155] Step S430, based on the ORM tool, loading the answer template library and the answer database, determining the target answer template corresponding to the target SQL statement in the answer template library, and determining the initial data corresponding to the target SQL statement in the answer database;

[0156] It should be noted that ORM tools are software tools that allow developers to use object-oriented methods to operate databases instead of directly writing SQL statements. ORM tools map tables in the database by defining models and perform database operations through these models.

[0157] It should also be noted that the answer template library is a set of predefined templates that define how to format and display data based on specific query results. These templates can be SQL query templates or result display templates.

[0158] The answer database refers to the database that stores the actual data that will be queried and used to generate the final answer or report.

[0159] In this embodiment, once there is a target SQL statement, the ORM tool will search for a matching template in the answer template library based on the content and structure of the statement. This template defines how to convert the query result into an answer format that the user can understand.

[0160] It should be noted that the target answer template refers to the template that matches the target SQL statement, which will be used to generate the final output result.

[0161] After determining the target answer template, the ORM tool uses the target SQL statement to execute a query in the answer database to retrieve data related to this statement.

[0162] In addition, it should be noted that the initial data refers to the original data retrieved directly from the database, which will be used to fill in the target answer template to generate the final answer or report.

[0163] The purpose of the whole process is to convert the user's question (through the target SQL statement) into a query that the database can understand, and use ORM tools to simplify this process. By using the answer template library and answer database, the system can automatically generate formatted answers to improve the efficiency and accuracy of data processing.

[0164] Step S440, converting the initial data into JSON format to obtain target data;

[0165] It should be noted that the initial data usually refers to the native format data obtained from the database query, such as the form of rows and columns. This data may exist in the form of arrays, dictionaries, or other database-specific data structures.

[0166] It should also be noted that JSON format conversion refers to converting these initial data into JSON format. JSON is a lightweight data exchange format that is easy for people to read and write, and easy for machines to parse and generate. It is based on a subset of JavaScript, but is independent of the language and is widely used for data transmission between network applications.

[0167] It can be understood that the target data refers to the converted JSON format data.

[0168] In this embodiment, subsequent processing and display can be facilitated by converting the data into JSON format. For example, in Web development, the backend service usually converts the database query results into JSON format and then sends them to the frontend application through an API.

[0169] Data in JSON format can also be used in various scenarios such as configuration files, data storage, and messaging.

[0170] The purpose of the whole process is to convert the raw data in the database into a more universal and easy-to-process format to facilitate data transmission, storage and further processing. JSON, as a widely supported data format, makes this process more efficient and reliable.

[0171] Step S450, obtaining a target answer based on the target answer template and the target data.

[0172] It should be noted that the target answer template is a predefined template that defines how to format the query results (data) into answers that users can understand. This template may contain text, placeholders, conditional statements, loop statements, etc., to guide how to display data.

[0173] It can be understood that the target answer is the final generated answer, which is obtained by filling the target data into the target answer template. This process may involve the following steps:

[0174] First, replace the placeholders in the target answer template with the values ​​in the target data. Then, execute the conditional statements and loop statements in the template to decide what to display based on the actual data situation. Finally, format the data according to the requirements of the template, such as date and time formatting, value formatting, etc.

[0175] The purpose of this process is to transform the raw data into a user-friendly, easy-to-understand format. The target answer template provides a flexible way to define how the answer is presented, while the target data provides the specific content.

[0176] By combining templates and data, the system can generate clear, accurate, and easy-to-understand answers to meet users' information needs.

[0177] The whole process is a data-to-information conversion process, which uses templates to guide the display of data, so that the final answer is both structured and dynamically generated according to different data. This method has a wide range of applications in automated report generation, question-answering systems, data analysis and other fields.

[0178] The present application proposes an answer acquisition method and related equipment. In the related technology, due to the limitation of semantic understanding ability, the semantic understanding result may be ambiguous, which leads to low accuracy of the answer. In the present application, first, a query answer instruction is obtained, and in response to the query answer instruction, an initial question is obtained. Then, the initial question is standardized to obtain a target question, and the target semantics corresponding to the target question is determined. Further, the table data and key fields with the highest correlation with the target semantics are selected, and based on the table data and the key fields, a preset statement conversion model is used to process the target question to obtain an initial SQL statement, wherein the preset statement conversion model is a trained statement conversion model. Finally, based on a preset SQL decoder, the initial SQL statement is standardized to obtain a target SQL statement, and the answer corresponding to the target SQL statement is searched to obtain the target answer.

[0179] It can be understood that, first, a preset large language model is used to obtain an initial SQL statement with higher accuracy, and then the initial SQL statement is standardized to obtain a target SQL statement with higher accuracy. Based on the target SQL statement with higher accuracy, the answer corresponding to the target SQL statement is searched, and then a target answer with higher accuracy is obtained, thereby improving the accuracy of the answer.

[0180] 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 refer to the above introduction, and will not be repeated later. Figure 2 Before step S300, the answer acquisition method further includes steps S310 to S340:

[0181] Step S310, obtaining a sample statement and a current statement conversion model, wherein the statement conversion result corresponding to the sample statement is a third SQL statement;

[0182] It should be noted that the statement conversion model refers to converting the statement form. In the present application, the answer acquisition device converts the sample statement in the natural language form into an SQL statement.

[0183] Step S320, based on the current statement conversion model, convert the sample statement to obtain a fourth SQL statement;

[0184] Step S330, determining whether the third SQL statement is the same as the fourth SQL statement, and if not, adjusting the parameters of the current statement conversion model;

[0185] If two SQL statements are found to be different, this may indicate inconsistency or instability in the model during inference. In this case, the parameters of the large language model need to be adjusted. The parameters may include: learning rate, regularization coefficient, model architecture, optimization algorithm, loss function weight.

[0186] It is understandable that the purpose of adjusting parameters is to improve the accuracy, consistency and generalization ability of the model, ensuring that the model can produce stable and reliable output when faced with the same input. By adjusting parameters, the performance of the model can be optimized to better suit a specific task or data set.

[0187] This process is usually iterative, requiring multiple comparisons of inference results and adjustments of parameters until the model's performance reaches a satisfactory level.

[0188] Step S340, based on the adjusted current statement conversion model, return to the current statement conversion model, perform statement conversion on the sample statement, and obtain a fourth SQL statement, until the third SQL statement is the same as the fourth SQL statement, and obtain a preset statement conversion model.

[0189] This process continues until the third and fourth SQL statements are exactly the same, which means that the model has achieved consistency during the transformation process and produces the same output for the same input.

[0190] It is understandable that once the third SQL statement is the same as the fourth SQL statement, it indicates that the model has been adjusted to an ideal state, and the model in this state is called the "preset statement conversion model". This "preset statement conversion model" is optimized and can stably convert statements and produce consistent results.

[0191] In this embodiment, continuous adjustment and testing are performed to ensure that the sentence conversion model can produce consistent and reliable conversion results when processing specific sample sentences. This process is crucial to improving the stability and reliability of the model, especially in application scenarios that require high consistency in model output.

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

[0193] This application also provides an answer acquisition device, please refer to Figure 4 , the answer acquisition device comprises:

[0194] An acquisition module 10, the acquisition module is used to acquire a query answer instruction, and acquire an initial question in response to the query answer instruction;

[0195] A determination module 20, the determination module is used to perform standardization processing on the initial question, obtain a target question, and determine a target semantics corresponding to the target question;

[0196] A selection module 30, the selection module is used to select the table data and key fields with the highest semantic relevance to the target, and based on the table data and the key fields, use a preset statement conversion model to process the target problem and obtain an initial SQL statement, wherein the preset statement conversion model is a trained statement conversion model;

[0197] The processing module 40 is used to perform standardization processing on the initial SQL statement based on a preset SQL decoder to obtain a target SQL statement, search for an answer corresponding to the target SQL statement, and obtain a target answer.

[0198] In one embodiment, the determining module includes:

[0199] A first acquisition unit is used to acquire a question template library, and determine semantic information corresponding to each question template in the question template library to obtain multiple groups of question template semantics;

[0200] A determination unit, configured to determine a first semantic meaning corresponding to the initial question, and calculate a semantic similarity value between the first semantic meaning and any one of the multiple sets of question template semantic meanings based on a preset semantic similarity calculation method, to obtain multiple sets of semantic similarity values;

[0201] The first setting unit is used to obtain the maximum value among the multiple groups of semantic similarity values, set the question template corresponding to the maximum value as the target question template, determine the target question based on the target question template, and determine the target semantics corresponding to the target question.

[0202] In one embodiment, the processing module includes:

[0203] A second acquisition unit is used to acquire a preset SQL template library, and map the initial SQL statement based on the preset SQL template library to obtain a first SQL statement;

[0204] The first processing unit is used to process the first SQL statement based on the target semantics using a preset SQL decoder to obtain a target SQL statement.

[0205] In one embodiment, the processing module further includes:

[0206] A second processing unit, configured to process the first SQL statement based on the target semantics using a preset SQL decoder to obtain a second SQL statement;

[0207] A third acquisition unit is used to acquire a preset SQL statement standard library, and perform statement standardization verification on the second SQL statement based on the preset SQL statement standard library to obtain a verification result;

[0208] A saving unit, if the verification result is a verification failure, saves the second SQL statement into a SQL statement training library, wherein the SQL statements in the SQL statement training library are used to generate standard SQL statements in a preset SQL statement standard library;

[0209] The second setting unit sets the second SQL statement as a target SQL statement if the verification result is successful.

[0210] In one embodiment, the processing module further includes:

[0211] A loading unit, based on an ORM tool, loads an answer template library and an answer database, determines a target answer template in the answer template library corresponding to the target SQL statement, and determines initial data in the answer database corresponding to the target SQL statement;

[0212] A format conversion unit, used for converting the initial data into JSON format to obtain target data;

[0213] A target answer is obtained based on the target answer template and the target data.

[0214] In one embodiment, the selection module includes:

[0215] A fourth acquisition unit is used to acquire a sample statement and a current statement conversion model, wherein the statement conversion result corresponding to the sample statement is a third SQL statement;

[0216] A conversion unit, configured to perform statement conversion on the sample statement based on a current statement conversion model to obtain a fourth SQL statement;

[0217] A judging unit, configured to judge whether the third SQL statement is the same as the fourth SQL statement, and if they are not the same, adjust the parameters of the current statement conversion model;

[0218] The training unit is used to return to the current statement conversion model based on the adjusted current statement conversion model, perform statement conversion on the sample statement, and obtain a fourth SQL statement, until the third SQL statement is the same as the fourth SQL statement, and obtain a preset statement conversion model.

[0219] The answer acquisition device provided by the present application adopts the answer acquisition method in the above embodiment, which can solve the technical problem of answer acquisition. Compared with the prior art, the beneficial effects of the answer acquisition device provided by the present application are the same as the beneficial effects of the answer acquisition method provided by the above embodiment, and the other technical features in the answer acquisition device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0220] The present application provides an answer acquisition 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 answer acquisition method in the above-mentioned embodiment one.

[0221] Reference below Figure 5 , which shows a schematic diagram of the structure of an answer acquisition device suitable for implementing the embodiment of the present application. The answer acquisition 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), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The answer acquisition device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0222] like Figure 5As shown, the answer acquisition device may include a processing device 1001 (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: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the answer acquisition device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the answer acquisition device to communicate wirelessly or wired with other devices to exchange data. Although the figure shows an answer acquisition 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 can be implemented or have alternatively.

[0223] 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 device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0224] The answer acquisition device provided by the present application adopts the answer acquisition method in the above embodiment, which can solve the technical problem of answer acquisition. Compared with the prior art, the beneficial effects of the answer acquisition device provided by the present application are the same as the beneficial effects of the answer acquisition method provided by the above embodiment, and the other technical features in the answer acquisition device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0225] 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.

[0226] 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.

[0227] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the answer acquisition method in the above-mentioned embodiment.

[0228] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0229] The computer-readable storage medium may be included in the answer acquisition device; or may exist independently without being assembled into the answer acquisition device.

[0230] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the answer acquisition device, the answer acquisition device:

[0231] Obtaining a query answer instruction, and obtaining an initial question in response to the query answer instruction;

[0232] Standardizing the initial question to obtain a target question, and determining a target semantics corresponding to the target question;

[0233] Selecting the table data and key fields with the highest semantic relevance to the target, and processing the target problem based on the table data and the key fields using a preset statement conversion model to obtain an initial SQL statement, wherein the preset statement conversion model is a trained statement conversion model;

[0234] Based on a preset SQL decoder, the initial SQL statement is standardized to obtain a target SQL statement, and an answer corresponding to the target SQL statement is searched to obtain a target answer.

[0235] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0236] 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.

[0237] 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.

[0238] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned answer acquisition method, and can solve the technical problem of answer acquisition. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the answer acquisition method provided by the above-mentioned embodiment, and will not be repeated here.

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

[0240] The computer program product provided by this application can solve the technical problem of answer acquisition. 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 answer acquisition method provided by the above embodiment, which will not be repeated here.

[0241] 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 method for obtaining an answer, characterized in that: The answer acquisition method comprises: Obtaining a query answer instruction, and obtaining an initial question in response to the query answer instruction; Standardizing the initial question to obtain a target question, and determining a target semantics corresponding to the target question; Selecting the table data and key fields with the highest semantic relevance to the target, and processing the target problem based on the table data and the key fields using a preset statement conversion model to obtain an initial SQL statement, wherein the preset statement conversion model is a trained statement conversion model; Based on a preset SQL decoder, the initial SQL statement is standardized to obtain a target SQL statement, and an answer corresponding to the target SQL statement is searched to obtain a target answer.

2. The answer acquisition method according to claim 1, characterized in that: The steps of normalizing the initial question to obtain the target question and determining the target semantics corresponding to the target question include: Obtain a question template library, and determine semantic information corresponding to each question template in the question template library to obtain multiple groups of question template semantics; Determine a first semantics corresponding to the initial question, and calculate a semantic similarity value between the first semantics and any one of the multiple groups of question template semantics based on a preset semantic similarity calculation method to obtain multiple groups of semantic similarity values; A maximum value among the multiple groups of semantic similarity values ​​is obtained, a question template corresponding to the maximum value is set as a target question template, and based on the target question template, the target question is determined, and a target semantics corresponding to the target question is determined.

3. The answer acquisition method according to claim 1, characterized in that: The step of performing standardization processing on the initial SQL statement based on a preset SQL decoder to obtain a target SQL statement further includes: Obtain a preset SQL template library, and map the initial SQL statement based on the preset SQL template library to obtain a first SQL statement; Based on the target semantics, the first SQL statement is processed using a preset SQL decoder to obtain a target SQL statement.

4. The answer acquisition method according to claim 3, characterized in that: The step of processing the first SQL statement based on the target semantics using a preset SQL decoder to obtain a target SQL statement further includes: Based on the target semantics, using a preset SQL decoder, processing the first SQL statement to obtain a second SQL statement; Obtain a preset SQL statement standard library, and perform statement standardization verification on the second SQL statement based on the preset SQL statement standard library to obtain a verification result; If the verification result is a verification failure, the second SQL statement is saved in an SQL statement training library, wherein the SQL statements in the SQL statement training library are used to generate standard SQL statements in a preset SQL statement standard library; If the verification result is successful, the second SQL statement is set as the target SQL statement.

5. The answer acquisition method according to claim 1, characterized in that: The step of searching for an answer corresponding to the target SQL statement to obtain the target answer further includes: Based on the ORM tool, load the answer template library and the answer database, determine the target answer template corresponding to the target SQL statement in the answer template library, and determine the initial data corresponding to the target SQL statement in the answer database; Convert the initial data into JSON format to obtain target data; A target answer is obtained based on the target answer template and the target data.

6. The answer acquisition method according to claim 1, characterized in that: Before the step of using the preset statement to transform the model, the method further includes: Obtaining a sample statement and a current statement conversion model, wherein a statement conversion result corresponding to the sample statement is a third SQL statement; Based on the current statement conversion model, convert the sample statement to obtain a fourth SQL statement; Determine whether the third SQL statement is the same as the fourth SQL statement, and if not, adjust the parameters of the current statement conversion model; Based on the adjusted current statement conversion model, returning to the current statement conversion model, performing statement conversion on the sample statement to obtain a fourth SQL statement, until the third SQL statement is the same as the fourth SQL statement, and obtaining a preset statement conversion model.

7. An answer acquisition device, characterized in that: The answer acquisition device comprises: An acquisition module, the acquisition module is used to acquire a query answer instruction, and acquire an initial question in response to the query answer instruction; A determination module, the determination module is used to perform standardization processing on the initial question, obtain a target question, and determine a target semantics corresponding to the target question; A selection module, the selection module is used to select the table data and key fields with the highest semantic relevance to the target, and based on the table data and the key fields, use a preset statement conversion model to process the target problem and obtain an initial SQL statement, wherein the preset statement conversion model is a trained statement conversion model; The processing module is used to perform standardization processing on the initial SQL statement based on a preset SQL decoder to obtain a target SQL statement, find an answer corresponding to the target SQL statement, and obtain a target answer.

8. An answer acquisition 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 answer acquisition method according to any one of claims 1 to 6.

9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the answer acquisition method according to any one of claims 1 to 6 are implemented.

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 answer acquisition method according to any one of claims 1 to 6 are implemented.

Citation Information

Cited By

  • Football intelligent question-answering method and device, computer equipment and storage medium

    CN121614594A

  • Football intelligent question and answer method and device, computer device and storage medium

    CN121614594B