Structured query statement generation method and device, medium and program product

By building a database of historical query requests in the database, matching and filtering the target query requests with these historical query requests, and generating SQL statements in combination with the deep learning model, the problem of low SQL generation accuracy in the existing technology is solved, and higher generation accuracy is achieved.

CN119739734APending Publication Date: 2025-04-01INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 6 Cited by

Patent Information

Application Number
CN202411929406.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

In the prior art, query request data and prompt words are directly input into the big model, and the generated SQL query statements are low in accuracy. Especially in complex real business scenarios, it is impossible to accurately locate the database source table corresponding to user needs, resulting in poor generation results.

Method used

By obtaining the target query request and matching it with M historical query requests in the target database, K historical query requests with high similarity are selected, and target SQL statements are generated based on the target language model. This method uses historical query requests in the pre-built target database, and combines the current query request to generate more accurate SQL statements.

Benefits of technology

The accuracy of generated SQL query statements is improved, and the problem of low SQL generation accuracy in the prior art is solved, especially in complex business scenarios, the generation effect is significantly improved by combining actual business knowledge.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119739734A_ABST
    Figure CN119739734A_ABST
Patent Text Reader

Abstract

The invention discloses a structured query statement generation method and device, a medium and a program product. The method relates to the field of artificial intelligence, and comprises the following steps: obtaining a target query request, the target query request comprising a request corresponding to a query operation of a target object on data in a business system of a financial institution; matching the target query request with M historical query requests in a target database to obtain a matching result; based on a matching result, screening out K historical query requests from the M historical query requests; based on the target query request and the K historical query requests, a target SQL statement is generated through the target language model, and the target SQL statement is used for querying data queried by the target query request. Through the method and the device, the problem that the accuracy of the generated SQL query statement is low due to the fact that the query request data and the cue word are directly input into a large model in the related technology is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and in particular, to a method, device, medium and program product for generating a structured query statement. Background Art

[0002] With the rapid development of information technology, database technology has been widely used in various fields. As an important tool for information management, database is of great significance for data storage, query and management. In database applications, Structured Query Language (SQL) is the most commonly used data query and operation language. However, the traditional SQL writing method requires users to have certain database knowledge and programming skills, which has a high threshold for non-professional users.

[0003] In related technologies, SQL is mainly generated through "large language model + prompt words". Figure 1 It is a flowchart generated according to a SQL statement in the related technology of this application, such as Figure 1 In the process on the left, after obtaining the user's query requirements, the prompt word template can be used to generate the final SQL result based on the large language model. Figure 1 As shown on the right side of the diagram, it includes: roles, things to do, library table information, user needs, and requirements. The large language model generally adopts a general large language model, or a large language model that is fine-tuned on a specific natural language to SQL dataset.

[0004] However, in related technologies, when faced with complex real-world business scenarios, due to a lack of actual business knowledge, it is impossible to accurately locate the database source tables corresponding to user needs and to correctly understand user needs, resulting in poor final generation results.

[0005] Currently, no effective solution has been proposed to solve the problem that the accuracy of the generated SQL query statements is low when the query request data and prompt words are directly input into the large model in the related art. Summary of the invention

[0006] The main purpose of the present application is to provide a method, device, medium and program product for generating structured query statements, so as to solve the problem in the related art that directly inputting query request data and prompt words into a large model results in low accuracy of the generated SQL query statements.

[0007] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a method for generating a structured query statement is provided. The method comprises: obtaining a target query request, wherein the target query request comprises: a request corresponding to a query operation performed by a target object on data in a business system of a financial institution; matching the target query request with M historical query requests in a target database to obtain a matching result, wherein the historical query request comprises: a data query request determined based on an SQL query statement of a historical time period, where M is a positive integer; based on the matching result, K historical query requests are screened out from the M historical query requests, where K is a positive integer less than M; based on the target query request and the K historical query requests, a target SQL statement is generated using a target language model, wherein the target SQL statement is used to query the data queried by the target query request, and the target language model comprises: a deep learning model for generating SQL statements that has been pre-trained.

[0008] Furthermore, based on the target query request and the K historical query requests, a target SQL statement is generated using a target language model, including: determining target information involved in the K historical query requests to obtain a first information set, wherein the target information includes at least one of the following: a data table identifier, a field identifier, and an SQL query statement associated with the historical query request; based on the target query request and the first information set, the target SQL statement is generated using the target language model.

[0009] Further, based on the target query request and the first information set, the target SQL statement is generated using the target language model, including: inputting the target query request, the information in the first information set, and a first preset prompt word into the target language model, and outputting a second information set, wherein the first preset prompt word is used to control the target language model to filter the information in the first information set; inputting the target query request, the information in the second information set, and a second preset prompt word into the target language model, and generating the target SQL statement, wherein the second preset prompt word is used to control the target language model to generate the target SQL statement.

[0010] Furthermore, after generating a target SQL statement based on the target query request and K historical query requests using a target language model, it includes: executing the target SQL statement to obtain a query result corresponding to the target query request, and sending the query result to a terminal device used by a target object; receiving feedback data from the terminal device, and determining whether the target SQL statement meets expectations based on the feedback data; and if the target SQL statement meets expectations, adding the target query request and the target SQL statement to the target database.

[0011] Furthermore, the method for generating a structured query statement also includes: when the target SQL statement does not meet expectations, inputting the feedback data and a third preset prompt word into the target language model, and outputting an analysis result, wherein the third preset prompt word is used to control the target language model to analyze the reason why the target SQL statement does not meet expectations based on the feedback data; based on the analysis result, regenerating the target SQL statement.

