Data query method and device, readable medium, electronic equipment and program product
通过机器学习模型在第一数据库中查找目标数据表信息并生成结构化查询语言语句,解决了现有技术中需要先查找数据表再查询的问题,实现了自然语言查询的自动化和高效数据查找。
Patent Information
- Application Number
- CN202411206280.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2024-11-15
AI Technical Summary
In business scenarios, the existing technology needs to first look up the data table where the target data is located, and then query it in the data table, which increases the complexity and difficulty of data query and affects efficiency.
Through the machine learning model, the target data table information is searched in the first database based on the natural language statements entered by the user, and a structured query language statement is generated for querying, simplifying the data search process and improving efficiency.
Automatic data search based on natural language is realized, reducing the difficulty and complexity of data query and improving data search efficiency.
Smart Images

Figure CN118964390A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular, to a data query method, device, readable medium, electronic device, and program product. Background Art
[0002] With the advent of the big data era, more and more data are being generated in business scenarios. In order to find the target data in a business scenario, it is generally necessary to first find the target data table where the target data is located, and then query the target data in the target data table. Summary of the invention
[0003] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0004] In a first aspect, the present disclosure provides a data query method, comprising: Obtain a target sentence input by a user in a natural language; A machine learning model is used to query the target statement in a first database to obtain target data table information, and a structured query language statement is generated for performing data query in a second database according to the target statement and the target data table information, wherein the first database is used to store metadata of a data table, and the second database stores a target data table associated with the target data table information; Execute the structured query language statement to obtain data query results; The data query result is displayed to the user.
[0005] In a second aspect, the present disclosure provides a data query device, comprising: An acquisition module, used for acquiring a target sentence input by a user in a natural language; A first processing module is used to query the first database according to the target statement through a machine learning model to obtain target data table information, and generate a structured query language statement for data query in a second database according to the target statement and the target data table information, wherein the first database is used to store metadata of a data table, and the second database stores a target data table associated with the target data table information; A second processing module is used to execute the structured query language statement to obtain a data query result; The display module is used to display the data query result to the user.
[0006] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of any one of the methods described in the first aspect.
[0007] In a fourth aspect, the present disclosure provides an electronic device, including: a storage device having a computer program stored thereon; A processing device is used to execute the computer program in the storage device to implement the steps of any one of the methods in the first aspect.
[0008] In a fifth aspect, the present disclosure provides a computer program product, comprising a computer program, which implements the steps of any one of the methods described in the first aspect when executed by a processor.
[0009] Through the above technical solution, the target data table can be searched in the first database based on the target statement input by the user through the machine learning model to obtain the target data table information, and then the structured query language statement for data query on the target data table in the second database is generated based on the target statement and the target data table information through the machine learning model, and finally the data query result is obtained and displayed to the user by executing the structured query language statement. Thus, the data can be automatically searched based on the target statement input by the user through the machine learning model, thereby simplifying the data search process and improving the data search efficiency. In addition, when performing data query based on this solution, the user can use natural language as the query statement without the need to pre-generate or query the structured query language statement used to query the data, thereby reducing the difficulty and complexity of data query and further improving the data search efficiency.
[0010] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings: Figure 1 is a flow chart of a data query method according to an exemplary embodiment of the present disclosure; Figure 2 is a flowchart of building a first database according to an exemplary embodiment of the present disclosure; Figure 3 is a schematic diagram showing a display of a data query result according to an exemplary embodiment of the present disclosure; Figure 4is a flow chart of another data query method according to an exemplary embodiment of the present disclosure; Figure 5 is a block diagram of a data query device according to an exemplary embodiment of the present disclosure; Figure 6 It is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0012] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0013] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0014] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0015] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0016] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0017] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0018] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0019] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0020] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0021] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0022] At the same time, it is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0023] As mentioned in the background art, in order to find the target data in a business scenario, it is generally necessary to first find the target data table where the target data is located, and then query the target data in the target data table.
[0024] For example, in an e-commerce business scenario, in order to understand the sales volume of a certain product, it is generally necessary to first determine the target query field, and then enter the target query field, such as product name and sales volume, on the data query page of the e-commerce data management platform. Afterwards, the backend of the e-commerce data management platform performs field matching in the database based on the input product name and sales volume, thereby finding the target data table containing the product name and sales volume. Afterwards, a structured query statement for querying data in the target data table is entered on the data query page to perform data query. This increases the complexity of the data query process and affects the efficiency of data query.
[0025] In view of this, the present disclosure provides a data query method, device, readable medium, electronic device and program product to solve the above technical problems.
[0026] The embodiments of the present disclosure are further explained below with reference to the accompanying drawings.
[0027] Figure 1 is a flowchart of a data query method according to an exemplary embodiment of the present disclosure, referring to Figure 1 , the method may include the following steps: S101: Obtain a target sentence input by a user in a natural language.
[0028] For example, a search box may be displayed on the data search page of the data management platform, and when the user performs an input operation in the search box, the target sentence input by the user in natural language is obtained. Alternatively, a smart object may be displayed on the data search page of the data management platform, and by clicking the smart object, a smart object page is displayed on the data search page, and when the user performs an input operation on the smart object page, the target sentence input by the user in natural language is obtained.
[0029] S102: Query the first database according to the target statement through the machine learning model to obtain target data table information, and generate a structured query language statement for data query in the second database according to the target statement and the target data table information, wherein the first database is used to store metadata of the data table, and the second database stores the target data table associated with the target data table information.
[0030] In this embodiment, the metadata of the data table stored in the first database can be determined according to actual conditions, and the present disclosure embodiment does not impose any restrictions on this. For example, in order to search for data from different dimensions, the metadata may include at least one of a data indicator, a data dimension, an enumeration value of a data dimension, and a data tag of the data table.
[0031] In this embodiment, the metadata may be stored in the first database in the form of natural language, or may be stored in the first database in the form of embedded vectors, and the embodiment of the present disclosure does not impose any limitation on this.
[0032] When the metadata is stored in the first database in the form of natural language, the first database can be obtained in the following manner: The original fields of each data stream and the fields contained in each data table in the business scenario are obtained, and then the corresponding relationship between the original fields of each data stream and the fields contained in each data table is established to obtain the database. For example, in the field of e-commerce, the fields of the original data stream such as click-through rate, number of visits, and visit duration can be automatically obtained, as well as the fields that need to be stored in each data table, such as data dimension fields, data indicator fields, data table labels, and each enumeration value field under the data dimension. Then, by establishing the corresponding relationship between the original fields of each data stream and the fields contained in each data table, the database is obtained.
[0033] Accordingly, after obtaining the target sentence input by the user in natural language, the target sentence can be input into the pre-trained machine learning model, and the target sentence can be identified by the machine learning model. After obtaining the user's intention, keywords are extracted from the target sentence based on the user's intention to obtain the key fields of the target sentence. After that, metadata matching is performed in the database based on the semantics of the key fields. After matching the target metadata, the target data table information is obtained by obtaining the relevant information of the data table corresponding to the target metadata, such as the table name, storage location, data range, field information, browsing information within a preset time range (such as browsing volume, browsing time or browsing user, etc.). After obtaining the target data table information, the identification information of the target data table can be determined, and the query question of the target sentence can be determined by the method of intent recognition. After that, the target prompt word is generated based on the query question and the identification information of the target data table, and the target prompt word is input into the pre-trained machine learning model, so as to obtain a structured query language statement for data query in the second database.
[0034] When the metadata is stored in the first database in the form of an embedded vector, the first database can be obtained in the following manner: like Figure 2 As shown, the original fields of each data stream in the business scenario and the fields contained in each data table are obtained, and then the fields contained in the data table are extracted and vectorized to obtain the corresponding embedding vectors, and then the corresponding relationship between the original fields of each data stream and the embedded vectors is established to obtain the database. For example, in the field of e-commerce, the fields of the original data stream such as click-through rate, visit volume and visit duration, as well as the fields required to be stored in each data table, such as data dimension fields, data indicator fields, data table labels, and each enumeration value field under the data dimension, can be automatically obtained. Then, the data dimension fields, data indicator fields, data table labels, and each enumeration value field under the data dimension are vectorized through the vectorization model to obtain the corresponding embedding vectors, and finally the corresponding relationship between the original fields such as data streams and the embedded vectors is established to obtain the database.
[0035] Accordingly, after obtaining the target sentence input by the user, the target sentence can be input into a pre-trained machine learning model, and the target sentence can be identified through the machine learning model. After obtaining the user's intent, keywords can be extracted from the target sentence based on the user's intent to obtain the key fields of the target sentence. After that, the target embedding vector of the key field can be determined, and the embedding vector can be matched in the database based on the semantics of the target embedding vector. After matching the embedding vector, the target data table information can be obtained by obtaining the relevant information of the data table corresponding to the embedding vector. After obtaining the target data table information, the identification information of the target data table can be determined, and the query question of the target sentence can be determined by the method of intent recognition. After that, the target prompt word is generated based on the query question and the identification information of the target data table, and the target prompt word is input into the pre-trained machine learning model to obtain a structured query language statement for data query in the second database.
[0036] Among them, the machine learning model for obtaining the target data table information by querying in the first database according to the target statement and the machine learning model for generating the structured query language statement for data query in the second database according to the target statement and the target data table information can be the same machine learning model or different machine learning models, and the embodiments of the present disclosure do not impose any restrictions on this.
[0037] In order to simplify the model structure of the machine learning model and improve the efficiency of the machine learning model in processing input data, in a possible manner, different machine learning models can be used to generate machine learning models and structured query language statements of target data table information. That is, the machine learning model is used to query the first database according to the target statement to obtain the target data table information, and the structured query language statement for data query in the second database is generated according to the target statement and the target data table information, which may include: A first machine learning model is used to query the first database according to the target statement to obtain target data table information; a second machine learning model is used to generate a structured query language statement for data query in the second database according to the target statement and the target data table information.
[0038] Among them, the first machine learning model can be an existing machine learning model in the relevant technology, or it can be a machine learning model that is improved from the existing machine learning model in the relevant technology. The embodiments of the present disclosure do not impose any restrictions on this. For example, the first machine learning model can be a Transforme model in the relevant technology, and thus, the Transforme model can be trained by constructing training samples, so that the Transforme model can accurately extract key fields in the target sentence.
[0039] For example, a sample sentence annotated with a label and used to query data can be obtained, where the label is used to indicate the real key field of the sample sentence, the sample sentence is input into the Transforme model to obtain the predicted key field, the loss function value of the real key field and the predicted key field is calculated, and the parameter value of the Transforme model is adjusted based on the loss function value until the Transforme model converges.
[0040] Among them, the second machine learning model can be an existing machine learning model in the relevant technology, or it can be a machine learning model that is improved from the existing machine learning model in the relevant technology. The embodiments of the present disclosure do not impose any restrictions on this. For example, the second machine learning model can be a large language model (LLM) in the relevant technology. Therefore, the LLM model can be trained by constructing training samples, so that the LLM model can output a structured query language statement according to the input prompt word.
[0041] For example, a sample prompt word annotated with a label can be obtained, where the label is used to indicate the actual structured query language statement corresponding to the sample prompt word, the sample prompt word is input into the LLM model to obtain a predicted structured query language statement, the loss function value of the actual structured query language statement and the predicted structured query language statement is calculated, and the parameter value of the LLM model is adjusted based on the loss function value until the LLM model converges.
[0042] Among them, the target embedding vector for determining the key field and the first machine learning model for extracting the key field of the target sentence may be the same machine learning model or may not be the same machine learning model, and the embodiments of the present disclosure do not impose any restrictions on this. When the target embedding vector for determining the key field and the first machine learning model for extracting the key field of the target sentence are not the same machine learning model, the machine learning model for determining the target embedding vector for the key field may be a pre-trained vectorization model.
[0043] S103: Execute the structured query language statement to obtain data query results.
[0044] S104: Displaying the data query result to the user.
[0045] Through the above technical solution, the target data table can be searched in the first database based on the target statement input by the user through the first machine learning model to obtain the target data table information, and then the structured query language statement for data query on the target data table in the second database can be generated based on the target statement and the target data table information through the second machine learning model. Finally, the data query result is obtained and displayed to the user by executing the structured query language statement. In this way, the machine learning model can be used to automatically search for data based on the target statement input by the user, thereby simplifying the data search process and improving the data search efficiency. In addition, when performing data query based on this solution, the user can use natural language as the query statement without the need to pre-generate a structured query language statement for querying data, thereby reducing the difficulty and complexity of data query and further improving the data search efficiency.
[0046] To facilitate understanding of the present solution, possible implementation methods in the present disclosure are described below.
[0047] In a possible manner, querying the first database according to the target sentence through the machine learning model to obtain the target data table may include: Extract key fields of the target sentence through a machine learning model; perform semantic recall in the first database at least based on the key fields to obtain first data table information, wherein the semantic recall is used to query data tables in the first database whose semantic similarity between metadata and key fields is greater than a preset threshold; perform matching retrieval in the first database at least based on the key fields to obtain second data table information, wherein the matching retrieval is used to retrieve data tables in the first database whose metadata and key fields are identical; accordingly, the target data table information includes first data table information and second data table information.
[0048] In this embodiment, the data table information (ie, the first data table information and the second data table information) may be identification information of the data table, or may be related information of the data table, and the embodiment of the present disclosure does not impose any limitation on this.
[0049] When the data table information is the identification information of the data table (such as the table name or the data table number of the data table), the correspondence between the data table identifier and the embedding vector can be pre-stored in the first database. Therefore, after determining the key field, the target embedding vector of the key field can be determined, and semantic recall and matching retrieval are performed in the first database based on the target embedding vector to obtain a first embedding vector whose similarity between the embedding vector in the first database and the target embedding vector is greater than a preset threshold, and a second embedding vector whose embedding vector in the first database is the same as the target embedding vector. Then, based on the correspondence between the data table identifier and the embedding vector in the first database, the first data table identifier corresponding to the first embedding vector and the second data table identifier corresponding to the second embedding vector are determined. Finally, by obtaining relevant information of the data tables corresponding to the first data table identifier and the second data table identifier, the target data table information including the first data table information and the second data table information is obtained.
[0050] When the data table information is relevant information of the data table, the first database may also pre-store the correspondence between the data table and the embedding vector. Thus, after determining the key field, the target embedding vector of the key field may be determined, and semantic recall and matching retrieval may be performed in the first database based on the target embedding vector to obtain a first embedding vector whose similarity between the embedding vector in the first database and the target embedding vector is greater than a preset threshold, and a second embedding vector whose embedding vector in the first database is the same as the target embedding vector. Then, based on the correspondence between the embedding vector and the data table in the first database, the first data table corresponding to the first embedding vector and the second data table corresponding to the second embedding vector are determined. Finally, the target data table information is obtained by obtaining relevant information of the first data table and the second data table.
[0051] For example, after extracting the key fields of the target sentence through the first machine learning model, the key fields can be input into the pre-trained vectorization model to obtain the corresponding target embedding vector. After that, the similarity between the target embedding vector and each embedding vector in the first database can be calculated by calculating the cosine similarity. After obtaining the similarity between the target embedding vector and each embedding vector in the first database, on the one hand, according to the similarity between the target embedding vector and each embedding vector in the first database and the preset threshold, the first embedding vector with a similarity greater than the preset threshold can be determined, and then the data table identifier corresponding to the first embedding vector is determined as the first data table identifier. On the other hand, a second embedding vector with a similarity of 100% with the target embedding vector can be screened out from the first database, and the data table identifier corresponding to the second embedding vector is determined as the second data table identifier. After obtaining the first data table identifier and the second data table identifier, the target data table information including the first data table information and the second data table information is obtained by obtaining the relevant information of the data tables corresponding to the first data table identifier and the second data table identifier.
[0052] Through the above method, after determining the key field, the data table can be searched in the first database based on the semantic recall and matching retrieval methods. Since the semantic recall is used to query the data table in the database where the similarity between the metadata and the key field is greater than the preset threshold, the data table where the field semantically similar to the key field is located can be found, thereby increasing the breadth of the recall. Matching retrieval is used to retrieve the data table in the database where the metadata is the same as the key field, thereby quickly locating the data table where the key field is located, thereby achieving more accurate and more efficient data retrieval.
[0053] It should be understood that the method of searching in the first database according to the key field in this embodiment is only for illustrative purposes and does not constitute a limitation on the solution. In a possible manner, after determining the key field, matching retrieval can be performed in the database only according to the key field. Alternatively, semantic recall can be performed in the database only according to the key field, thereby improving the search efficiency of the data table.
[0054] Possible approaches may also include: Determining an expansion word having the same semantics as the key field in a preset word library, wherein the preset word library is used to store a plurality of preset words; Accordingly, performing semantic recall in the first database at least according to the key field may include: According to the key field and the expansion word, semantic recall is performed in the first database, wherein the semantic recall is used to query the data table in the first database whose semantic similarity between the metadata and the key field or the expansion word is greater than a preset threshold; Accordingly, performing a matching search in the first database at least according to the key field may include: According to the key field and the extended word, a matching search is performed in the first database, wherein the matching search is used to search for data tables in the first database whose metadata are the same as the key field or the extended word.
[0055] For example, if the key field is "consumption", the expansion word with the same semantics as "consumption" determined in the preset word library is "cost", so semantic recall can be performed in the first database based on the semantics of "consumption" and "cost". If the metadata recalled in the first database based on the semantics of "consumption" is metadata A, and the metadata recalled in the first database based on the semantics of "cost" is metadata B, then the relevant information of the data table corresponding to metadata A and the relevant information of the data table corresponding to metadata B can be obtained, thereby obtaining the target data table information.
[0056] For example, the key field is "consumption", and the expansion word with the same semantics as "consumption" determined in the preset word library is "cost", so that the metadata matching search can be performed in the database based on the semantics of "consumption" and "cost". If the metadata matched in the first database based on the semantics of "consumption" is metadata C, and the metadata matched in the first database based on the semantics of "cost" is metadata D, then the relevant information of the data table corresponding to metadata C and the relevant information of the data table corresponding to metadata D can be obtained, thereby obtaining the target data table information.
[0057] For example, the key field is "consumption", and the expansion word with the same semantics as "consumption" determined in the preset vocabulary is "cost". Therefore, matching retrieval and semantic recall can be performed in the database based on the semantics of "consumption" and "cost". If the metadata recalled in the first database based on the semantics of "consumption" is metadata A, the metadata recalled in the first database based on the semantics of "cost" is metadata B, the metadata matched in the first database based on the semantics of "consumption" is metadata C, and the metadata matched in the first database based on the semantics of "cost" is metadata D, then the relevant information of the data table corresponding to metadata A, the relevant information of the data table corresponding to metadata B, the relevant information of the data table corresponding to metadata C, and the relevant information of the data table corresponding to metadata D can be obtained, thereby obtaining the target data table information.
[0058] By the above method, the extended word with the same semantics as the key field can be obtained, so as to search in the first database based on the key field and the extended word. Since the semantics of the extended word is the same as that of the key field, the relevance and accuracy of the search result can be improved.
[0059] In a possible manner, querying the first database according to the target statement through the machine learning model to obtain the target data table information may include: The key fields of the target sentence are extracted through a machine learning model, and based on the key fields, queries are performed in the first database according to different query dimensions to obtain multiple candidate data table information, wherein the query dimensions include queries on data indicators and / or data dimensions, queries on enumeration values, and queries on data labels; according to the matching degree between the candidate data table associated with the candidate data table information and the key fields, a preset number of target data tables are selected from the multiple candidate data tables, and the matching degree is at least determined by the number of metadata matched by the key fields in the candidate data table.
[0060] In this embodiment, data indicators, data dimensions, enumeration values, and data labels can be determined according to actual conditions, and the embodiments of the present disclosure do not impose any restrictions on this. For example, in the field of e-commerce, data indicators can be sales volume, visits, or clicks. Data dimensions can be product categories, sales regions, or sales time. Enumeration values can be categories of goods, such as electronic products, beauty products, or home furnishings. Data labels can be categories of data tables, such as data tables for electronic products or data tables for beauty products.
[0061] In this embodiment, according to the matching degree between the candidate data table associated with the candidate data table information and the key field, selecting a preset number of target data table information from multiple candidate data tables may be: presetting a matching degree threshold, and determining the candidate data tables with matching degrees greater than the matching degree threshold as the target data table information. Alternatively, the number of target data tables may be pre-determined, and after obtaining the matching degree between each candidate data table and the key field, a preset number of candidate data tables may be selected as the target data tables according to the matching degree. Of course, other methods may also be used, and the disclosed embodiment does not impose any limitation on this.
[0062] In a possible manner, selecting a preset number of target data table information from multiple candidate data tables according to the matching degree between the candidate data table associated with the candidate data table information and the key field may include: For each candidate data table information, determine the target metadata matched by the keyword in the candidate data table associated with the candidate data table information, and determine the query dimension corresponding to each target metadata. According to the preset weight value corresponding to each query dimension, perform weighted summation on the number of target metadata matched under different query dimensions to obtain the matching value between the candidate data table and the key field; according to the matching value, select a preset number of data tables from multiple candidate data tables as target data tables.
[0063] In this embodiment, according to the matching value, selecting a preset number of data tables from multiple candidate data tables as target data tables may be: predetermining the number of target data tables, and after obtaining the matching value between each candidate data table and the key field, selecting the preset number of candidate data tables as target data tables according to the size of the matching value. Alternatively, a matching threshold may be pre-set, and after obtaining the matching value between each candidate data table and the key field, determining the candidate data table corresponding to the matching value greater than the matching threshold as the target data table.
[0064] Among them, the matching threshold, preset number and preset weight value can be determined according to actual conditions, and the embodiments of the present disclosure do not impose any restrictions on this.
[0065] For example, the matching threshold can be set to 2, and the query dimension can include a data indicator dimension, a data label dimension, and an enumeration value dimension, wherein the preset weight value of the data indicator dimension is 0.8, the preset weight value of the data label dimension is 0.5, and the preset weight value of the enumeration value dimension is 0.5. If the candidate data table includes candidate data table A and candidate data table B, if the target metadata matched by the keyword in candidate data table A includes: metadata under 2 data indicator dimensions and metadata under 1 data label dimension, then the matching value between candidate data table A and the key field is: 2×0.8+0.5=2.1. If the target metadata matched by the keyword in candidate data table B includes: metadata under 1 data indicator dimension, metadata under 1 data label dimension, and metadata under 1 enumeration value dimension, then the matching value between candidate data table A and the key field is: 0.8+0.5+0.5=1.8. Therefore, candidate data table A can be determined as the target data table.
[0066] It should be understood that, in this embodiment, determining the matching value between the candidate data table and the key field, and selecting a preset number of data tables from multiple candidate data tables as target data tables based on the matching value is only for illustrative purposes and does not constitute a limitation on the solution. In a possible manner, for each candidate data table, the number of metadata matched by the key field in the candidate data table can be determined, and then a preset number of data tables can be selected from multiple candidate data tables as target data tables based on the number of metadata matched by the key field in each candidate data table.
[0067] For example, the preset number is set to 2, and the candidate data tables include candidate data table A, candidate data table B, and candidate data table C. The number of metadata matched by key fields in candidate data table A is 6, the number of metadata matched by key fields in candidate data table B is 4, and the number of metadata matched by key fields in candidate data table C is 5. Therefore, candidate data table A and candidate data table C can be determined as target data tables.
[0068] Through the above method, the data table can be searched in the first database from different search dimensions according to the key field, and the target data table can be determined according to the matching value between the found data table and the key field. The matching value between the data table and the key field can be analyzed from multiple dimensions, further improving the search accuracy of the data table.
[0069] After obtaining the target data table information through any of the above methods, a structured query language statement for performing data query in the second database can be generated through a machine learning model based on the target statement and the target data table information.
[0070] In a possible manner, generating a structured query language statement for performing data query in the second database according to the target statement and the target data table information by a machine learning model may include: Based on the target statement, a query question is determined, and identification information of a target data table is determined; based on the query question, identification information and a preset prompt word template, a target prompt word is generated, and the target prompt word is used to instruct the machine learning model to generate a structured query language statement based on the query question and identification information; the target prompt word is input into the machine learning model to obtain a structured query language statement for performing data query in a second database, wherein the machine learning model is at least used to output a structured query language statement according to the input prompt word.
[0071] In this embodiment, based on the target sentence, determining the query question may be through intent recognition or keyword extraction, or other methods, which are not limited in any way in the disclosed embodiment.
[0072] In this embodiment, the identification information of the target data table may be the table name of the target data table, or the number of the target data table, or other names, which are not limited in any way in this embodiment of the disclosure.
[0073] In this embodiment, the prompt word template can be set according to actual conditions, and the embodiment of the present disclosure does not impose any restrictions on this. For example, the prompt word template can be set as: please generate a structured query language statement for querying the corresponding question in the data table corresponding to the identification information based on "query question: XXXX and identification information: XXXX".
[0074] In this embodiment, by pre-setting a prompt word template, after obtaining the identification information of the query question and the target data table, the identification information of the query question and the target data table can be directly filled into the corresponding position of the prompt word template, thereby quickly generating the target prompt text, thereby improving the generation speed of the structured query language statement, and the efficiency of querying data according to the structured query language statement, thereby improving the user experience.
[0075] In a possible manner, the target data table information is associated with multiple target data tables. Accordingly, generating a structured query language statement for performing data query in the second database according to the target statement and the target data table information through a machine learning model may include: Randomly determine a data table from multiple target data tables as the data table to be queried; generate a structured query language statement for performing data query in a second database according to the target statement and information of the data table to be queried through a machine learning model; Accordingly, the method may further include: While displaying the data query results, the information of multiple target data tables is displayed.
[0076] For example, the target data table includes target data table A, target data table B and target data table C, and any one of the three target data tables is randomly selected as the data table to be queried, for example, target data table B is selected as the data table to be queried. Thus, the identification information of target data table B and the query question of the target statement can be determined, and the identification information and the query question are filled into the corresponding position of the prompt word template to obtain the target prompt word. Afterwards, the target prompt word can be input into the second machine learning model to generate a structured query language statement for performing data query in target data table B in the second database. Then, the structured query language statement is executed to obtain the query result of performing data query in target data table B. Finally, the data table information of target data table A, target data table B and target data table C can be obtained, and the obtained query result and the data table information of target data table A, target data table B and target data table C can be displayed to the user.
[0077] It should be understood that this is only an illustrative description and does not constitute a limitation of the solution. In a possible manner, multiple target data tables associated with the target data table information can also be used as the data table to be queried, so that data query can be performed in multiple target data tables. In a possible manner, the target data table corresponding to the maximum matching value can also be used as the data table to be queried, so as to perform data query.
[0078] Possible approaches may also include: Display query controls respectively associated with multiple target data tables to the user, wherein the query controls are used for the user to trigger a data query operation on the data table; in response to a trigger operation on a query control, perform a data query on the data table associated with the query control to obtain a new data query result; and display the new data query result to the user.
[0079] In this embodiment, the triggering operation on the query control may be a click operation, a long press operation, or a sliding operation on the triggering control, and the embodiment of the present disclosure does not impose any limitation on this.
[0080] For example, Figure 3 As shown, the data query results, the data table information corresponding to the data query results, and the viewing control "View Complete SQL (Structured Query Language, Structured Query Language Statement)" for viewing the structured query language statement can be displayed on the display page, and the data table information of each target data table, such as the table name or the matched metadata, etc., can be displayed on the display page, and the query control "Query Again" can be displayed next to each data table information. By clicking "Query Again", the data query results and the data table information corresponding to the data query results can be updated.
[0081] Through the above method, while displaying the data query results to the user, the information of the target data table and the query control for the user to trigger the data query operation on the data table can be displayed. Therefore, a secondary query can be performed based on the data query results and the actual needs of the user, thereby further improving the accuracy of the data query results.
[0082] To facilitate understanding of the data query method disclosed herein, a possible implementation of this solution is described below: like Figure 4 As shown, the data search page of the data management platform displays a smart object. By clicking on the smart object, a smart object page is displayed on the data search page. When the user enters the target sentence "How much was yesterday's consumption" in natural language on the smart object page, the backend of the data management platform inputs "How much was yesterday's consumption" into the first machine learning model. The first machine learning model performs intent recognition and key field extraction on "How much was yesterday's consumption" to obtain the key field "consumption". After that, based on the semantics of "consumption", proper nouns and / or synonyms are expanded in the preset vocabulary to obtain the expanded word "cost". After obtaining the expanded word "cost", "consumption" and "cost" are vectorized by the first machine learning model to obtain the word embedding vector of "consumption" and the word embedding vector of "cost". Then, based on the word embedding vector of "consumption" and the word embedding vector of "cost", semantic recall and detection matching are performed in the first database according to dimensions such as data indicators, data dimensions, enumeration values, and data labels to obtain candidate data table information. Afterwards, a matching value between the candidate data table associated with the candidate data table information and “consumption” or “cost” is determined, and target data table information is determined from a plurality of candidate data table information according to the size of the matching value.
[0083] After obtaining the target data table information, determine the identification information of the target data table and determine the query question of the target statement. Then, fill the identification information and the query question into the corresponding positions of the prompt word template to obtain the target prompt text, and input the target prompt text into the second machine learning model to obtain a structured query language statement for data query in the second database. Then, execute the structured query language statement to obtain the query result, and display the query result on the smart object page by visualizing the data results.
[0084] Based on the same concept, the embodiment of the present disclosure also provides a data query device, such as Figure 5 As shown, the data query device 500 may include: An acquisition module 501 is used to acquire a target sentence input by a user in a natural language; The first processing module 502 is used to query the first database according to the target statement through the machine learning model to obtain the target data table information, and generate a structured query language statement for data query in the second database according to the target statement and the target data table information, wherein the first database is used to store metadata of the data table, and the second database stores the target data table associated with the target data table information; The second processing module 503 is used to execute the structured query language statement to obtain the data query result; The first display module 504 is used to display the data query result to the user.
[0085] Through the above-mentioned data query device 500, the target data table can be searched in the first database based on the target statement input by the user through the machine learning model to obtain the target data table information, and then the structured query language statement for data query on the target data table in the second database is generated based on the target statement and the target data table information through the machine learning model, and finally the data query result is obtained and displayed to the user by executing the structured query language statement. Thus, the data can be automatically searched based on the target statement input by the user through the machine learning model, thereby simplifying the data search process and improving the data search efficiency. In addition, when performing data query based on this solution, the user can use natural language as the query statement without pre-generating the structured query language statement for querying the data, thereby reducing the difficulty and complexity of data query and further improving the data search efficiency.
[0086] In a possible manner, the first processing module 502 may include: A first processing submodule is used to determine a query question based on a target statement and to determine identification information of a target data table; A second processing submodule is used to generate a target prompt word based on the query question, the identification information and a preset prompt word template, wherein the target prompt word is used to instruct the machine learning model to generate a structured query language statement based on the query question and the identification information; The third processing submodule is used to input the target prompt word into the machine learning model to obtain a structured query language statement for performing data query in the second database, wherein the machine learning model is at least used to output the structured query language statement based on the input prompt word.
[0087] In a possible manner, the target data table information is associated with multiple target data tables. Accordingly, the first processing module 502 may include: A first determination submodule is used to randomly determine a data table from multiple target data tables as a data table to be queried; A fourth processing submodule, configured to generate a structured query language statement for performing data query in a second database according to the target statement and information of the data table to be queried through a machine learning model; Accordingly, the data query device 500 may further include: The second display module is used to display information of multiple target data tables while displaying the data query results.
[0088] In a possible manner, the data query device 500 may further include: A third display module is used to display query controls respectively associated with multiple target data tables to the user, wherein the query controls are used for the user to trigger a data query operation on the data table; A query module, for performing a data query on a data table associated with a query control in response to a trigger operation on a query control, and obtaining a new data query result; The fourth display module is used to display new data query results to the user.
[0089] In a possible manner, the first processing module 502 may include: A fifth processing submodule is used for the first machine learning model to query the first database according to the target sentence to obtain target data table information; The sixth processing submodule is used to generate a structured query language statement for performing data query in the second database according to the target statement and the target data table information through the second machine learning model.
[0090] In a possible manner, the first processing module 502 may include: a seventh processing submodule, for extracting key fields of a target sentence through a machine learning model; An eighth processing submodule is used to perform semantic recall in the first database at least according to the key field to obtain first data table information, wherein the semantic recall is used to query the data table in the first database whose semantic similarity between the metadata and the key field is greater than a preset threshold; A ninth processing submodule, configured to perform a matching search in the first database at least according to the key field to obtain second data table information, wherein the matching search is used to search for a data table in the first database whose metadata is identical to the key field; Accordingly, the target data table information includes first data table information and second data table information.
[0091] In a possible manner, the first processing module 502 may further include: A second determination submodule is used to determine an expansion word having the same semantics as the key field in a preset word library, wherein the preset word library is used to store a plurality of preset words; Accordingly, the eighth processing submodule may be used to: perform semantic recall in the first database according to the key fields and the expansion words, wherein the semantic recall is used to query the data table in the first database whose semantic similarity between the metadata and the key fields or the expansion words is greater than a preset threshold; Accordingly, the ninth processing submodule can be used to: perform matching search in the first database according to the key fields and the expansion words, wherein the matching search is used to search for data tables in the first database whose metadata are the same as the key fields or the expansion words.
[0092] In a possible manner, the first processing module 502 may include: a tenth processing submodule, configured to extract key fields of the target sentence through a machine learning model, and query the first database according to different query dimensions based on the key fields to obtain information of multiple candidate data tables, wherein the query dimensions include querying data indicators and / or data dimensions, querying enumeration values, and querying data labels; The selection submodule is used to select a preset number of target data tables from multiple candidate data tables according to the matching degree between the candidate data tables associated with the candidate data table information and the key fields, wherein the matching degree is determined at least by the number of metadata matched by the key fields in the candidate data tables.
[0093] In a possible manner, the selection submodule may include: A first processing unit is used to determine, for each candidate data table information, target metadata matched by the keyword in the candidate data table associated with the candidate data table information, and determine the query dimension corresponding to each target metadata, and perform weighted summation on the number of target metadata matched under different query dimensions according to a preset weight value corresponding to each query dimension, to obtain a matching value between the candidate data table and the key field; The selection unit is used to select a preset number of data tables from a plurality of candidate data tables as target data tables according to the matching values.
[0094] Based on the same concept, an embodiment of the present disclosure further provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processing device, the steps of any of the above-mentioned data query methods are implemented.
[0095] Based on the same concept, the present disclosure also provides an electronic device, which may include: a storage device having a computer program stored thereon; The processing device is used to execute the computer program in the storage device to implement the steps of any of the above data query methods.
[0096] Based on the same concept, an embodiment of the present disclosure further provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned data query methods when executed by a processor.
[0097] Reference below Figure 6 , which shows a schematic diagram of the structure of an electronic device (600) suitable for implementing an embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0098] like Figure 6 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0099] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0100] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0101] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0102] In some embodiments, any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol) can be used for communication, and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0103] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0104] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains a target sentence input by a user in a natural language; queries in a first database according to the target sentence through a machine learning model to obtain target data table information, and generates a structured query language statement for data query in a second database according to the target sentence and the target data table information through a machine learning model, wherein the first database is used to store metadata of the data table, and the second database stores a target data table associated with the target data table information; executes the structured query language statement to obtain a data query result; and displays the data query result to the user.
[0105] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0106] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0107] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a module does not, in some cases, limit the module itself.
[0108] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0109] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0110] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0111] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0112] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Claims
1. A data query method, characterized in that: include: Obtain a target sentence input by a user in a natural language; A machine learning model is used to query the target statement in a first database to obtain target data table information, and a structured query language statement is generated for performing data query in a second database according to the target statement and the target data table information, wherein the first database is used to store metadata of a data table, and the second database stores a target data table associated with the target data table information; Execute the structured query language statement to obtain data query results; The data query result is displayed to the user.
2. The data query method according to claim 1, characterized in that: The step of generating a structured query language statement for performing data query in a second database according to the target statement and the target data table information includes: Based on the target statement, determining a query question and determining identification information of the target data table; Based on the query question, the identification information and a preset prompt word template, a target prompt word is generated, wherein the target prompt word is used to instruct the machine learning model to generate a structured query language statement based on the query question and the identification information; The target prompt word is input into the machine learning model to obtain a structured query language statement for performing data query in the second database, wherein the machine learning model is at least used to output a structured query language statement based on the input prompt word.
3. The data query method according to claim 1, characterized in that: The target data table information is associated with a plurality of target data tables, and generating a structured query language statement for performing data query in a second database according to the target statement and the target data table information includes: Randomly determine a data table from the plurality of target data tables as the data table to be queried; Generate a structured query language statement for performing data query in a second database according to the target statement and information of the data table to be queried; The method further comprises: While displaying the data query result, information of multiple target data tables is displayed.
4. The data query method according to claim 3, characterized in that: Also includes: Displaying query controls respectively associated with a plurality of the target data tables to the user, wherein the query controls are used for the user to trigger a data query operation on the data table; In response to a trigger operation on the query control, query the data table associated with the query control to obtain a new data query result; The new data query result is displayed to the user.
5. The data query method according to any one of claims 1 to 4, characterized in that: The method of querying the first database according to the target statement through the machine learning model to obtain target data table information, and generating a structured query language statement for performing data query in the second database according to the target statement and the target data table information, includes: Querying the first database according to the target statement through the first machine learning model to obtain target data table information; A structured query language statement for performing data query in a second database is generated through a second machine learning model based on the target statement and the target data table information.
6. The data query method according to any one of claims 1 to 4, characterized in that: The querying in the first database according to the target statement through the machine learning model to obtain target data table information includes: Extracting key fields of the target sentence through a machine learning model; At least according to the key field, semantic recall is performed in the first database to obtain first data table information, wherein the semantic recall is used to query the data table in the first database whose semantic similarity between the metadata and the key field is greater than a preset threshold; At least according to the key field, a matching search is performed in the first database to obtain second data table information, wherein the matching search is used to search for a data table in the first database whose metadata is the same as the key field; Correspondingly, the target data table information includes the first data table information and the second data table information.
7. The data query method according to claim 6, characterized in that: Also includes: Determining an expansion word having the same semantics as the key field in a preset word library, wherein the preset word library is used to store a plurality of preset words; The performing semantic recall in the first database at least according to the key field includes: According to the key field and the expanded word, semantic recall is performed in the first database, wherein the semantic recall is used to query the data table in the first database whose semantic similarity between the metadata and the key field or the expanded word is greater than the preset threshold; The performing a matching search in the first database at least according to the key field includes: A matching search is performed in the first database according to the key field and the extended word, wherein the matching search is used to search for a data table in the first database whose metadata is the same as the key field or the extended word.
8. The data query method according to any one of claims 1 to 4, characterized in that: The querying in the first database according to the target statement through the machine learning model to obtain target data table information includes: Extracting key fields of the target sentence through a machine learning model, and querying in the first database according to different query dimensions based on the key fields to obtain multiple candidate data table information, wherein the query dimensions include querying data indicators and / or data dimensions, querying enumeration values, and querying data labels; A preset number of target data tables are selected from the plurality of candidate data tables according to the matching degree between the candidate data table associated with the candidate data table information and the key field, wherein the matching degree is determined at least by the number of metadata matched by the key field in the candidate data table.
9. The data query method according to claim 8, characterized in that: The selecting a preset number of target data table information from a plurality of the candidate data tables according to the matching degree between the candidate data table associated with the candidate data table information and the key field comprises: For each candidate data table information, determine the target metadata matched by the keyword in the candidate data table associated with the candidate data table information, and determine the query dimension corresponding to each target metadata, and perform weighted summation on the number of target metadata matched under different query dimensions according to the preset weight value corresponding to each query dimension, to obtain the matching value between the candidate data table and the key field; According to the matching value, a preset number of data tables are selected from the plurality of candidate data tables as target data tables.
10. A data query device, characterized in that: include: An acquisition module, used for acquiring a target sentence input by a user in a natural language; A first processing module is used to query the first database according to the target statement through a machine learning model to obtain target data table information, and generate a structured query language statement for data query in a second database according to the target statement and the target data table information, wherein the first database is used to store metadata of a data table, and the second database stores a target data table associated with the target data table information; A second processing module is used to execute the structured query language statement to obtain a data query result; The first display module is used to display the data query result to the user.
11. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing device, the steps of the method according to any one of claims 1 to 9 are implemented.
12. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 9.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Data query method and device, storage medium and electronic equipment
CN118170795A
Generating structured queries from natural language text
US20170161262A1
Cited By
Method and device for determining data table, equipment, medium and product
CN119271805A
Database table recall method, device and system and storage medium
CN119357220A
Method and device for generating SQL (Structured Query Language) based on semantic alignment and hierarchical Agent
CN119377255A
Intelligent agent-based statement conversion method and device, electronic equipment and storage medium
CN120804302A
Database access flow control method and device, storage medium and program product
CN121233617A
