Data processing method, system, device, storage medium and program product

By filtering the database tables and entering only matching table structure information, the problem of low conversion accuracy of the NL2SQL solution is solved, the query accuracy and user experience are improved, and the technical threshold is lowered.

CN118132684BActive Publication Date: 2024-10-22ALIBABA CLOUD FEITIAN (HANGZHOU) CLOUD COMPUTING TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410554133.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-07
Publication Date
2024-10-22
Estimated Expiration
2044-05-07

AI Technical Summary

Technical Problem

The existing NL2SQL solution based on generative large models has low conversion accuracy, which affects the front-end human-computer interaction experience. Especially when there are a large number of database tables and the table and field names are not standardized, it is difficult to improve the query accuracy.

Method used

By filtering the database tables, only the table structure information of the target database table that matches the user's query requirements is input to the generative large model, avoiding confusion caused by too many database tables in the large model, and improving conversion accuracy and query accuracy. .

Benefits of technology

It effectively reduces the analysis pressure of large models, improves conversion and query accuracy, and lowers the technical threshold for ordinary users to query the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118132684B_ABST
    Figure CN118132684B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a data processing method, system, device, storage medium and program product. The method includes the following steps: obtaining a user question text; extracting descriptive information related to the table structure information of the database table to be queried from the user question text; screening out a target database table that matches the descriptive information from the database; inputting the table structure information of the target database table and the user question text into a generative big model, so that the generative big model converts the user question text into a structured query statement. The technical solution provided by the embodiments of the present application can not only reduce the analysis pressure of the big model, but also help the big model improve the conversion accuracy and query accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data processing method, system, device, storage medium and program product. Background Art

[0002] NL2SQL (Natural Language To SQL) is a tool that converts the user's natural language into executable structured query language (SQL).

[0003] Currently, a large amount of information is stored in structured and semi-structured knowledge bases. The analysis and acquisition of such data requires interaction with the database through programming languages ​​such as SQL. However, the difficulty of using SQL limits non-technical users and brings a high threshold to data analysis and use. People are in urgent need of technology or tools to complete the interaction between natural language and database, so the NL2SQL task was born.

[0004] At present, the existing NL2SQL solutions based on generative large models have the problem of low conversion accuracy, which affects the front-end human-computer interaction experience of the entire solution. Summary of the invention

[0005] In view of the above problems, the present application is proposed to provide a data processing method, system, device, storage medium and program product that solve the above problems or at least partially solve the above problems.

[0006] In a first aspect of the present application, a data processing method is provided, comprising:

[0007] Get the user question text related to the database query;

[0008] Extracting descriptive information related to the table structure information of the database table to be queried from the user question text;

[0009] According to the matching condition between the description information and the table structure information of the database table in the database, a target database table matching the description information is screened out from the database;

[0010] The table structure information of the target database table and the user question text are input into a generative big model, so that the generative big model converts the user question text into a structured query statement; the structured query statement is used to query the database.

[0011] A second aspect of the present application provides a data processing method, comprising:

[0012] Obtaining tax question text related to tax database queries;

[0013] Extracting descriptive information related to the table structure information of the database table to be queried from the tax question text;

[0014] Filtering out a target database table matching the description information from the tax database;

[0015] The table structure information of the target database table and the tax problem text are input into a generative big model, so that the generative big model converts the tax problem text into a structured query statement; the structured query statement is used to query the tax database.

[0016] The third aspect of the present application provides a data processing system. It includes: a client and a server; wherein:

[0017] The client is used to send user question text related to database query to the server;

[0018] The server is used to receive the user question text; extract descriptive information related to the table structure information of the database table to be queried from the user question text; screen out the target database table matching the descriptive information from the database; input the table structure information of the target database table and the user question text into the generative big model, so that the generative big model converts the user question text into a structured query statement; execute the structured query statement to obtain a database query result; send the database query result to the client; the structured query statement is used to query the database.

[0019] In a fourth aspect of the present application, an electronic device is provided. The electronic device comprises: a memory and a processor, wherein:

[0020] The memory is used to store programs;

[0021] The processor is coupled to the memory, and is used to execute the program stored in the memory to implement any of the methods described above.

[0022] According to a fifth aspect of the present application, a computer-readable storage medium storing a computer program is provided, wherein the computer program can implement any of the above-described methods when executed by a computer.

[0023] In a sixth aspect of the present application, a computer program product is provided, comprising a computer program, which implements any of the methods described above when executed by a processor.

[0024] In the technical solution provided in the embodiment of the present application, the table structure information of all tables in the database is not directly fed (i.e., input) into the generative large model, but before feeding it to the generative large model, the database tables in the database are screened, and the target database tables that match the user's query requirements are screened out, and the table structure information of the target database tables is fed to the generative large model, so that the confusion caused by too many database tables in the large model can be avoided. It can be seen that the technical solution provided in the embodiment of the present application can not only reduce the analysis pressure of the large model, but also help the large model improve the conversion accuracy and query accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0026] Figure 1 An interactive schematic diagram of a data processing system provided in one embodiment of the present application;

[0027] Figure 2 An example of matching degree calculation provided in an embodiment of the present application;

[0028] Figure 3 A flowchart of a data processing method provided in one embodiment of the present application;

[0029] Figure 4 A structural block diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0030] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below according to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0031] In addition, some of the processes described in the specification, claims and the above-mentioned figures of the present application include multiple operations that appear in a specific order, and these operations may not be executed in the order in which they appear in this article or may be executed in parallel. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish between different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit the "first" and "second" to be different types.

[0032] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0033] First, the vocabulary involved in the embodiments of the present application is explained. It can be understood that this explanation is for a clearer understanding of the embodiments of the present application, and does not necessarily constitute a limitation on the embodiments of the present application.