[0012] Further, the matching result includes: the similarity between each of the M historical query requests and the target query request, and based on the matching result, screening out K historical query requests from the M historical query requests, including: based on the matching result, screening out historical query requests whose similarity with the target query request is greater than a preset similarity threshold from the M historical query requests, to obtain N historical query requests, where N is a positive integer less than M; when N is greater than K, screening out the first K historical query requests from the N historical query requests in order of similarity from large to small.

[0013] Furthermore, the target database is obtained in the following manner: constructing an initial database, wherein the initial database includes: a database without added data; obtaining M historical SQL statements, and extracting a data table identifier and a field identifier in each of the historical SQL statements, wherein the M historical SQL statements include: SQL query statements that were successfully run in the business system during the historical time period; analyzing the query intent of the M historical SQL statements to obtain analysis results, and generating M historical query requests based on the analysis results; adding the M historical query requests, the M historical SQL statements, and the data table identifier and field identifier in each of the historical SQL statements to the initial database to obtain the target database.

[0014] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a device for generating a structured query statement is provided. The device comprises: an acquisition unit, which is used to acquire a target query request, wherein the target query request comprises: a request corresponding to a query operation performed by a target object on data in a business system of a financial institution; a matching unit, which is used to match the target query request with M historical query requests in a target database to obtain a matching result, wherein the historical query request comprises: a data query request determined based on an SQL query statement of a historical time period, where M is a positive integer; a screening unit, which is used to screen out K historical query requests from the M historical query requests based on the matching result, wherein K is a positive integer less than M; a generating unit, which is used to generate a target SQL statement based on the target query request and the K historical query requests using a target language model, wherein the target SQL statement is used to query the data queried by the target query request, and the target language model comprises: a deep learning model for generating SQL statements that has been pre-trained.

[0015] Furthermore, the generation unit includes: a determination subunit, used to determine the target information involved in K of the historical query requests to obtain a first information set, wherein the target information includes at least one of the following: a data table identifier, a field identifier, and an SQL query statement associated with the historical query request; a generation subunit, used to generate the target SQL statement based on the target query request and the first information set using the target language model.

[0016] Furthermore, the generation subunit includes: a processing module, used to input the target query request, the information in the first information set and a first preset prompt word into the target language model, and output a second information set, wherein the first preset prompt word is used to control the target language model to filter the information in the first information set; a generation module, used to input the target query request, the information in the second information set and a second preset prompt word into the target language model, and generate the target SQL statement, wherein the second preset prompt word is used to control the target language model to generate the target SQL statement.

[0017] Furthermore, the device for generating structured query statements also includes: an execution unit, which is used to generate a target SQL statement based on the target query request and K historical query requests using a target language model, and then execute the target SQL statement to obtain a query result corresponding to the target query request, and send the query result to a terminal device used by a target object; a first processing unit, which is used to receive feedback data from the terminal device and determine whether the target SQL statement meets expectations based on the feedback data; and an adding unit, which is used to add the target query request and the target SQL statement to the target database if the target SQL statement meets expectations.

[0018] Furthermore, the device for generating structured query statements also includes: a second processing unit, which is used to input the feedback data and a third preset prompt word into the target language model and output an analysis result when the target SQL statement does not meet expectations, wherein the third preset prompt word is used to control the target language model to analyze the reason why the target SQL statement does not meet expectations based on the feedback data; and a third processing unit, which is used to regenerate the target SQL statement based on the analysis result.

[0019] Further, the matching result includes: the similarity between each of the M historical query requests and the target query request, and the screening unit includes: a first screening subunit, used to screen out historical query requests whose similarity with the target query request is greater than a preset similarity threshold from the M historical query requests based on the matching result, to obtain N historical query requests, where N is a positive integer less than M; and a second screening subunit, used to screen out the first K historical query requests from the N historical query requests in descending order of similarity when N is greater than K.

[0020] Furthermore, the target database is obtained through the following sub-units: a construction sub-unit, which is used to construct an initial database, wherein the initial database includes: a database without added data; a processing sub-unit, which is used to obtain M historical SQL statements and extract the data table identifier and field identifier in each of the historical SQL statements, wherein the M historical SQL statements include: SQL query statements that have been successfully run in the business system during the historical time period; an analysis sub-unit, which is used to analyze the query intent of the M historical SQL statements, obtain analysis results, and generate M historical query requests based on the analysis results; an adding sub-unit, which is used to add the M historical query requests, the M historical SQL statements, and the data table identifier and field identifier in each of the historical SQL statements to the initial database to obtain the target database.

[0021] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored executable program, wherein when the executable program is run, the device where the computer-readable storage medium is located is controlled to execute the method for generating the structured query statement.

[0022] According to another aspect of the present application, an electronic device is provided, comprising: a memory storing an executable program; and a processor for running the program, wherein the method for generating a structured query statement is executed when the program is running.

[0023] According to another aspect of the present application, a computer program product is provided, comprising computer instructions, wherein when the computer instructions are executed by a processor, the steps of the method for generating a structured query statement are implemented.

[0024] In an embodiment of the present application, a target query request is obtained, wherein the target query request includes: a request corresponding to a query operation performed by a target object on data in a business system of a financial institution; the target query request is matched with M historical query requests in a target database to obtain a matching result, wherein the historical query request includes: a data query request determined based on an SQL query statement of a historical time period, where M is a positive integer; based on the matching result, K historical query requests are screened out from the M historical query requests, wherein K is a positive integer less than M; based on the target query request and the K historical query requests, a target SQL statement is generated using a target language model, wherein the target SQL statement is used to query the data queried by the target query request, and the target language model includes: a deep learning model for generating SQL statements that has been pre-trained as a model, thereby solving the technical problem in the related art of directly inputting query request data and prompt words into a large model, resulting in low accuracy of the generated SQL query statement.

