Data query method and device, electronic equipment and storage medium
By generating target query statements using a pre-set vector database and a large language model, the accuracy and efficiency issues of natural language data query in the field of business intelligence are solved, enabling real-time and accurate data query and access control, and improving user experience.
Patent Information
- Application Number
- CN202511019462.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-23
- Publication Date
- 2025-11-07
AI Technical Summary
Existing technologies for natural language data querying in the field of business intelligence suffer from problems such as insufficient accuracy, unreliable performance, coarse-grained access control, and unsatisfactory result presentation. In particular, the SQL statements generated by AI models are difficult to match the level of human engineers in terms of syntax, semantic understanding, and query performance.
By matching the target problem with a pre-set vector database, the pre-set problem and its reference query parameter set are determined. The target query parameter set is generated using a large language model, and the target query statement is generated for data query. Combined with access control and visualization, the accuracy and efficiency of data query are improved.
It enables real-time and accurate natural language question-and-answer data queries, improving the accuracy and efficiency of data queries, and implementing data-level and field-level access control and optimized result presentation.
Smart Images

Figure CN120910086A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to a data query method and device, electronic equipment and storage medium. BACKGROUND
[0002] In the traditional field of business intelligence (BI), indicators, reports and visual large screens are often used as the final form of presenting data to business decision makers (users). Users need to locate specific reports through keyword search and find the required data; in addition, developers need to exhaust the needs of business decision makers in advance to provide sufficient reports. Current natural language data query generally translates natural language into database SQL statements through NL2SQL technology, and obtains data query results after executing the query.
[0003] However, the above scheme has the following defects: 1. Lack of accuracy. The accuracy of the AI model output SQL is still far from the output precision of human engineers. This is mainly due to the limitations of the model in processing complex natural language problems and reasoning ability. The main performance is: first, the generated SQL statement syntax is incorrect and cannot be executed; second, the generated SQL semantic understanding is incorrect and the query result is wrong; third, the generated result has randomness. 2. Performance cannot be guaranteed. SQL statements with the same query purpose may have multiple implementation methods, and the query performance of the SQL statement generated by the AI model is difficult to achieve the optimization level of human engineers. 3. The granularity of permission control is coarse. The generated SQL statement is difficult to control the query range by row-level granularity, and can only limit the query data table range in advance. 4. The result presentation form does not meet the needs. The result obtained by directly querying using NL2SQL is a data sequence, which needs subsequent processing. SUMMARY
[0004] The present application provides a data query method, device, electronic equipment and storage medium, which can provide instant, accurate natural language question and answer type data query, improve the accuracy and query efficiency of data query.
[0005] According to one aspect of the present application, a data query method is provided, comprising:
[0006] In response to a data query event being triggered, a target question is obtained;
[0007] A preset question matched with the target question is determined based on a preset vector database, and a reference query parameter set corresponding to the preset question is determined;
[0008] A target query parameter set corresponding to the target question is determined based on the preset question and the reference query parameter set;
[0009] generate a target query statement based on the target query parameter set, and perform data query based on the target query statement to obtain a data query result.
[0010] According to another aspect of the present application, a data query device is provided, comprising:
[0011] a target question obtaining module configured to obtain a target question in response to a data query event being triggered;
[0012] a reference query parameter set determining module configured to determine a preset question matched with the target question based on a preset vector database, and determine a reference query parameter set corresponding to the preset question;
[0013] a target query parameter set determining module configured to determine a target query parameter set corresponding to the target question based on the preset question and the reference query parameter set;
[0014] a data query result obtaining module configured to generate a target query statement based on the target query parameter set, and perform data query based on the target query statement to obtain a data query result.
[0015] According to another aspect of the present application, an electronic device is provided, comprising:
[0016] at least one processor; and
[0017] a memory communicatively connected with the at least one processor; wherein
[0018] the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the data query method according to any one of the embodiments of the present application.
[0019] According to another aspect of the present application, a computer readable storage medium is provided, which stores computer instructions for enabling a processor to implement the data query method according to any one of the embodiments of the present application when executed.
[0020] The data query scheme of the embodiment of the present application, in response to a data query event being triggered, acquires a target question; determines a preset question matched with the target question based on a preset vector database, and determines a reference query parameter set corresponding to the preset question; determines a target query parameter set corresponding to the target question based on the preset question and the reference query parameter set; generates a target query statement based on the target query parameter set, and performs data query based on the target query statement to acquire a data query result. Through the technical scheme provided by the embodiment of the present application, instant and accurate natural language question and answer type data query can be provided, and the accuracy and query efficiency of data query are improved.
[0021] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0023] Figure 1 A flow chart of a data query method provided by the embodiment of the present application;
[0024] Figure 2 A data query system architecture diagram provided by the embodiment of the present application;
[0025] Figure 3 An interaction process schematic diagram of each module in the data query system when data query is performed, provided by the embodiment of the present application;
[0026] Figure 4 A structure schematic diagram of a data query device provided by the embodiment of the present application;
[0027] Figure 5 A structure schematic diagram of an electronic device for implementing the data query method of the embodiment of the present application. DETAILED DESCRIPTION
[0028] In the following, the technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all the other embodiments obtained by a person of ordinary skill in the art without creative work should belong to the protection scope of the present application.
[0029] It should be noted that the terms "first", "second" and the like in the description and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily have to include all the steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0030] Figure 1 A flowchart of a data query method provided by an embodiment of the present application is provided. The embodiment can be applied to the case of data query. The method can be executed by a data query device, which can be realized in the form of hardware and / or software, and can be configured in an electronic device. As shown in the figure, the method comprises: Figure 1
[0031] S110, in response to a data query event being triggered, obtaining a target question.
[0032] In the embodiment of the present application, when a data query request is received, it is determined that a data query event is triggered. The data query request can include a trigger request of a data query button by a user through a data query system, or a preset voice instruction input by the user through the data query system. In response to the data query event being triggered, a target question is obtained. The target question can be a natural language question, that is, a question to be answered input by the user in the form of natural language.
[0033] S120, determining a preset question matched with the target question based on a preset vector database, and determining a reference query parameter set corresponding to the preset question.
[0034] The preset vector database is a set of data vectors corresponding to the historical questions input by the user. The preset vector database can be constructed in the following manner: obtaining a set of historical questions input by the user, converting each historical question in the set of historical questions into a corresponding data vector by using a vector converter, and then constructing the preset vector database based on the data vectors corresponding to all the historical questions in the set of historical questions. In the embodiment of the application, the preset vector database is accessed, and a preset question that matches the target question is determined based on the preset vector database. The preset question can be understood as a question in a question library corresponding to the preset vector database that has the highest similarity to the target question.
[0035] Optionally, determining the preset question that matches the target question based on the preset vector database comprises: converting the target question into a corresponding question vector; calculating the similarity between the question vector and each data vector in the preset vector database respectively, and taking the question corresponding to the data vector with the maximum similarity in the preset vector database as the preset question that matches the target question. For example, the target question is converted into a corresponding question vector by using a vector converter, and the similarity between the question vector and each data vector in the preset vector database is calculated respectively, wherein the similarity is the Euclidean distance between the question vector and the data vector. The data vector with the maximum similarity to the question vector is determined from the preset vector database, and the question corresponding to the data vector is taken as the preset question that matches the target question. This arrangement has the advantage that the preset question with the highest similarity to the target question can be accurately determined.
[0036] In the embodiment of the application, after the preset question with the highest similarity to the target question is determined based on the preset vector database, a set of reference query parameters corresponding to the preset question is further determined. For example, the set of reference query parameters corresponding to the preset question is determined based on a predetermined correspondence between questions and reference query parameters. For example, the set of reference query parameters can include at least two reference query parameters and a query statement template. The reference query parameters can include a preset data table and a query field parameter used to query the preset question. It can be understood that the preset data table is a data table in which the query result of the preset question is located, that is, in which data table the data corresponding to the preset question is queried, the query field parameter is a key parameter information included in the preset question and needed to be queried, and the query statement template is a template in which the query field parameter is combined into a query statement when the query result (that is, the answer to the preset question) corresponding to the preset question is obtained.
[0037] S130, determining a set of target query parameters corresponding to the target question based on the preset question and the set of reference query parameters.
[0038] In the embodiment of the present application, the target query parameter set corresponding to the target question is determined by analyzing the target question with reference to the preset question and the corresponding reference query parameter set. The target query parameter set can include multiple target query parameters, wherein the target query parameters can include a target data table used to query the target question and a target query field parameter included in the target question. Optionally, the target query parameter set corresponding to the target question is determined based on the preset question and the reference query parameter set, which includes inputting the target question, the preset question and the reference query parameter set into a pre-trained large language model, and determining the target query parameter set corresponding to the target question according to the output result of the large language model. The advantage of this setting is that the target query parameter set corresponding to the target question can be quickly and accurately determined.
[0039] For example, the target question, the preset question and the reference query parameter set are input into the pre-trained large language model, so that the large language model analyzes the semantics of the target question with the preset question and the reference query parameter set as reference examples, thereby determining at least two target query parameters corresponding to the target question according to the output result of the large language model, and generating a target query parameter set based on the at least two target query parameters, that is, the large language model outputs the target query parameter set corresponding to the target question. The large language model is a machine learning model in the field of artificial intelligence, which is used to quickly determine the query parameter set corresponding to the input question. It can be understood that the large language model can be pre-trained based on a large-scale data set, so that the trained large language model can efficiently handle complex tasks such as natural language analysis.
[0040] It can be understood that the form of user questions is finite, so the data vectors contained in the preset vector database are finite. In the embodiment of the present application, after the preset question and the reference query parameter set corresponding to the target question are determined based on the preset vector database, the reference query parameter set is replaced by the large language model with reference to the preset question and the reference query parameter set, thereby determining the target query parameter set corresponding to the target question, so as to cope with infinite query condition combinations, which helps to improve the accuracy of subsequent data query.
[0041] S140, generating a target query statement based on the target query parameter set, and performing data query based on the target query statement to obtain a data query result.
[0042] In the embodiment of the present application, the target query statement is generated according to the target query parameter set, that is, each target query parameter contained in the target query parameter set is assembled into the target query statement, wherein the target query statement is an SQL statement. Optionally, the reference query parameter set contains a query statement template corresponding to the preset question; the target query statement is generated based on the target query parameter set, which includes assembling each target query parameter contained in the target query parameter set into the target query statement according to the query statement template. The advantage of this setting is that it can effectively improve the effectiveness of the target query statement, thereby helping to further improve the accuracy of the data query result corresponding to the target question. In the embodiment of the present application, the reference query parameter set contains a query statement template, wherein the query statement template is a template for splicing other query parameters in the reference query parameter set corresponding to the preset question into the corresponding query statement, which can also be understood as a template for combining query field parameters into a query statement when obtaining the query result (i.e. the answer to the preset question) corresponding to the preset question. Since the preset question is the question with the highest similarity to the target question, and the target query parameter set corresponding to the target question is determined based on the preset question and the corresponding reference query parameter set, the set of each target query parameter is determined, therefore, the target query parameter set and the reference query parameter set have high similarity in parameter structure, so each target query parameter contained in the target query parameter set can be assembled into the target query statement according to the query statement template.
[0043] In the embodiment of the present application, data query is performed in the target data warehouse based on the target query statement to obtain a data query result. The target data warehouse is a basic data resource library formed by using a dimensional modeling methodology to uniformly summarize, splice, convert, and process data common in business fields, and arranging them by theme. Optionally, before performing data query in the target data warehouse based on the target query statement, a pre-aggregation technology can be used to construct a historical query acceleration index for historical questions corresponding to the target data warehouse and to query the corresponding historical answers in the target data warehouse based on a historical query acceleration engine. When performing data query in the target data warehouse based on the target query statement, the pre-aggregation technology is used to convert the target query statement into a target query acceleration engine, and the historical answers corresponding to the historical acceleration engine matching the target query acceleration engine in the target data warehouse are used as the data query result. The pre-aggregation technology is a technology for performing pre-computation on common complex computation and aggregation operation when data query contains complex computation and aggregation operation, and storing the computation result, so that the query result can be directly returned when the same condition is queried again, thereby accelerating the query.
[0044] The data query method of the embodiment of the present application, in response to a data query event being triggered, acquires a target question; determines a preset question matched with the target question based on a preset vector database, and determines a reference query parameter set corresponding to the preset question; determines a target query parameter set corresponding to the target question based on the preset question and the reference query parameter set; generates a target query statement based on the target query parameter set, and performs data query based on the target query statement to acquire a data query result. Through the technical solution provided by the embodiment of the present application, instant and accurate natural language question and answer type data query can be provided, and the accuracy and query efficiency of data query are improved.
[0045] In some embodiments, the target query parameter set contains a target data table used for querying the target question and a key field in the target question; before generating the target query statement based on the target query parameter set, the method further includes: acquiring identity authentication information of a target user inputting the target question, determining whether the target user has data level query authority on the target data table and field level query authority on the target field based on the identity authentication information; and generating the target query statement based on the target query parameter set includes: when it is determined based on the identity authentication information that the target user has data level query authority on the target data table and field level query authority on the target field, generating the target query statement based on the target query parameter set. The advantage of such setting is that data level authority control and field level authority control can be realized when data query is performed, and the security of data query is effectively ensured.
[0046] In the embodiment of the present application, the target query parameter set contains a target data table used for querying the target problem, that is, the data corresponding to the target problem is queried in the target data table, and the target query parameter set also contains a key field in the target problem, that is, the key field is queried in the target data table. However, not every data table is set with query permission for all users, and not all fields in the data table are set with query permission for all users. Therefore, the user query permission is verified before the target query statement is generated based on the target query parameter set. Specifically, identity verification information of a target user inputting the target problem is obtained, wherein the identity verification information can include any one of face information, fingerprint information or account password information. The identity verification information of the target user is matched with first identity information of a first user who has query permission of the target data table and pre-stored, and if there is first identity information matching the identity verification information of the target user, it means that the target user has data-level query permission of the target data table. When the target user has data-level query permission of the target data table, the identity verification information of the target user is further matched with second identity information of a second user who has query permission of the target field in the target data table and pre-stored, and if there is second identity information matching the identity verification information of the target user, it means that the target user has field-level query permission of the target field in the target data table. When it is determined based on the identity verification information that the target user has both data-level query permission of the target data table and field-level query permission of the target field in the target data table, the target query statement is generated based on the target query parameter set.
[0047] In some embodiments, after determining the preset problem matching the target problem based on the preset vector database, the method further includes determining a visualization parameter of a query result corresponding to the preset problem; and after obtaining the data query result, the method further includes displaying the data query result based on the visualization parameter. For example, after determining the preset problem with the highest similarity to the target problem based on the preset vector database, the visualization parameter of the query result corresponding to the preset problem can be determined based on a preset correspondence between the problem and the visualization parameter. The visualization parameter is used to reflect the way of visualizing the query result corresponding to the preset problem. Since the preset problem is the problem with the highest similarity to the target problem, the data query result corresponding to the target problem is displayed in the same way as the query result corresponding to the preset problem, that is, the data query result corresponding to the target problem is displayed in the same way as the query result corresponding to the preset problem. This setting has the advantage of effectively improving the display effect of the data query result corresponding to the target problem and improving the user experience.
[0048] Optionally, the data query result is displayed based on the visualization parameter, and the target query statement is displayed, wherein the target query statement is used to indicate the user to determine whether the data query result is accurate. In the embodiment of the present application, the data query result is displayed in the visualization area based on the visualization parameter, and the target query statement is displayed in the visualization area, that is, the data query result is synchronously displayed in the visualization area in the presentation mode corresponding to the visualization parameter and the target query statement, so that the target user analyzes the target query statement when viewing the data query result, and manually checks whether the data query result is accurate.
[0049] Figure 2 A data query system architecture diagram is provided for the embodiment of the present application, as shown in Figure 2As shown, the data query system includes a WEB client, a query total control module, a query template retrieval module, a large model module, a permission control module, a data query acceleration module, a data visualization module, a metadata management module, and a target data warehouse storage module. The WEB client is a medium for the data query system to interact with the user. When performing data query, the WEB client receives a target question input by a target user in natural language. In addition, the WEB client can also be a data query result display platform, i.e., used to display the data query result. The query total control module is used to coordinate and control the query template retrieval module, the large model module, the permission control module, the data query acceleration module, and the data visualization module during data query, i.e., interacts with the above modules to complete the processing and response of the overall data query request. The target data warehouse storage module is used to store the target data warehouse to provide data basis for the data query acceleration module when performing data query. The metadata management module is used to record all metadata corresponding to the target data warehouse stored in the target data warehouse storage module, and provide a vector database for the query template retrieval module. The metadata can include table structure, data definition, data lineage relationship, etc. of all data tables. The query template retrieval module is used to determine a preset question matched with the target question input by the user based on the preset vector database, and determine a reference query parameter set corresponding to the preset question. In addition, the query template retrieval module is also used to determine a visualization parameter of the query result corresponding to the preset question. The large model module is used to perform semantic analysis on the target question by taking the preset question and the reference query parameter set as reference through a large language model, and determine a target query parameter set corresponding to the target question. The permission control module is used to identify whether the user performing data query has data query permission, and intercepts unauthorized query (i.e., a user without data query permission). The data query acceleration module is used to assemble each target query parameter in the target query parameter set into a target query statement according to a query statement template, and construct a query acceleration index corresponding to the target query statement by using a pre-aggregation technology, so as to realize data query in the target data warehouse stored in the target data warehouse storage module. The data visualization module is used to render the data query result corresponding to the target question into a suitable presentation form for display on the WEB client.
[0050] Figure 3 An interaction process diagram of each module in the data query system when performing data query is provided for the embodiments of the present application. As shown in Figure 3 The interaction process of each module in the data query system when performing data query can include the following steps:
[0051] Firstly, the user inputs a target question through the WEB client, such as the target question is “How is the daily increment trend of the XX branch deposit in the recent 30 days?”
[0052] The second step is that the query control module receives the target question sent by the WEB client and forwards the target question to the query template retrieval module. The query template retrieval module determines the preset question with the highest similarity to the target question based on the preset vector database. For example, the preset question is "trend chart of total asset balance in the past 7 days", and the query template retrieval module determines the question and answer pair as:
[0053] Question: "trend chart of total asset balance in the past 7 days"
[0054] Answer:
[0055]
[0056]
[0057] It can be understood that the above answer includes a set of reference query parameters corresponding to the preset question and a visualization parameter of the query result corresponding to the preset question.
[0058] The third step is that the query control module receives the question and answer pair (i.e., the preset question, the set of reference query parameters, and the visualization parameter of the query result corresponding to the preset question) fed back by the query template retrieval module, and then initiates a parameter replacement request to the large model module. The large model module determines a set of target query parameters corresponding to the target question based on the preset question and the set of reference query parameters in response to the parameter replacement request. For example, the large model module can be asked as follows:
[0059] "You are an expert in the field of semantic processing, and can analyze the sample question "trend chart of total asset balance in the past 7 days" into a sample answer:
[0060]
[0061] Please answer the following question: "how is the daily increment trend of deposits in XX branch in the past 30 days?"
[0062] The result fed back by the large model module is:
[0063] "The following is the analysis result of the question "how is the daily increment trend of deposits in XX branch in the past 30 days?"
[0064]
[0065] It can be understood that the analysis result of the question "how is the daily increment trend of deposits in XX branch in the past 30 days?" is the set of target query parameters corresponding to the target question.
[0066] In the fourth step, the query general control module receives the target query parameter set fed back by the large model module, and sends a permission verification request to the permission verification module. The permission verification module, in response to the permission verification request, determines whether the target user has the data table level query permission of "INDEX_A0001_HIS" and the field level query permission of the target field "XX branch" based on the obtained identity authentication information of the target user. The permission verification module feeds back the permission verification result (the verification result of the data table level query permission and the verification result of the field level query permission) to the query general control module.
[0067] In the fifth step, when the query general control module determines that the target user has the query permission according to the permission verification result, the query general control module sends the target query parameter set to the data query acceleration module. The data query acceleration module assembles each target query parameter in the target query parameter set into a target query statement according to the query statement template. In the process of assembling the target query statement, some default conditions (such as the latest date) can be inserted. Assuming that the latest date is '20240101', the assembled target query statement for the target question "What is the daily incremental trend of the XX branch deposit in the last 30 days?" can be:
[0068]
[0069] The data query acceleration module performs data query based on the target query statement and obtains a data query result.
[0070] In the sixth step, the query general control module receives the data query result fed back by the data query acceleration module. The query general control module sends a visualization request to the visualization module, and sends the visualization parameter obtained in the second step and the data query result obtained in the fifth step to the visualization module. The visualization module, in response to the visualization request, renders the data query result into a columnar trend chart composed of the daily incremental data of the XX branch deposit in the last 30 days.
[0071] In the seventh step, the query general control module receives the columnar trend chart (visualization result) fed back by the visualization module, and feeds back the columnar trend chart obtained in the sixth step and the target query statement obtained in the fifth step to the WEB client at the same time, so as to display the columnar trend chart and the target query statement on the WEB client.
[0072] Figure 4 A structural schematic diagram of a data query device provided by the embodiment of the application is shown in FIG. 1. Figure 4 As shown in FIG. 1, the device comprises:
[0073] A target question acquisition module 410 is configured to acquire a target question in response to a data query event being triggered.
[0074] The reference query parameter set determination module 420 is configured to determine a preset problem matched with the target problem based on the preset vector database, and determine a reference query parameter set corresponding to the preset problem;
[0075] The target query parameter set determination module 430 is configured to determine a target query parameter set corresponding to the target problem based on the preset problem and the reference query parameter set;
[0076] The data query result acquisition module 440 is configured to generate a target query statement based on the target query parameter set, and perform data query based on the target query statement to acquire a data query result.
[0077] Optionally, the reference query parameter set determination module is configured to:
[0078] convert the target problem into a corresponding problem vector;
[0079] calculate the similarity between the problem vector and each data vector in the preset vector database respectively, and take the problem corresponding to the data vector with the maximum similarity in the preset vector database as the preset problem matched with the target problem.
[0080] Optionally, the target query parameter set determination module is configured to:
[0081] input the target problem, the preset problem and the reference query parameter set into a pre-trained large language model, and determine the target query parameter set corresponding to the target problem according to an output result of the large language model.
[0082] Optionally, the target query parameter set includes a target data table used for querying the target problem and a key field in the target problem.
[0083] Further comprising:
[0084] The query permission verification module is configured to acquire identity verification information of a target user inputting the target problem before generating a target query statement based on the target query parameter set, and determine whether the target user has data-level query permission on the target data table and field-level query permission on the target field based on the identity verification information.
[0085] The data query result acquisition module is configured to:
[0086] generate a target query statement based on the target query parameter set when it is determined based on the identity verification information that the target user has data-level query permission on the target data table and field-level query permission on the target field.
[0087] Optionally, the reference query parameter set comprises a query statement template corresponding to the preset question.
[0088] The data query result acquisition module is configured to:
[0089] The target query parameters in the target query parameter set are assembled into a target query statement according to the query statement template.
[0090] Optionally, the method further comprises:
[0091] The visualization parameter determination module is configured to, after determining the preset question matching the target question based on the preset vector database, determine a visualization parameter of a query result corresponding to the preset question.
[0092] The method further comprises:
[0093] The data query result display module is configured to, after acquiring the data query result, display the data query result based on the visualization parameter.
[0094] Optionally, the method further comprises:
[0095] The target query statement display module is configured to, while displaying the data query result based on the visualization parameter, display the target query statement, wherein the target query statement is used to instruct a user to determine whether the data query result is accurate.
[0096] The data query device provided in the embodiments of the present application can execute the data query method provided in any of the embodiments of the present application, and has the corresponding functional modules and beneficial effects of the execution method.
[0097] Figure 5 A structural schematic diagram of an electronic device 10 that can be used to implement embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit the implementations of the present application described and / or claimed in this document.
[0098] As Figure 5As shown, the electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., connected to the at least one processor 11 in communication. The memory stores computer programs executable by the at least one processor 11, and the processor 11 can perform various appropriate actions and processes according to the computer programs stored in the read-only memory (ROM) 12 or loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0099] Various components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc., an output unit 17, such as various types of displays, a speaker, etc., a storage unit 18, such as a magnetic disk, an optical disk, etc., and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.
[0100] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as the data query method.
[0101] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program according to embodiments of the present application. For example, embodiments of the present application include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network through the communication unit 19, or installed from the storage unit 18, or installed from the ROM 12. When the computer program is executed by the processor 11, the above-mentioned functions defined in the methods of embodiments of the present application are performed.
[0102] In some embodiments, the data query method can be implemented as a computer program tangibly embodied in a computer readable storage medium, e.g., storage unit 18. In some embodiments, parts or all of the computer program can be loaded and / or installed onto electronic device 10 via, e.g., ROM 12 and / or communication unit 19. When the computer program is loaded onto RAM 13 and executed by processor 11, one or more steps of the data query method described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the data query method by other means, e.g., with the aid of firmware.
[0103] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a complex programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0104] Computer programs used to implement the methods of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the computer program, when executed by the processor of the machine, implements the functions / acts specified in the flowcharts and / or block diagrams. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine and partially on a remote machine or entirely on a remote machine or server.
[0105] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0106] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0107] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by 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), a blockchain network, and the Internet.
[0108] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.
[0109] It should be understood that the various forms of flow shown above can be used to reorder, add or delete steps. For example, each step described in the present application can be executed in parallel, sequentially or in a different order, as long as the desired results of the technical solutions of the present application can be achieved, which is not limited herein.
[0110] The above detailed description does not constitute a limitation on the scope of protection of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A data query method, characterized by, The method comprises the following steps: in response to a data query event being triggered, obtaining a target question; determining a preset question matched with the target question based on a preset vector database, and determining a reference query parameter set corresponding to the preset question; determining a target query parameter set corresponding to the target question based on the preset question and the reference query parameter set; generating a target query statement based on the target query parameter set, and performing data query based on the target query statement to obtain a data query result.
2. The method of claim 1, wherein, The method comprises the following steps: converting the target question into a corresponding question vector; calculating the similarity between the question vector and each data vector in the preset vector database respectively, and taking the question corresponding to the data vector with the maximum similarity in the preset vector database as the preset question matched with the target question.
3. The method of claim 1, wherein, The method comprises the following steps: inputting the target question, the preset question and the reference query parameter set into a pre-trained large language model, and determining the target query parameter set corresponding to the target question according to the output result of the large language model.
4. The method of claim 1, wherein, The target query parameter set contains a target data table used for querying the target question and a key field in the target question; Before generating the target query statement based on the target query parameter set, the method further comprises the following steps: obtaining the identity verification information of a target user inputting the target question, and determining whether the target user has data-level query authority on the target data table and field-level query authority on the target field based on the identity verification information; The method comprises the following steps: when it is determined based on the identity verification information that the target user has data-level query authority on the target data table and field-level query authority on the target field, generating the target query statement based on the target query parameter set.
5. The method of claim 1, wherein, The reference query parameter set contains a query statement template corresponding to the preset question; The method comprises the following steps: assembling each target query parameter contained in the target query parameter set into a target query statement according to the query statement template.
6. The method of claim 1, wherein, After determining the preset question matched with the target question based on the preset vector database, the method further comprises the following steps: determining a visualization parameter of a query result corresponding to the preset question; After obtaining the data query result, the method further comprises the following steps: displaying the data query result based on the visualization parameter.
7. The method of claim 6, wherein, While displaying the data query result based on the visualization parameter, the method further comprises the following steps: displaying the target query statement; wherein the target query statement is used to instruct a user to determine whether the data query result is accurate.
8. A data query apparatus, characterized by comprising: The method comprises the following steps: a target question obtaining module, configured to obtain a target question in response to a data query event being triggered; The reference query parameter set determination module is configured to determine a preset question matched with the target question based on a preset vector database, and determine a reference query parameter set corresponding to the preset question; The target query parameter set determination module is configured to determine a target query parameter set corresponding to the target question based on the preset question and the reference query parameter set; The data query result acquisition module is configured to generate a target query statement based on the target query parameter set, and perform data query based on the target query statement to acquire a data query result.
9. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected with the at least one processor in communication; wherein The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the data query method in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions, and the computer instructions are used to enable the processor to implement the data query method in any one of claims 1-7 when executed.