[0034] Generative big models are an important concept in the field of artificial intelligence. They combine advanced technologies such as deep learning and natural language processing to generate realistic text, images, audio and other content. This model has a large number of parameters and can process large-scale data sets, thereby providing higher predictive power and accuracy. Generative big models are widely used in machine translation, intelligent dialogue, creative design and other fields. Exemplarily, the generative big model can be a generative pre-trained transformer model 4 (GPT-4). In this solution, the generative big model used is a trained generative big model.

[0035] Text semantic vector: The text can be sent to a text encoder to obtain a vector that can represent the semantic features of the text. The text encoder can use models such as Transformer commonly used in natural language processing (NLP), and this solution does not limit this. In this solution, the text can be: the field name of a field, the annotation information of a field, the table name, the annotation information of the table name, etc. The first semantic vector, the second semantic vector, the third semantic vector, and the fourth semantic vector below all belong to text semantic vectors. Exemplarily, the dimensions of the first semantic vector, the second semantic vector, the third semantic vector, and the fourth semantic vector can be the same.

[0036] Table structure information (Schema): refers to the organizational structure information of the database table in the database, including the table name, field name, etc.

[0037] An interactive interface is provided to users through a knowledge question-answering system based on a generative big model (hereinafter referred to as the big model). Users input user question text through the interactive interface, and the generative big model is used to convert the user question into an SQL statement. The database is queried based on the SQL statement to obtain the query results, which are then displayed to the user through the interactive interface.

[0038] Generally speaking, the knowledge question-answering system is aimed at ordinary users (that is, non-professional database technicians). Ordinary users use natural language, such as Chinese, when entering user question texts, and ordinary users have almost no understanding of the table structure information inside the database. In other words, ordinary users may not know which table the required data is located in or what the corresponding field name is. Therefore, the user may have errors when describing the query requirements, which will lead to low accuracy of the NL2SQL solution.

[0039] In addition, in the data warehouses of some industries (for example, tax databases), there are often a large number of database tables, and the names of database tables and fields are relatively arbitrary and poorly standardized. Especially in Chinese scenarios, although the table name and field name of the database table are still composed of strings, the string may have a complete word meaning (for example, the complete pinyin of a Chinese word), or it may be an acronym of a Chinese word, such as dsjid (big data ID), false invoice amount (xkje), and cargo name (hwmc) in the tax scenario. This will also lead to low accuracy of the NL2SQL solution.

[0040] In order to solve or partially solve the above technical problems, the embodiment of the present application provides a new NL2SQL solution. That is, through the large model information extraction technology and vector recall technology, the tables and fields in the database are screened, so as to screen out the database tables that match the user's query requirements from a large number of database tables, thereby improving the accuracy of data query and lowering the technical threshold for ordinary users to query the database. The technical concept of the technical solution provided by the embodiment of the present application is: the entire NL2SQL process is divided into two steps:

[0041] Step 1: By analyzing the user question text input by the user, locate the database table that needs to be queried from a large number of database tables.

[0042] Step 2: Based on the table structure information of the located database table, use the big model to convert the user question text into SQL statements.

[0043] In the technical solution provided in the embodiment of the present application, the table structure information of all tables in the database is not directly fed (i.e., input) to the large model, but before feeding to the large model, the database tables in the database are screened, and the table structure information of the screened database tables is fed to the large model. In this way, not only will it not be limited by the length of the input information of the large model, but it can also avoid the confusion of the large model caused by too many database tables. It can be seen that the technical solution provided in the embodiment of the present application can not only reduce the analysis pressure of the large model, but also help the large model find a suitable table from a large number of database tables, thereby effectively improving the conversion accuracy and query accuracy.

[0044] The following will be combined Figure 1 The data processing method provided in the embodiment of the present application is introduced in detail.

[0045] like Figure 1 As shown, the system architecture involved in the data processing method provided in the embodiment of the present application includes: a client 10 and a server 20.

[0046] Among them, the client 10 is the client program of the large model application installed on the terminal device. Terminal device: It can also be called a terminal. It can be a mobile terminal, a fixed terminal or a portable terminal, such as a mobile phone, a site, a unit, a device, a multimedia computer, a multimedia tablet, an Internet node, a communicator, a desktop computer, a laptop computer, a notebook computer, a netbook computer, a tablet computer, a personal communication system device, a personal navigation device, a personal digital assistant, an audio / video player, a digital camera / camcorder, a positioning device, a television receiver, a radio broadcast receiver, an e-book device, a game device or any combination thereof, including accessories, peripherals or any combination thereof of these devices. It is also foreseeable that the terminal device can support any type of interface device for the user (such as a wearable device), etc.

[0047] The server 20 is a server program of the large model application running on the server. Server: The server can be one or more servers. The server can also be a physical server or a virtual server, etc. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0048] The client 10 is used to send the user question text to the server 20 .

[0049] Optionally, the client 10 is further used to: provide a user interaction interface to the user; and receive a user question text input by the user in the user interaction interface.

[0050] The user question text is a natural language. Exemplarily, the user question text is a Chinese user question text.

[0051] Exemplarily, the user interaction interface is a conversational interface with the robot (or large model).

[0052] The server 20 is used to: receive the user question text sent by the client 10, extract the descriptive information related to the table structure information of the database table to be queried from the user question text; filter out the target database table matching the descriptive information from the database; input the table structure information of the target database table and the user question text into the generative big model, so that the generative big model converts the user question text into a structured query statement (hereinafter referred to as SQL statement); execute the structured query statement to obtain a database query result; and send the database query result to the client 10.

[0053] Optionally, the client 10 may also display the database query structure to the user.