[0025] In the present invention, historical query requests that match the query request data are screened out through a pre-built target database, and then SQL statements are generated using a large model based on the screened historical query requests and current query requests, thereby achieving the purpose of combining actual business knowledge (i.e., historical query requests) with current query requests and using the target language model to generate SQL query statements, avoiding the situation in the related art where query request data and prompt words are directly input into the large model, resulting in low accuracy of the generated SQL query statements, thereby achieving the technical effect of improving the accuracy of the SQL query statements generated in the business system. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0027] Figure 1 It is a flowchart generated according to a SQL statement in the related technology of this application;

[0028] Figure 2 A hardware structure block diagram of a computer terminal for implementing a method for generating a structured query statement is shown;

[0029] Figure 3 It is a flowchart of a method for generating a structured query statement according to an embodiment of the present application;

[0030] Figure 4 is a flowchart of another method for generating a structured query statement provided according to an embodiment of the present application;

[0031] Figure 5 is a schematic diagram of a device for generating a structured query statement according to an embodiment of the present application;

[0032] Figure 6 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0033] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0035] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:

[0036] Large Language Model (LLM): A deep learning model trained based on massive text data. The "large model" in the embodiments of the present application also refers to a large language model.

[0037] Prompt: In the fields of computer science and artificial intelligence, especially natural language processing and machine learning, a short piece of text or instruction is used to guide a model to generate output or perform a specific task. In natural language processing, a prompt can be a question, a command, or any text that can inspire the model to produce a relevant answer.

[0038] Structured Query Language (SQL): is a special purpose programming language, a database query and programming language used to access data and query, update and manage relational database systems.

[0039] Vector database: a database used to store and query vectors. The vectors stored in it come from the vectorization of text, speech, images, videos, etc.

[0040] Vector similarity retrieval: is a form of database retrieval that focuses on finding the vector that is most similar to the query vector. In machine learning, vectors are often used to represent features of data. For example, in image recognition, images can be represented by feature vectors. Vector similarity retrieval allows finding vectors that are close to a specific query vector in feature space and can be used in many applications, such as recommendation systems, image retrieval, speech recognition, and natural language processing.

[0041] Retrieval-Augmented Generation (RAG): is a model that combines retrieval and generation techniques. It generates answers or content by referencing information from an external knowledge base. It has strong interpretability and customization capabilities and is suitable for multiple natural language processing tasks such as question-answering systems, document generation, and intelligent assistants. The advantages of the RAG model are its strong versatility, instant knowledge updates, and more efficient and accurate information services through end-to-end evaluation methods.

[0042] It should be noted that the collected information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this application are information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data are in compliance with relevant laws, regulations and standards, necessary confidentiality measures are taken, and public order and good customs are not violated, and corresponding operation entrances are provided for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or institutions to provide users with corresponding operation entrances for users to choose to agree or refuse the results of automated decision-making; if the user chooses to refuse, the expert decision-making process will be entered.

[0043] Embodiment 1

[0044] According to an embodiment of the present application, a method embodiment of a method for generating a structured query statement is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0045] The method embodiment provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 2 The hardware structure block diagram of a computer terminal (or mobile device) for implementing a method for generating a structured query statement is shown. Figure 2 As shown, the computer terminal 20 (or mobile device) may include one or more (202a, 202b, ..., 202n are used to illustrate) processors 202 (the processor 202 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 204 for storing data, and a transmission device 206 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 2 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 2 More or fewer components as shown, or with Figure 2 Different configurations shown.

[0046] It should be noted that the one or more processors 202 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 20 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0047] The memory 204 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the method for generating structured query statements in the embodiment of the present application. The processor 202 executes various functional applications and data processing by running the software programs and modules stored in the memory 204, that is, the method for generating structured query statements described above is realized. The memory 204 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 204 may further include a memory remotely arranged relative to the processor 202, and these remote memories may be connected to the computer terminal 20 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0048] The transmission device 206 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 20. In one example, the transmission device 206 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 206 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0049] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 20 (or mobile device).

[0050] Under the above operating environment, this application provides Figure 3 The method for generating the structured query statement shown. Figure 3 It is a flowchart of a method for generating a structured query statement according to the first embodiment of the present application.

[0051] Step S301, obtaining a target query request, wherein the target query request includes: a request corresponding to a query operation performed by a target object on data in a business system of a financial institution.

[0052] The above-mentioned target query request may include: a request corresponding to a query operation performed by a target object on data in a business system of a financial institution. The above-mentioned target object may include but is not limited to: a user, a worker of a financial institution.

[0053] Step S302, matching the target query request with M historical query requests in the target database to obtain a matching result, wherein the historical query request includes: a data query request determined based on an SQL query statement in a historical time period, and M is a positive integer.

[0054] The above-mentioned target database may record: M historical query requests, the SQL query statement of each historical query request, the data table name and field involved in each historical query request, etc. The historical query request may include: based on the SQL query statements that have been successfully run in the business system in the past, using an intelligent agent (such as a large model) to analyze these SQL query statements, understand the intention of the statements, and thus infer the query request corresponding to the statement. The historical query request may also include: the query request of the user that can be directly obtained in the historical time period and the corresponding SQL query statement.

[0055] In this embodiment, the target query request can be vectorized to obtain a processed target query request, the similarity between the processed target query request and the vectorized data corresponding to M historical query requests is calculated, and the matching results of the M historical query requests and the target query request in the target database are determined based on the similarity.

[0056] Step S303: based on the matching results, K historical query requests are screened out from the M historical query requests, where K is a positive integer less than M.

[0057] The above matching result may include: the similarity between each of the M historical query requests and the target query request, and then the M historical query requests may be screened in descending order of similarity to obtain K historical query requests.

