Question query method, device, equipment, medium and program product
By training a problem identification model based on a dual training set using the BERT model, the problem of accurately identifying the mapping relationship between natural language and database table entities and SQL syntax is solved, enabling non-professionals to efficiently query database data, which is particularly suitable for complex queries in the financial and real estate fields.
Patent Information
- Application Number
- CN202211003815.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-22
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-08-22
AI Technical Summary
Existing technologies struggle to accurately identify the relationships between natural language and database table entities, as well as the mapping between natural language and SQL syntax, making it difficult for non-professionals to efficiently query database data.
A problem identification model based on the BERT model and trained on a dual training set is adopted. Using the problem sample dataset and the CSpider dataset, the model identifies the mapping relationship between problem text and database table entities, as well as the mapping relationship between problem statement logic and SQL syntax. The model is preprocessed and optimized to improve the identification accuracy.
It greatly improves the accuracy of query results, allowing non-professionals to directly query database data using natural language, lowering the threshold for data acquisition and analysis, and is particularly suitable for complex queries in fields such as finance and real estate.
Smart Images

Figure CN115292352B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of this disclosure relate to the fields of artificial intelligence technology or finance, specifically to a problem query method, apparatus, device, medium, and program product. Background Technology
[0002] NL2SQL (NLP Language To SQL) translates natural language into executable SQL statements. Its purpose is to allow non-technical professionals to query data on demand without needing to master database languages, lowering the barrier to entry for database use and supporting users in data mining and analysis using natural language. The key aspects of NL2SQL technology are accurately identifying the relationships between natural language and database table entities, as well as the mapping between natural language and SQL syntax. Summary of the Invention
[0003] In view of this, embodiments of the present disclosure provide a method, apparatus, device, medium, and program product for improving the relationship between natural language and database table entities, as well as the mapping relationship between natural language and SQL syntax for querying problems.
[0004] According to a first aspect of this disclosure, a question query method is provided, comprising: obtaining a question to be queried, wherein the question to be queried is in natural language; inputting the question to be queried into a pre-trained question recognition model to obtain an SQL statement matching the question to be queried; and inputting the SQL statement matching the question to a database system to obtain a question query result, wherein obtaining the question query result includes obtaining field values matching the question to be queried from a database table, wherein the pre-trained question query model is trained using a BERT model based on a dual training set, wherein the dual training set includes a question sample dataset and a CSpider dataset, wherein the question sample dataset is used to train the model's ability to recognize the mapping relationship between question text and database table entities, and the CSpider dataset is used to train the model's ability to recognize the logic of question statements and the mapping relationship between question statements and SQL syntax.
[0005] According to embodiments of this disclosure, the training method for pre-training the problem identification model includes: pre-training a BERT model based on a problem sample dataset to obtain a first identification model, wherein the first identification model is used to obtain a first identification result, wherein the first identification result includes an entity matching the problem sample, the entity including a table name, and at least one of a field name and / or field type; training the first identification model based on CSpider dataset samples to obtain a second identification model, wherein the second identification model is used to obtain a second identification result, the second identification result including the first identification result, the problem statement logic, and the mapping relationship between the problem statement and SQL syntax; obtaining an SQL sample statement based on the second identification result and SQL statement concatenation rules; and optimizing the first identification model and / or SQL statement concatenation rules based on the logical accuracy and execution accuracy of the SQL sample statement until the logical accuracy and execution accuracy reach a preset threshold, thereby obtaining the problem identification model.
[0006] According to embodiments of this disclosure, the step of pre-training the BERT model based on a problem sample dataset to obtain a first recognition model further includes: determining whether the accuracy of the first recognition result is less than a threshold; and when the accuracy of the first recognition result is less than the threshold, optimizing the first recognition result, wherein the optimization includes at least one of adding a matching relationship and / or adding a problem sample, wherein the added matching relationship includes adding a matching relationship between a special problem sample and an entity.
[0007] According to an embodiment of this disclosure, a method for obtaining the problem sample dataset includes: preprocessing the problem sample to be queried to obtain the problem sample dataset, wherein the preprocessing includes word segmentation and feature vector construction of the problem sample to be queried.
[0008] According to embodiments of this disclosure, optimizing the first identification model based on the logical accuracy and execution accuracy of the SQL sample statements includes training with additional problem sample data.
[0009] According to embodiments of this disclosure, the problem statement logic and the mapping relationship between the problem statement and SQL syntax include at least one of the following: table association relationship triggered by the problem statement, aggregation relationship, keyword operation, logical nesting relationship, and multiple clauses.
[0010] According to embodiments of this disclosure, obtaining the question to be queried further includes: obtaining user question information, wherein the user question information includes voice information; and performing voice recognition on the user question information to obtain the question to be queried.
[0011] According to embodiments of this disclosure, the question query method is used for customer risk identification, wherein the question to be queried includes risk inquiry information, and the question query result includes risky customer information and / or customer risk information.
[0012] A second aspect of this disclosure provides a question query apparatus, comprising: a question acquisition module configured to acquire a question to be queried, wherein the question to be queried is in natural language; a language conversion module configured to input the question to be queried into a pre-trained question recognition model to acquire an SQL statement matching the question to be queried, wherein the pre-trained question query model is trained using a BERT model based on a dual training set, wherein the dual training set includes a question sample dataset and a CSpider dataset, wherein the question sample dataset is used to train the model's ability to recognize the mapping relationship between question text and database table entities, and the CSpider dataset is used to train the model's ability to recognize the logic of question statements and the mapping relationship between question statements and SQL syntax; and a question query module configured to input the SQL statement matching the question to be queried into a database system to acquire a question query result, wherein acquiring the question query result includes acquiring field values matching the question to be queried from a database table.
[0013] A second aspect of this disclosure provides a training apparatus for a problem identification model, comprising: a first training module, a second training module, a concatenation module, and a verification module. The first training module is configured to pre-train a BERT model based on a problem sample dataset to obtain a first identification model. The first identification model is used to obtain a first identification result, wherein the first identification result includes entities matching the problem samples, and the entities include table names, and at least one of field names and / or field types. The second training module is configured to train the first identification model based on samples from the CSpider dataset to obtain a second identification model. The second identification model is used to obtain a second identification result, which includes the first identification result, problem statement logic, and a mapping relationship between the problem statement and SQL syntax. The concatenation module is configured to obtain SQL sample statements based on the second identification result and SQL statement concatenation rules. The verification module is configured to optimize the first identification model and / or the SQL statement concatenation rules based on the logical accuracy and execution accuracy of the SQL sample statements until the logical accuracy and execution accuracy reach preset thresholds, thereby obtaining the problem identification model.
[0014] According to embodiments of this disclosure, the first training module further includes a judgment submodule and an adjustment submodule. The judgment submodule is configured to determine whether the accuracy of the first recognition result is less than a threshold. The adjustment submodule is configured to optimize the first recognition result when the accuracy of the first recognition result is less than the threshold, wherein the optimization includes at least one of adding matching relationships and / or adding question samples, wherein the added matching relationships include adding matching relationships between special question samples and entities.
[0015] According to an embodiment of this disclosure, the first training module may further include a data preprocessing submodule, configured to preprocess the query question sample to obtain the question sample dataset, wherein the preprocessing includes word segmentation and feature vector construction of the query question sample.
[0016] A fourth aspect of this disclosure provides an electronic device comprising: one or more processors; and a memory for storing one or more programs, wherein, when the one or more programs are executed by the one or more processors, the one or more processors perform the above-described problem query method.
[0017] The fifth aspect of this disclosure also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the above-described problem query method.
[0018] A sixth aspect of this disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the aforementioned problem query method.
[0019] The method provided in this disclosure queries an input query question based on a question recognition model trained using a dual training set and a BERT model. The question recognition model trained using the dual training set and the BERT model has a high accuracy in recognizing the mapping relationship between question text and database table entities, as well as the mapping relationship between question statement logic and question statement and SQL syntax, greatly improving the accuracy of the question query results. Attached Figure Description
[0020] The foregoing contents, as well as other objects, features, and advantages of this disclosure, will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0021] Figure 1 The illustration shows an application scenario diagram of the problem query method, apparatus, device, medium, and program product according to embodiments of the present disclosure.
[0022] Figure 2 A flowchart illustrating a problem query method according to an embodiment of this disclosure is shown schematically.
[0023] Figure 3 A flowchart illustrating a training method for obtaining the problem identification model through pre-training according to an embodiment of the present disclosure is shown.
[0024] Figure 4 The flowchart illustrates a method for pre-training a BERT model based on a problem sample dataset to obtain a first recognition model according to an embodiment of the present disclosure.
[0025] Figure 5 A flowchart illustrating a method for obtaining the problem sample dataset according to an embodiment of this disclosure is shown schematically.
[0026] Figure 6 A flowchart illustrating a method for obtaining a query question according to an embodiment of this disclosure is shown schematically.
[0027] Figure 7 A schematic block diagram of a problem query device according to an embodiment of the present disclosure is shown.
[0028] Figure 8 A schematic block diagram of a problem acquisition module 710 according to an embodiment of the present disclosure is shown.
[0029] Figure 9 A schematic block diagram of a training apparatus for a problem identification model according to an embodiment of the present disclosure is shown.
[0030] Figure 10 A schematic block diagram of a training apparatus for a problem identification model according to an embodiment of the present disclosure is shown.
[0031] Figure 11 A schematic diagram illustrating the structure of a first training module according to other embodiments of the present disclosure is shown.
[0032] Figure 12 A block diagram schematically illustrates an electronic device suitable for implementing a problem query method according to an embodiment of the present disclosure. Detailed Implementation
[0033] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.
[0034] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0035] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0036] When using expressions such as "at least one of A, B, and C", they should generally be interpreted in accordance with the meaning that is commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B, and C, etc.).
[0037] In the technical solution disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure, and application of user personal information comply with the provisions of relevant laws and regulations, necessary confidentiality measures have been taken, and there is no violation of public order and good morals.
[0038] In the technical solution disclosed herein, the user's authorization or consent is obtained before acquiring or collecting the user's personal information.
[0039] NL2SQL (NLP Language To SQL) is a technology that translates a user's natural language into executable SQL statements. Its purpose is to allow non-technical professionals to query data on demand without needing to master database languages, lowering the barrier to entry for database use and supporting users in data mining or data analysis using natural language. The key aspects of NL2SQL technology are accurately identifying the relationships between natural language and database table entities, as well as the mapping between natural language and SQL syntax.
[0040] In view of the above, embodiments of this disclosure provide a question query method, comprising: obtaining a question to be queried, wherein the question to be queried is in natural language; inputting the question to be queried into a pre-trained question recognition model to obtain an SQL statement matching the question to be queried; and inputting the SQL statement matching the question to a database system to obtain a question query result, wherein obtaining the question query result includes obtaining field values matching the question to be queried from a database table, wherein the pre-trained question query model is trained using a BERT model based on a dual training set, wherein the dual training set includes a question sample dataset and a CSpider dataset, wherein the question sample dataset is used to train the model's ability to recognize the mapping relationship between question text and database table entities, and the CSpider dataset is used to train the model's ability to recognize the logic of question statements and the mapping relationship between question statements and SQL syntax.
[0041] It should be noted that the problem query method, apparatus, device, medium, and program products provided in this disclosure can be used in the area of artificial intelligence technology related to the conversion of natural language into executable SQL statements, and can also be used in various fields other than artificial intelligence technology, such as the financial field. The application fields of the problem query method, apparatus, device, medium, and program products provided in this disclosure are not limited.
[0042] The above-described operations for achieving at least one objective of this disclosure will be described below in conjunction with the accompanying drawings and their descriptions.
[0043] Figure 1 The illustration shows an application scenario diagram of the problem query method, apparatus, device, medium, and program product according to embodiments of the present disclosure.
[0044] like Figure 1 As shown, application scenario 100 according to this embodiment may include terminal devices 101, 102, and 103, a network 104, and a server 105. Network 104 serves as a medium for providing a communication link between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0045] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0046] Terminal devices 101, 102, and 103 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0047] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using terminal devices 101, 102, and 103 (for example only). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.
[0048] It should be noted that the problem query method provided in this embodiment can generally be executed by server 105. Correspondingly, the problem query device provided in this embodiment can generally be located in server 105. The problem query method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the problem query device provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105.
[0049] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0050] The following will be based on Figure 1 The described scene, through Figures 2-6 The problem query method of the disclosed embodiments is described in detail.
[0051] Figure 2 A flowchart illustrating a problem query method according to an embodiment of this disclosure is shown schematically.
[0052] like Figure 2 As shown, the problem query method of this embodiment includes operations S210 to S230. The problem query method can be executed by a processor or by any electronic device including a processor.
[0053] In operation S210, retrieve the question to be queried.
[0054] In operation S220, the question to be queried is input into the pre-trained question recognition model to obtain the SQL statement that matches the question to be queried.
[0055] In operation S230, the SQL statement matching the query question is input into the database system to obtain the query result, wherein obtaining the query result includes retrieving the field value matching the query question from the database table.
[0056] According to embodiments of this disclosure, the question query method is built upon NL2SQL technology. Therefore, the question to be queried, input into the question recognition model, is in natural language form. After the question is input into the question recognition model, the natural language question can be converted into an executable SQL statement matching the question. Furthermore, the query result can be obtained by inputting the SQL statement into a database system.
[0057] In the embodiments of this disclosure, the pre-trained question query model is trained using a BERT model based on a dual training set. Specifically, the BERT model serves as the basic model structure for training, utilizing a dual training set including a question sample dataset and a CSpider dataset. BERT is a typical pre-trained language model that employs a transformer model as its feature extractor. The attention mechanism in the transformer model can learn the relationships between words in a sentence, thus improving accuracy through contextual information. The question sample dataset is used to train the model's ability to recognize the mapping relationship between question text and database table entities. It can be understood that the question sample dataset can be question text with the same or similar logic as the question to be queried, and with consistent or similar wording. Pre-training the model using the question sample dataset allows for a relatively accurate recognition of the correspondence between the natural language of the question text and database table entities. Based on this, the CSpider dataset is used to train the model's ability to recognize the logic of question statements and the mapping relationship between question statements and SQL syntax. CSpider is a Chinese Text-to-SQL dataset translated from the Spider dataset, covering multiple fields such as finance and real estate. It is more suitable for training complex SQL sentences. Combined with the CSpider dataset, a model can be trained to identify the types of SQL operations and processing logic in a problem, converting text into executable SQL statements.
[0058] The method provided in this disclosure uses a question recognition model trained with a dual training set and a BERT model to query the input question. The question recognition model has a high accuracy in recognizing the mapping relationship between question text and database table entities, as well as the mapping relationship between question statement logic and SQL syntax, significantly improving the accuracy of the question query results. Furthermore, since the CSpider dataset covers multiple fields such as finance and real estate, the question query method provided in this disclosure is particularly suitable for querying questions in these fields, such as identifying financial risks.
[0059] Figure 3 A flowchart illustrating a training method for obtaining the problem identification model through pre-training according to an embodiment of the present disclosure is shown.
[0060] like Figure 3 As shown, the training method for obtaining the problem identification model through pre-training in this embodiment includes operations S310 to S340.
[0061] In operation S310, the BERT model is pre-trained based on the problem sample dataset to obtain a first recognition model. The first recognition model is used to obtain a first recognition result, wherein the first recognition result includes entities that match the problem samples, and the entities include table names, and at least one of field names and / or field types.
[0062] In operation S320, the first recognition model is trained based on samples from the CSpider dataset to obtain a second recognition model. The second recognition model is used to obtain a second recognition result, which includes the first recognition result, the logic of the question statement, and the mapping relationship between the question statement and the SQL syntax.
[0063] In operation S330, SQL sample statements are obtained based on the second identification result and SQL statement concatenation rules.
[0064] In operation S340, the first identification model and / or SQL statement concatenation rules are optimized based on the logical accuracy and execution accuracy of the SQL sample statement until the logical accuracy and execution accuracy reach a preset threshold, and the problem identification model is obtained.
[0065] In the embodiments of this disclosure, firstly, the BERT model is pre-trained using a question sample dataset to obtain a first recognition model. This model enables semantic recognition of table names, field names, or field types mentioned in the question, in order to match relevant table information within the database. For example, in the question "Query Zhang San's loan balance," both "Zhang San" and "loan balance" are keywords in the question sample. "Loan balance" matches the "Loan Balance Table" data table in the database, and "Zhang San" matches the "Individual Customer Name" field in the data table. Thus, an association can be established between the question sample and the "Loan Balance Table" table name. Furthermore, the "Individual Customer Name" field name is matched using keywords. This achieves an accurate construction of the mapping relationship between the question text and database table entities.
[0066] Furthermore, considering the logical results of the query statements and the mapping relationship between the query statements and SQL syntax, the CSpider dataset is more suitable as a training set, combined with the BERT model for training. The CSpider dataset inherits the advantages of the classic Text-to-SQL dataset, the Spider dataset. Compared to other datasets that only support single-table queries, the CSpider dataset supports common keywords, aggregation operations, and complex sentence structures such as multiple clauses and nesting. For example, the queries "How many inclusive finance customers are at risk of loan reversal?" and "How many inclusive finance customers have experienced loan reversal?", although different in wording, both correspond to the COUNT operation and the same condition after WHERE. Utilizing the CSpider dataset effectively improves the BERT model's ability to recognize complex sentences, bridging the gap between natural language and SQL syntax.
[0067] After obtaining the second identification result based on the second identification model, SQL sample statements can be obtained based on the obtained second identification result and SQL statement concatenation rules for execution in the database system. For example, operations on entities (tables), entities (field names), and keywords identified in the problem can be converted into the SQL statement "select customer name from loan return model table where time (year) = this year".
[0068] In embodiments of this disclosure, the first recognition model and / or SQL statement concatenation rules can be optimized based on the logical accuracy and execution accuracy of the transformed SQL sample statements. Specifically, the logical accuracy can be obtained by comparing the concatenated and transformed SQL statement with the actual SQL statement. For execution accuracy, a test set of questions and answers can be constructed by compiling a set of commonly used questions, and the actual results can be compared with the results of the test set to determine the accuracy of the answer. Embodiments of this disclosure can simultaneously use logical accuracy and execution accuracy to evaluate the model's recognition accuracy. Thresholds for logical accuracy and execution accuracy can be preset. When the optimized model reaches the threshold for both logical accuracy and execution accuracy for the transformed SQL sample statements, optimization stops, and the question recognition model of this disclosure is obtained. It is understood that in embodiments of this disclosure, the question recognition model is used to obtain SQL statements based on question text transformation.
[0069] In some specific embodiments, optimizing the first identification model based on the logical accuracy and execution accuracy of the SQL sample statements includes training with additional problem sample data. In specific embodiments of this disclosure, the model's performance can be continuously trained and optimized by increasing training samples and adjusting syntax or logical structure. If the logical accuracy is low, more problem sample data can be added, and the BERT model can be used to improve the recognition ability of the mapping relationship between problem keywords and database table entities. If the execution accuracy is low, there are two possibilities. One possibility is that there are problems with the SQL syntax, specifically manifested in the SQL statements identified for more complex problems, where there may be problems with the concatenated SQL syntax, such as field type conversion, missing primary keys in join statements, or missing query fields in the table. In this case, on the one hand, the concatenated statements can be optimized to improve the SQL statement conversion result; on the other hand, prompt statements can be added to provide the user with information not found in the data table. Another possibility is that the execution result does not match the expectation. This involves examining the erroneous problem samples and the identified SQL statements to determine if the failure is due to incorrect mapping relationships, syntax issues, or logical structure problems. If it's a mapping relationship error, it's treated as a case of low logical accuracy, and the number of problem samples is increased to improve accuracy. If it's a syntax problem, the same method as the first possibility can be used to solve it. If it's a logical structure problem (i.e., an SQL statement order issue), for example, the query "Query the number of risk hits in loan return by sorting by company name in descending order" is identified as "select customer type, count(*) from loan return table order by customer type groupby customer type". Because "sort by company name in descending order" is at the beginning of the statement, the "orderby" operation is identified first, causing the statement to fail. In such scenarios, the concatenation order of the model's SQL statements can be adjusted according to the actual situation to avoid logical structure problems as much as possible and optimize the model's performance. It's understandable that after applying the problem identification model, problems can be continuously collected, and the model's performance can be optimized periodically based on abnormal problem samples according to the actual problem identification results and user feedback.
[0070] Figure 4 The flowchart illustrates a method for pre-training a BERT model based on a problem sample dataset to obtain a first recognition model according to an embodiment of the present disclosure.
[0071] like Figure 4 As shown, the method for pre-training the BERT model based on the problem sample dataset to obtain the first recognition model in this embodiment includes operations S410 to S420.
[0072] In operation S410, it is determined whether the accuracy of the first recognition result is less than a threshold.
[0073] In operation S420, when the accuracy of the first identification result is less than a threshold, the first identification result is optimized. The optimization includes at least one of adding a new matching relationship and / or adding a new problem sample. The new matching relationship includes adding a matching relationship between a new special problem sample and an entity.
[0074] In the embodiments of this disclosure, when the accuracy of the first identification result is less than a threshold, the accuracy of the first identification model in identifying more keywords and the mapping relationship between different expressions of keywords and database table entities can be improved by adding new question samples. On the other hand, for the association between special domains or professional terms and database table entities, matching relationships between special question samples and database table entities can be added. As an example of a specific implementation, the mapping relationship between special keywords and database table entities can be added based on expert experience. For example: "Query the list of general legal entity customers whose collateral has been seized in the past two years," where "general legal entity" specifically refers to large enterprise customers, as a type of customer; "collateral seizure" is an abnormal situation among collateral anomalies, i.e., associated with the "collateral anomaly table." By adding the special keyword "general legal entity" and "customer type" fields, and the matching relationship between the special keyword "collateral seizure" and the table name of the "collateral anomaly table," the accuracy of the first identification model in identifying special keywords can be improved.
[0075] In some embodiments, the logic of the question statement and the mapping relationship between the question statement and SQL syntax include at least one of the following: table joins triggered by the question statement, aggregation relationships, keyword operations, logical nesting relationships, and multiple clauses. Table joins may include Left Join, Inner Join, Right Join, etc.; aggregation relationships may include Count, Max, Group By, etc.; and keyword operations may include Select, Where, Order By, etc.
[0076] Figure 5 A flowchart illustrating a method for obtaining the problem sample dataset according to an embodiment of this disclosure is shown schematically.
[0077] like Figure 5 As shown, the method for obtaining the problem sample dataset in this embodiment includes operation S510.
[0078] In operation S510, the query question sample is preprocessed to obtain the question sample dataset, wherein the preprocessing includes word segmentation and feature vector construction of the query question sample.
[0079] Figure 6 A flowchart illustrating a method for obtaining a query question according to an embodiment of this disclosure is shown schematically.
[0080] like Figure 6 As shown, the method for obtaining the query question in this embodiment includes operations S610 to S620.
[0081] In operation S610, user question information is obtained, wherein the user question information includes voice information.
[0082] In operation S620, the user's question information is subjected to speech recognition to obtain the question to be queried.
[0083] In the embodiments of this disclosure, the query question can be obtained based on speech recognition. For example, a user asks a question on a PC or mobile device using a microphone or other speech acquisition device, such as: "Does xxx company have any overdue interest payments in the past two years?" or "Can you provide a list of customers who have received loan repayments this year?" The speech question can be converted into text format using a speech recognition device.
[0084] As mentioned above, the embodiments of this disclosure utilize the CSpider dataset to improve the model's ability to identify the logic of problem statements and the mapping relationship between problem statements and SQL syntax, thus making it particularly suitable for problem identification in fields such as finance and real estate.
[0085] In one specific embodiment, the problem query method is used for customer risk identification.
[0086] As credit business models gradually transform, problems such as multiple information sources, information asymmetry, and uncontrollable risks in traditional credit processes have become increasingly prominent with the development of micro and small enterprise (MSE) lending. With urban digital transformation and the opening up of government data, banks are leveraging multi-source public data from various data institutions, combined with their own internal data, to develop diverse risk control models and create customer risk profiles. They are also using data tracking to record business flow logs, calculate real-time internal business operations, and statistically analyze indicators such as loan return rates and loan-to-deposit ratios to control post-loan risks. Currently, major banks have accumulated vast amounts of customer information, risk information, and risk control model data to achieve end-to-end risk management for loans. They have streamlined data from different channels and with different structures, building data asset platforms, data middleware, and other platforms to manage the data, ensuring that the data quality and standardization meet exportable standards. However, with the increasing scale and complexity of data, business personnel still need to understand and verify customer information from multiple channels, making it difficult to accurately obtain substantive risk information. As regulatory policies continue to tighten, the workload of managers in daily statistics and risk verification is constantly increasing. Due to a lack of professional data analysis skills, when faced with verification requests from regulatory authorities, they can only rely on technical personnel to write SQL scripts to obtain lists of risky customers. This process is complex and time-consuming, severely impacting the efficiency of pre- and post-loan management. In a specific embodiment of this disclosure, a constructed query method can be used to perform query operations on the acquired customer and risk data to obtain relevant statistical data, enabling the rapid capture of customer risk information or the association of risky customers.
[0087] In specific embodiments of this disclosure, the question to be queried includes risk inquiry information, and the query result includes risk customer information and / or customer risk information. Typical risk inquiry information and query results can be exemplified as follows:
[0088] 1) Input: Query whether xxx company has any overdue interest payments in the past 2 years? Output: Yes / No.
[0089] 2) Input: Query the list of customers who have received loan returns this year. Output: Customer list.
[0090] 3) Input: Query the risk information associated with company xxx in the past 3 months. Output: List of risk tags.
[0091] 4) Input: List of companies that had no sales revenue in the current year. Output: Customer list.
[0092] 5) Input: Company xxx, which is at risk of being listed as a dishonest judgment debtor. Query relevant case numbers. Output: Case number.
[0093] In specific embodiments of this disclosure, applying the question-based query method to customer risk identification can transform the traditional credit business model. It allows non-professionals to directly query data using natural language, significantly reducing the workload of data acquisition, statistics, and analysis. Business personnel can directly obtain risk information for individual customers by asking questions, quickly assessing the risk level of loan applications. Managers can quickly obtain relevant customer lists for single or multiple risks, efficiently fulfilling verification requirements. This reduces the workload of technical personnel in repeatedly creating similar data reports and decreases the demand for similar data. Simultaneously, it increases efficiency and reduces the burden on front-end and back-end personnel, allowing saved human resources to be invested in front-end marketing or back-end R&D. Furthermore, the application of this method enhances risk control capabilities. Business personnel can access customer risk information at any time, accurately identifying high-risk customers during the pre-loan approval process, providing data support for customer rating assessments and loan disbursement. In post-loan management, they can monitor customer conditions in real time, controlling bad debt risk and reducing the incidence of non-performing loans by querying loan-to-deposit ratios, sales return rates, and overdue interest. On the other hand, the application of the above methods, combined with natural language processing technology, enables intelligent interaction of customer risk information, outputting data that was originally stored in the database as a service, which can be reused in various financial risk control scenarios.
[0094] It should be noted that, in specific embodiments of this disclosure, the risk customer information and / or customer risk information recorded in the database may involve customer information. Before obtaining user information, the user's consent or authorization may be obtained.
[0095] Based on the above-described problem query method, embodiments of this disclosure also provide a problem query device. The following will combine... Figure 7 The device is described in detail.
[0096] Figure 7 A schematic block diagram of a problem query device according to an embodiment of the present disclosure is shown.
[0097] like Figure 7 As shown, the problem query device 700 of this embodiment includes a problem acquisition module 710, a language conversion module 720, and a problem query module 730.
[0098] The question acquisition module 710 is configured to acquire questions to be queried, wherein the questions to be queried are in natural language.
[0099] The language conversion module 720 is configured to input the query question into a pre-trained question recognition model to obtain an SQL statement matching the query question. The pre-trained question query model is trained using a BERT model based on a dual training set. The dual training set includes a question sample dataset and a CSpider dataset. The question sample dataset is used to train the model's ability to recognize the mapping relationship between question text and database table entities, while the CSpider dataset is used to train the model's ability to recognize the logic of question statements and the mapping relationship between question statements and SQL syntax.
[0100] The problem query module 730 is configured to input the SQL statement matching the problem to be queried into the database system and obtain the problem query result, wherein obtaining the problem query result includes obtaining the field value matching the problem to be queried from the database table.
[0101] In some embodiments, the problem acquisition module may further include a receiving submodule and an identification submodule.
[0102] Figure 8 A schematic block diagram of a problem acquisition module 710 according to an embodiment of the present disclosure is shown.
[0103] like Figure 8 As shown, the problem acquisition module 710 of this embodiment includes a receiving submodule 7101 and an identification submodule 7102.
[0104] The receiving submodule 7101 is configured to acquire user question information, wherein the user question information includes voice information.
[0105] The recognition submodule 7102 is configured to perform speech recognition on the user's question information to obtain the question to be queried.
[0106] Based on the above-described problem query method, embodiments of this disclosure also provide a training apparatus for a problem identification model. The following will combine... Figure 9 The device is described in detail.
[0107] Figure 9 A schematic block diagram of a training apparatus for a problem identification model according to an embodiment of the present disclosure is shown.
[0108] like Figure 9 As shown, the problem query device 800 of this embodiment includes a first training module 810, a second training module 820, a splicing module 830, and a verification module 840.
[0109] The first training module 810 is configured to pre-train the BERT model based on the problem sample dataset to obtain a first recognition model. The first recognition model is used to obtain a first recognition result, wherein the first recognition result includes entities that match the problem samples, and the entities include table names, and at least one of field names and / or field types.
[0110] The second training module 820 is configured to train the first recognition model based on samples from the CSpider dataset to obtain a second recognition model. The second recognition model is used to obtain a second recognition result, which includes the first recognition result, the logic of the question statement, and the mapping relationship between the question statement and the SQL syntax.
[0111] The splicing module 830 is configured to obtain SQL sample statements based on the second recognition result and the SQL statement splicing rules.
[0112] The verification module 840 is configured to optimize the first identification model and / or SQL statement concatenation rules based on the logical accuracy and execution accuracy of the SQL sample statement until the logical accuracy and execution accuracy reach a preset threshold, thereby obtaining the problem identification model.
[0113] According to embodiments of this disclosure, the first training module further includes a judgment submodule and an adjustment submodule.
[0114] Figure 10 A schematic block diagram of a training apparatus for a problem identification model according to an embodiment of the present disclosure is shown.
[0115] like Figure 10 As shown, the first training module 810 of this embodiment includes a judgment submodule 8101 and an adjustment submodule 8102.
[0116] The judgment submodule 8101 is configured to determine whether the accuracy of the first recognition result is less than a threshold.
[0117] The adjustment submodule 8102 is configured to optimize the first identification result when the accuracy of the first identification result is less than a threshold, wherein the optimization includes at least one of adding a new matching relationship and / or adding a new problem sample, wherein the new matching relationship includes adding a matching relationship between a new special problem sample and an entity.
[0118] In other embodiments, the first training module may also include a data preprocessing submodule.
[0119] Figure 11 A schematic diagram illustrating the structure of a first training module according to other embodiments of the present disclosure is shown.
[0120] like Figure 11 As shown, the first training module 810 in some other embodiments includes a data preprocessing submodule 8103.
[0121] The data preprocessing submodule 8103 is configured to preprocess the query question sample to obtain the question sample dataset, wherein the preprocessing includes word segmentation and feature vector construction of the query question sample.
[0122] According to embodiments of this disclosure, any and multiple modules among the acquisition module 710, language conversion module 720, question query module 730, receiving submodule 7101, recognition submodule 7102, first training module 810, second training module 820, splicing module 830, verification module 840, judgment submodule 8101, adjustment submodule 8102, and data preprocessing submodule 8103 can be combined into one module, or any one of these modules can be split into multiple modules. Alternatively, at least some of the functions of one or more of these modules can be combined with at least some of the functions of other modules and implemented in one module. According to embodiments of this disclosure, at least one of the following modules can be implemented, at least partially, as hardware circuits, such as field-programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems-on-a-chip, systems-on-a-substrate, systems-on-package, application-specific integrated circuits (ASICs), or any other reasonable means of integrating or packaging circuits, or as hardware or firmware, or as any one of software, hardware, and firmware implementations, or as a suitable combination of any of these three implementations, or as a combination of any of them. Alternatively, at least one of the following modules can be implemented, at least partially, as a computer program module: acquisition module 710, language conversion module 720, question query module 730, receiving submodule 7101, recognition submodule 7102, first training module 810, second training module 820, splicing module 830, verification module 840, judgment submodule 8101, adjustment submodule 8102, and data preprocessing submodule 8103. When the computer program module is run, it can perform the corresponding function.
[0123] Figure 12 A block diagram schematically illustrates an electronic device suitable for implementing a problem query method according to an embodiment of the present disclosure.
[0124] like Figure 12As shown, an electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage portion 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0125] RAM 903 stores various programs and data required for the operation of electronic device 900. Processor 901, ROM 902, and RAM 903 are interconnected via bus 904. Processor 901 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 902 and / or RAM 903. It should be noted that the programs may also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.
[0126] According to embodiments of this disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to a bus 904. The electronic device 900 may also include one or more of the following components connected to the I / O interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 910 as needed so that computer programs read from it can be installed into the storage section 908 as needed.
[0127] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.
[0128] According to embodiments of this disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this disclosure, the computer-readable storage medium may include one or more memories other than ROM 902 and / or RAM 903 described above.
[0129] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to cause the computer system to implement the methods provided in the embodiments of this disclosure.
[0130] When the computer program is executed by the processor 901, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0131] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 909, and / or installed from a removable medium 911. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0132] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, it performs the functions defined in the system of this disclosure embodiment. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0133] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on a user's computing device, partially on a user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0134] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0135] Those skilled in the art will understand that the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways, even if such combinations or combinations are not explicitly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.
[0136] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.
Claims
1. A question query method characterized by, The method comprises: acquiring a query question, wherein the query question is in natural language; inputting the query question into a pre-trained question recognition model to acquire an SQL statement matched with the query question; and inputting the SQL statement matched with the query question into a database system to acquire a query result, wherein the acquiring the query result comprises acquiring a field value matched with the query question from a database table, wherein the pre-trained question recognition model is trained based on a dual training set by using a Bert model, wherein the dual training set comprises a question sample data set and a CSpider data set, wherein the question sample data set is used to train the model to recognize the mapping relationship between the question text and the database table entity, and the CSpider data set is used to train the model to recognize the mapping relationship between the question statement logic and the question statement and the SQL syntax, wherein the training method for pre-training the question recognition model comprises: pre-training the Bert model based on the question sample data set to acquire a first recognition model, wherein the first recognition model is used to acquire a first recognition result, and the first recognition result comprises an entity matched with the question sample, and the entity comprises at least one of a table name, a field name and / or a field type; training the first recognition model based on the CSpider data set sample to acquire a second recognition model, wherein the second recognition model is used to acquire a second recognition result, and the second recognition result comprises the first recognition result, the question statement logic and the mapping relationship between the question statement and the SQL syntax; acquiring an SQL sample statement based on the second recognition result and an SQL statement splicing rule; and optimizing the first recognition model and / or the SQL statement splicing rule based on the logical accuracy rate and the execution accuracy rate of the SQL sample statement until the logical accuracy rate and the execution accuracy rate reach a preset threshold to acquire the question recognition model.
2. The method of claim 1, wherein, The pre-training of the Bert model based on the question sample data set to acquire the first recognition model further comprises: judging whether the accuracy rate of the first recognition result is less than a threshold; and when the accuracy rate of the first recognition result is less than the threshold, optimizing the first recognition result, wherein the optimization comprises at least one of adding a matching relationship and adding a question sample, and the added matching relationship comprises an added matching relationship between a special question sample and an entity.
3. The method of claim 1, wherein, The method for acquiring the question sample data set comprises: pre-processing the query question sample to acquire the question sample data set, wherein the pre-processing comprises segmenting the query question sample and constructing a feature vector.
4. The method of claim 1, wherein, The optimization of the first recognition model based on the logical accuracy rate and the execution accuracy rate of the SQL sample statement comprises adding question sample data for training.
5. The method of claim 1, wherein, The mapping relationship between the question statement logic and the question statement and the SQL syntax comprises at least one of a table association relationship triggered based on the question statement, an aggregation relationship, a keyword operation, a logical nesting relationship and a multi-clause.
6. The method of claim 1, wherein, The obtaining the question to be queried further includes: obtaining user query information, wherein the user query information comprises voice information; and performing voice recognition on the user query information to obtain the question to be queried.
7. The method of claim 1, wherein, The question query method is used for customer risk identification, wherein the question to be queried comprises risk query information, and the question query result comprises risk customer information and / or customer risk information.
8. A question query apparatus characterized by comprising: comprise: a question obtaining module configured to obtain a question to be queried, wherein the question to be queried is in natural language; a language conversion module configured to input the question to be queried into a pre-trained question query model to obtain a SQL statement matched with the question to be queried, wherein the pre-trained question query model is trained based on a dual training set by using a Bert model, wherein the dual training set comprises a question sample data set and a CSpider data set, wherein the question sample data set is used to train the model to recognize the mapping relationship between question text and database table entities, and the CSpider data set is used to train the model to recognize the mapping relationship between question statement logic and SQL syntax; and a question query module configured to input the SQL statement matched with the question to be queried into a database system to obtain a question query result, wherein the obtaining the question query result comprises obtaining field values matched with the question to be queried from a database table, wherein the question query device further comprises a first training module, a second training module, a splicing module and a verification module, the first training module is configured to pre-train a Bert model based on a question sample data set to obtain a first recognition model, wherein the first recognition model is used to obtain a first recognition result, and the first recognition result comprises entities matched with question samples, and the entities comprise at least one of a table name, a field name and / or a field type; the second training module is configured to train the first recognition model based on a CSpider data set sample to obtain a second recognition model, wherein the second recognition model is used to obtain a second recognition result, and the second recognition result comprises the first recognition result, question statement logic and the mapping relationship between question statement and SQL syntax; the splicing module is configured to obtain a SQL sample statement based on the second recognition result and a SQL statement splicing rule; and the verification module is configured to optimize the first recognition model and / or the SQL statement splicing rule based on the logical accuracy and execution accuracy of the SQL sample statement until the logical accuracy and execution accuracy reach a preset threshold to obtain the question query model. 9.An electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method according to any one of claims 1-7.
10. A computer readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the method of any one of claims 1-7.
11. A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of claims 1-7.
Citation Information
Patent Citations
Natural language query method based on deep learning
CN111522839A
Method for converting natural language into SQL (Structured Query Language) statement based on deep learning
CN114880347A