[0054] As an option, the server 20 may send the database query result and the SQL statement to the client 10; the client 10 may display the database query result and the SQL statement to the user.

[0055] Optionally, after generating the SQL statement, the server does not execute the SQL statement, but sends the SQL statement to the client 10. In one embodiment, the client 10 may provide the SQL statement to the user so that the user can perform subsequent processing, such as database query.

[0056] like Figure 1 As shown, the data processing method provided in the embodiment of the present application includes the following steps:

[0057] 101. Receive a user question text input by a user.

[0058] The user question text is associated with a database query.

[0059] The client 10 may provide an interactive interface to the user; and receive a user question text input by the user through the interactive interface.

[0060] The user question text is in natural language. In the Chinese scenario, the user question text may be a Chinese user question text. For example, the user question text is "query all big data IDs, legal representative names, and tax payer ID numbers that satisfy the taxpayer identification number containing Zhang San or the tax payer ID number equal to 123".

[0061] 102. Send user question text.

[0062] The client 10 sends the user question text to the server 20 .

[0063] 103. Use the big model to extract information describing the fields to be queried, information describing the fields used as query conditions, and information describing the table name of the database table to be queried from the user's question text.

[0064] The information used to describe the fields to be queried and the information used to describe the fields used as query conditions can be collectively referred to as information used to describe the fields in the database table to be queried. The information used to describe the fields to be queried, the information used to describe the fields used as query conditions, and the information used to describe the table name of the database table to be queried all belong to the description information related to the table structure information of the database table to be queried.

[0065] Among them, the information used to describe the fields to be queried can be called query field information (select_fields); the information used to describe the fields used as query conditions can be called condition field information (condition_fields); and the information used to describe the table name of the database table to be queried can be called table information (table).

[0066] Among them, the field to be queried, that is, the field to be queried, is generally the main field of the query, following the "select" in the SQL statement, and can be one or more, that is, the extracted query field information can be one or more. The query condition refers to the information that limits the condition, including the field name and field value of the condition field (that is, the field used as the query condition). The query condition follows the "where" in the SQL statement. The number of fields used as conditions can be one or more, that is, the extracted condition field information can be one or more. If there is no condition limit in the user's question text, the extraction result of the supporting condition field information is empty.

[0067] Considering that when users describe their query requirements, they may not know in which table the information they want is located, if the user specifies the table information in the statement, it will be extracted. If it is not specified, it is also supported not to extract it temporarily, that is, the extraction result of the table information is supported to be empty.

[0068] Continuing with the above example, the user's question text is "Query all big data IDs, legal representative names, and tax payer ID numbers that satisfy the taxpayer identification number containing Zhang San or the tax payer ID number equal to 123"; the extraction result: {'condition_fields': ['Taxpayer identification number', 'Tax payer ID number'], 'select_fields':['big data ID', 'Legal representative name', 'Tax payer ID number'],'table': []"}. In other words, the extracted condition field information includes: taxpayer identification number and tax payer ID number; the extracted query field information includes big data ID, legal representative name, and tax payer ID number; the extraction result of the table information is empty.

[0069] Optionally, a first prompt word is generated based on the user question text; the first prompt word is used to describe the task, that is, to prompt the large model to extract information used to describe the fields to be queried, information used to describe the fields used as query conditions, and information used to describe the table name of the database table to be queried from the user question text.

[0070] In order to facilitate the reuse of prompt words, a prompt word template can be set. For example, the prompt word template can be "You are an information extraction expert. Please think step by step and extract the fields and table names that can be used to write SQL query statements based on the information provided by the user, and give the results in json format. It must contain condition_fields, select_fields, and table fields, and use # as a symbol before and after them. Please note that if the table name is not clearly given, table should be []; if the condition field information is not clearly given, condition_fields should be ['*']. The user input information is: ${}". Among them, ${} is a placeholder for filling in user input information.

[0071] Continuing with the above example, the user's question text is "Query all big data IDs, legal representative names, and tax payer ID numbers that satisfy the taxpayer identification number containing Zhang San or the tax payer ID number being 123", and the user input information is filled into the prompt word template to obtain the prompt word "You are an information extraction expert. Please think step by step and extract the fields and table names that can be used to write SQL query statements based on the information provided by the user, and give the results in json format. It must include condition_fields, select_fields, and table fields, and use # as symbols before and after them. Please note that if the table name is not explicitly given, table should be []; if the condition field information is not explicitly given, condition_fields should be ['*']. The user input information is: Query all big data IDs, legal representative names, and tax payer ID numbers that satisfy the taxpayer identification number containing Zhang San or the tax payer ID number being 123".

[0072] It can be seen that the prompt word template is used to construct the prompt word, which may include a fixed part and a placeholder for filling in user input information. Among them, the first prompt word template is used to describe the task type.

[0073] In order to improve the accuracy of information extraction from large models, the first prompt word may also include: information extraction samples. The information extraction samples include: user question text samples and information extraction results of user question text samples. For example, the user question text sample is "query for invoicing data that satisfies the company name of abc and the invoicing date of 2010"; its information extraction result is #{'condition_fields': ['Company name', 'Invoicing date'], 'select_fields': ['Invoicing data'], 'table': []”}#.

[0074] In this embodiment, feeding information extraction samples to the large model can provide a basis for the large model to extract information, thereby improving the extraction accuracy.

[0075] Optionally, the first prompt word template may include an information extraction sample, that is, the information extraction sample is a fixed part of the first prompt word template.

[0076] It should be noted that in actual applications, the user question text generally contains information for describing the fields to be queried, but does not necessarily contain information for describing the fields used as query conditions and information for describing the table names of the database tables to be queried. Therefore, in actual applications, the extraction results may show that: the extraction results for the information for describing the fields used as query conditions are empty; the extraction results for the information for describing the table names of the database tables to be queried are empty.

