Method, device and equipment for query statement generation and readable medium
By receiving natural language input and using indicator index libraries and machine learning models to generate computer-executable query statements, it solves the problems of semantic mismatch and unknown vocabulary in traditional NL2SQL technology, improves the accuracy and efficiency of query statements, and satisfies the production environment. usage requirements.
Patent Information
- Application Number
- CN202410658556.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-08-30
AI Technical Summary
Traditional NL2SQL technology has problems with semantic mismatch and unknown vocabulary in the schema linking stage, which results in the natural language query input by the user being unable to be accurately converted into SQL statements, especially in the production environment, which cannot meet the requirements for online use.
Provide a method to generate a computer-executable query statement by receiving natural language input and using the indicator template and data table information in the indicator index library, including determining the matching indicator and data table information from the indicator index library and completing the template. missing information, and use machine learning models to generate legitimate query statements.
It improves the output quality, accuracy and generation efficiency of query statements, and can effectively support users' indicator data queries in production environments.
Smart Images

Figure CN118568128A
Abstract
Description
Technical Field
[0001] Example embodiments of the present disclosure generally relate to the field of computer technology, and more particularly, to a method, apparatus, device, and computer-readable storage medium for generating a query statement. Background Art
[0002] With the rapid development of information technology, NL2SQL (Natural Language to SQL) is a technology that converts users' natural statements into executable Structured Query Language (SQL) statements. NL2SQL can be applied to a variety of scenarios such as semantic parsing and intelligent question answering, but there are some problems in the traditional implementation of NL2SQL. Summary of the invention
[0003] In a first aspect of the present disclosure, a method for query statement generation is provided. The method includes: receiving user input expressed in natural language; determining at least one indicator matching the user input from an indicator index library, the indicator index library including multiple indicators related to a data table and having a query number greater than a query threshold and an indicator template corresponding to each indicator, each indicator template including indicator information related to the corresponding indicator, data table information, and processing information; and generating a query statement matching the user input based on at least one indicator template corresponding to at least one indicator and a query generation condition, the query statement being related to at least one indicator, and the query statement being executable by a computer.
[0004] In a second aspect of the present disclosure, a device for query statement generation is provided. The device includes: a receiving module configured to receive user input expressed in natural language; a determining module configured to determine at least one indicator matching the user input from an indicator index library, the indicator index library including multiple indicators related to a data table and having a query number greater than a query threshold and an indicator template corresponding to each indicator, each indicator template including indicator information related to the corresponding indicator, data table information, and processing information; and a generating module configured to generate a query statement matching the user input based on at least one indicator template corresponding to the at least one indicator and a query generation condition, the query statement being related to the at least one indicator and being executable by a computer.
[0005] In a third aspect of the present disclosure, an electronic device is provided. The electronic device includes at least one processing unit; and at least one memory, the at least one memory is coupled to the at least one processing unit and stores instructions for execution by the at least one processing unit, and when the instructions are executed by the at least one processing unit, the electronic device executes the method of the first aspect of the present disclosure.
[0006] In a fourth aspect of the present disclosure, a computer-readable storage medium is provided, wherein a computer program is stored on the computer-readable storage medium, and the computer program can be executed by a processor to perform the method according to the first aspect of the present disclosure.
[0007] It should be understood that the contents described in the summary of the invention are not intended to limit the key features or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In the following, in conjunction with the accompanying drawings and with reference to the following detailed description, the above and other features, advantages and aspects of various implementations of the present disclosure will become more apparent. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:
[0009] Figure 1 A schematic diagram showing an example environment in which embodiments of the present disclosure can be implemented;
[0010] Figure 2 A schematic diagram of an index architecture according to some embodiments of the present disclosure is shown;
[0011] Figure 3 A schematic diagram showing a process for query statement generation according to some embodiments of the present disclosure is shown;
[0012] Figure 4 A schematic diagram showing an example of a process for query statement generation according to some embodiments of the present disclosure;
[0013] Figure 5 A schematic structural block diagram of an apparatus for generating a query statement according to some embodiments of the present disclosure is shown; and
[0014] Figure 6 A block diagram of a computing device is shown in which one or more embodiments of the present disclosure may be implemented. DETAILED DESCRIPTION
[0015] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some 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. On the contrary, these embodiments are provided to provide 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.
[0016] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The term "some embodiments" should be understood as "at least some embodiments". Other explicit and implicit definitions may also be included below.
[0017] It should be noted that the acquisition, storage and application of user personal information involved in the technical solution of the present disclosure are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[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, so that the user can independently choose whether to provide personal information to software or hardware such as electronic devices, applications, servers or storage media that execute operations of the technical solution of the present disclosure based on the prompt message.
[0020] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information is sent to the user in a manner such as a pop-up window, in which the prompt information can be presented in text form. In addition, the pop-up window can also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0021] Traditionally, NL2SQL solutions mainly include three methods. The first method (sketch-based) is to convert the NL2SQL task into a slot filling task, such as the SQL generation model (SQLNet). The second method (grammar-based) is to build a syntax tree, such as IRNet. IRNet is a SQL grammar matching model that can convert natural language (NL) and SQL grammar into SQL statements. The third method (seq2seq) is to directly generate SQL end-to-end, such as the bidirectional encoder representation from embedding representation (Bidirectional Encoder Representation from Transformer, BERT). The development of large language model (LLM) technology has provided a new direction for NL2SQL. Compared with traditional methods, the accuracy has been greatly improved, and more complex SQL statements can be generated.
[0022] Although the accuracy of the solution using machine language models to determine query statements has been improved compared to traditional solutions, there are still some problems in actual use. Most of the above problems occur in the schema linking stage, which is the process of establishing relationships between natural language and the data tables and fields in the database schema. Since user input is a query question stated by the user and does not contain the processing logic of the query question (such as which database fields to aggregate based on, what the filtering conditions are, etc.), the information provided by natural language alone is not enough to complete the query task.
[0023] In addition, SQL is a computer language used for efficient query in relational databases, rather than a semantic language similar to natural language. Therefore, there may be a mismatch between the semantics stated in natural language and the implementation details represented by SQL, that is, a mismatch problem. At the same time, during the prediction process, a large number of natural language words that have not appeared in the training set will appear, resulting in the inability to correctly predict the fields in the data table that the natural language actually refers to, that is, a lexical problem.
[0024] However, the solution of using machine language models to determine query statements focuses on solving the above two problems, but the effect is not significant and still cannot reach the level of online availability. Especially in the production environment, users are often operators who do not understand SQL, and users mostly want to query indicator data (such as the number of activated users, conversion rate, retention rate, etc.). These indicator types of queries rely only on machine language models and cannot complete the schema linking stage.
[0025] In view of this, an embodiment of the present disclosure provides a solution for converting natural language to query language. The solution includes: receiving user input expressed in natural language; determining at least one indicator matching the user input from an indicator index library; and generating a query statement matching the user input based on at least one indicator template corresponding to the at least one indicator and a query generation condition. In this way, a query statement corresponding to the user input can be generated, and the output quality, accuracy and generation efficiency of the query statement can be improved.
[0026] Figure 1 1 is a schematic diagram of an example environment 100 in which embodiments of the present disclosure can be implemented. Figure 1 As shown, environment 100 may include electronic device 120 .
[0027] The electronic device 120 is at least configured to determine and output a query statement 125 that matches the user input 105 through the received user input 105 represented in natural language. An index library 110 may also be configured in the electronic device 120. The index library 110 may provide the electronic device 120 with information that matches the user input 105 in the above statement determination process. The query statement 125 may also be executed by the electronic device to search for the information that the user wants from the index library 110. When the user searches for the information he wants from the index library 110, the relevant information, such as indicator information, data table information, and data table information, may be recalled by vector retrieval.
[0028] The electronic device 120 may include any computing system with computing capabilities, such as various computing devices / systems, terminal devices, server devices, etc. The terminal device may be any type of mobile terminal, fixed terminal or portable terminal, including a mobile phone, a desktop computer, a laptop computer, a notebook computer, a netbook computer, a tablet computer, a media computer, a multimedia tablet, a handheld computer, a portable game terminal, a VR / AR device, a personal communication system (Personal Communication System, PCS) device, a personal navigation device, a personal digital assistant (Personal Digital Assistant, PDA), an audio / video player, a digital camera / camcorder, a positioning device, a television receiver, a radio broadcast receiver, an e-book device, a game device, or any combination of the foregoing, including accessories and peripherals of these devices or any combination thereof.
[0029] It should be understood that the structure and function of the various elements in the environment 100 are described for exemplary purposes only and do not imply any limitation on the scope of the present disclosure.
[0030] Some example embodiments of the present disclosure will be described below with continued reference to the accompanying drawings.
[0031] As will be described in detail below, in the embodiment of the present disclosure, the conversion from natural language to query language (e.g., SQL language) is completed based on one or more types of index libraries 110 to convert user input in natural language into query statements that can be executed by a computer. Figure 2 To describe the index library construction process. Figure 2 FIG. 2 is a schematic diagram of an index architecture 200 according to some embodiments of the present disclosure. Figure 1 The process 200 is described with reference to the environment 100 of FIG.
[0032] like Figure 2 As shown, the index library 110 required to be used in the query statement generation process may include an indicator index library 225 , a data table index library 235 , and a processing index library 245 .
[0033] like Figure 2 As shown, in some embodiments, the indicator index library 225 can be constructed from the indicator data in the indicator platform 220. The indicator data in the indicator platform 220 can be input by the data analyst 210, and the indicator data includes multiple indicators with a query number greater than the query threshold and an indicator template (sketch) corresponding to each indicator. The indicator index library 225 includes multiple indicators related to the data table and the query number greater than the query threshold and an indicator template corresponding to each indicator. Each indicator template includes indicator information related to the corresponding indicator, data table information and processing information. The indicator information can be an indicator name, an indicator field, a filtering condition, etc., the data table information can be a data table type, a partition field, a partition format, a time field, a time format, etc., and the processing information can be a calculation logic, etc.
[0034] In some examples, the indicator types can be divided into atomic indicators and derived indicators. The derived indicators can be obtained from multiple atomic indicators according to certain rules, and the certain rules can be calculation formulas, etc. For example, if the derived indicator is click-through rate, then the corresponding atomic indicators can be exposure rate and number of clicks.
[0035] In some examples, indicator templates can be divided into atomic indicator templates and derived indicator templates according to indicator types. Atomic indicator templates can include but are not limited to at least one of the following: indicator name, database, data table, data table type, indicator field, field calculation method, partition field, partition format, time field, time format, time dimension, business dimension, and filter condition. Derivative indicator templates can include but are not limited to at least one of the following: atomic indicator, calculation logic, and business dimension.
[0036] In some embodiments, the data table index library 235 can be constructed from the database 230. The database 230 includes data table information of the electronic device 110 during actual operation, and the data table information includes multiple data tables related to indicators. The data table index library 235 includes data table information corresponding to multiple indicators.
[0037] In addition, the processing index library 245 can be constructed from the processing information library 240. The processing information in the processing information library 240 can be input by the data analyst 210. The processing information can indicate the processing logic related to multiple indicators. The processing logic can be a calculation formula and calculation logic, such as the calculation formula and calculation logic of the click-through rate, and the calculation formula and calculation logic of the penetration conversion rate. The processing index library 245 includes processing information corresponding to multiple indicators.
[0038] Figure 3 FIG. 3 is a schematic diagram of a process 300 for query statement generation according to some embodiments of the present disclosure. The process 300 may be implemented at the electronic device 120. For ease of discussion, reference will be made to FIG. Figure 1 The process 300 is described with reference to the environment 100 of FIG.
[0039] like Figure 3 As shown, the electronic device 120 receives the user input 105 expressed in natural language, and matches the user input 105 with the index library 110 in the electronic device 120. The user input 105 indicates that a query is to be performed on the data table. In the embodiment of the present disclosure, it is expected that the user input expressed in natural language will be converted into a query statement (e.g., an SQL statement) executable by a computer, so that the computer can execute the data query and return the corresponding query result to the user. As shown in FIG. Figure 2 As described, in an embodiment of the present disclosure, the index library 110 includes at least an indicator index library 225 , and in some embodiments also includes a data table index library 235 and a processing index library 245 .
[0040] In some embodiments, the electronic device 120 may match the user input 105 with the indicator index library 225. The electronic device 120 may determine at least one indicator 320 that matches the user input 105 from the indicator index library 225, and each indicator in the indicator index library 225 has a corresponding indicator template. The electronic device 120 may determine an indicator template 325 corresponding to the indicator 320.
[0041] In some embodiments, the electronic device 120 may match the user input 105 with the data table index library 235. The data table index library 235 may include data table information corresponding to multiple indicators. The electronic device 120 may determine the data table information 330 that matches the user input 105 from the data table index library 235, and the data table information includes at least one data table that matches the user input.
[0042] In some examples, the electronic device 120 may filter the fields in the determined data table information 330 whose correlation with the user input is lower than the correlation threshold to obtain the filtered data table information 330. In other examples, the electronic device 120 may also use a schema filter to obtain the filtered data table information 330. When there is missing data table information in the indicator template 325, the electronic device 120 may use the filtered data table information to complete the missing data table information in the indicator template 325.
[0043] In addition, the electronic device 120 may also match the user input 105 with the processing index library 245. The processing index library 245 may include processing information 330 corresponding to multiple indicators. The electronic device 120 may determine the processing information 350 that matches the user input 105 from the processing index library 245. The processing information 350 may indicate the processing logic associated with at least one indicator 320 that matches the user input 105.
[0044] At block 340, the electronic device 120 determines whether the indicator template 325 needs data table information completion. In some embodiments, if the electronic device 120 determines at block 340 that the indicator template 325 needs data table information completion, then at block 345, the electronic device 120 completes the missing data table information in the indicator template 325 based on the filtered data table information 335. After the data table information in the indicator template 325 is completed, at block 360, the electronic device 120 determines whether the completed indicator template 325 satisfies the query generation condition.
[0045] In other embodiments, if the electronic device 120 determines in box 340 that the indicator template 325 does not need data table information completion, then in box 360, the electronic device 120 determines whether the indicator template 325 meets the query generation condition. If in box 360, the electronic device 120 determines that the indicator template 325 meets the query generation condition, then in box 365, the electronic device 120 uses the indicator template 325 and the predetermined generation rule 365 to generate a query statement 390 that matches the user input 105.
[0046] If, at box 360, the electronic device 120 determines that the indicator template 325 does not meet the query generation condition, then the electronic device 120 generates a prompt word input (prompt) 370 using the indicator template 325 and the processing information 350. The electronic device 120 can provide the prompt word input 370 to the machine learning model 375, which can be an LLM. The machine learning model 375 can output a candidate query statement. At box 380, the electronic device 120 determines whether the candidate query statement meets the legality requirements. If, at box 380, the electronic device 120 determines that the candidate query statement meets the legality requirements, then the electronic device 120 generates the candidate query statement as a query statement 390 that matches the user input 105. If, at box 380, the electronic device 120 determines that the candidate query statement does not meet the legality requirements, then the electronic device 120 determines a report 385 corresponding to the illegal candidate query statement. The electronic device 120 can input the illegal candidate query statement and the report 385 into the machine learning model 375.
[0047] In addition, the machine learning model 375 can regenerate a first candidate query statement for the illegal candidate query statement through a report 385. In box 380, the electronic device 120 can determine whether the first candidate query statement meets the legality requirements. If the electronic device 120 determines in box 380 that the candidate query statement does not meet the legality requirements, then the electronic device 120 determines a first report corresponding to the illegal first candidate query statement. The electronic device 120 can input the illegal first candidate query statement and the first report into the machine learning model 375. The machine learning model 375 can regenerate a second candidate query statement for the illegal candidate query statement through a report 385. And in box 380, the electronic device 120 can determine whether the second candidate query statement meets the legality requirements, until the statement output by the machine learning model 375 is legal, the electronic device 120 can determine the legal statement as the query statement 390.
[0048] Figure 4 A schematic diagram showing an example of a process 400 for query statement generation according to some embodiments of the present disclosure is shown. Figure 1 The process 400 is described with reference to the environment 100 of FIG. 4 . The process 400 may be implemented at the electronic device 120 .
[0049] At block 410 , the electronic device 120 receives user input in natural language.
[0050] In block 420 , the electronic device 120 determines at least one indicator matching the user input from the indicator index library.
[0051] In some embodiments, the indicator index library includes multiple indicators related to the data table and with query times greater than the query threshold, and an indicator template corresponding to each indicator, each indicator template includes indicator information, data table information and processing information related to the corresponding indicator.
[0052] In box 430, the electronic device 120 generates a query statement matching the user input based on at least one indicator template corresponding to the at least one indicator and the query generation condition.
[0053] In some embodiments, the query statement is associated with at least one indicator, and the query statement is computer executable.
[0054] In some embodiments, the electronic device 120 generates a query statement matching the user input based on at least one indicator template corresponding to at least one indicator and the query generation condition, including: in response to at least one indicator template satisfying the query generation condition, the electronic device 120 generates a query statement matching the user input based on at least one indicator template using a predetermined generation rule. In other embodiments, in response to at least one indicator template not satisfying the query generation condition, the electronic device 120 generates a query statement matching the user input based on a prompt word input corresponding to at least one indicator template using a machine learning model.
[0055] In some embodiments, in response to missing data table information in at least one indicator template, the electronic device 120 uses data table information in a data table index library to complete the missing data table information in at least one indicator template, and the data table index library includes data table information corresponding to multiple indicators; and in response to the completed indicator template satisfying the query generation condition, the electronic device 120 uses predetermined generation rules to generate a query statement that matches the user input based on at least one indicator template.
[0056] In some embodiments, the electronic device 120 uses the data table information in the data table index library to complete the missing data table information in at least one indicator template, including: the electronic device 120 determines the data table information that matches the user input from the data table index library, and the data table information includes at least one data table that matches the user input; the electronic device 120 filters the fields in the at least one data table whose correlation with the user input is lower than the correlation threshold to obtain filtered data table information; and the electronic device 120 uses the filtered data table information to complete the missing data table information in at least one indicator template.
[0057] In some embodiments, the electronic device 120 utilizes a machine learning model to generate a query statement that matches the user input based on a prompt word input corresponding to at least one indicator template, including: the electronic device 120 generates a prompt word input for the machine learning model based on at least one indicator template and processing information that matches the user input; the electronic device 120 provides the prompt word input to the machine learning model to obtain a candidate query statement output by the machine learning model; and the electronic device 120 generates a query statement that matches the user input based on the candidate query statement.
[0058] In some embodiments, the processing information is determined from a processing index library, the processing index library includes processing information corresponding to a plurality of indicators, and the processing information indicates processing logic associated with at least one indicator matching the user input.
[0059] In some embodiments, the electronic device 120 generates a query statement that matches the user input based on a candidate query statement, including: in response to the candidate query statement satisfying the legitimacy requirement, the electronic device 120 generates the candidate query statement as a query statement that matches the user input; in response to the candidate query statement not satisfying the legitimacy requirement, the electronic device 120 determines a report corresponding to an illegal candidate query statement; and the electronic device 120 generates a query statement that matches the user input based on the illegal query statement and the report.
[0060] In some embodiments, the electronic device 120 generates a query statement that matches the user input based on the illegal query statement and the report, including: the electronic device 120 inputs the report and the illegal candidate query statement into the machine learning model to determine a modified candidate query statement; the electronic device 120 generates the modified candidate query statement as a query statement that matches the user input in response to the modified candidate query statement satisfying the legality requirements.
[0061] In summary, the embodiments of the present disclosure can generate a query statement corresponding to a user input, and can improve the output quality, accuracy, and generation efficiency of the query statement.
[0062] The embodiments of the present disclosure also provide corresponding devices for implementing the above methods or processes. Figure 5 A schematic structural block diagram of an apparatus 500 for generating a query statement according to some embodiments of the present disclosure is shown. The apparatus 500 may be implemented as or included in the electronic device 120. Each module / component in the apparatus 500 may be implemented by hardware, software, firmware or any combination thereof.
[0063] like Figure 5As shown, the device 500 includes a receiving module 510, which is configured to receive user input expressed in natural language. The device 500 also includes a determining module 520, which is configured to determine at least one indicator matching the user input from an indicator index library, the indicator index library includes multiple indicators related to the data table and the query times greater than the query threshold and an indicator template corresponding to each indicator, each indicator template includes indicator information related to the corresponding indicator, data table information and processing information. The device 500 also includes a generating module 530, which is configured to generate a query statement matching the user input based on at least one indicator template corresponding to at least one indicator and a query generation condition, the query statement is related to at least one indicator, and the query statement is computer executable.
[0064] In some embodiments, the generation module 530 is further configured to generate a query statement matching the user input based on the at least one indicator template using a predetermined generation rule in response to the at least one indicator template satisfying the query generation condition.
[0065] In some embodiments, the generation module 530 is further configured to generate a query statement matching the user input based on a prompt word input corresponding to at least one indicator template using a machine learning model in response to at least one indicator template not satisfying a query generation condition.
[0066] In some embodiments, the device 500 also includes a completion module, which is configured to, in response to missing data table information in at least one indicator template, use data table information in a data table index library to complete the missing data table information in at least one indicator template, and the data table index library includes data table information corresponding to multiple indicators; and in response to the completed indicator template satisfying the query generation condition, use predetermined generation rules to generate a query statement that matches the user input based on at least one indicator template.
[0067] In some embodiments, the completion module is also configured to determine data table information that matches the user input from a data table index library, the data table information including at least one data table that matches the user input; filter fields in at least one data table whose correlation with the user input is lower than a correlation threshold to obtain filtered data table information; and use the filtered data table information to complete missing data table information in at least one indicator template.
[0068] In some embodiments, the device 500 also includes a first generation module, which is configured to generate a prompt word input for the machine learning model based on at least one indicator template and processing information matching the user input; provide the prompt word input to the machine learning model to obtain a candidate query statement output by the machine learning model; and generate a query statement matching the user input based on the candidate query statement.
[0069] In some embodiments, the processing information is determined from a processing index library, the processing index library includes processing information corresponding to a plurality of indicators, and the processing information indicates processing logic associated with at least one indicator matching the user input.
[0070] In some embodiments, the device 500 also includes a judgment module, which is configured to generate a candidate query statement as a query statement that matches the user input in response to the candidate query statement satisfying the legality requirements; determine a report corresponding to the illegal candidate query statement in response to the candidate query statement not satisfying the legality requirements; and generate a query statement that matches the user input based on the illegal query statement and the report.
[0071] In some embodiments, the judgment module is also configured to input the report and the illegal candidate query statement into the machine learning model to determine the modified candidate query statement; in response to the modified candidate query statement meeting the legality requirements, the modified candidate query statement is generated as a query statement that matches the user input.
[0072] The units and / or modules included in the device 500 can be implemented in various ways, including software, hardware, firmware, or any combination thereof. In some embodiments, one or more units and / or modules can be implemented using software and / or firmware, such as machine executable instructions stored on a storage medium. In addition to or as an alternative to machine executable instructions, some or all of the units and / or modules in the device 500 can be implemented at least in part by one or more hardware logic components. As an example and not limitation, exemplary types of hardware logic components that can 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.
[0073] It should be understood that one or more steps in the above method can be performed by a suitable electronic device or a combination of electronic devices. Such an electronic device or a combination of electronic devices may include, for example, Figure 1 The electronic device 120 in.
[0074] Figure 6 1 shows a block diagram of an electronic device 600 in which one or more embodiments of the present disclosure may be implemented. It should be understood that Figure 6 The electronic device 600 shown is merely exemplary and should not constitute any limitation on the functionality and scope of the embodiments described herein. Figure 6 The electronic device 600 shown can be used to implement Figure 1 Electronic equipment 120 or Figure 5 Device 500.
[0075] like Figure 6As shown, the electronic device 600 is in the form of a general electronic device. The components of the electronic device 600 may include, but are not limited to, one or more processors or processing units 610, a memory 620, a storage device 630, one or more communication units 640, one or more input devices 650, and one or more output devices 660. The processing unit 610 may be an actual or virtual processor and is capable of performing various processes according to a program stored in the memory 620. In a multi-processor system, multiple processing units execute computer executable instructions in parallel to improve the parallel processing capability of the electronic device 600.
[0076] The electronic device 600 typically includes a plurality of computer storage media. Such media can be any available media accessible to the electronic device 600, including but not limited to volatile and non-volatile media, removable and non-removable media. The memory 620 can be a volatile memory (e.g., registers, caches, random access memory (RAM)), a non-volatile memory (e.g., a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), flash memory) or some combination thereof. The storage device 630 can be a removable or non-removable medium, and can include a machine-readable medium, such as a flash drive, a disk, or any other medium, which can be used to store information and / or data and can be accessed within the electronic device 600.
[0077] The electronic device 600 may further include additional removable / non-removable, volatile / non-volatile storage media. Figure 6 As shown in , a disk drive for reading or writing from a removable, non-volatile disk (e.g., a "floppy disk") and an optical drive for reading or writing from a removable, non-volatile optical disk may be provided. In these cases, each drive may be connected to the bus (not shown) by one or more data media interfaces. The memory 620 may include a computer program product 625 having one or more program modules that are configured to perform various methods or actions of various embodiments of the present disclosure.
[0078] The communication unit 640 implements communication with other electronic devices through a communication medium. Additionally, the functions of the components of the electronic device 600 can be implemented with a single computing cluster or multiple computing machines that can communicate through a communication connection. Therefore, the electronic device 600 can operate in a networked environment using a logical connection with one or more other servers, a network personal computer (PC), or another network node.
[0079] The input device 650 may be one or more input devices, such as a mouse, a keyboard, a tracking ball, etc. The output device 660 may be one or more output devices, such as a display, a speaker, a printer, etc. The electronic device 600 may also communicate with one or more external devices (not shown) through the communication unit 640 as needed, such as a storage device, a display device, etc., communicate with one or more devices that allow a user to interact with the electronic device 600, or communicate with any device that allows the electronic device 600 to communicate with one or more other electronic devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface (not shown).
[0080] According to an exemplary implementation of the present disclosure, a computer-readable storage medium is provided, on which computer-executable instructions are stored, wherein the computer-executable instructions are executed by a processor to implement the method described above. According to an exemplary implementation of the present disclosure, a computer program product is also provided, which is tangibly stored on a non-transitory computer-readable medium and includes computer-executable instructions, and the computer-executable instructions are executed by a processor to implement the method described above.
[0081] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices, equipment, and computer program products implemented according to the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0082] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processing unit of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0083] Computer-readable program instructions can be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, so that the instructions executed on the computer, other programmable data processing apparatus, or other device implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0084] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple implementations of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of a module, program segment or instruction includes one or more executable instructions for realizing the logical function of the specification. In some implementations as replacements, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse 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 realized by a special hardware-based system that performs the function or action of the specification, or can be realized by a combination of special hardware and computer instructions.
[0085] The above descriptions of various implementations of the present disclosure are exemplary, non-exhaustive, and not limited to the disclosed implementations. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described implementations. The selection of terms used herein is intended to best explain the principles of the implementations, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the various implementations disclosed herein.
Claims
1. A method for generating a query statement, comprising: receiving user input in natural language; Determine at least one indicator matching the user input from an indicator index library, wherein the indicator index library includes a plurality of indicators related to the data table and having a query number greater than a query threshold, and an indicator template corresponding to each indicator, wherein each indicator template includes indicator information related to the corresponding indicator, data table information, and processing information; as well as Based on at least one indicator template corresponding to the at least one indicator and a query generation condition, a query statement matching the user input is generated, the query statement is related to the at least one indicator, and the query statement is executable by a computer.
2. The method according to claim 1, wherein generating a query statement matching the user input based on at least one indicator template corresponding to the at least one indicator and a query generation condition comprises: In response to the at least one indicator template satisfying the query generation condition, a query statement matching the user input is generated based on the at least one indicator template using a predetermined generation rule.
3. The method according to claim 2, further comprising: In response to the at least one indicator template not satisfying the query generation condition, a query statement matching the user input is generated based on a prompt word input corresponding to the at least one indicator template using a machine learning model.
4. The method according to claim 2, further comprising: In response to the data table information in the at least one indicator template being missing, using the data table information in the data table index library to complete the missing data table information in the at least one indicator template, the data table index library including data table information corresponding to a plurality of indicators; as well as In response to the completed indicator template satisfying the query generation condition, a query statement matching the user input is generated based on the at least one indicator template using the predetermined generation rule.
5. The method according to claim 4, wherein using the data table information in the data table index library to complete the missing data table information in the at least one indicator template comprises: Determining data table information matching the user input from the data table index library, the data table information including at least one data table matching the user input; Filtering the fields in the at least one data table whose relevance to the user input is lower than a relevance threshold to obtain filtered data table information; as well as The filtered data table information is used to complete the missing data table information in the at least one indicator template.
6. The method according to claim 3, wherein using a machine learning model to generate a query statement matching the user input based on a prompt word input corresponding to the at least one indicator template comprises: generating the prompt word input of the machine learning model based on the at least one indicator template and the processed information matching the user input; Providing the prompt word input to the machine learning model to obtain a candidate query statement output by the machine learning model; as well as Based on the candidate query statements, a query statement matching the user input is generated.
7. The method according to claim 6, wherein the processing information is determined from the processing index library, the processing index library includes processing information corresponding to the multiple indicators, and the processing information indicates processing logic related to the at least one indicator matching the user input.
8. The method according to claim 6, wherein generating a query statement matching the user input based on the candidate query statement comprises: In response to the candidate query statement satisfying the legality requirement, generating the candidate query statement into the query statement matching the user input; In response to the candidate query statement not satisfying the legality requirement, determining a report corresponding to the illegal candidate query statement; as well as Based on the illegal query statement and the report, a query statement matching the user input is generated.
9. The method according to claim 8, generating a query statement matching the user input based on the illegal query statement and the report comprises: Inputting the report and the illegal candidate query statement into the machine learning model to determine a modified candidate query statement; In response to the modified candidate query statement satisfying the legality requirement, the modified candidate query statement is generated as the query statement matching the user input.
10. A device for generating a query statement, comprising: A receiving module configured to receive a user input expressed in a natural language; a determination module configured to determine at least one indicator matching the user input from an indicator index library, wherein the indicator index library includes a plurality of indicators related to the data table and having a query number greater than a query threshold, and an indicator template corresponding to each indicator, wherein each indicator template includes indicator information related to the corresponding indicator, data table information, and processing information; as well as A generation module is configured to generate a query statement matching the user input based on at least one indicator template corresponding to the at least one indicator and a query generation condition, wherein the query statement is related to the at least one indicator and is computer executable.
11. An electronic device, comprising: at least one processing unit; as well as At least one memory, the at least one memory is coupled to the at least one processing unit and stores instructions for execution by the at least one processing unit, the instructions, when executed by the at least one processing unit, cause the electronic device to perform the method according to any one of claims 1 to 9.
12. A computer-readable storage medium having a computer program stored thereon, wherein the computer program can be executed by a processor to implement the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Method and device for generating SQL statements according to natural languages
CN110888897A
Query method and device
CN111008309A
Structured query language generation method and system
CN111984674A
Data query method and device based on semantic recognition, equipment and storage medium
CN112380240A
Data management method and device based on index analysis, equipment and medium
CN113722370A
Cited By
Method, device and equipment for retrieving information, medium and program product
CN119201986A
Intelligent online form template arrangement method for simply fusing form model and Text2SQL (Structured Query Language)
CN119808745A
Index data query method and system and related products
CN121455980A
Method and apparatus for generating visualization result for indicator, device, medium, and product
WO2026137635A1