[0058] Step S304, based on the target query request and K historical query requests, using the target language model, generate a target SQL statement, wherein the target SQL statement is used to query the data queried by the target query request, and the target language model includes: a deep learning model that has been pre-trained for generating SQL statements.

[0059] The above-mentioned target language model may include: a large language model, which can obtain the table names, fields, field definitions, and actually executed SQL query statements involved in K historical query requests in this embodiment, and then the target language model can generate a target SQL statement based on the target query request, the table names, fields, field definitions, and actually executed SQL query statements involved in the K historical query requests, and preset prompt words. This avoids the situation in the related art where the SQL query statements are generated only based on prompt words and query requests without combining specific business scenarios, and the accuracy of the generated SQL query statements is low, thereby achieving the technical effect of improving the accuracy of SQL query statement generation.

[0060] Through the above steps, in this embodiment, the historical query requests matching the query request data are screened out through the pre-built target database, and then based on the screened historical query requests and the current query request, the SQL statement is generated using the big model, so as to achieve the purpose of combining the actual business knowledge (i.e., the historical query request) with the current query request, and generating the SQL query statement using the target language model, thereby avoiding the situation in the related art where the query request data and the prompt word are directly input into the big model, and the accuracy of the generated SQL query statement is low, thereby achieving the technical effect of improving the accuracy of the SQL query statement generated in the business system. This solves the technical problem in the related art where the query request data and the prompt word are directly input into the big model, and the accuracy of the generated SQL query statement is low.

[0061] Optionally, in the method for generating structured query statements provided in an embodiment of the present application, a target SQL statement is generated based on a target query request and K historical query requests using a target language model, including: determining target information involved in the K historical query requests to obtain a first information set, wherein the target information includes at least one of the following: a data table identifier, a field identifier, and an SQL query statement associated with the historical query request; and generating a target SQL statement based on the target query request and the first information set using a target language model.

[0062] The above-mentioned target information may include but is not limited to: data table identifier, field identifier, field definition and SQL query statement associated with historical query request. The data table identifier may include the name of the data table (referred to as table name), and the field identifier may include: the name of the field in the data table (referred to as field name).

[0063] In this embodiment, the data table identifier, field identifier and corresponding SQL query statement associated with each historical query request in the K historical query requests can be read in the target database to obtain a first information set. Then, based on the target query request, the data table identifier and field identifier in the first information set can be filtered using the target language model to obtain a filtered first information set, and then the target SQL statement can be generated based on the target query request and the filtered first information set using the target language model.

[0064] The target SQL statement is generated using the target language model through the data tables, fields and SQL query statements involved in the target query request and the historical query request, thereby avoiding the situation in the related technology where only the target query request is input into the large language model to generate the SQL query statement, resulting in inaccurate results, thereby achieving the technical effect of improving the accuracy of SQL query statement generation.

[0065] Optionally, in the method for generating a structured query statement provided in an embodiment of the present application, a target SQL statement is generated based on a target query request and a first information set using a target language model, including: inputting the target query request, information in the first information set, and a first preset prompt word into the target language model, and outputting a second information set, wherein the first preset prompt word is used to control the target language model to filter the information in the first information set; inputting the target query request, information in the second information set, and a second preset prompt word into the target language model, and generating a target SQL statement, wherein the second preset prompt word is used to control the target language model to generate a target SQL statement.

[0066] The above-mentioned first preset prompt word can be used to control the target language model to filter the information in the first information set. For example, the first preset prompt word may include: filtering the data table identifier and field identifier in the first information set based on the query content involved in the target query request. The above-mentioned second preset prompt word can be used to control the target language model to generate a target SQL statement. For example, the second preset prompt word may include: based on the query content involved in the target query request and the data table identifier and field identifier in the second information set, generating an SQL query statement for querying the data queried by the target query request.

[0067] In this embodiment, the target query request, the information in the first information set, and the first preset prompt word can be input into the target language model to filter the information in the first information set to obtain a second information set. The information is filtered through the target language model, thereby achieving the technical effect of improving the efficiency of information screening.

[0068] After obtaining the second information set, the target query request, the information in the second information set, and the second preset prompt word may be input into the target language model to generate a target SQL statement.

[0069] In this embodiment, the target language model is first used to filter the data table identifier, field identifier and other information involved in the historical query request. Based on the filtered information, the target language model is used to generate the target SQL statement, thereby achieving the technical effect of improving the accuracy of the SQL query statement.

[0070] Optionally, in the method for generating structured query statements provided in an embodiment of the present application, after generating a target SQL statement based on a target query request and K historical query requests using a target language model, it includes: executing the target SQL statement, obtaining a query result corresponding to the target query request, and sending the query result to a terminal device used by the target object; receiving feedback data from the terminal device, and determining whether the target SQL statement meets expectations based on the feedback data; and if the target SQL statement meets expectations, adding the target query request and the target SQL statement to the target database.

[0071] In this embodiment, after the target SQL statement is generated, the target SQL statement can be executed in the database of the business system to query the data queried by the target query request to obtain the query result, and then the query result can be sent to the terminal device used by the target object for display. In order to facilitate the determination of whether the query result is accurate, the terminal device can also be used to receive feedback data from the target object, and determine whether the target SQL statement meets expectations based on the feedback data, that is, whether the query result is accurate.

[0072] When the target SQL statement meets expectations, the target query request and the target SQL statement can be added to the target database, and the target database can be updated to provide more reference information for subsequent new query requirements and improve the accuracy of SQL query statement generation.

[0073] When the target SQL statement does not meet expectations, the reason why the target SQL statement meets expectations can be analyzed, and the target SQL statement can be regenerated based on the analyzed reason to improve the accuracy of the generated SQL query statement.