[0077] 104. Match in field vector library.

[0078] The field vector library stores the semantic vectors of the fields of multiple tables in the database. Optionally, the field vector library stores the semantic vectors of all fields of all tables in the database. Exemplarily, the semantic vector of the field is associated with the field name of the field and stored in the field vector library.

[0079] In some scenarios, the semantic vector of a field can be a semantic vector obtained by vectorizing the field name of the field. For example, when the field name consists of complete English words, the vector obtained by vectorizing the field name can be used as the semantic vector corresponding to the field.

[0080] In some scenarios, the semantic vector of a field can be a semantic vector obtained by vectorizing the annotation information of the field. For example, when the field name is an abbreviation of a Chinese word, the vector obtained by vectorizing the annotation information of the field can be used as the semantic vector of the field. For example, the field name of the field is "nsrsbh" and its annotation information is "taxpayer identification number".

[0081] It should be noted that when creating a database table in a database, the creating user will provide table structure information and comment information corresponding to the table structure information, for example, providing a DDL (Data Definition Language) statement. The DDL statement contains table structure information (Schema information) and comment information corresponding to the table structure information. The comment information is an explanation / description of the table structure information. The table structure information includes: table name and field name of the field. The comment information includes: comment information of the table name and comment information of the field (which can also be understood as comment information of the field name). In the Chinese scenario, the comment information can be Chinese comment information.

[0082] For example, the following DDL statement is shown:

[0083] Create table 'swzd'(

[0084] 'dsjid' string comment 'Big data unique code',

[0085] 'xkje' string comment 'false amount',

[0086] 'hwmc' string comment 'goods name', )

[0088] Commet 'tax bill'

[0089] In the DDL statement in the example, 'dsjid' is the field name of the field, and 'big data unique code' is the comment information of the field 'dsjid'; 'xkje' is the field name of the field, and 'false invoice amount' is the comment information of the field 'xkje'; 'hwmc' is the field name of the field, and 'goods name' is the comment information of the field 'hwmc'; 'swzd' is the table name, and 'tax bill' is the comment information of the table name 'swzd'.

[0090] Optionally, when the large model supports Chinese input by users on the front end, the annotation information of each field is Chinese annotation information.

[0091] The extracted information for describing the fields in the database table to be queried (i.e., the first information) is matched in the field vector library. The information for describing the fields in the database table to be queried includes: information for describing the fields to be queried and / or information for describing the fields used as query conditions. That is, the information for describing the fields in the database table to be queried may be one or more. Exemplarily, the first information may be one or more, and the first information is information for describing the fields to be queried or information for describing the fields used as query conditions.

[0092] Specifically, the information used to describe the fields in the database table to be queried can be vectorized to obtain a first vector to be matched (i.e., the first semantic vector mentioned above); the semantic vectors of each field in the database table in the database are obtained from the field vector library (i.e., the second semantic vector mentioned above); the similarity between the first vector to be matched and the semantic vector of the field is determined; and according to the similarity, the matching degree between the information used to describe the fields in the database table to be queried and the fields in the database table is determined. Note: The similarity in this article can specifically be cosine similarity.

[0093] 105. Match in table vector library.

[0094] The table vector library stores the semantic vectors of the table names of multiple tables in the database. Optionally, the table vector library stores the semantic vectors of the table names of all tables in the database. Exemplarily, the semantic vectors of the table names are associated with the table names and stored in the table vector library.

[0095] In some scenarios, the semantic vector of the table name can be a semantic vector obtained by vectorizing the table name. For example, when the table name is composed of complete English words, the vector obtained by vectorizing the table name can be used as the semantic vector corresponding to the table name.

[0096] In some scenarios, the semantic vector of a table name can be a semantic vector obtained by vectorizing the annotation information of the table name. For example, when the table name is an abbreviation of a Chinese word, the vector obtained by vectorizing the annotation information of the table name can be used as the semantic vector corresponding to the table name. For example, the table name is "nsr" and its annotation information is "taxpayer".

[0097] Optionally, when the large model supports Chinese input by users on the front end, the annotation information of each table name is Chinese annotation information.

[0098] The extracted information for describing the table name of the database table to be queried is matched in the table vector library.

[0099] Specifically, the information used to describe the table name of the database table to be queried can be vectorized to obtain a second vector to be matched (that is, the third semantic vector mentioned above); the semantic vector of the table name of the database table in the database is obtained from the table vector library (that is, the fourth semantic vector mentioned above); the similarity between the second vector to be matched and the semantic vector of the table name of the database table is determined; based on the similarity, the matching degree between the information used to describe the table name of the database table to be queried and the table name of the database table is determined.

[0100] 106. Comprehensively sort the table.

[0101] For any database table in the database, the degree of match between the information describing the field in the database table to be queried and the database table is determined according to the degree of match calculated in the above step 104 (i.e., the first degree of match mentioned above). Specifically, the highest degree of match between each of the multiple fields in the database table and the information describing the field in the database table to be queried is used as the degree of match between the information describing the field in the database table to be queried and the database table. For any database table in the database, the degree of match between the information describing the table name of the database table to be queried and the database table is determined according to the degree of match calculated in the above step 105. Specifically, the degree of match between the information describing the table name of the database table to be queried and the table name of the database table can be used as the degree of match between the information describing the table name of the database table to be queried and the database table.

[0102] The matching score of the database table is determined according to the matching degree between the information used to describe the fields in the database table to be queried and the database table and the matching degree between the information used to describe the table name of the database table to be queried and the database table; and the multiple database tables are sorted from high to low according to the matching scores of the database tables.