[0074] Optionally, in the method for generating a structured query statement provided in an embodiment of the present application, the method for generating a structured query statement also includes: when the target SQL statement does not meet expectations, inputting feedback data and a third preset prompt word into a target language model, and outputting an analysis result, wherein the third preset prompt word is used to control the target language model to analyze the reason why the target SQL statement does not meet expectations based on the feedback data; and regenerating the target SQL statement based on the analysis result.

[0075] The third preset prompt word mentioned above can be used to control the target language model to analyze the reason why the target SQL statement does not meet expectations based on the feedback data.

[0076] In order to improve the analysis efficiency of the reasons why the target SQL statement does not meet expectations, the target language model can be used to analyze the reasons why the target SQL statement does not meet expectations. For example, the feedback data and the third preset prompt word can be input into the target language model, and the analysis result can be output. Then, based on the analysis result, the target SQL statement can be regenerated. For example, if the analysis result indicates that the reason why the target SQL statement does not meet expectations is that the user demand description is vague, the target query request can be reacquired; if the reason why the target SQL statement does not meet expectations is that the matching effect with the historical query request in the target database is not ideal, the retrieval relevance score threshold can be lowered to obtain more reference information of historical query requests; if the reason why the target SQL statement does not meet expectations is that the data table identifier (for example, table name) and field identifier are extracted incorrectly, the target language model can be used to re-screen the information in the first information set (for example, data table identifier, field identifier), and then the target language model can be used to re-generate the target SQL statement.

[0077] The target SQL statement is regenerated according to the feedback data of the target object, thereby achieving the purpose of improving the accuracy of the generated SQL statement and realizing the technical effect of improving the user experience.

[0078] Optionally, in the method for generating a structured query statement provided in an embodiment of the present application, the matching result includes: the similarity between each historical query request in M ​​historical query requests and the target query request, and based on the matching result, K historical query requests are screened out from the M historical query requests, including: based on the matching result, from the M historical query requests, historical query requests whose similarity with the target query request is greater than a preset similarity threshold are screened out to obtain N historical query requests, where N is a positive integer less than M; when N is greater than K, the first K historical query requests are screened out from the N historical query requests in order of similarity from large to small.

[0079] The above matching result includes: the similarity between each of the M historical query requests and the target query request.

[0080] In this embodiment, historical query requests whose similarity with the target query request is greater than a preset similarity threshold can be screened out from the historical query requests to obtain N historical query requests. If N is greater than K, the first K historical query requests are screened out from the N historical query requests in descending order of similarity. If N is equal to K, the N historical query requests can be directly determined as K historical query requests. If N is less than K, the preset similarity threshold can also be adjusted so that the number of historical query requests that can be screened out according to the preset similarity threshold is greater than K, so that K historical query requests can be screened out from the N historical query requests.

[0081] In this embodiment, K historical query requests with higher similarity are screened out from M historical query requests in the target database according to a preset similarity threshold, thereby achieving the purpose of screening out historical query requests related to the target query request from the existing historical query requests.

[0082] Optionally, in the method for generating structured query statements provided in an embodiment of the present application, the target database is obtained in the following manner: constructing an initial database, wherein the initial database includes: a database without added data; obtaining M historical SQL statements, and extracting a data table identifier and a field identifier in each historical SQL statement, wherein the M historical SQL statements include: SQL query statements that were successfully run in the business system during a historical time period; analyzing the query intent of the M historical SQL statements to obtain analysis results, and generating M historical query requests based on the analysis results; adding the M historical query requests, the M historical SQL statements, and the data table identifier and field identifier in each historical SQL statement to the initial database to obtain the target database.

[0083] In this embodiment, an initial database can be constructed, and then M historical SQL statements can be obtained, and the data table identifiers (table names) and field identifiers (field names) involved in the historical SQL statements can be extracted. The query intent of each historical SQL statement can also be inferred, and M historical query requests can be generated according to the corresponding query intent. For example, the historical SQL statements and preset prompt words can be input into a large model, and the large model can be used to infer the query intent of each historical SQL statement, and M historical query requests can be generated according to the corresponding query intent. The M historical query requests, M historical SQL statements, and the data table identifiers, field identifiers, and field definitions in each historical SQL statement are added to the initial database to obtain the target database.

[0084] Figure 4 is a flowchart of another method for generating a structured query statement according to an embodiment of the present application, such as Figure 4 As shown, including:

[0085] Preparation: After obtaining the SQL query statements (corresponding to M historical SQL statements) that have been successfully run in the business system in the past (i.e., historical time period), use an intelligent agent (e.g., a large model) to analyze these SQL query statements, understand the intent of the statements, and thus infer the user needs corresponding to the statements (corresponding to M historical query requests), and vectorize the inferred user demand strings. At the same time, parse out the data table names and fields involved, and form a demand data with the inferred query needs and actual SQL query statements, and store them in the demand library (corresponding to the target database) for backup.

[0086] In the first step, after receiving the user query requirement (corresponding to the target query request), the text of the user query requirement can be vectorized. The vectorization method here should be consistent with the vectorization method in the preparation work, so as to ensure that the text is mapped to the same vector space, which is convenient for subsequent similarity matching and retrieval.

[0087] In the second step, the user's query requirements are matched with the existing requirements (historical query requests) in the requirement library (target database) for similarity, and the K most relevant historical requirements are retrieved to obtain the table names, fields, field definitions, and actually executed SQL query statements involved in these historical requirements.

[0088] The third step is to submit the user query requirements and the relevant information queried in the second step to the big model, and use the big model to select and decide on table names and fields.

[0089] The fourth step is to submit the user's query requirements, the table names and fields selected in the third step to the big model, generate the SQL query statement (target SQL statement), and get the final result.