[0103] Exemplarily, when there are multiple pieces of information used to describe the fields in the database table to be queried, the sum of the matching degrees between the multiple pieces of information used to describe the fields in the database table to be queried and the database table is determined as the first score of the database table; the matching degree between the information used to describe the table name of the database table to be queried and the database table is used as the second score of the database table. The first score and the second score are summed or weighted to obtain the matching score of the database table. Exemplarily, the weight corresponding to the first score can be 0.3; the weight corresponding to the second score can be 0.7. The first score is related to the information input by the user to describe the fields in the database table to be queried, and the second score is related to the information input by the user to describe the table name. It can be considered that the importance of the second score is greater than the importance of the first score. Therefore, the weight corresponding to the second score can be set to be greater than the weight corresponding to the first score.

[0104] It should be noted that when no information describing the table name of the database table to be queried is extracted, the above step 105 does not need to be performed, and the above second score does not need to be considered when calculating the matching score of the database table in step 106. For example, the first score can be directly used as the matching score of the database table.

[0105] When no information describing the fields in the database table to be queried is extracted, the above step 104 does not need to be performed, and the above first score does not need to be considered when calculating the matching score of the database table in step 106. For example, the second score can be directly used as the matching score of the database table.

[0106] The following will be combined Figure 2 The following is an example of how to determine the matching score of a database table:

[0107] Assume that the information extracted to describe the fields in the database table to be queried includes: taxpayer ID, input amount, and output ratio. Among them, taxpayer ID (i.e., unique code) is the information used to describe the field used as the query condition, and input amount and output ratio are both information used to describe the fields to be queried. Note: In this example, no information is extracted to describe the table name of the database table to be queried.

[0108] The database includes: table a, table b, table c, table d...; table a includes fields a1, field a2, field a3...; table b includes fields b1, field b2, field b3...; table c includes fields c1, field c2, field c3...; table d includes fields d1, field d2, field d3...

[0109] By comparing the vectors one by one, the matching degree between the taxpayer ID and each field of each table in the database is determined, such as Figure 2 As shown in Table 1, for each database table, the maximum value of the matching degrees between multiple fields in the table and the taxpayer ID is used as the matching degree between the taxpayer ID and the database table.

[0110] Determine the matching degree of the input amount with each field of each table in the database, such as Figure 2 As shown in Table 2, for each database table, the maximum value of the matching degrees between multiple fields in the table and the input amount is used as the matching degree between the input amount and the database table.

[0111] Determine the matching degree between the sales item proportion and each field of each table in the database, such as Figure 2 As shown in Table 3, for each database table, the maximum value of the matching degrees between multiple fields in the table and the sales item ratio is used as the matching degree between the sales item ratio and the database table.

[0112] For each database table, the sum of the matching degree between the database table and the taxpayer ID, the matching degree between the database table and the input amount, and the matching degree between the database table and the output ratio is taken as the matching score of the database table.

[0113] Table a, table b, table c, table d, etc. in the database are sorted from high to low according to the matching scores, and the database table ranked first is selected, that is, table a.

[0114] 107. Get the table structure information of the TopN table.

[0115] The specific value of N can be set according to actual needs. In one embodiment, N can be set to 5. In another embodiment, N can be set to 1.

[0116] According to the sorting condition in 106 above, N database tables with the highest sorting can be determined; and the table structure information of these N database tables can be obtained.

[0117] In one achievable manner, annotation information of the table structure information of the N database tables may also be obtained.

[0118] It should be noted that in addition to sorting and filtering the above N database tables, database tables can also be filtered by setting a table score threshold. For example, database tables with scores greater than or equal to the table score threshold can be used as filtered database tables.

[0119] 108. Filter the fields in the table structure information to obtain filtered table structure information.

[0120] For any database table among the N database tables, according to the calculation result in the above step 104, the matching degree between each field in the database table and the information used to describe the field in the database table to be queried is obtained; according to the matching degree between each field in the database table and the information used to describe the field in the database table to be queried, the third score of each field in the database table is determined; the third score of each field is determined by the matching degree between the field and the information used to describe the field in the database table to be queried. Exemplarily, the third score of each field is the sum of the matching degree between at least one information used to describe the field in the database table to be queried and the field.

[0121] According to the third score of each field in the database table, multiple fields in the database table are sorted to determine the top M fields; the top M fields are retained in the table structure information of the database table, and the remaining fields are deleted to obtain the filtered table structure information of the database table.

[0122] It should be noted that in addition to sorting and filtering to obtain fields, you can also filter fields in the database table by setting a field score threshold. For example, you can use fields with scores greater than or equal to the field score threshold as the filtered fields.

[0123] In actual applications, since some tables have many fields and the annotation information of the fields is relatively lengthy, considering that this information will be added to the large model with the prompt word Prompt later, this lengthy information will challenge the input information length limit of the large model, and is not conducive to the large model selecting the correct field for output from many fields. In addition, general user problem business scenarios do not require all fields of a table. Therefore, it is necessary to streamline the fields of the filtered table according to the actual situation.

[0124] 109. Generate prompt words according to the filtered table structure information and the user question text.

[0125] For the convenience of distinction, the prompt word generated in step 109 may be referred to as a second prompt word. The second prompt word is used to prompt the large model to write an SQL statement according to the user's question text and the filtered table structure information.

[0126] Optionally, the second prompt word may be generated according to the filtered table structure information, the user question text, and the second prompt word template.

[0127] The second prompt word template is used to construct the second prompt word, which may include a fixed part and a placeholder for filling in user input information and a placeholder for filling in table structure information. The second prompt word template is used to describe the task type.