[0090] In the fifth step, the user executes the SQL query statement in the database system of the business system and provides feedback. If the generated SQL query statement meets the user's query requirements, the user's query requirements, the table names and fields obtained by the intermediate query process, and the final generated SQL will be stored in the requirements library, thereby providing more reference information for subsequent new query requirements. If the generated SQL query statement does not meet the user's query requirements, the above content will be handed over to the big model again to analyze the reasons. If the reason is that the user's query requirements are vague, return to the first step to collect user query requirements again; if the reason is that the matching effect is not ideal, return to the second step, lower the retrieval relevance score threshold (corresponding to the preset similarity threshold), and obtain more reference information; if the reason is that the table name and field extraction are incorrect, return to the third step and re-analyze the table name and field.

[0091] In this embodiment, a large language model, vector database, vector similarity retrieval and other technical means are comprehensively utilized to first collect and analyze the SQL that has been successfully executed in the database system to form a corresponding expert knowledge base (target database); when a new user demand (corresponding to a target query request) is received, the new demand and past demand (corresponding to a historical query request), the new demand and the full database table description are matched to obtain the library table information on which the new demand depends and the SQL successfully executed for the past demand as a reference, thereby obtaining more accurate business background information, improving the accuracy of SQL generation, and overcoming the problem of poor performance of large language models in existing solutions in complex real business scenarios, so as to improve the accuracy of generated SQL statements.

[0092] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0093] Embodiment 2

[0094] The embodiment of the present application also provides a structured query statement generation device. It should be noted that the structured query statement generation device of the embodiment of the present application can be used to execute the structured query statement generation method provided in the embodiment of the present application. The structured query statement generation device provided in the embodiment of the present application is introduced below.

[0095] According to an embodiment of the present application, a device for implementing the above structured query statement generation method is also provided, such as Figure 5 As shown, the device includes: an acquisition unit 51, a matching unit 52, a screening unit 53 and a generation unit 54.

[0096] An acquisition unit 51 is used to acquire a target query request, wherein the target query request includes: a request corresponding to a query operation performed by a target object on data in a business system of a financial institution;

[0097] A matching unit 52 is used to match the target query request with M historical query requests in the target database to obtain a matching result, wherein the historical query request includes: a data query request determined based on an SQL query statement in a historical time period, and M is a positive integer;

[0098] A screening unit 53, configured to screen out K historical query requests from the M historical query requests based on the matching results, where K is a positive integer less than M;

[0099] The generation unit 54 is used to generate a target SQL statement based on the target query request and K historical query requests using a target language model, wherein the target SQL statement is used to query the data queried by the target query request, and the target language model includes: a deep learning model that has been pre-trained for generating SQL statements.

[0100] In the structured query statement generation device provided by the embodiment of the present application, the target query request can be obtained by the acquisition unit 51, wherein the target query request includes: the request corresponding to the query operation of the target object on the data in the business system of the financial institution, and the target query request is matched with M historical query requests in the target database by the matching unit 52 to obtain a matching result, wherein the historical query request includes: the data query request determined by the SQL query statement of the historical time period, M is a positive integer, and the screening unit 53 screens out K historical query requests from the M historical query requests based on the matching result, wherein K is a positive integer less than M, and the generation unit 54 generates a target SQL statement based on the target query request and the K historical query requests using the target language model, wherein the target SQL statement is used to query the data queried by the target query request, and the target language model includes: a deep learning model for generating SQL statements that has been pre-trained by the model. Thus, the technical problem of low accuracy of the generated SQL query statement by directly inputting the query request data and the prompt word into the large model in the related art is solved.

[0101] In the present invention, historical query requests that match the query request data are screened out through a pre-built target database, and then SQL statements are generated using a large model based on the screened historical query requests and current query requests, thereby achieving the purpose of combining actual business knowledge (i.e., historical query requests) with current query requests and using the target language model to generate SQL query statements, avoiding the situation in the related art where query request data and prompt words are directly input into the large model, resulting in low accuracy of the generated SQL query statements, thereby achieving the technical effect of improving the accuracy of the SQL query statements generated in the business system.

[0102] Optionally, in the structured query statement generation device provided in the embodiment of the present application, the generation unit includes: a determination subunit, used to determine the target information involved in K historical query requests to obtain a first information set, wherein the target information includes at least one of the following: a data table identifier, a field identifier, and an SQL query statement associated with the historical query request; a generation subunit, used to generate a target SQL statement based on the target query request and the first information set using a target language model.

[0103] Optionally, in the structured query statement generation device provided in the embodiment of the present application, the generation subunit includes: a processing module, used to input the target query request, information in the first information set, and a first preset prompt word into the target language model, and output a second information set, wherein the first preset prompt word is used to control the target language model to filter the information in the first information set; a generation module, used to input the target query request, information in the second information set, and a second preset prompt word into the target language model, and generate a target SQL statement, wherein the second preset prompt word is used to control the target language model to generate a target SQL statement.

[0104] Optionally, in the structured query statement generation device provided in the embodiment of the present application, the structured query statement generation device also includes: an execution unit, which is used to generate a target SQL statement based on the target query request and K historical query requests using a target language model, and then execute the target SQL statement to obtain a query result corresponding to the target query request, and send the query result to a terminal device used by the target object; a first processing unit, which is used to receive feedback data from the terminal device and determine whether the target SQL statement meets expectations based on the feedback data; and an adding unit, which is used to add the target query request and the target SQL statement to the target database when the target SQL statement meets expectations.

[0105] Optionally, in the structured query statement generation device provided in the embodiment of the present application, the structured query statement generation device also includes: a second processing unit, used to input feedback data and a third preset prompt word into a target language model when the target SQL statement does not meet expectations, and output an analysis result, wherein the third preset prompt word is used to control the target language model to analyze the reason why the target SQL statement does not meet expectations based on the feedback data; and a third processing unit, used to regenerate the target SQL statement based on the analysis result.

[0106] Optionally, in the structured query statement generation device provided in the embodiment of the present application, the matching result includes: the similarity between each historical query request in the M historical query requests and the target query request, and the screening unit includes: a first screening sub-unit, which is used to screen out historical query requests whose similarity with the target query request is greater than a preset similarity threshold from the M historical query requests based on the matching result, to obtain N historical query requests, where N is a positive integer less than M; and a second screening sub-unit, which is used to screen out the top K historical query requests from the N historical query requests in order of similarity from large to small when N is greater than K.

[0107] Optionally, in the structured query statement generation device provided in the embodiment of the present application, the target database is obtained through the following sub-units: a construction sub-unit, used to construct an initial database, wherein the initial database includes: a database without added data; a processing sub-unit, used to obtain M historical SQL statements, and extract the data table identifier and field identifier in each historical SQL statement, wherein the M historical SQL statements include: SQL query statements that have been successfully run in the business system during the historical time period; an analysis sub-unit, used to analyze the query intent of the M historical SQL statements, obtain analysis results, and generate M historical query requests based on the analysis results; an adding sub-unit, used to add the M historical query requests, the M historical SQL statements, and the data table identifier and field identifier in each historical SQL statement to the initial database to obtain the target database.

[0108] It should be noted that the acquisition unit 51, matching unit 52, screening unit 53 and generation unit 54 described above correspond to steps S301 to S304 in Embodiment 1, and the examples and application scenarios implemented by the two modules and the corresponding steps are the same, but are not limited to the contents disclosed in Embodiment 1 described above. It should be noted that the modules or units described above may be hardware components or software components stored in a memory (e.g., memory 204) and processed by one or more processors (e.g., processors 202a, 202b, ..., 202n), and the modules described above may also be run in the computer terminal 20 provided in Embodiment 1 as part of the device.

[0109] Embodiment 3

[0110] An embodiment of the present application may provide an electronic device, Figure 6 is a structural block diagram of an electronic device according to an embodiment of the present application. Figure 6 As shown, the electronic device may include: one or more ( Figure 6 (only one is shown) processor 1002, memory 1004, storage controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.

[0111] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the above-mentioned method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0112] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: obtain a target query request, wherein the target query request includes: a request corresponding to a query operation performed by a target object on data in a business system of a financial institution; match the target query request with M historical query requests in a target database to obtain a matching result, wherein the historical query request includes: a data query request determined based on an SQL query statement in a historical time period, where M is a positive integer; based on the matching result, filter out K historical query requests from the M historical query requests, where K is a positive integer less than M; based on the target query request and the K historical query requests, generate a target SQL statement using a target language model, wherein the target SQL statement is used to query the data queried by the target query request, and the target language model includes: a deep learning model that has been pre-trained for generating SQL statements.

[0113] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: based on the target query request and K historical query requests, using the target language model, generate a target SQL statement, including: determining the target information involved in the K historical query requests to obtain a first information set, wherein the target information includes at least one of the following: a data table identifier, a field identifier, and an SQL query statement associated with the historical query request; based on the target query request and the first information set, using the target language model, generate a target SQL statement.

[0114] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: based on the target query request and the first information set, using the target language model, generate a target SQL statement, including: inputting the target query request, the information in the first information set, and the first preset prompt word into the target language model, and outputting the second information set, wherein the first preset prompt word is used to control the target language model to filter the information in the first information set; inputting the target query request, the information in the second information set, and the second preset prompt word into the target language model, and generating a target SQL statement, wherein the second preset prompt word is used to control the target language model to generate the target SQL statement.

[0115] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: after generating the target SQL statement based on the target query request and K historical query requests using the target language model, it includes: executing the target SQL statement, obtaining the query result corresponding to the target query request, and sending the query result to the terminal device used by the target object; receiving feedback data from the terminal device, and determining whether the target SQL statement meets expectations based on the feedback data; if the target SQL statement meets expectations, adding the target query request and the target SQL statement to the target database.

[0116] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: The method for generating a structured query statement also includes: when the target SQL statement does not meet expectations, inputting feedback data and a third preset prompt word into a target language model, and outputting an analysis result, wherein the third preset prompt word is used to control the target language model to analyze the reason why the target SQL statement does not meet expectations based on the feedback data; based on the analysis result, regenerating the target SQL statement.

[0117] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: the matching results include: the similarity between each historical query request in the M historical query requests and the target query request, and based on the matching results, K historical query requests are screened out from the M historical query requests, including: based on the matching results, from the M historical query requests, historical query requests whose similarity with the target query request is greater than a preset similarity threshold are screened out to obtain N historical query requests, where N is a positive integer less than M; when N is greater than K, the first K historical query requests are screened out from the N historical query requests in order of similarity from large to small.

[0118] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: the target database is obtained in the following manner: constructing an initial database, wherein the initial database includes: a database without added data; obtaining M historical SQL statements, and extracting the data table identifier and field identifier in each historical SQL statement, wherein the M historical SQL statements include: SQL query statements that have been successfully run in the business system in a historical time period; analyzing the query intent of the M historical SQL statements to obtain analysis results, and generating M historical query requests based on the analysis results; adding the M historical query requests, the M historical SQL statements, and the data table identifier and field identifier in each historical SQL statement to the initial database to obtain the target database.