[0128] Exemplarily, the second prompt word template is "You are an SQL expert, good at writing SQL statements; known table structure information is: ${}"; please write SQL statements according to user input information and table structure information, and use # as marks before and after; user input information is: ${}".

[0129] Optionally, a prompt word is generated based on the filtered table structure information and its annotation information and the user question text. Exemplarily, a second prompt word is generated based on the filtered table structure information and its annotation information, the user question text and a second prompt word template. The second prompt word template includes placeholders for filling in the table structure information and the annotation information.

[0130] Exemplarily, the second prompt word is:

[0131] <system>: You are an SQL expert and are good at writing SQL statements.

[0132] The known table structure information and its annotation information are:

[0133] CREATE TABLE nsrxx_table (

[0134] `dsjid` STRING COMMENT 'Big data ID',

[0135] `nsrsbh` STRING COMMENT 'Taxpayer Identification Number',

[0136] `nsrmc` STRING COMMENT 'Taxpayer Name',

[0137] `fddbrxm` STRING COMMENT 'Legal representative's name',

[0138] `bsrxm` STRING COMMENT 'Tax payer name',

[0139] `bsrsfzjhm` STRING COMMENT 'Tax payer ID number',

[0140] `rfq` STRING COMMENT 'Daily partition' )

[0142] COMMENT 'Taxpayer Information Form';

[0143] Please write SQL statements based on user input information, table structure information and comment information, and use # as symbols before and after them.

[0144] The second prompt word only includes the table structure information of a database table. That is, the value of N in the step 107 is 1.

[0145] 110. Input the prompt word into the big model to obtain the SQL statement output by the big model.

[0146] The second prompt word is input into the large model, and the large model outputs an SQL statement based on the second prompt word. The SQL statement is used to query the database.

[0147] 111. Execute SQL statements to obtain database query results.

[0148] Execute SQL statements, that is, execute database queries, and obtain database query results.

[0149] 112. Return the database query results.

[0150] The server 20 returns the database query result to the client 10 that provides the user question text, and the client 10 displays it to the user through an interactive interface.

[0151] It should be noted that, in actual application, the above field vector library and table vector library may not be set. In the absence of field vector library and table vector library, the semantic vector of the field in the database and the semantic vector of the table name may be calculated in the manner described in the above embodiments during matching.

[0152] Through experiments, it was found that the technical solution provided in the embodiment of the present application has strong technical feasibility when applied in a database query scenario with more than 300 database tables.

[0153] Figure 3 Schematic diagram of the data processing method provided in the embodiment of the present application. The execution subject of the method may be the server 20 in the above embodiment. Figure 3 As shown, the method includes:

[0154] 301. Get the user question text.

[0155] 302. Extract description information related to the table structure information of the database table to be queried from the user question text.

[0156] 303. Filter out a target database table matching the description information from the database.

[0157] 304. Input the table structure information of the target database table and the user question text into the generative big model, so that the generative big model converts the user question text into a structured query statement.

[0158] In the above 301, the user question text is related to the database query. The user question text can be an English user text or a Chinese user text. In the tax scenario, the user question text can be a tax question text; and the database is a tax database.

[0159] In the above 302, the description information related to the table structure information of the database table to be queried may include but is not limited to: information for describing the fields to be queried, information for describing the fields used as query conditions, and information for describing the table name of the database table to be queried. In practical applications, the information to be extracted may be more or less, and the embodiments of the present application do not specifically limit this.

[0160] In one embodiment, description information related to the table structure information of the database table to be queried may be extracted from the user question text according to a preset extraction rule.

[0161] In another embodiment, information extraction can be accomplished with the aid of a generative large model. Optionally, the step of "extracting descriptive information related to the table structure information of the database table to be queried from the user question text" in 302 above can be accomplished by the following steps:

[0162] 3021. Generate a first prompt word according to the user question text.

[0163] 3022. Input the first prompt word into the generative big model so that the generative big model can extract descriptive information related to the table structure information of the database table to be queried from the user question text.

[0164] Among them, the first prompt word is used to prompt the generative large model to extract one or more of the information used to describe the field to be queried, the information used to describe the field used as the query condition, and the information used to describe the table name of the database table to be queried from the user question text.

[0165] In one embodiment, the step of "generating a first prompt word according to the user question text" in 3021 above includes: generating a first prompt word according to the user question text and an extracted sample. The extracted sample includes: a user question text sample and an extracted result thereof.

[0166] For the specific implementation process, please refer to the corresponding contents in the above embodiments, which will not be repeated here.

[0167] In the above 303, the target database table may be a database table whose table structure information matches the description information. Optionally, based on the matching between the description information and the table structure information of the database table in the database, the target database table matching the description information is screened out from the database.

[0168] When the description information includes information for describing fields in the database table to be queried (i.e., the first information) and does not include information for describing the table name of the database table to be queried (i.e., the second information), the matching situation between the description information and the table structure information of the database table in the database may include: the matching degree between the information for describing the fields in the database table to be queried and the table structure information of the database table in the database.

[0169] When the description information includes information for describing fields in a database table to be queried and information for describing a table name of the database table to be queried, the matching situation of the description information and the table structure information of the database table in the database may include: the matching degree of the information for describing the fields in the database table to be queried and the table structure information of the database table in the database, and the matching degree of the information for describing the table name of the database table to be queried and the table structure information of the database table in the database.

[0170] In the above 304, a second prompt word may be generated according to the table structure information of the target database table and the user question text; the second prompt word is input into the generative big model so that the generative big model converts the user question text into a structured query statement. The structured query statement is used to query the database.

[0171] The specific implementation of the above step 304 can refer to the corresponding content in the above embodiments, which will not be repeated here.

[0172] Optionally, the above method may further include:

[0173] 305. When the description information includes first information for describing a field in a database table to be queried, vectorize the first information to obtain a first semantic vector.