[0119] By adopting the embodiment of the present application, the historical query requests matching the query request data are screened out through the pre-built target database, and then based on the screened historical query requests and the current query request, the SQL statement is generated using the big model, so as to achieve the purpose of combining the actual business knowledge (i.e., the historical query request) with the current query request, and generating the SQL query statement using the target language model, thereby avoiding the situation in the related art where the query request data and the prompt word are directly input into the big model, and the accuracy of the generated SQL query statement is low, thereby achieving the technical effect of improving the accuracy of the SQL query statement generated in the business system. In addition, the technical problem in the related art where the query request data and the prompt word are directly input into the big model, and the accuracy of the generated SQL query statement is low is solved.

[0120] It can be understood by those skilled in the art that Figure 6 The structure shown is for illustration only, and the electronic device may also be a smart phone, a tablet computer, a PDA, a mobile Internet device (MID), a PAD or other terminal device. Figure 6 The structure of the electronic device is not limited. Figure 6 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 6 Different configurations are shown.

[0121] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0122] Embodiment 4

[0123] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the method for generating structured query statements provided in the first embodiment.

[0124] Optionally, in this embodiment, the above storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.

[0125] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing the steps of the method for generating a structured query statement.

[0126] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0127] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0128] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0129] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0130] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0131] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0132] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for generating a structured query statement, characterized in that: include: Obtaining a target query request, wherein the target query request includes: a request corresponding to a query operation performed by a target object on data in a business system of a financial institution; Matching the target query request with M historical query requests in the target database to obtain a matching result, wherein the historical query request includes: a data query request determined based on an SQL query statement in a historical time period, and M is a positive integer; Based on the matching results, K historical query requests are screened out from the M historical query requests, where K is a positive integer less than M; Based on the target query request and the K historical query requests, a target SQL statement is generated using a target language model, wherein the target SQL statement is used to query the data queried by the target query request, and the target language model includes: a deep learning model that has been pre-trained for generating SQL statements.

2. The method for generating a structured query statement according to claim 1, characterized in that: Based on the target query request and the K historical query requests, a target SQL statement is generated using a target language model, including: Determine the target information involved in the K historical query requests to obtain a first information set, wherein the target information includes at least one of the following: a data table identifier, a field identifier, and an SQL query statement associated with the historical query request; Based on the target query request and the first information set, the target SQL statement is generated using the target language model.

3. The method for generating a structured query statement according to claim 2, characterized in that: Based on the target query request and the first information set, the target SQL statement is generated using the target language model, including: Inputting the target query request, the information in the first information set, and a first preset prompt word into the target language model, and outputting a second information set, wherein the first preset prompt word is used to control the target language model to filter the information in the first information set; The target query request, the information in the second information set, and a second preset prompt word are input into the target language model to generate the target SQL statement, wherein the second preset prompt word is used to control the target language model to generate the target SQL statement.

4. The method for generating a structured query statement according to claim 1, characterized in that: After generating a target SQL statement based on the target query request and the K historical query requests by using a target language model, the method further includes: Execute the target SQL statement to obtain a query result corresponding to the target query request, and send the query result to a terminal device used by the target object; receiving feedback data from the terminal device, and determining whether the target SQL statement meets expectations based on the feedback data; When the target SQL statement meets expectations, the target query request and the target SQL statement are added to the target database.

5. The method for generating a structured query statement according to claim 4, characterized in that: The method further comprises: In the case that the target SQL statement does not meet expectations, the feedback data and a third preset prompt word are input into the target language model, and an analysis result is output, wherein the third preset prompt word is used to control the target language model to analyze the reason why the target SQL statement does not meet expectations based on the feedback data; Based on the analysis result, the target SQL statement is regenerated.

6. The method for generating a structured query statement according to claim 1, characterized in that: The matching result includes: the similarity between each of the M historical query requests and the target query request, and based on the matching result, screening out K historical query requests from the M historical query requests, including: Based on the matching result, historical query requests whose similarity with the target query request is greater than a preset similarity threshold are screened out from the M historical query requests to obtain N historical query requests. N is a positive integer less than M; When N is greater than K, the first K historical query requests are screened out from the N historical query requests in descending order of similarity.

7. The method for generating a structured query statement according to claim 1, characterized in that: The target database is obtained by: Constructing an initial database, wherein the initial database includes: a database without data added; Acquire M historical SQL statements, and extract a data table identifier and a field identifier in each of the historical SQL statements, wherein the M historical SQL statements include: SQL query statements that are successfully executed in the business system during the historical time period; Analyze the query intentions of the M historical SQL statements to obtain analysis results, and generate M historical query requests based on the analysis results; The M historical query requests, the M historical SQL statements, and the data table identifier and field identifier in each historical SQL statement are added to the initial database to obtain the target database.

8. A device for generating a structured query statement, characterized in that: include: An acquisition unit is used to acquire a target query request, wherein the target query request includes: a request corresponding to a query operation performed by a target object on data in a business system of a financial institution; A matching unit, configured to match the target query request with M historical query requests in a target database to obtain a matching result, wherein the historical query request includes: a data query request determined based on an SQL query statement in a historical time period, and M is a positive integer; A screening unit, configured to screen out K historical query requests from the M historical query requests based on the matching result, where K is a positive integer less than M; A generation unit is used to generate a target SQL statement based on the target query request and K historical query requests using a target language model, wherein the target SQL statement is used to query the data queried by the target query request, and the target language model includes: a deep learning model that has been pre-trained for generating SQL statements.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is run, the device where the computer-readable storage medium is located is controlled to execute the method for generating a structured query statement according to any one of claims 1 to 7.

10. A computer program product comprising computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the method for generating a structured query statement according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Intelligent agent-based statement conversion method and device, electronic equipment and storage medium

    CN120804302A

  • Agent-based sentence conversion method and device, electronic equipment and storage medium

    CN120804302B

  • Query statement generation method and electronic equipment

    CN121029953A

  • A query statement generation method and an electronic device

    CN121029953B

  • Information reporting method and system and related product

    CN121619215A