[0174] 306. Obtain a second semantic vector of a field of a database table in the database.

[0175] 307. Determine a first matching degree between the first information and the table structure information of the database table according to the similarity between the first semantic vector and the second semantic vector.

[0176] The matching condition between the description information and the table structure information of the database table in the database includes: the first matching degree.

[0177] The specific implementation of the above steps 305 to 307 can refer to the corresponding contents in the above embodiments, which will not be repeated here.

[0178] Optionally, the second semantic vector of the field is obtained by vectorizing annotation information of the field.

[0179] Optionally, the above method may further include:

[0180] 308. When the description information includes second information for describing a table name of a database table to be queried, vectorize the second information to obtain a third semantic vector.

[0181] 309. Obtain a fourth semantic vector of a table name of a database table in the database.

[0182] 310. Determine a second matching degree between the second information and the table structure information of the database table according to the similarity between the third semantic vector and the fourth semantic vector.

[0183] The matching condition between the description information and the table structure information of the database table in the database includes: the second matching degree.

[0184] The specific implementation of the above steps 308 to 310 can refer to the corresponding contents in the above embodiments, which will not be repeated here.

[0185] Optionally, the fourth semantic vector of the table name is obtained by vectorizing annotation information of the table name.

[0186] Optionally, the above step 303 of "selecting a target database table matching the description information from the database according to the matching between the description information and the table structure information of the database table in the database" can be implemented by the following steps:

[0187] 3031. When the description information includes first information for describing a field in the database table to be queried and does not include second information for describing a table name of the database table to be queried, select a target database table matching the description information from the database according to the first matching degree.

[0188] 3032. When the description information includes first information for describing a field in a database table to be queried and second information for describing a table name of the database table to be queried, weighted sum of the first matching degree and the second matching degree is performed to obtain a matching score of the database table in the database; according to the matching score, a target database table matching the description information is screened out from the database; the weight corresponding to the first matching degree is less than the weight of the second matching degree.

[0189] 3033. When the description information includes the second information but does not include the first information, based on the second match, filter out a target database table that matches the description information from the database.

[0190] The specific implementation methods of the above steps 3031, 3032 and 3033 can refer to the corresponding contents in the above embodiments, which will not be repeated here.

[0191] Optionally, the table structure information of the target database table includes: a table name and field names of multiple fields; the description information includes first information for describing the fields in the database table to be queried. Before inputting the table structure information of the target database table and the user question text into the generative large model, the method further includes:

[0192] 311. Obtain a matching degree between a field in the multiple fields and the first information.

[0193] 312. Filter the multiple fields according to the matching degree between the fields in the multiple fields and the first information to obtain filtered table structure information of the target database table.

[0194] After filtering multiple fields, the filtered fields are obtained; the filtered table structure information includes: table name and filtered fields.

[0195] The specific implementation of the above steps 311 and 312 can refer to the corresponding contents in the above embodiments, which will not be repeated here.

[0196] Optionally, the above method further includes:

[0197] 313. Execute the structured query statement to obtain a database query result.

[0198] 314. Send the database query result to the user.

[0199] It should be noted here that: for the contents of each step not fully described in detail in the method provided in the embodiment of the present application, please refer to the corresponding contents in the above embodiment, which will not be repeated here. In addition, in addition to the above steps, the method provided in the embodiment of the present application may also include other parts or all of the steps in the above embodiments, which can be specifically referred to the corresponding contents in the above embodiments, which will not be repeated here.

[0200] It should be noted that the technical solution provided in the embodiment of the present application can be applied not only in tax scenarios, but also in various scenarios such as e-commerce, medical care, and education affairs, and the embodiment of the present application does not specifically limit this. Among them, the tax scenario can specifically be a tax risk control scenario.

[0201] Figure 4 FIG. 1 is a schematic diagram showing the structure of an electronic device provided by an embodiment of the present application. Figure 4 As shown, the electronic device includes a memory 1101 and a processor 1102. The memory 1101 can be configured to store various other data to support operations on the electronic device. Examples of these data include instructions for any application or method for operating on the electronic device. The memory 1101 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read only memory (EEPROM), an erasable programmable read only memory (EPROM), a programmable read only memory (PROM), a read only memory (ROM), a magnetic memory, a flash memory, a magnetic disk or an optical disk.

[0202] The memory 1101 is used to store programs;

[0203] The processor 1102 is coupled to the memory 1101 and is used to execute the program stored in the memory 1101 to implement the methods provided by the above-mentioned method embodiments.

[0204] Further, if Figure 4 As shown, the electronic device also includes: a communication component 1103, a display 1104, a power component 1105, an audio component 1106 and other components. Figure 4 Only some components are shown schematically, which does not mean that the electronic device only includes Figure 4 Components shown.

[0205] Accordingly, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a computer, the steps or functions of the methods provided in the above-mentioned method embodiments can be implemented.

[0206] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, can implement the steps or functions of the methods provided in the above-mentioned method embodiments.

[0207] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0208] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM (Read Only Memory) / RAM (Random Access Memory), a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0209] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.< / system>

Claims

1. A data processing method, It is characterized in that include: Get the user question text related to the database query; Extracting descriptive information related to the table structure information of the database table to be queried from the user question text; When the description information includes first information, vectorizing the first information to obtain a first semantic vector; the first information includes information for describing the field to be queried and / or information for describing the field as a query condition; Acquire a second semantic vector of a field of a database table in a database; the second semantic vector of the field is obtained by vectorizing annotation information of the field; Determining a first matching degree between the first information and the table structure information of the database table according to the similarity between the first semantic vector and the second semantic vector; According to the matching condition between the description information and the annotation information corresponding to the table structure information of the database table in the database, a target database table matching the description information is screened out from the database; wherein the matching condition is determined according to the similarity between the semantic vector of the description information and the semantic vector of the annotation information corresponding to the table structure information of the database table in the database; the annotation information is an explanation or description of the table structure information; the database includes a database table whose table name or field name is an acronym of a Chinese word; the matching condition includes the first matching degree; The table structure information of the target database table and the user question text are input into a generative big model, so that the generative big model converts the user question text into a structured query statement; the structured query statement is used to query the database.

2. The method according to claim 1, It is characterized in that Extracting descriptive information related to the table structure information of the database table to be queried from the user question text, including: Generate a first prompt word according to the user question text; The first prompt word is input into the generative big model, so that the generative big model can extract the descriptive information related to the table structure information of the database table to be queried from the user question text.

3. The method according to claim 2, It is characterized in that The first prompt word is used to prompt the generative large model to extract information used to describe the field to be queried, information used to describe the field used as the query condition, and information used to describe the table name of the database table to be queried from the user question text.

4. The method according to claim 2, It is characterized in that Generating a first prompt word according to the user question text includes: Generate a first prompt word according to the user question text and the extracted sample; The extraction samples include: user question text samples and extraction results thereof.

5. The method according to claim 1, It is characterized in that Also includes: When the description information includes second information, vectorizing the second information to obtain a third semantic vector; the second information is information used to describe the table name of the database table to be queried; Obtaining a fourth semantic vector of a table name of a database table in the database; Determining a second matching degree between the second information and the table structure information of the database table according to the similarity between the third semantic vector and the fourth semantic vector; The matching condition between the description information and the table structure information of the database table in the database includes: the second matching degree; and the fourth semantic vector of the table name is obtained by vectorizing the annotation information of the table name.

6. The method according to claim 5, It is characterized in that According to the matching condition between the description information and the table structure information of the database table in the database, a target database table matching the description information is screened out from the database, including: When the description information includes the first information but does not include the second information, screening out a target database table matching the description information from the database according to the first matching degree; When the description information includes the second information but does not include the first information, according to the second match, a target database table matching the description information is screened out from the database; When the description information includes the first information and the second information, a weighted sum is performed on the first matching degree and the second matching degree to obtain a matching score of a database table in the database; according to the matching score, a target database table matching the description information is screened out from the database; and the weight corresponding to the first matching degree is less than the weight of the second matching degree.

7. The method according to claim 1, It is characterized in that The table structure information of the target database table includes: a table name and field names of multiple fields; the description information includes first information; the first information includes information for describing the field to be queried and / or information for describing the field as a query condition; Before inputting the table structure information of the target database table and the user question text into the generative large model, the method further includes: Obtaining a matching degree between a field in the plurality of fields and the first information; According to the matching degree between a field in the plurality of fields and the first information, the plurality of fields are screened to obtain screened table structure information of the target database table.

8. The method according to claim 1, It is characterized in that Also includes: Execute the structured query statement to obtain a database query result; The database query result is sent to the client that provides the user question text.

9. A data processing method, It is characterized in that include: Obtaining tax question text related to tax database queries; Extracting descriptive information related to the table structure information of the database table to be queried from the tax question text; When the description information includes first information, vectorizing the first information to obtain a first semantic vector; the first information includes information for describing the field to be queried and / or information for describing the field as a query condition; Acquire a second semantic vector of a field of a database table in a tax database; the second semantic vector of the field is obtained by vectorizing annotation information of the field; Determining a first matching degree between the first information and the table structure information of the database table according to the similarity between the first semantic vector and the second semantic vector; According to the matching condition between the description information and the table structure information of the database table in the tax database, a target database table matching the description information is screened out from the tax database; wherein the matching condition is determined according to the similarity between the semantic vector of the description information and the semantic vector of the annotation information corresponding to the table structure information of the database table in the database; the annotation information is an explanation or description of the table structure information; the database includes a database table whose table name or field name is an acronym of a Chinese word; the matching condition includes the first matching degree; The table structure information of the target database table and the tax problem text are input into a generative big model, so that the generative big model converts the tax problem text into a structured query statement; the structured query statement is used to query the tax database.

10. A data processing system, It is characterized in that include: Client and server; among them, The client is used to send user question text related to database query to the server; The server is used to receive the user question text; extract descriptive information related to the table structure information of the database table to be queried from the user question text; when the descriptive information includes first information, vectorize the first information to obtain a first semantic vector; the first information includes information used to describe the field to be queried and / or information used to describe the field as a query condition; obtain a second semantic vector of the field of the database table in the database; the second semantic vector of the field is obtained by vectorizing the annotation information of the field; according to the similarity between the first semantic vector and the second semantic vector, determine the first matching degree between the first information and the table structure information of the database table; according to the matching situation between the descriptive information and the table structure information of the database table in the database, ... Filter out a target database table that matches the description information; wherein the matching situation is determined based on the similarity between the semantic vector of the description information and the semantic vector of the annotation information corresponding to the table structure information of the database table in the database; the annotation information is an explanation or description of the table structure information; the database includes database tables whose table names or field names are acronyms of Chinese words; the matching situation includes the first matching degree; input the table structure information of the target database table and the user question text into a generative big model, so that the generative big model converts the user question text into a structured query statement; execute the structured query statement to obtain a database query result; send the database query result to the client; the structured query statement is used to query the database.

11. An electronic device, It is characterized in that include: A memory and a processor, wherein The memory is used to store programs; The processor is coupled to the memory, and is configured to execute the program stored in the memory to implement the method according to any one of claims 1 to 9.

12. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by a computer, the method according to any one of claims 1 to 9 can be implemented.

13. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.