Method for generating structured query language, system, and electronic device
By detecting the client's query information to be converted, obtaining matching database information and generating prompt information, and using dialogue model to analyze and output structured query language, the problem of generating SQL statements in the prior art is solved, and a more accurate and practical generation effect is achieved.
Patent Information
- Application Number
- PCT/CN2024/126843
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-05
- Filing Date
- 2024-10-23
- Publication Date
- 2025-06-12
AI Technical Summary
In the prior art, a structured query language is generated only through the mapping of natural language to SQL statements, which is problematic and difficult to apply, and SQL statements matching database information cannot be effectively generated.
By detecting the client's query information to be converted, the database information matching the structured query language to be converted is obtained, and prompt information is generated based on this, input it into the dialogue model for analysis, and output the structured query language.
It improves the accuracy and fit of the structured query language generated and the practical application, and solves the problem that the structured query language cannot be effectively generated.
Smart Images

Figure CN2024126843_12062025_PF_FP_ABST
Abstract
Description
Structured query language generation method, system and electronic device
[0001] This disclosure claims priority to Chinese patent application number 2023116599411, filed with the China Patent Office on December 5, 2023, and entitled “Method, system and electronic device for generating structured query language,” the entire contents of which are incorporated by reference into this disclosure. Technical Field
[0002] The present disclosure relates to the fields of large model technology and application development, and in particular to a method, system, and electronic device for generating a structured query language. Background Art
[0003] In the era of big data, data development has become a crucial task. Among these tasks, quickly determining Structured Query Language (SQL) statements to improve production efficiency is crucial.
[0004] In related technologies, SQL can only be determined through a traditional natural language to SQL (NL2SQL) model that converts natural language into executable SQL statements. This technology determines SQL statements based solely on the mapping between natural language (NL) and SQL statements. However, it lacks the modeling of database information that matches the SQL statements, making it unrealistic and difficult to apply to actual data development. Therefore, the technical problem of being unable to effectively generate structured query language still exists.
[0005] Currently, no effective solutions have been proposed for the above technical problems.
[0006] Summary of the Invention
[0007] The embodiments of the present disclosure provide a method, system, and electronic device for generating a structured query language, so as to at least solve the technical problem of low efficiency in data scheduling.
[0008] According to one aspect of an embodiment of the present disclosure, a method for generating structured query language (SQL) is provided. The method, applied in a cloud environment, may include the following steps: detecting query information to be converted from a client, wherein the query information is used to represent the semantics of the SQL to be converted; obtaining database information matching the SQL to be converted, wherein the database information is used to represent the data structure required to execute an operation function corresponding to the SQL to be converted in the database; generating prompt information based at least on the database information; inputting the prompt information into a dialogue model, and using the dialogue model to analyze the query information and database information in the prompt information to output the SQL.
[0009] According to another aspect of an embodiment of the present disclosure, a model generation method is provided. The method may include the following steps: obtaining a database information sample set corresponding to a structured query language sample set; inputting the database information sample set into an initial dialogue model, analyzing the database information sample set using the initial dialogue model, and outputting a query information sample set corresponding to the structured query language sample set, wherein the initial dialogue model is trained based at least on the initial structured query language sample set, and the query information samples in the query information sample set are used to represent the semantics of the corresponding structured query language samples in the structured query language sample set; and training a large model based on the database information sample set and the query information sample set to obtain a dialogue model, wherein the dialogue model is used to analyze the query information and database information in the prompt information to generate structured query language, wherein the prompt information is generated based at least on database information matching the structured query language, the query information is used to represent the semantics of the structured query language, and the database information is used to represent the data structure required to execute the operation function corresponding to the structured query language in the database.
[0010] According to another aspect of an embodiment of the present disclosure, another method for generating a structured query language is provided. The method is applied to a client and may include the following steps: detecting query information received in an interactive interface, wherein the query information is used to represent the semantics of the structured query language to be generated; in response to the query information, displaying database information matching the structured query language to be generated in the interactive interface, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the structured query language to be generated in the database; displaying prompt information generated based on at least the database information on the interactive interface; inputting the prompt information into a dialogue model, and displaying the structured query language obtained by analyzing the query information and database information in the prompt information using the dialogue model on the interactive interface.
[0011] According to another aspect of an embodiment of the present disclosure, another method for generating structured query language is provided. The method may include: responding to multimodal information received in a dialogue interface, wherein the multimodal information includes query information corresponding to the structured query language to be generated, the query information being used to represent the semantics of the structured query language to be generated; displaying database information matching the structured query language to be generated in the dialogue interface, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the converted structured query language in the database; displaying prompt information generated based on at least the database information on the dialogue interface; inputting the prompt information into a dialogue model, and using the dialogue model to analyze the query information and database information in the prompt information to output the structured query language; and displaying reply information generated based on the structured query language on the dialogue interface.
[0012] According to another aspect of an embodiment of the present disclosure, another method for generating a structured query language is provided. The method may include: detecting query information to be converted by calling a first interface, wherein the first interface includes a first parameter, the parameter value of the first parameter is query information, and the query information is used to represent the semantics of the structured query language to be converted; obtaining database information matching the structured query language to be converted, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the structured query language to be converted in the database; generating prompt information based at least on the database information; inputting the prompt information into a dialogue model, and using the dialogue model to analyze the query information and database information in the prompt information to output the structured query language; outputting the structured query language by calling a second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter is the structured query language.
[0013] According to another aspect of an embodiment of the present disclosure, a system for generating structured query language is provided. The system may include: an input terminal for inputting query information to be converted, wherein the query information is used to represent the semantics of the structured query language to be converted; a processing terminal for obtaining database information matching the structured query language to be converted and generating prompt information based at least on the database information, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the structured query language to be converted in the database; and a model inference terminal for inputting the prompt information into a dialogue model, analyzing the query information and database information in the prompt information using the dialogue model, and outputting the structured query language.
[0014] According to another aspect of an embodiment of the present disclosure, an electronic device is also provided, which may include a memory and a processor: the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the above-mentioned computer-executable instructions are executed by the processor, any of the above-mentioned structured query language generation methods is implemented.
[0015] According to another aspect of an embodiment of the present disclosure, a processor is further provided, and the processor is configured to run a program, wherein any one of the above-mentioned methods for generating a structured query language is executed when the program is running.
[0016] According to another aspect of an embodiment of the present disclosure, a computer-readable storage medium is further provided, which includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute any of the above-mentioned structured query language generation methods.
[0017] According to another aspect of an embodiment of the present disclosure, a computer program is further provided. When the computer program is executed by a processor, the computer program implements any one of the above-mentioned methods for generating a structured query language.
[0018] In an embodiment of the present disclosure, when a client needs a structured query language to assist in data development, the client can input the corresponding semantics that can generate the structured query language, that is, the query information corresponding to the structured query language, on the client's interactive interface. After detecting that there is query information to be converted into structured query language in the interactive interface of a certain client, the query information can be transmitted from the client to the cloud. Based on the query information, the cloud can determine from the database the data structure required for the operation function performed when executing the structured query language corresponding to the query information, that is, the database information that matches the structured query language, and can be transmitted to the interactive interface of the corresponding client for display. The cloud can generate prompt information corresponding to the structured query language based on at least the database information, and can be transmitted to the interactive interface of the corresponding client for display. The cloud can use the prompt information to prompt the dialogue model to generate the corresponding required structured query language, and can be transmitted to the interactive interface of the corresponding client for display. Considering that related technologies only generate structured query languages based on the mapping between natural language and structured query languages, which may be out of touch with reality and difficult to apply, the present disclosure can further model the database information corresponding to the structured information, avoiding the abnormal situations that occur in the above-mentioned related technologies, thereby achieving the purpose of improving the accuracy of the structured information to be generated and the degree of fit with actual applications, thereby achieving the technical effect of effectively generating structured query languages and solving the technical problem of being unable to effectively generate structured query languages.
[0019] It is easy to note that the above general description and the following detailed description are only for the purpose of exemplifying and explaining the present disclosure, and do not constitute a limitation of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The exemplary embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation of the present disclosure. In the drawings:
[0021] FIG1 is a schematic diagram of an application scenario of a method for generating a structured query language according to an embodiment of the present disclosure;
[0022] FIG2 is a flow chart of a method for generating a structured query language according to an embodiment of the present disclosure;
[0023] FIG3 is a flow chart of a method for generating a model according to an embodiment of the present disclosure;
[0024] FIG4 is a flow chart of another method for generating a structured query language according to an embodiment of the present disclosure;
[0025] FIG5 is a flowchart of another method for generating a structured query language according to an embodiment of the present disclosure;
[0026] FIG6 is a flowchart of another method for generating a structured query language according to an embodiment of the present disclosure;
[0027] FIG7 is a schematic diagram of an SQL classification result according to an embodiment of the present disclosure;
[0028] FIG8 is a schematic diagram of a model reasoning according to an embodiment of the present disclosure;
[0029] FIG9 is a schematic diagram of a system for generating a structured query language according to an embodiment of the present disclosure;
[0030] FIG10 is a schematic diagram of a structured query language generation device according to an embodiment of the present disclosure;
[0031] FIG11 is a schematic diagram of a device for generating a model according to an embodiment of the present disclosure;
[0032] FIG12 is a schematic diagram of another structured query language generation device according to an embodiment of the present disclosure;
[0033] FIG13 is a schematic diagram of another structured query language generation device according to an embodiment of the present disclosure;
[0034] FIG14 is a schematic diagram of another structured query language generation device according to an embodiment of the present disclosure;
[0035] FIG15 is a structural block diagram of a computer terminal according to an embodiment of the present disclosure;
[0036] FIG16 is a block diagram of an electronic device for a method for generating a structured query language according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0037] In order to enable those skilled in the art to better understand the solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the embodiments described are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present disclosure.
[0038] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure 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 numbers used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes 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.
[0039] The technical solution provided by the present disclosure is mainly implemented using large-scale model technology. The large model here refers to a deep learning model with large-scale model parameters, which can usually contain hundreds of millions, tens of billions, hundreds of billions, trillions, or even more than ten trillion model parameters. The large model can also be called a cornerstone model / foundation model (Foundation Model). The large model is pre-trained by large-scale unlabeled corpus to produce a pre-trained model with more than 100 million parameters. This model can adapt to a wide range of downstream tasks and has good generalization capabilities, such as large-scale language models (LLMs) and multi-modal pre-training models.
[0040] It should be noted that when the large model is actually applied, the pre-trained model can be fine-tuned with a small number of samples, so that the large model can be applied to different tasks. For example, the large model can be widely used in natural language processing (NLP), computer vision, speech processing and other fields. Specifically, it can be applied to computer vision tasks such as visual question answering (VQA), image captioning (IC), and image generation. It can also be widely used in natural language processing tasks such as text-based sentiment classification, text summary generation, and machine translation. Therefore, the main application scenarios of the large model include but are not limited to digital assistants, intelligent robots, search, online education, office software, e-commerce, and intelligent design.
[0041] Example 1
[0042] According to an embodiment of the present disclosure, a method for generating a structured query language is 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.
[0043] Taking into account the huge amount of model parameters of the large model and the limited computing resources of the mobile terminal, the above-mentioned structured query language generation method provided by the embodiment of the present disclosure can be applied to the application scenario shown in Figure 1, but is not limited to this. In the application scenario shown in Figure 1, the large model is deployed in the server 10, which can be a cloud server. The server 10 can be connected to one or more client devices 20 through a local area network connection, a wide area network connection, an Internet connection, or other types of data networks. The client devices 20 here can include but are not limited to: smart phones, tablet computers, laptops, PDAs, personal computers, smart home devices, car-mounted devices, etc. The client devices together constitute the client relative to the server. An interactive interface for obtaining application generation instructions can be deployed on the graphical user interface of the client device, and the interactive interface can be a generative dialogue interface. The client device 20 can interact with the user through the graphical user interface to implement the call to the large model, thereby implementing the structured query language generation method provided by the embodiment of the present disclosure.
[0044] In an embodiment of the present disclosure, a system consisting of a client device and a server can perform the following steps: If a structured query language (SQL) needs to be determined during data development, the semantics corresponding to the required SQL, i.e., query information corresponding to the SQL, can be input on an interactive interface on the client device. The client device can obtain the query information and send it to the server via a network. After receiving the query information, the server can perform the following steps: Step S102: Detecting query information to be converted from the client, wherein the query information represents the semantics of the SQL to be converted; Step S104: Retrieving database information that matches the SQL to be converted, wherein the database information represents the data structure required to execute the corresponding operation function of the SQL to be converted in the database; Step S106: Generating prompt information based on at least the database information; Step S108: Inputting the prompt information into a dialogue model, and using the dialogue model to analyze the query information and database information in the prompt information to output the SQL. The SQL can be output to the client device. In the above process, the database information and prompt information determined by the server can be sent to the client device via a network. The database information and prompt information during the structured query language generation process can be displayed on the interactive interface of the client device. Based on the above two types of information presented, if the accuracy is insufficient, they can be adjusted on the interactive interface to ensure the accuracy of the final required structured query language. After the server determines the structured query language, it can also be transmitted to the corresponding client device via the network, and after the client device receives the structured query language, the structured query language can be displayed. It should be noted that if the operating resources of the client device can meet the deployment and operation conditions of the large model, the embodiment of the present disclosure can be carried out in the client device.
[0045] The embodiments of the present disclosure propose the following method from the technical implementation side. Under the above operating environment, the embodiment 1 of the present disclosure provides a method for generating a structured query language as shown in Figure 2. Figure 2 is a flow chart of a method for generating a structured query language according to the present disclosure. As shown in Figure 2, the method can be applied to the cloud and includes the following steps:
[0046] Step S202 : detecting query information to be converted from the client, wherein the query information is used to represent the semantics of the structured query language to be converted.
[0047] In the technical solution provided in the above step S202 of the present disclosure, the cloud can determine in real time whether the client transmits the query information to be converted to it, wherein the query information may include a language for describing the structured query language to be converted, such as a natural language. Natural language (NL) can be used to represent the semantics of the structured query language to be generated. An interactive interface exists in the client device included in the client. The interactive interface can be a dialogue interface for a user of the client device to communicate with an SQL assistant that can issue SQL statements to generate the SQL statements required by the user. Structured query language can be used to write code, that is, the code written using the SQL language can be an SQL statement.
[0048] Optionally, when a structured query language is needed to assist in data development, query information describing the required structured query language can be input on the interactive interface of the corresponding client. Optionally, this embodiment performs real-time detection on the interactive interface to determine whether query information has been input. After determining whether query information has been input, the input query information can be tested.
[0049] Optionally, the client can perform real-time detection on its interactive interface to determine whether natural language that needs to be converted into structured query semantics is written. If natural language is detected, the natural language can be transmitted to the cloud via a network or other transmission method. The cloud can then detect and analyze the semantics of the natural language from the client, parsing out information such as the characteristics of the structured query language required to express the natural language, thereby facilitating matching with the structured query language that matches the semantics of the natural language.
[0050] Optionally, before determining the structured query language used to describe the natural language input in the interactive interface, a conversational model to be deployed in the cloud that can determine SQL statements through natural language in a conversational manner can be pre-trained. For example, a pre-trained code language model can be used to construct a method for automatically converting natural language to SQL, namely, the NL2SQL automated conversion method. After training the pre-trained code language model, a final conversational model is obtained and deployed in the corresponding cloud. Through this conversational model, when a user inputs natural language from the corresponding client's interactive interface, after the natural language is transmitted to the cloud, the conversational model can be used to achieve the effect of a conversation with the SQL assistant in the conversational model in the cloud, matching the SQL statement that matches the natural language input by the user. The pre-trained code language model can be a large pre-trained language source code model (StarCoder).
[0051] Optionally, in the process of building an automated conversion method for NL2SQL, one can focus on relying on the basic understanding capabilities of a large language model, which may include the ability to understand natural language and code. In the process of building this method, the main processes required are data organization, model training, model evaluation, and model reasoning.
[0052] Step S204 : obtaining database information that matches the structured query language to be converted, wherein the database information is used to represent a data structure required for executing an operation function corresponding to the structured query language to be converted in the database.
[0053] In the technical solution provided in step S204 of the present disclosure, after detecting the natural language to be converted from the client, database information matching the structured query language corresponding to the natural language can be determined based on the natural language, and the database information can be displayed in the interactive interface. The database information can be a database schema definition language (Data Definition Language, DDL), which can include tables and fields in the database. The database information matching the structured language can be used to represent the data structure required to execute the corresponding operation function of the structured query language to be generated in the database, that is, the tables and fields that are useful for generating the corresponding structured query language selected from a large number of tables and fields in the database. The database can be an enterprise-level Software-as-a-Service (SaaS) cloud data warehouse suitable for data analysis scenarios, such as a big data computing service (MaxCompute) platform. The operation function can be a function that can be implemented by the corresponding structured query language, for example, it can mainly include the following types: SQL generation, SQL error correction, SQL comment writing, SQL rewriting, and SQL Q&A. This is only for example and does not impose specific restrictions on the functions that can be implemented by SQL statements and the types of functions. The data structure may be a table (table information) and a field. This is only an example and does not impose any specific restrictions on the data structure.
[0054] Optionally, after obtaining a structured query language in the interactive interface and transmitting it to the cloud, the structured query language can be processed in the cloud, and the database therein can be called through the cloud to filter out data structures that match the SQL statement corresponding to the natural language from a large number of data structures in the database, that is, to filter out tables and fields that are beneficial to generating the SQL statement from a large number of tables and fields in the database.
[0055] Optionally, during the model inference process included in the automated NL2SQL conversion method, a database information screening process can be performed. For example, in this process, a table and field screening model can be used to screen the automatically acquired DDL in the database, extracting tables and fields that are useful for generating the corresponding SQL from the large amount of DDL as model input for the conversational model. It should be noted that the above process and method for extracting DDL that matches SQL is for illustrative purposes only and is not a specific limitation herein.
[0056] Step S206: Generate prompt information based at least on the database information.
[0057] In the technical solution provided in the above step S206 of the present disclosure, after determining the database information that matches the structured query language corresponding to the natural language based on the natural language, corresponding prompt information can be determined based at least on the database information and sent to the interactive interface for display, wherein the prompt information can be a prompt corresponding to the SQL function.
[0058] Optionally, in the model inference process included in the NL2SQL automated conversion method, zero-sample inference may be performed after database information screening. During the zero-sample inference process, prompt information may be generated.
[0059] Optionally, corresponding prompt information can be generated for different operational functions. For example, for SQL-generated functions, for database information matched based on natural language in the cloud, that is, for given database information, corresponding prompt information can be determined by answering questions. It should be noted that the above process and method for determining prompt information are for illustrative purposes only and are not specifically limited here.
[0060] Step S208: input the prompt information into the dialogue model, and use the dialogue model to analyze the query information and database information in the prompt information to output a structured query language.
[0061] In the technical solution provided in the above step S208 of the present disclosure, after the corresponding prompt information is determined based on at least the database information, the prompt information can be input into the dialogue model, and the dialogue model can start to generate the corresponding structured query language based on the query information and database information in the prompt information. After the dialogue model generates the structured query language, it is sent to the client device and can be displayed on the interactive interface of the client device. The dialogue model can be a trained SQL dialogue model, which can also be an NL2SQL model.
[0062] Optionally, during the data organization and model training process, the pre-trained code language model can be fine-tuned in a supervised manner to enable it to use NL2SQL, resulting in a trained conversational model. After training, a model evaluation can be performed. Specifically, during this process, the trained conversational model can be tested on a standard dataset to assess its performance. If the evaluation results pass, the conversational model can be put into normal use, i.e., deployed to the cloud to generate structured query language based on natural language.
[0063] Alternatively, a well-performing NL2SQL model can be used to assist in data development. This NL2SQL model can be deployed in the cloud. When prompted, it can trigger the NL2SQL model to start generating SQL statements. The NL2SQL model can generate the SQL statement required by the user and send it to the corresponding interactive interface for display.
[0064] Since determining SQL statements solely through traditional NL2SQL using the mapping between NL and SQL statements can be unrealistic and difficult to apply to actual data development processes, there is still a technical problem of being unable to effectively convert data. However, in the embodiments of the present disclosure, in order to solve the above-mentioned problem of a single NL to SQL statement mapping, it is necessary to organize the existing data so that the model can learn patterns from rich natural language (input information). Further modeling of database information that matches SQL statements can be considered, thereby organizing the NL2SQL data into a form that combines NL and DDL and maps them to SQL, so that the model can learn sufficient knowledge from natural language and database information, and then generate corresponding SQL statements based on this. Based on the above method, it is possible to avoid being unrealistic and difficult to apply, achieve the purpose of being practical and easy to apply to data development, and thus solve the technical problem of being unable to effectively generate SQL statements in related technologies.
[0065] Through steps S202 to S208 of the present disclosure, when a client needs structured query language to assist in data development, it can enter the corresponding semantics that can generate the structured query language on the client's interactive interface, that is, the query information corresponding to the structured query language. After detecting that there is query information to be converted into structured query language in the interactive interface of a client, the natural language can be transmitted from the client to the cloud. Based on the query information, the cloud can determine from the database the data structure required for the operation function performed when executing the structured query language corresponding to the query information, that is, the database information that matches the structured query language, and can be transmitted to the interactive interface of the corresponding client for display. The cloud can generate prompt information corresponding to the structured query language based on at least the database information, and can be transmitted to the interactive interface of the corresponding client for display. The cloud can use the prompt information to prompt the dialogue model to generate the corresponding required structured query language, and can be transmitted to the interactive interface of the corresponding client for display.
[0066] Considering that related technologies only generate structured query languages based on the mapping between natural language and structured query languages, which may be out of touch with reality and difficult to apply, the present disclosure can further model the database information corresponding to the structured information, avoiding the abnormal situations that occur in the above-mentioned related technologies, thereby achieving the purpose of improving the accuracy of the structured information to be generated and the degree of fit with actual applications, thereby achieving the technical effect of effectively generating structured query languages and solving the technical problem of being unable to effectively generate structured query languages.
[0067] The above method of this embodiment is further introduced below.
[0068] As an optional implementation, step S204, obtaining database information matching the structured query language to be converted, includes: determining the operation function type corresponding to the structured query language to be generated; and obtaining database information matching the operation function type.
[0069] In this embodiment, database information corresponding to different operation function types can be determined based on the operation function type corresponding to the structured query language to be generated, and the database information can be sent to the corresponding interactive interface for display. The operation function type can be used to indicate the type of operation function, for example, it can include SQL generation, SQL error correction, SQL comment writing, SQL rewriting, and SQL extraction. The database information corresponding to the SQL generation type is SQL generation prompt; the database information corresponding to the SQL error correction type is SQL error correction prompt; the database information corresponding to the SQL comment writing type is SQL comment prompt; the database information corresponding to the SQL rewriting type is SQL rewriting prompt; and the database information corresponding to the SQL extraction type is SQL extraction prompt.
[0070] It should be noted that the above-mentioned operation function types are only examples and are not specifically limited here. As long as it is necessary to determine the database information and combine the database information and natural language to determine the process and method of structured query language, they are all within the scope of protection of the embodiments of the present disclosure.
[0071] Optionally, since SQL statements have a variety of functions, and in data development, SQL statements with different functions may be needed to assist in data development, corresponding database information needs to be configured for SQL statements with different operation function types. Therefore, when users have the need to generate the required SQL statements, they can select the corresponding operation function type according to their own preferences to carry out targeted problem processing, and match the corresponding database information under the corresponding operation function type from the database, thereby improving the pertinence and accuracy of determining the database information.
[0072] For example, database information corresponding to different operational function types can be preconfigured and then stored in a database in a categorized manner. Based on the user's selection in natural language, the desired operational function type can be determined. Database information useful for generating the user's desired SQL statement can then be filtered and extracted from the corresponding database category. The filtered database information corresponding to the structured query language (SQL) used as the model input for the conversational model. By categorizing database information by operational function type, the efficiency of extracting the required database information is improved, thereby achieving the technical effect of increasing the efficiency of generating the SQL statement.
[0073] As an optional implementation, step S206 generates prompt information based at least on database information, including: using an information generation template to generate prompt information from the operation function and database information, wherein the information generation template is used to represent the rules for generating prompt information in the query scenario corresponding to the structured query language.
[0074] In this embodiment, both the operational function and database information can be input into an information generation template, which can be processed to generate corresponding prompt information, which can be sent to an interactive interface, and the generated prompt information can be displayed on the interactive interface. The information generation template can be used to represent the rules for generating prompt information in query scenarios corresponding to the structured query language, and can be a predefined template. The query scenario is used to reflect the user's requirements for different operational functions of the structured query language, that is, it can be used to reflect the user's selection of the required structured query language operational function.
[0075] Optionally, during the database information screening process during model inference, the table and field screening model can be used to automatically filter and extract database information (i.e., tables and fields) from the database that are useful for generating the SQL statements required by the user, based on the user's different needs in different query scenarios. This information is then used as the model input for the conversational model.
[0076] Optionally, after the database information screening process is complete, a zero-shot inference process can be performed. During this process, based on the user's needs in different query scenarios, the user's question (i.e., the user's structured query language operation function) can be embedded in a predefined template, combined with the database information extracted in the above steps. This template, which embeds the completed operation function and database information, is then input into the conversational model as prompt information. The conversational model analyzes this information, infers the user's required structured query language, and uses this structured query language as the model output of the conversational model. This is then returned to the interactive interface of the corresponding client device for display, i.e., the model output is returned to the user.
[0077] For example, the SQL generation prompt: Given the following MaxCompute database information: ${schema}, answer the question (if it is a partitioned table, add partition field conditions): ${prompt}. The SQL error correction prompt: Based on the MaxCompute SQL syntax rules and the requirements of ${prompt}, please fix the SQL bug: ```sql\n${schema}. The SQL comment prompt: Please comment on the following MaxCompute SQL: ```sql\n${schema}\n``` and retain the original SQL: ${prompt}. The SQL rewrite prompt: Given the following SQL: ```sql\n${schema}\n```, modify it according to the MaxCompute SQL syntax rules and return: ${prompt}. The SQL extraction prompt: Given the following text content: ${prompt}, extract the SQL from it and return it. It should be noted that the above are only examples of prompts corresponding to several SQL functions, where schema is a DDL or SQL statement and prompt is obtained based on the user's selection, that is, prompt is user input.
[0078] As an optional implementation, the method further includes: determining, in a query information sample set, a query information sample having the highest similarity to the query information, and determining, in a structured query language sample set, a structured query language sample corresponding to the query information sample, wherein the query information sample set and the structured query language sample set are used to train a dialogue model, and the query information sample is used to represent the semantics of the structured query language sample; generating prompt information based at least on database information, including: generating prompt information based on the structured query language sample, the natural language sample, and the database information; step S206, generating prompt information based at least on the database information, including: generating prompt information based on the structured query language sample, the query information sample, and the database information.
[0079] In this embodiment, the query information sample set with the highest similarity to the query information can be determined, and the structured query language sample corresponding to the query information sample set can be determined in the structured query language sample set. Corresponding prompt information can be determined based on the structured query language sample, the query information sample, and the database information, and the prompt information can be sent to the interactive interface and displayed. The query information sample set and the structured query language sample set can be used to train the final dialogue model. The query information sample set and the structured query language sample set can be collectively referred to as a training set. The query information sample set can be a natural language sample set.
[0080] Optionally, during model inference, after zero-shot inference, a few-shot inference process can be performed. Before performing few-shot inference, based on the user's query question (i.e., natural language), similar queries and corresponding SQL statements can be extracted from the training set. Specifically, a natural language sample similar to the natural language presented in the current query question is determined from the natural language sample set in the training set, and a structured query language sample corresponding to the natural language sample is determined from the structured query language sample set in the training set, resulting in a natural language sample-structured query language sample pair, i.e., a query question-SQL statement pair. Thus, during the few-shot inference process, prompt information can be determined using the natural language sample-structured query language sample pair corresponding to the natural language sample with the greatest similarity to the currently input natural language, along with the corresponding database information. This prompt information is then input into the conversation model to help the conversation model infer the structured query language corresponding to the current natural language.
[0081] For example, the prompt message could be as follows: <|system|> The following is a conversation between a SQL assistant and a human. The assistant answers questions based on the human's questions, simply outputting SQL statements. SQL statements are returned as Markdown code, avoiding redundant information. The <|user|> model can answer questions based on the following similar examples: \nAsk and answer the following questions: {Similar question 1}\n{SQL statement for question 1}\nAsk and answer the following questions: {Similar question 2}\n{SQL statement for question 2}\nAsk and answer the following questions: {Similar question 3}\n{SQL statement for question 3}\nGiven the following database information: {Table information}, answer the SQL query question: {User question}. <|bot|>
[0082] As an optional implementation, determining the query information sample with the highest similarity to the query information in the query information sample set includes: using a similarity model to determine the query information sample in the query information sample set, wherein the similarity model is used to determine the output data with the highest similarity to the input data.
[0083] In this embodiment, a similarity model can be used to determine, from a set of query information samples, the query information sample with the highest similarity to the current query information. The similarity model can be used to determine the output data with the highest similarity to the input data. In the disclosed embodiment, the input data can be the natural language input by the current user, and the output data can be the natural language sample with the highest similarity to the input natural language.
[0084] Optionally, before performing few-sample inference, a similarity model can be used to extract a natural language sample set with the highest similarity to the natural language from the natural language sample set in the training set based on the natural language input by the user, and a structured query language sample set corresponding to the natural language sample set can be extracted from the structured query language sample set in the training set.
[0085] If only the natural language detected on the current interactive interface is input into the dialogue model for inference, resulting in a structured query language corresponding to the natural language, the resulting structured query language would have a low accuracy. However, in the disclosed embodiments, a query question with the highest similarity to the query question currently entered by the user on the interactive interface, along with the SQL statement corresponding to the query question, can be pre-extracted from a training set. This extracted query question-SQL statement with the highest similarity and the corresponding database information pair can be input into the dialogue model as a prompt to assist the dialogue model in inferring the natural language input by the current user. This allows the inferred SQL statement corresponding to the current natural language to be compared with the SQL statement in the prompt information. If the similarity is low, this may indicate a problem with the SQL statement inferred by the dialogue model. If the similarity is high, this indicates that the SQL statement inferred by the dialogue model is accurate, thereby achieving the technical effect of improving the accuracy of structured query language determination.
[0086] As an optional implementation, the method may further include: outputting the structured query language to the client.
[0087] In this embodiment, the structured query language may be output to a client, where the client may be a client device.
[0088] Optionally, the query information and database information in the prompt information are analyzed in the cloud using a conversational model to obtain structured query language (SQL). The SQL can then be transmitted to a connected client device via a network. After the client device receives the SQL, the SQL can be displayed on an interactive interface of the client device.
[0089] The present disclosure also provides a method for generating a model. FIG3 is a flow chart of a method for generating a model according to an embodiment of the present disclosure. As shown in FIG3 , the method may include the following steps:
[0090] Step S302: Obtain a database information sample set corresponding to the structured query language sample set.
[0091] In the technical solution provided in the above step S302 of the present disclosure, a structured query language sample set can be constructed, and a database information sample set corresponding to the structured query language can be obtained.
[0092] Optionally, in order to train the final dialogue model, a database information sample set and a structured query language sample set need to be prepared in advance.
[0093] Step S304: Input the database information sample set into the initial dialogue model, analyze the database information sample set using the initial dialogue model, and output a query information sample set corresponding to the structured query language sample set. The initial dialogue model is trained based on at least the initial structured query language sample set, and the query information samples in the query information sample set are used to represent the semantics of the corresponding structured query language samples in the structured query language sample set.
[0094] In the technical solution provided in step S304 of the present disclosure, an initial dialogue model is used to analyze a database information sample set corresponding to a structured query language sample set to generate a natural language sample set, wherein the initial dialogue model is trained based on at least the initial structured query language sample set, and the query information samples in the query information sample set are used to represent the semantics of the corresponding structured query language samples in the structured query language sample set.
[0095] Optionally, an initial conversation model is used to analyze the database information sample set corresponding to the structured query language sample set to generate a corresponding natural language sample set. A large model can be trained based on the database information sample set and the natural language sample set to obtain a conversation model. The initial conversation model can be a model trained based on at least the initial structured query language sample set, for example, a SQL conversation model trained based on open source data such as the initial structured query language sample set. The initial structured query language sample set can include open source NL2SQL data. The natural language samples in the natural language sample set can be used to represent the semantics of the corresponding structured query language samples in the structured query language sample set. The large model can be a pretrained code language model, for example, the pretrained language model Starcoder. The conversation model can be a conversation model that has acquired NL2SQL capabilities, for example, an NL2SQL model or an SQL conversation model.
[0096] To address the issues inherent in related technologies that rely solely on mapping between NL and SQL, the disclosed embodiments organize existing open-source data so that the conversational model can learn patterns from the rich information within. This organizes the NLSQL data into a NL+DDL to SQL format, enabling the conversational model to learn sufficient knowledge from NL and DDL. Generating corresponding SQL statements based on this knowledge ensures more accurate SQL statements.
[0097] Step S306: Based on the database information sample set and the query information sample set, the large model is trained to obtain a dialogue model, wherein the dialogue model is used to analyze the query information and database information in the prompt information to generate a structured query language. The prompt information is generated based on at least the database information that matches the structured query language. The query information is used to represent the semantics of the structured query language, and the database information is used to represent the data structure required to execute the corresponding operation function of the structured query language in the database.
[0098] In the technical solution provided in step S306 of the present disclosure, a large model can be trained based on a sample set of database information and a sample set of query information to obtain a conversation model. The conversation model can be used to analyze the query information and database information in the prompt information to generate structured query language (SQL). The prompt information can be generated based on at least database information that matches the SQL. The query information can be used to represent the semantics of the SQL. The database information can be used to create the data structures required to execute the corresponding operation functions of the SQL in the database.
[0099] Optionally, the large model is trained based on the database information sample set and the query information sample set to obtain a dialogue model.
[0100] Optionally, during the data organization process, open source data can be acquired and converted. During the acquisition and conversion of open source data, open source NLSQL data can be used, and the open source structured query language in the form of a non-data warehouse tool (Hive) can be generated into Hive format, including DDL statements and SQL statements.
[0101] Through steps S302 to S306 of the present disclosure, a database information sample set corresponding to a structured query language sample set is obtained; the database information sample set is input into an initial dialogue model, and the initial dialogue model is used to analyze the database information sample set, outputting a query information sample set corresponding to the structured query language sample set. The initial dialogue model is trained based on at least the initial structured query language sample set, and the query information samples in the query information sample set are used to represent the semantics of the corresponding structured query language samples in the structured query language sample set. The large model is trained based on the database information sample set and the query information sample set to obtain a dialogue model. The dialogue model is used to analyze the query information and database information in the prompt information to generate structured query language. The prompt information is generated based on at least database information matching the structured query language. The query information is used to represent the semantics of the structured query language, and the database information is used to represent the data structure required to execute the operation function corresponding to the structured query language in the database. This achieves the technical effect of effectively generating structured query language and solves the technical problem of being unable to effectively generate structured query language.
[0102] The above method of this embodiment is further introduced below.
[0103] As an optional implementation, the method further includes: classifying the database information sample set according to the operation functions corresponding to the structured query language sample set in the database; analyzing the database information sample set using the initial dialogue model, and outputting the query information sample set corresponding to the structured query language sample set, including: analyzing the classified database information sample set using the initial dialogue model, and outputting the query information sample set corresponding to the structured query language sample set.
[0104] In this embodiment, the database information sample set can be analyzed according to the operation functions corresponding to the structured query language sample set in the database, and the initial dialogue model can be used to analyze the database information sample set corresponding to the structured query language sample set classified according to the operation functions to generate a corresponding query information sample set.
[0105] Optionally, during the data organization process, after acquiring and converting the open source data, an automated generation process for application function data can be performed. In this process, the existing SQL statements in the application function data can be categorized according to their operational functions, and a number of SQL statements from each category can be extracted for backup.
[0106] Optionally, after extracting several SQL statements for each category for backup, a SQL dialogue model trained based on open source data can be used to generate natural language descriptions to form NL2SQL data pairs of application function data.
[0107] Optionally, the NL2SQL data pairs of the application function data need to be manually verified and modified to ensure their accuracy.
[0108] For example, SQL can be categorized into the following six types: 1) Data Query Language (DQL); 2) Database Schema Definition Language (DDL); 3) Data Manipulation Language (DML); 4) Tool Command Language (TCL); 5) Data Control Language (DCL); and 6) Command. It should be noted that the number and types of SQL categorized above are for illustrative purposes only and are not intended to be limiting.
[0109] For another example, the DQL class may include the following statements: CTE Select statements (for example, WITH SELECT), basic query Select statements (for example, Select", select distinct, Select field, and Select From Table), branch statements (for example, Case WHEN), aggregate functions (for example, SUM, COUNT, AVG, MIN, MAX, and Having), built-in functions (for example, max_pt), window functions (for example, WINDOW, OVER, FILTER, and Row_Number), QUALIFY statements (for example, QUALIFY), transformation PIVOT statements (for example, PIVOT and UNPIVOT), subquery statements (for example, a Select statement nested in a Select statement), connection Select statements (for example, INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, and SEMI JOIN), Union Select statements (for example, intersect, union, except, and minus), conditional query Select statements (for example, WHERE and partitioning and non-partitioning), sorting Select statements (for example, ORDER BY), and so on. BY), grouping select statements (for example, GROUP BY), and limiting select statements (for example, LIMIT). WHERE can include LIKE, RLIKE, REGEXP, IN, NOT IN, BETWEEN, IS NULL, IS NOT NULL, NOT, =, AND, OR, >, >=, <, and <=. ORDER BY can include DESC and ASC.
[0110] As an optional example, the DDL class can include the following statements: CREATE statements (e.g., Create Table and Create Function), ALTER statements (e.g., ALTER TABLE), and DROP statements (e.g., DROP TABLE and DROP FUNCTION). Create Table statements can include Create Non-Partition Table, Create Partition Table, and Create External Table.
[0111] For example, the DML class includes the following statements: INSERT statements (e.g., INSERT INTO and INSERT OVERWRITE), UPDATE statements (e.g., UPDATE SET), DELETE statements (e.g., DELETE), and MERGE statements (e.g., MERGE INTO). The TCL class includes the following statements: COMMIT and ROLLBACK. The DCL class includes the following statements: GRANT and REVOKE. The COMMAND class includes the following statement: SET.
[0112] It should be noted that the statements contained in each category obtained by the above SQL classification are only examples and are not specifically limited here.
[0113] As an optional implementation, the large model is trained based on the database information sample set and the query information sample set to obtain a dialogue model, including: based on the classified database information sample set and the query information sample set, the large model is supervised trained to obtain a dialogue model.
[0114] In this embodiment, the large model can be supervised trained based on the classified database information sample set and the natural language sample set to obtain a dialogue model.
[0115] Optionally, after the data organization process is completed, a model training process can be started. In this process, the large model can be supervised trained based on the classified database information sample set, that is, supervised fine-tuning, to obtain a dialogue model with NL2SQL capabilities.
[0116] For example, supervised fine-tuning is performed on the pre-trained language model Starcoder, enabling the model to acquire NL2SQL capabilities and become a conversational model.
[0117] As an optional implementation, the method further includes: training an initial dialogue model based on an initial structured query language sample set of data types matching different operation functions.
[0118] In this embodiment, an initial dialogue model may be trained based on an initial structured query language sample set of data types matching different operation functions, wherein the data type may be used to indicate whether the data is in Hive format.
[0119] Optionally, using open source NL2SQL data, you can generate non-Hive structured query language into Hive format to train an initial conversation model, that is, a pre-trained code language model.
[0120] In an embodiment of the present disclosure, after detecting that there is query information to be converted into a structured query language in the interactive interface of a certain client, the query information can be transmitted from the client to the cloud. Based on the query information, the cloud can determine from the database the data structure required for the operation function performed when executing the structured query language corresponding to the query information, and generate prompt information corresponding to the structured query language based on the matched data structure. The prompt information can be used by the cloud to prompt the dialogue model to generate the corresponding required structured query language, and can be transmitted to the interactive interface of the corresponding client for display. Since the present disclosure can further model the database information corresponding to the structured information, it avoids the abnormal situations that occur in the above-mentioned related technologies, thereby achieving the purpose of improving the accuracy of the structured information generated and the degree of fit with the actual application, thereby achieving the technical effect of effectively converting data and solving the technical problem of being unable to effectively convert data.
[0121] The present disclosure also provides a method for generating a structured query language from the client side. FIG4 is a flow chart of a method for generating a structured query language according to an embodiment of the present disclosure. As shown in FIG4 , the method may include the following steps:
[0122] Step S402 : detecting query information received in the interactive interface, wherein the query information is used to represent the semantics of the structured query language to be generated.
[0123] In the technical solution provided in the above step S402 of the present disclosure, the query information received on the interactive interface can be detected, wherein the query information may include the natural language corresponding to the structured query language to be generated, the user selection submitted by the user of the client device for the required structured query language, and the query question made for the required structured query language.
[0124] Optionally, when it is desired to display a structured query language for data development on an interactive interface of a client device, natural language describing the desired structured query language may be input on the interactive interface of the corresponding client device. The interactive interface may be checked in real time to determine whether query information has been input. After determining that query information has been input, the input query information may be checked.
[0125] Step S404 , in response to the query information, displaying database information matching the structured query language to be generated in the interactive interface, wherein the database information is used to represent the data structure required to execute the operation function corresponding to the structured query language to be generated in the database.
[0126] In the technical solution provided in the above step S404 of the present disclosure, after detecting that query information has been received in the interactive interface, database information matching the structured query language corresponding to the query information can be determined based on the query information, and the database information can be displayed in the interactive interface.
[0127] Optionally, after detecting the query information received in the interactive interface, the query information can be transmitted to the cloud. The cloud can perform semantic analysis on the query information to determine the structured query language corresponding to the natural language in the query information, and further call database information in the database that can match the structured query language.
[0128] Optionally, after the database information matching the SQL statement is determined via the cloud based on the above method, the database information can be transmitted via the cloud to an interactive interface for inputting query information corresponding to the database information for display. If the database information is inaccurate or does not meet the user's requirements, a corresponding adjustment operation can be performed on the interactive interface to issue a request to modify the database information. The modified database information, which is accurate or meets the user's requirements, is then sent to the corresponding interactive interface for display, thereby ensuring the accuracy of the acquired database information and, further, the accuracy of the structured query language subsequently generated.
[0129] Step S406: Displaying prompt information generated at least based on the database information on the interactive interface.
[0130] In the technical solution provided in the above step S406 of the present disclosure, after displaying database information matching the structured query language to be generated in the interactive interface in response to the query information, corresponding prompt information can be determined based at least on the database information and sent to the interactive interface for display.
[0131] Optionally, in the model inference process included in the NL2SQL automated conversion method, zero-sample inference may be performed after database information screening. During the zero-sample inference process, prompt information may be generated.
[0132] Optionally, after determining the prompt information based on the above method, the prompt information can be transmitted via the cloud to the interactive interface for inputting the query information corresponding to the prompt information for display. If the prompt information is inaccurate or does not meet the user's needs, a corresponding adjustment operation can be performed on the interactive interface to issue a corresponding request to modify the prompt information. The modified prompt information, which is accurate or meets the user's needs, is sent to the corresponding interactive interface for display, thereby ensuring the accuracy of the obtained prompt information and further ensuring the accuracy of the structured query language generated subsequently.
[0133] Step S408: input the prompt information into the dialogue model, and display the structured query language obtained by analyzing the prompt information and database information using the dialogue model on the interactive interface.
[0134] In the technical solution provided in the above step S408 of the present disclosure, after displaying the prompt information generated at least based on the database information on the interactive interface, the prompt information can be used to prompt the dialogue model to start generating the corresponding structured query language, and after the dialogue model generates the structured query language, it can be displayed on the interactive interface, wherein the dialogue model can be a trained SQL dialogue model, which can also be an NL2SQL model.
[0135] Alternatively, a well-performing NL2SQL model can be used to assist in data development. This NL2SQL model can be deployed in the cloud. When prompted, it can trigger the NL2SQL model to start generating SQL statements. The NL2SQL model can generate the SQL statement required by the user and send it to the corresponding interactive interface for display.
[0136] Optionally, after the required structured query language is displayed on the interactive interface, if the structured query language is inaccurate or does not meet the user's needs, a corresponding adjustment operation can be performed on the interactive interface to issue a corresponding request to modify the structured query language, and the modified structured query language that is accurate or meets the user's needs is sent to the corresponding interactive interface for display, thereby ensuring the accuracy of the required structured query language.
[0137] In the embodiment of the present disclosure, in order to solve the problem of single NL to SQL statement mapping, it is necessary to organize the existing data so that the model can learn patterns from rich query information (input information). Further modeling of database information matching the SQL statement can be considered, so as to organize the NL2SQL data into a form of NL and DDL combined and mapped to SQL, so that the model can learn enough knowledge from natural language and database information, and then generate corresponding SQL statements based on this. Based on the above method, it is possible to avoid situations that are divorced from reality and difficult to apply, and achieve the purpose of being practical and easy to apply to data development, thereby solving the technical problem of the inability to effectively generate SQL statements in related technologies.
[0138] Through steps S402 to S408 of the present disclosure, when it is desired to display the structured query language used for data development on the interactive interface of the client device, a query message composed of natural language capable of generating the structured query language can be input on the interactive interface. After detecting the presence of the query message in the interactive interface, database information that matches the structured query language corresponding to the query message is determined from the database based on the query message and transmitted to the interactive interface for display. At least prompt information corresponding to the structured query language can be generated based on the database information and transmitted to the interactive interface for display. The prompt information can be used to prompt the dialogue model to generate the corresponding required structured query language and transmit it to the interactive interface for display. Since further modeling can be performed on the database information corresponding to the structured information, the unrealistic and difficult-to-apply issues encountered in the above-mentioned techniques are avoided, thereby achieving the goal of improving the accuracy of the generated structured information and its degree of alignment with actual conditions. This achieves the technical effect of effectively generating the structured query language and solves the technical problem of being unable to effectively generate the structured query language.
[0139] The above method of this embodiment is further introduced below.
[0140] As an optional implementation, step S406 displays prompt information generated at least based on database information on the interactive interface, including: inputting the operation function and database information into an information generation template, and displaying the generated prompt information on the interactive interface, wherein the information generation template is used to represent the rules for generating prompt information in the query scenario corresponding to the structured query language.
[0141] In this embodiment, an information generation template may be used to generate prompt information from the operation function and database information, wherein the information generation template may be used to represent a rule for generating prompt information in a query scenario corresponding to a structured query language.
[0142] Optionally, the operation function and database information are input into the information generation template, which can be processed to obtain corresponding prompt information, and can be sent to the interactive interface, and the generated prompt information can be displayed on the interactive interface.
[0143] Optionally, during the database information screening process during model inference, the table and field screening model can be used to automatically filter and extract from the database database information (i.e., tables and fields) that are useful for generating the SQL statements required by the user, based on the different user needs in different query scenarios. This information is then used as the model input for the conversational model.
[0144] Optionally, after the database information screening process is complete, a zero-shot inference process can be performed. During this process, based on the user's needs in different query scenarios, the user's question (i.e., the user's structured query language operation function) can be embedded in a predefined template, combined with the database information extracted in the above steps. This template, which embeds the completed operation function and database information, is then input into the conversational model as prompt information. The conversational model analyzes this information, infers the user's required structured query language, and uses this structured query language as the model output of the conversational model. This is then returned to the interactive interface of the corresponding client device for display, i.e., the model output is returned to the user.
[0145] As an optional implementation, the method further includes: inputting the operation function and database information into an information generation template, and displaying the generated prompt information on an interactive interface, wherein the information generation template is used to represent the rules for generating prompt information in a query scenario corresponding to a structured query language.
[0146] In this embodiment, the operation function type corresponding to the structured query language to be generated can be determined, and database information matching the operation function type can be obtained, wherein the operation function type can be used to indicate the type of the operation function.
[0147] Optionally, according to the operation function type corresponding to the structured query language to be generated, database information corresponding to different operation function types is determined, and the database information can be sent to a corresponding interactive interface for display.
[0148] In the embodiments of the present disclosure, since SQL statements have a variety of operational functions, and in data development, SQL statements with different operational functions may be required to assist in data development, corresponding database information needs to be configured for SQL statements of different operational function types. Therefore, when a user has the opportunity to generate a required SQL statement, he or she can select the corresponding operational function type according to his or her own choice to perform targeted problem processing, and the corresponding database information under the corresponding operational function type is matched from the database, thereby improving the pertinence and accuracy of determining the database information.
[0149] As an optional implementation, the method further includes: determining, in a query information sample set, a query information sample having the highest similarity to the query information, and determining, in a structured query language sample set, a structured query language sample corresponding to the query information sample, wherein the query information sample set and the structured query language sample set are used to train a dialogue model, and the query information sample is used to represent the semantics of the structured query language sample; step S406, displaying, on an interactive interface, prompt information generated at least based on database information, including: displaying, on the interactive interface, prompt information generated based on the structured query language sample, the query information sample, and the database information.
[0150] In this embodiment, the query information sample with the highest similarity to the query information can be determined from the query information sample set, and the structured query language sample corresponding to the query information sample set can be determined from the structured query language sample set. Furthermore, corresponding prompt information can be determined based on the structured query language sample, the query information sample, and the database information, and the prompt information can be sent to the interactive interface for display.
[0151] Optionally, during model inference, after zero-shot inference, a few-shot inference process can be performed. Before performing few-shot inference, based on the user's query question (i.e., natural language), similar queries and corresponding SQL statements can be extracted from the training set. Specifically, a natural language sample similar to the natural language presented in the current query question is determined from the natural language sample set in the training set, and a structured query language sample corresponding to the natural language sample is determined from the structured query language sample set in the training set, resulting in a natural language sample-structured query language sample pair, i.e., a query question-SQL statement pair. Thus, during the few-shot inference process, prompt information can be determined using the natural language sample-structured query language sample pair corresponding to the natural language sample with the greatest similarity to the currently input natural language, along with the corresponding database information. This prompt information is then input into the conversation model to help the conversation model infer the structured query language corresponding to the current natural language.
[0152] As an optional implementation, the method further includes: modifying the query information sample set in response to a modification operation performed on the interactive interface.
[0153] In this embodiment, the query information sample set can be displayed on the interactive interface. When a modification operation to modify the query information sample set is detected on the interactive interface, a corresponding modification instruction can be generated to modify the corresponding query information sample set and display the modified query information sample set.
[0154] The embodiment of the present disclosure also provides a method for generating a structured query language from an interactive side, wherein the interactive side may be a dialogue generation system, which may also be called a dialogue interface.
[0155] FIG5 is a flow chart of another method for generating a structured query language according to an embodiment of the present disclosure. As shown in FIG5 , the method may include the following steps:
[0156] Step S502 : responding to multimodal information received in the dialogue interface, wherein the multimodal information includes query information corresponding to the structured query language to be generated, and the query information is used to represent the semantics of the structured query language to be generated.
[0157] In the technical solution provided in step S502 above, multimodal information can be input into the dialog interface for communicating with the SQL assistant, wherein the query information can be used to represent the semantics of the structured query language to be generated. The multimodal information can include query information corresponding to the structured query language to be generated.
[0158] Optionally, when generating the required structured query language, the client device can communicate with the SQL assistant on a dialogue interface capable of communicating with the SQL assistant regarding the structured query language that the enterprise intends to use for the data to be developed. Multimodal information capable of expressing the required structured query language can be entered into the dialogue interface, and the multimodal information can be displayed in the dialogue interface.
[0159] Optionally, after receiving the multimodal information in the dialogue interface, a structured query language required by the user may be generated based on the multimodal information.
[0160] Step S504 : displaying database information matching the structured query language to be generated in the dialogue interface, wherein the database information is used to represent the data structure required for executing the operation function corresponding to the converted structured query language in the database.
[0161] In the technical solution provided in the above step S504 of the present disclosure, database information matching the structured query language to be generated can be displayed in the dialogue interface, wherein the database information can be used to represent the data structure required to execute the corresponding operation function of the converted structured query language in the database.
[0162] Optionally, after inputting multimodal information corresponding to the required structured query language on the dialogue interface, the multimodal information can be transmitted to the server through the dialogue interface for processing. The server can then determine database information that matches the structured query language and send the database information to the dialogue interface of the corresponding client device for display.
[0163] Step S506: Displaying prompt information generated at least based on the database information on the dialogue interface.
[0164] In this embodiment, prompt information generated at least based on database information may be displayed on the dialogue interface.
[0165] Optionally, the server may determine corresponding prompt information based at least on the database information, and send the corresponding prompt information to the dialogue interface of the client device for display.
[0166] Step S508: input the prompt information into a dialogue model, and use the dialogue model to analyze the query information and the database information in the prompt information, and output a structured query language.
[0167] In this embodiment, prompt information may be used to prompt the dialogue model to generate a corresponding structured query language.
[0168] Optionally, a dialogue model with good performance can be used to assist in data development. This dialogue model is deployed on a server, and when prompted, it can trigger the dialogue model to start generating structured query language. The dialogue model can then generate the structured query language required by the user and send it to the corresponding dialogue interface.
[0169] Step S510: Displaying the response information generated based on the structured query language on the dialogue interface.
[0170] In this embodiment, after the dialogue interface receives the structured query language sent by the server, reply information generated based on the structured query language may be displayed on the dialogue interface.
[0171] Through the above-mentioned steps S502 to S510 of the present disclosure, in response to multimodal information received in the dialogue interface, wherein the multimodal information includes a natural language corresponding to the structured query language to be generated, and the natural language is used to represent the semantics of the structured query language to be generated; database information matching the structured query language to be generated is displayed in the dialogue interface, wherein the database information is used to represent the data structure required for executing the corresponding operation function of the converted structured query language in the database; prompt information generated based on at least the database information is displayed on the dialogue interface; the prompt information is used to prompt the dialogue model to generate the structured query language; and reply information generated based on the structured query language is displayed on the dialogue interface, thereby achieving the technical effect of being able to effectively generate the structured query language and solving the technical problem of being unable to effectively generate the structured query language.
[0172] The above method of this embodiment is further introduced below.
[0173] As an optional embodiment, the type of multimodal information includes at least one of the following: text information containing character information, video frame information containing frame image information, and audio information; the type of reply information includes at least one of the following: text information, image information, video information, and voice information.
[0174] In this embodiment, the types of multimodal information may include at least one of the following: text information including character information, video frame information including frame images, and audio information. It should be noted that the above multimodal information types are only examples and are not specifically limited here.
[0175] According to an embodiment of the present disclosure, a data generation method is also provided based on the upper-layer software service side of the computing edge. 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 the 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.
[0176] FIG6 is a flow chart of another method for generating a structured query language according to an embodiment of the present disclosure. As shown in FIG6 , the method may include the following steps:
[0177] Step S602: Detect query information to be converted by calling a first interface, wherein the first interface includes a first parameter, the parameter value of the first parameter is query information, and the query information is used to represent the semantics of the structured query language to be converted.
[0178] In the technical solution provided in the above step S602 of the present disclosure, a first interface can be called to detect whether there is query information to be converted on the interactive interface, wherein the first interface may include a first parameter, the parameter value of the first parameter may be query information, and the query information is used to represent the semantics of the structured query language to be converted.
[0179] Step S604: Obtain database information that matches the structured query language to be converted, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the structured query language to be converted in the database.
[0180] In the technical solution provided in the above step S604 of the present disclosure, database information matching the structured query language to be converted can be obtained, wherein the database information can be used to represent the data structure required to execute the corresponding operation function of the structured query language to be converted in the database.
[0181] Optionally, after obtaining query information about a certain structured query language in the interactive interface, the query information can be transmitted to the server for processing. The server can call the database to filter out data structures that match the SQL statement required by the query information from a large number of data structures in the database, that is, filter out tables and fields that are beneficial to generating the SQL statement from a large number of tables and fields in the database.
[0182] Optionally, during the model inference process included in the automated conversion method for implementing NL2SQL, database information screening can be performed. That is, a table and field screening model can be used to screen the automatically acquired DDL, and tables and fields that are beneficial for generating the corresponding SQL can be extracted from a large amount of DDL as model input.
[0183] Step S606: Generate prompt information based at least on the database information.
[0184] In the technical solution provided in the above step S606 of the present disclosure, prompt information can be generated based at least on the database information.
[0185] Optionally, in the model inference process included in the NL2SQL automatic conversion method, zero-sample inference can be performed after database information screening. In the zero-sample inference process, prompt information can be generated first.
[0186] Step S608: input the prompt information into the dialogue model, and use the dialogue model to analyze the query information and database information in the prompt information to output a structured query language.
[0187] In the technical solution provided in the above step S608 of the present disclosure, prompt information can be used to prompt the dialogue model, and the query information in the prompt information can be converted into a structured query language.
[0188] Optionally, during the data organization and model training process, the pre-trained code language model can be fine-tuned in a supervised manner to enable it to use NL2SQL, resulting in a trained conversational model. After training, a model evaluation can be performed. Specifically, during this evaluation, the trained conversational model can be tested on a standard dataset to assess its performance. If the evaluation passes, the conversational model can be put into normal use, i.e., deployed to a server to generate structured query language based on query information.
[0189] Step S610: Outputting structured query language by calling a second interface, wherein the second interface includes a second parameter, and a parameter value of the second parameter is structured query language.
[0190] In the technical solution provided in the above step S610 of the present disclosure, the structured query language can be output by calling the second interface, wherein the second interface can include a second parameter, and the parameter value of the second parameter can be the structured query language.
[0191] Through the above-mentioned steps S602 to S610 of the present disclosure, the natural language to be converted is detected by calling a first interface, wherein the first interface includes a first parameter, the parameter value of the first parameter is a natural language, and the natural language is used to represent the semantics of the structured query language to be converted; database information matching the structured query language to be converted is obtained, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the structured query language to be converted in the database; prompt information is generated based on at least the database information; the prompt information is used to prompt the dialogue model to convert the natural language into the structured query language; and the structured query language is output by calling a second interface, wherein the second interface includes a second parameter, the parameter value of the second parameter is the structured query language, thereby achieving the technical effect of being able to effectively generate the structured query language and solving the technical problem of being unable to effectively generate the structured query language.
[0192] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0193] It should be noted that for the aforementioned method embodiments, for simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present disclosure is not limited by the order of the actions described, because according to the present disclosure, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present disclosure.
[0194] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of the present disclosure.
[0195] Example 2
[0196] In the current era of big data, data development has become a critical task for enterprises. This project aims to help data developers generate SQL statements for data development using natural language, thereby improving productivity. Related technologies currently rely solely on the traditional NL2SQL model for determining SQL statements. This model simply maps NL to SQL statements, but lacks the ability to model the database information that matches the SQL statements. This makes it unrealistic and difficult to apply to actual data development. Consequently, the technical problem of effectively converting data persists.
[0197] Optionally, the present disclosure provides a text-to-SQL conversion method based on a large language model, which solves the technical problem of being unable to effectively convert data. Unlike traditional solutions that do not model database information that matches SQL statements, this method avoids the technical problem of being unable to effectively convert data due to being out of touch with reality and difficult to apply to actual data development, and solves the technical problem of being unable to effectively convert data.
[0198] In an embodiment of the present disclosure, upon detecting the presence of natural language to be converted into structured query language in a client's interactive interface, the natural language can be transmitted from the client to the cloud. Based on the natural language, the cloud can determine from a database the data structure required for the operation function performed when executing the structured query language corresponding to the natural language, and generate prompt information corresponding to the structured query language based on the matched data structure. The cloud can use the prompt information to prompt the dialogue model to generate the corresponding required structured query language, which can then be transmitted to the corresponding client's interactive interface for display.
[0199] Since the present disclosure can further model the database information corresponding to the structured information, it avoids the abnormal situations that occur in the above-mentioned related technologies, thereby achieving the purpose of improving the accuracy of the required structured information generated and the degree of fit with actual applications, thereby achieving the technical effect of effectively converting data and solving the technical problem of being unable to effectively convert data.
[0200] The above method of this embodiment is further introduced below.
[0201] In this example, a method for automated natural language to SQL (NL2SQL) conversion was constructed using a pretrained code language model. This method primarily relies on the fundamental understanding capabilities of a large language model, including understanding natural language and code. The method primarily relies on the following components: data organization, model training, model evaluation, and model reasoning.
[0202] In this embodiment, to address the numerous issues inherent in the prior art of solely mapping NL to SQL, the disclosed embodiment organizes existing open-source data so that the conversational model can learn patterns from the rich information within. This organizes the NLSQL data into a NL+DDL to SQL format, enabling the conversational model to learn sufficient knowledge from NL and DDL. Generating corresponding SQL statements based on this knowledge ensures more accurate SQL statements.
[0203] Optionally, during the data organization process, open source data can be acquired and converted. During the acquisition and conversion of open source data, open source NLSQL data can be used, and the open source structured query language in the form of a non-data warehouse tool (Hive) can be generated into Hive format, including DDL statements and SQL statements.
[0204] Optionally, during the data organization process, after acquiring and converting the open source data, an automated generation process for application function data can be performed. In this process, the existing SQL statements in the application function data can be categorized according to their operational functions, and a number of SQL statements from each category can be extracted for backup.
[0205] Optionally, after extracting several SQL statements for each category, a SQL conversation model trained on open-source data can be used to generate natural language descriptions to form NL2SQL data pairs for application function data. These NL2SQL data pairs require manual verification and modification to ensure accuracy.
[0206] For example, Figure 7 is a schematic diagram of an SQL classification result according to an embodiment of the present disclosure. As shown in Figure 7, SQL can be classified into the following six categories: 1) Data query language; 2) Database schema definition language; 3) Data manipulation language; 4) Scripting language; 5) Data control language; 6) Command language. It should be noted that the number and types of SQL classified above are for illustrative purposes only and are not intended to be limiting.
[0207] For another example, as shown in FIG7 , the DQL class may include the following statements: CTE Select statements (e.g., WITH SELECT), basic query Select statements (e.g., Select", select distinct, Select field, and Select From Table), branch statements (e.g., Case WHEN), aggregate functions (e.g., SUM, COUNT, AVG, MIN, MAX, and HAVING), built-in functions (e.g., max_pt), window functions (e.g., WINDOW, OVER, FILTER, and Row_Number), QUALIFY statements (e.g., QUALIFY), transformation PIVOT statements (e.g., PIVOT and UNPIVOT), subquery statements (e.g., a Select statement nested within a Select statement), join Select statements (e.g., INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, and SEMI JOIN), Union Select statements (e.g., intersect, union, except, and minus), conditional query Select statements (e.g., WHERE and partitioning and non-partitioning), sorting Select statements (e.g., ORDER BY). BY), grouping select statements (for example, GROUP BY), and limiting select statements (for example, LIMIT). WHERE can include LIKE, RLIKE, REGEXP, IN, NOT IN, BETWEEN, IS NULL, IS NOT NULL, NOT, =, AND, OR, >, >=, <, and <=. ORDER BY can include DESC and ASC.
[0208] As an optional example, as shown in Figure 7, the DDL class can include the following statements: CREATE statements (e.g., Create Table and Create Function), ALTER statements (e.g., ALTER TABLE), and DROP statements (e.g., DROP TABLE and DROP FUNCTION). Create Table statements can include Create Non-Partition Table, Create Partition Table, and Create External Table.
[0209] For example, as shown in Figure 7, the DML class may include the following statements: INSERT statements (e.g., INSERT INTO and INSERT OVERWRITE), UPDATE statements (e.g., UPDATE SET), DELETE statements (e.g., DELETE), and MERGE statements (e.g., MERGE INTO). The TCL class may include the following statements: COMMIT and ROLLBACK. The DCL class may include the following statements: GRANT and REVOKE. The COMMAND class may include the following statement: SET.
[0210] In this embodiment, after the data organization process is completed, the model training process can be started. In this process, the large model can be supervised trained based on the classified database information sample set, that is, supervised fine-tuning, to obtain a dialogue model with NL2SQL capabilities.
[0211] Optionally, supervised fine-tuning is performed based on the pre-trained language model Starcoder so that the model acquires NL2SQL capabilities and becomes a conversational model.
[0212] Optionally, after model training, a model evaluation process begins. During this process, the trained conversation model can be tested on a standard dataset to evaluate its performance. If the evaluation results pass, the conversation model can be put into normal use. That is, the conversation model can be deployed to a server to generate structured query language based on query information.
[0213] Alternatively, a well-performing NL2SQL model can be used to assist in data development. This NL2SQL model is deployed on a server, and when prompted, it triggers the NL2SQL model to start generating SQL statements. The NL2SQL model generates the SQL statement required by the user and sends it to the corresponding interactive interface for display.
[0214] In this embodiment, after the model evaluation process is completed, model inference can begin.
[0215] Optionally, during the database information screening process during model inference, the table and field screening model can be used to automatically filter and extract database information (i.e., tables and fields) from the database that is useful for generating the SQL statements required by the user, based on the different user needs in different query scenarios. This information is then used as model input for the conversational model. For example, the table and field screening model can be used to filter automatically acquired DDL and extract tables and fields that are useful for generating SQL statements as model input.
[0216] Optionally, after the database information screening process is complete, a zero-shot inference process can be performed. During this process, based on the user's needs in different query scenarios, the user's question (i.e., the user's structured query language operation function) can be embedded in a predefined template, combined with the database information extracted in the above steps. This template, which embeds the completed operation function and database information, is then input into the conversational model as prompt information. The conversational model analyzes this information, infers the user's required structured query language, and uses this structured query language as the model output of the conversational model. This is then returned to the interactive interface of the corresponding client device for display, i.e., the model output is returned to the user.
[0217] For example, the SQL generation prompt: Given the following MaxCompute database information: ${schema}, answer the question (if it is a partitioned table, add partition field conditions): ${prompt}. SQL error correction prompt: Based on MaxCompute SQL syntax rules and the requirements of ${prompt}, please fix the SQL bug: ```sql\n${schema}. SQL comment prompt: Please comment on the following MaxCompute SQL: ```sql\n${schema}\n``` and retain the original SQL: ${prompt}. SQL rewrite prompt: Given the following SQL: ```sql\n${schema}\n```, modify it according to MaxCompute SQL syntax rules and return: ${prompt}. SQL extraction prompt: Given the following text content: ${prompt}, extract the SQL from it and return it. It should be noted that the above are only examples of prompts corresponding to several SQL functions, where schema is a DDL or SQL statement and prompt is obtained based on the user's selection, that is, prompt is user input.
[0218] Optionally, during model inference, after zero-shot inference, a few-shot inference process can be performed. Before performing few-shot inference, based on the user's query question (i.e., query information), similar queries and corresponding SQL statements can be extracted from the training set. Specifically, natural language samples similar to the natural language presented in the current query question are identified from the natural language sample set in the training set, and structured query language samples corresponding to the natural language samples are identified from the structured query language sample set in the training set, resulting in a natural language sample-structured query language sample pair, i.e., a query question-SQL statement pair. Thus, during the few-shot inference process, prompt information can be determined using the natural language sample-structured query language sample pair corresponding to the natural language sample with the greatest similarity to the currently input natural language, along with the corresponding database information. This prompt information is then input into the conversation model to help the conversation model infer the structured query language corresponding to the current natural language.
[0219] For example, FIG8 is a schematic diagram of a model reasoning according to an embodiment of the present disclosure. As shown in FIG8 , based on different user needs, that is, user selections, for example, the user can select SQL generation, SQL error correction, SQL comment writing, SQL rewriting, or SQL Q&A. Problem processing can be performed on the user selection, such as table lookup or prompting, and can be embedded in a predefined template to generate prompt information, output the prompt information, and input the prompt information into the SQL dialogue model for reasoning, and the output of the model is returned to the user, that is, structured query language can be generated and output to the client device.
[0220] For another example, the prompt message might be as follows: <|system|> The following is a conversation between a SQL assistant and a human. The assistant answers questions based on the human's questions, simply outputting SQL statements. SQL statements are returned as Markdown code, avoiding redundant information. The <|user|> model can answer questions based on the following similar examples: \nAsk and answer the following questions: {Similar question 1}\n{SQL statement for question 1}\nAsk and answer the following questions: {Similar question 2}\n{SQL statement for question 2}\nAsk and answer the following questions: {Similar question 3}\n{SQL statement for question 3}\nGiven the following database information: {Table information}, answer the SQL query question: {User question}. <|bot|>
[0221] It should be noted that the preferred implementation scheme involved in the above embodiments of the present disclosure is the same as the solution provided in Example 1, as well as the application scenario and implementation process, but is not limited to the solution provided in Example 1.
[0222] Example 3
[0223] According to an embodiment of the present disclosure, a system for generating a structured query language is also provided. FIG9 is a schematic diagram of a system for generating a structured query language according to an embodiment of the present disclosure. As shown in FIG9 , the system for generating a structured query language may include an input terminal 902 , a processing terminal 904 , and a model inference terminal 906 .
[0224] The input terminal 902 is used to input query information to be converted, wherein the query information is used to represent the semantics of the structured query language to be converted.
[0225] In the technical solution provided by the input terminal 902 of the present disclosure, the natural language to be converted can be input through the input terminal 902, wherein the natural language can be used to represent the semantics of the structured query language to be converted.
[0226] Optionally, a detection is performed to determine whether there is a natural language to be converted in the interactive interface. When it is detected that there is a natural language to be converted, the natural language may be transmitted to the processing end 904 through the input end 902 for processing.
[0227] The processing end 904 is used to obtain database information that matches the structured query language to be converted, and generate prompt information based at least on the database information, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the structured query language to be converted in the database.
[0228] In the technical solution provided by the processing end 904 of the present disclosure, the processing end 904 processes the natural language to determine database information that matches the structured query language to be converted, and can generate prompt information based at least on the database information, wherein the database information can be used to represent the data structure required to execute the corresponding operation function of the structured query language to be converted in the database.
[0229] Optionally, after obtaining the natural language of a structured query language in the interactive interface, the natural language can be processed. By calling the database, data structures that match the SQL statements required by the natural language can be screened out from a large number of data structures in the database, that is, tables and fields that are beneficial to generating the SQL statement can be screened out from a large number of tables and fields in the database.
[0230] Optionally, in the model inference process included in the NL2SQL automated conversion method, zero-sample inference may be performed after database information screening. During the zero-sample inference process, prompt information may be generated.
[0231] Optionally, corresponding prompt information can be generated for different operation functions. For example, for the SQL generation function, for the database information matched based on the query information in the server, that is, for the given database information, the corresponding prompt information can be determined by answering questions.
[0232] The model inference terminal 906 is used to input the prompt information into the dialogue model, and use the dialogue model to analyze the query information and database information in the prompt information, and output structured query language.
[0233] In the technical solution provided by the above-mentioned model inference end 906 of the present disclosure, the model inference end can use prompt information to prompt the dialogue model and generate a structured query language.
[0234] Alternatively, a well-performing NL2SQL model can be used to assist in data development. This NL2SQL model is deployed on a server, and when prompted, it triggers the NL2SQL model to start generating SQL statements. The NL2SQL model generates the SQL statement required by the user and sends it to the corresponding interactive interface for display.
[0235] The structured query language generation system disclosed herein uses an input terminal to input natural language to be converted, where the natural language is used to represent the semantics of the structured query language to be converted. A processing terminal obtains database information matching the structured query language to be converted, and generates prompt information based at least on the database information, where the database information represents the data structure required to execute the corresponding operation function of the structured query language to be converted. A model inference terminal uses the prompt information to prompt a dialogue model to convert the natural language into structured query language. This achieves the technical effect of effectively generating structured query language, solving the technical problem of being unable to effectively generate structured query language.
[0236] Example 4
[0237] According to an embodiment of the present disclosure, there is also provided a structured query language generation device for implementing the structured query language generation method shown in FIG. 2 .
[0238] FIG10 is a schematic diagram of a structured query language generation apparatus according to an embodiment of the present disclosure. As shown in FIG10 , the structured query language generation apparatus 1000 may include: a first detection unit 1002 , a first acquisition unit 1004 , a first generation unit 1006 , and a first conversion unit 1008 .
[0239] The first detection unit 1002 is configured to detect query information to be converted from a client, wherein the query information is used to represent the semantics of the structured query language to be converted.
[0240] The first acquiring unit 1004 is configured to acquire database information matching the structured query language to be converted, wherein the database information is used to represent a data structure required for executing an operation function corresponding to the structured query language to be converted in the database.
[0241] The first generating unit 1006 is configured to generate prompt information based at least on the database information.
[0242] The first conversion unit 1008 is configured to input the prompt information into the dialogue model, analyze the query information and database information in the prompt information using the dialogue model, and output a structured query language.
[0243] It should be noted that the first detection unit 1002, first acquisition unit 1004, first generation unit 1006, and first conversion unit 1008 described above correspond to steps S202 to S208 in Example 1. The examples and application scenarios implemented by the four units and the corresponding steps are the same, but are not limited to the contents disclosed in Example 1. It should be noted that the above-mentioned units can be hardware components or software components stored in a memory and processed by one or more processors. The above-mentioned units can also be part of an apparatus and can be run in the computer terminal provided in Example 5.
[0244] According to an embodiment of the present disclosure, a model generation device for implementing the model generation method shown in FIG. 3 is also provided.
[0245] FIG11 is a schematic diagram of a model generation device according to an embodiment of the present disclosure. As shown in FIG11 , the model generation device 1100 may include: a second acquisition unit 1102 , a first processing unit 1104 , and a first training unit 1106 .
[0246] The second acquiring unit 1102 is configured to acquire a database information sample set corresponding to the structured query language sample set.
[0247] The first processing unit 1104 is configured to input the database information sample set into the initial dialogue model, analyze the database information sample set using the initial dialogue model, and output a query information sample set corresponding to the structured query sample set, wherein the initial dialogue model is trained based on at least the initial structured query sample set, and the query information samples in the query information sample set are used to represent the semantics of corresponding structured query language samples in the structured query language sample set.
[0248] The first training unit 1106 is used to train the large model based on the database information sample set and the query information sample set to obtain a dialogue model, wherein the dialogue model is used to analyze the query information and database information in the prompt information to generate a structured query language. The prompt information is generated based on at least the database information that matches the structured query language. The query information is used to represent the semantics of the structured query language, and the database information is used to represent the data structure required to execute the corresponding operation function of the structured query language in the database.
[0249] It should be noted that the second acquisition unit 1102, the first processing unit 1104, and the first training unit 1106 correspond to steps S302 to S306 in Example 1. The three units and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in Example 1. It should be noted that the above units can be hardware components or software components stored in a memory and processed by one or more processors. The above units can also be part of the device and can run in the computer terminal provided in Example 5.
[0250] According to an embodiment of the present disclosure, there is also provided a structured query language generation device for implementing the structured query language generation method shown in FIG. 4 .
[0251] FIG12 is a schematic diagram of a structured query language generation apparatus according to an embodiment of the present disclosure. As shown in FIG12 , the structured query language generation apparatus 1200 may include: a second detection unit 1202 , a first display unit 1204 , a second display unit 1206 , and a third display unit 1208 .
[0252] The second detection unit 1202 is configured to detect query information received in the interactive interface, wherein the query information is used to represent the semantics of the structured query language to be generated.
[0253] The first display unit 1204 is used to display database information matching the structured query language to be generated in the interactive interface in response to the query information, wherein the database information is used to represent the data structure required to execute the operation function corresponding to the structured query language to be generated in the database.
[0254] The second display unit 1206 is configured to display prompt information generated at least based on the database information on the interactive interface.
[0255] The third display unit 1208 is used to input the prompt information into the dialogue model, and display on the interactive interface a structured query language obtained by analyzing the query information and database information in the prompt information using the dialogue model.
[0256] It should be noted that the second detection unit 1202, first display unit 1204, second display unit 1206, and third display unit 1208 correspond to steps S402 to S408 in Example 1. The four units and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in Example 1. It should be noted that the above-mentioned units can be hardware components or software components stored in a memory and processed by one or more processors. The above-mentioned units can also be part of the device and can be run in the computer terminal provided in Example 5.
[0257] According to an embodiment of the present disclosure, there is also provided a structured query language generation device for implementing the structured query language generation method shown in FIG. 5 .
[0258] FIG13 is a schematic diagram of another structured query language generation device according to an embodiment of the present disclosure. As shown in FIG13 , the structured query language generation device 1300 may include: a first receiving unit 1302 , a fourth display unit 1304 , a fifth display unit 1306 , a second generating unit 1308 , and a sixth display unit 1310 .
[0259] The first receiving unit 1302 is configured to respond to multimodal information received in the dialogue interface, wherein the multimodal information includes query information corresponding to the structured query language to be generated, and the query information is used to represent the semantics of the structured query language to be generated.
[0260] The fourth display unit 1304 is used to display database information matching the structured query language to be generated in the dialogue interface, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the converted structured query language in the database.
[0261] The fifth display unit 1306 is configured to display prompt information generated at least based on the database information on the dialogue interface.
[0262] The second generating unit 1308 is configured to input the prompt information into the dialogue model, analyze the query information and database information in the prompt information using the dialogue model, and output a structured query language.
[0263] The sixth display unit 1310 is configured to display the response information generated based on the structured query language on the dialogue interface.
[0264] It should be noted that the first receiving unit 1302, the fourth display unit 1304, the fifth display unit 1306, the second generating unit 1308, and the sixth display unit 1310 correspond to steps S502 to S510 in Example 1. The examples and application scenarios implemented by the five units and the corresponding steps are the same, but are not limited to the contents disclosed in Example 1. It should be noted that the above-mentioned units can be hardware components or software components stored in a memory and processed by one or more processors. The above-mentioned units can also be part of the device and can be run in the computer terminal provided in Example 5.
[0265] According to an embodiment of the present disclosure, a structured query language generation device for implementing the structured query language generation method shown in FIG. 6 is also provided.
[0266] FIG14 is a schematic diagram of another structured query language generation apparatus according to an embodiment of the present disclosure. As shown in FIG14 , the structured query language generation apparatus 1400 may include: a first calling unit 1402 , a third acquiring unit 1404 , a third generating unit 1406 , a second converting unit 1408 , and a second calling unit 1410 .
[0267] The first calling unit 1402 is configured to detect query information to be converted by calling a first interface, wherein the first interface includes a first parameter, the parameter value of the first parameter is query information, and the query information is used to represent the semantics of the structured query language to be converted.
[0268] The third acquiring unit 1404 is configured to acquire database information matching the structured query language to be converted, wherein the database information is used to represent a data structure required to execute an operation function corresponding to the structured query language to be converted in the database.
[0269] The third generating unit 1406 is configured to generate prompt information based at least on the database information.
[0270] The second conversion unit 1408 is configured to input the prompt information into the dialogue model, analyze the query information and database information in the prompt information using the dialogue model, and output a structured query language.
[0271] The second calling unit 1410 is configured to output the structured query language by calling a second interface, wherein the second interface includes a second parameter, and a parameter value of the second parameter is the structured query language.
[0272] It should be noted that the first calling unit 1402, the third obtaining unit 1404, the third generating unit 1406, the second converting unit 1408, and the second calling unit 1410 described above correspond to steps S602 to S610 in Example 1. The examples and application scenarios implemented by the five units and the corresponding steps are the same, but are not limited to the contents disclosed in Example 1. It should be noted that the above-mentioned units can be hardware components or software components stored in a memory and processed by one or more processors. The above-mentioned units can also be part of the device and can be run in the computer terminal provided in Example 5.
[0273] In the above-described device, when a client needs structured query language to assist in data development, it can input the corresponding semantics that can generate the structured query language, that is, query information corresponding to the structured query language, on the client's interactive interface. After detecting the presence of query information to be converted into structured query language in a client's interactive interface, the query information can be transmitted from the client to the cloud. Based on the query information, the cloud can determine from the database the data structure required for the operation function performed when executing the structured query language corresponding to the query information, that is, the database information that matches the structured query language, and transmit it to the corresponding client's interactive interface for display. The cloud can generate prompt information corresponding to the structured query language based on at least the database information, and transmit it to the corresponding client's interactive interface for display. The cloud can use the prompt information to prompt the dialogue model to generate the corresponding required structured query language, and transmit it to the corresponding client's interactive interface for display. Considering that related technologies only generate structured query languages based on the mapping between query information and structured query languages, which may be out of touch with reality and difficult to apply, the present disclosure can further model the database information corresponding to the structured information, avoiding the abnormal situations that occur in the above-mentioned related technologies, thereby achieving the purpose of improving the accuracy of the structured information to be generated and the degree of fit with actual applications, thereby achieving the technical effect of effectively generating structured query languages and solving the technical problem of being unable to effectively generate structured query languages.
[0274] Example 5
[0275] The embodiment of the present disclosure may provide a computer terminal, which may be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal may also be replaced by a terminal device such as a mobile terminal.
[0276] Optionally, in this embodiment, the computer terminal may be located in at least one network device among a plurality of network devices of a computer network.
[0277] In this embodiment, the computer terminal can execute program code for the following steps in the structured query language generation method: detecting query information to be converted from a client, wherein the query information is used to represent the semantics of the structured query language to be converted; obtaining database information matching the structured query language to be converted, wherein the database information is used to represent a data structure required to execute an operation function corresponding to the structured query language to be converted in the database; generating prompt information based at least on the database information; inputting the prompt information into a dialogue model, and using the dialogue model to analyze the query information and database information in the prompt information to output the structured query language.
[0278] Optionally, Figure 15 is a block diagram of a computer terminal according to an embodiment of the present disclosure. As shown in Figure 15, the computer terminal A may include: one or more (only one is shown in the figure) processors 1502, a memory 1504, a storage controller, and a peripheral interface, wherein the peripheral interface is connected to a radio frequency module, an audio module, and a display.
[0279] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the method and device for generating structured query language in the embodiment of the present disclosure. 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 for generating structured query language. 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 can be connected to the computer terminal A 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 a combination thereof.
[0280] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: determining the operation function type corresponding to the structured query language to be generated; and obtaining database information matching the operation function type.
[0281] Optionally, the processor may further execute program code of the following steps: using an information generation template to generate prompt information from the operation function and database information.
[0282] Optionally, the processor may further execute program code for the following steps: determining, in a query information sample set, a query information sample having the highest similarity to the query information, and determining, in a structured query language sample set, a structured query language sample corresponding to the query information sample, wherein the query information sample set and the structured query language sample set are used to train a dialogue model, and the query information sample is used to represent the semantics of the structured query language sample; and generating prompt information based on the structured query language sample, the query information sample, and the database information.
[0283] Optionally, the processor may further execute program code of the following steps: using a similarity model to determine a query information sample in the query information sample set, wherein the similarity model is used to determine output data having the highest similarity to the input data.
[0284] Optionally, the processor may further execute program code of the following steps: outputting the structured query language to the client.
[0285] As another optional example, the processor may call information and applications stored in the memory through a transmission device to perform the following steps: obtaining a database information sample set corresponding to a structured query language sample set; inputting the database information sample set into an initial dialogue model, analyzing the database information sample set using the initial dialogue model, and outputting a query information sample set corresponding to the structured query language sample set, wherein the initial dialogue model is trained based on at least the initial structured query language sample set, and the query information samples in the query information sample set are used to represent the semantics of the corresponding structured query language samples in the structured query language sample set; training a large model based on the database information sample set and the query information sample set to obtain a dialogue model, wherein the dialogue model is used to analyze the query information and database information in the prompt information to generate a structured query language, wherein the prompt information is generated based on at least database information matching the structured query language, the query information is used to represent the semantics of the structured query language, and the database information is used to represent the data structure required to execute the operation function corresponding to the structured query language in the database.
[0286] Optionally, the processor may further execute program code for the following steps: classifying the database information sample set according to the operation functions corresponding to the structured query language sample set in the database; analyzing the classified database information sample set using the initial dialogue model, and outputting the query information sample set corresponding to the structured query language sample set.
[0287] Optionally, the processor may further execute the program code of the following steps: based on the classified database information sample set and the query information sample set, the large model is supervised trained to obtain a dialogue model.
[0288] Optionally, the processor may further execute program code of the following steps: training an initial dialogue model based on an initial structured query language sample set of data types matching different operation functions.
[0289] As another optional example, the processor may call information and applications stored in the memory through a transmission device to perform the following steps: detecting query information received in an interactive interface, wherein the query information is used to represent the semantics of a structured query language to be generated; in response to the query information, displaying database information matching the structured query language to be generated in the interactive interface, wherein the database information is used to represent a data structure required in a database to execute an operation function corresponding to the structured query language to be generated; displaying prompt information generated at least based on the database information on the interactive interface; inputting the prompt information into a dialogue model, and displaying on the interactive interface a structured query language obtained by analyzing the query information and database information in the prompt information using the dialogue model.
[0290] Optionally, the processor may further execute program code of the following steps: determining an operation function type corresponding to the structured query language to be generated; and displaying database information matching the operation function type in the interactive interface.
[0291] Optionally, the processor may further execute program code of the following steps: inputting the operation function and database information into an information generation template, and displaying the generated prompt information on the interactive interface.
[0292] Optionally, the processor may further execute program code for the following steps: determining, in a query information sample set, a query information sample having the highest similarity to the query information, and determining, in a structured query language sample set, a structured query language sample corresponding to the query information sample, wherein the query information sample set and the structured query language sample set are used to train a dialogue model, and the query information sample is used to represent the semantics of the structured query language sample; and displaying, on an interactive interface, prompt information generated at least based on database information, including: displaying, on the interactive interface, prompt information generated based on the structured query language sample, the query information sample, and the database information.
[0293] Optionally, the processor may further execute program code of the following steps: in response to a modification operation performed on the interactive interface, modify the query information sample set.
[0294] As another optional example, the processor may call information and applications stored in the memory through a transmission device to perform the following steps: responding to multimodal information received in a dialogue interface, wherein the multimodal information includes query information corresponding to the structured query language to be generated, and the query information is used to represent the semantics of the structured query language to be generated; displaying database information matching the structured query language to be generated in the dialogue interface, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the converted structured query language in the database; displaying prompt information generated at least based on the database information on the dialogue interface; inputting the prompt information into a dialogue model, and using the dialogue model to analyze the query information and database information in the prompt information to output the structured query language; and displaying reply information generated based on the structured query language on the dialogue interface.
[0295] Optionally, the processor may further execute program code of the following steps: the type of multimodal information includes at least one of the following: text information including character information, video frame information including frame image information, and audio information; the type of reply information includes at least one of the following: text information, image information, video information, and voice information.
[0296] As another optional example, the processor can call the information and application stored in the memory through the transmission device to perform the following steps: detecting the query information to be converted by calling the first interface, wherein the first interface includes a first parameter, and the parameter value of the first parameter is the query information, and the query information is used to represent the semantics of the structured query language to be converted; obtaining database information matching the structured query language to be converted, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the structured query language to be converted in the database; generating prompt information based on at least the database information; inputting the prompt information into the dialogue model, and using the dialogue model to analyze the query information and database information in the prompt information, and outputting the structured query language; outputting the structured query language by calling the second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter is the structured query language.
[0297] According to the embodiment of the present disclosure, when a client needs a structured query language to assist in data development, the client can input the corresponding semantics that can generate the structured query language, that is, the query information corresponding to the structured query language, on the client's interactive interface. After detecting that there is query information to be converted into structured query language in the interactive interface of a certain client, the query information can be transmitted from the client to the cloud. Based on the query information, the cloud can determine from the database the data structure required for the operation function performed when executing the structured query language corresponding to the query information, that is, the database information that matches the structured query language, and can be transmitted to the interactive interface of the corresponding client for display. The cloud can generate prompt information corresponding to the structured query language based on at least the database information, and can be transmitted to the interactive interface of the corresponding client for display. The cloud can use the prompt information to prompt the dialogue model to generate the corresponding required structured query language, and can be transmitted to the interactive interface of the corresponding client for display. Considering that related technologies only generate structured query languages based on the mapping between natural language and structured query languages, which may be out of touch with reality and difficult to apply, the present disclosure can further model the database information corresponding to the structured information, avoiding the abnormal situations that occur in the above-mentioned related technologies, thereby achieving the purpose of improving the accuracy of the structured information to be generated and the degree of fit with actual applications, thereby achieving the technical effect of effectively generating structured query languages and solving the technical problem of being unable to effectively generate structured query languages.
[0298] Those skilled in the art will appreciate that the structure shown in FIG15 is merely illustrative, and the computer terminal may also be a smartphone (such as an Android phone, iOS phone, etc.), a tablet computer, a PDA, a mobile internet device (MID), a PAD, or other terminal device. FIG15 does not limit the structure of the above-mentioned electronic devices. For example, the computer terminal A may include more or fewer components (such as a network interface, a display device, etc.) than those shown in FIG15 , or may have a configuration different from that shown in FIG15 .
[0299] A person skilled in the art will 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, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0300] Example 6
[0301] The embodiment of the present disclosure further provides a computer-readable storage medium. Optionally, in this embodiment, the computer-readable storage medium can be used to store the program code executed by the method for generating structured query language provided in the first embodiment.
[0302] Optionally, in this embodiment, the 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.
[0303] Optionally, in this embodiment, the storage medium is configured to store program code for executing the following steps: detecting query information to be converted from the client, wherein the query information is used to represent the semantics of the structured query language to be converted; obtaining database information matching the structured query language to be converted, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the structured query language to be converted in the database; generating prompt information based at least on the database information; inputting the prompt information into the dialogue model, and using the dialogue model to analyze the query information and database information in the prompt information, and outputting the structured query language.
[0304] Optionally, in this embodiment, the storage medium is configured to store program code for executing the following steps: obtaining a database information sample set corresponding to a structured query language sample set; inputting the database information sample set into an initial dialogue model, analyzing the database information sample set using the initial dialogue model, and outputting a query information sample set corresponding to the structured query language sample set, wherein the initial dialogue model is trained based on at least the initial structured query language sample set, and the query information samples in the query information sample set are used to represent the semantics of the corresponding structured query language samples in the structured query language sample set; training a large model based on the database information sample set and the query information sample set to obtain a dialogue model, wherein the dialogue model is used to analyze the query information and database information in the prompt information to generate a structured query language, the prompt information is generated based on at least database information matching the structured query language, the query information is used to represent the semantics of the structured query language, and the database information is used to represent the data structure required to execute the operation function corresponding to the structured query language in the database.
[0305] Optionally, in this embodiment, the storage medium is configured to store program code for executing the following steps: detecting query information received in the interactive interface, wherein the query information is used to represent the semantics of the structured query language to be generated; in response to the query information, displaying database information matching the structured query language to be generated in the interactive interface, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the structured query language to be generated in the database; displaying prompt information generated at least based on the database information on the interactive interface; inputting the prompt information into the dialogue model, and displaying the structured query language obtained by analyzing the query information and database information in the prompt information using the dialogue model on the interactive interface.
[0306] Optionally, in this embodiment, the storage medium is configured to store program code for executing the following steps: responding to multimodal information received in the dialogue interface, wherein the multimodal information includes query information corresponding to the structured query language to be generated, and the query information is used to represent the semantics of the structured query language to be generated; displaying database information matching the structured query language to be generated in the dialogue interface, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the converted structured query language in the database; displaying prompt information generated based on at least the database information on the dialogue interface; inputting the prompt information into the dialogue model, and using the dialogue model to analyze the query information and database information in the prompt information, and outputting the structured query language; displaying reply information generated based on the structured query language on the dialogue interface.
[0307] Optionally, in this embodiment, the storage medium is configured to store program code for executing the following steps: detecting query information to be converted by calling a first interface, wherein the first interface includes a first parameter, the parameter value of the first parameter is query information, and the query information is used to represent the semantics of the structured query language to be converted; obtaining database information matching the structured query language to be converted, wherein the database information is used to represent the data structure required to execute the corresponding operation function of the structured query language to be converted in the database; generating prompt information based on at least the database information; inputting the prompt information into a dialogue model, and using the dialogue model to analyze the query information and database information in the prompt information, and outputting the structured query language; outputting the structured query language by calling a second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter is the structured query language.
[0308] In an embodiment of the present disclosure, when a client needs a structured query language to assist in data development, the client can input the corresponding semantics that can generate the structured query language, that is, the query information corresponding to the structured query language, on the client's interactive interface. After detecting that there is query information to be converted into structured query language in the interactive interface of a certain client, the query information can be transmitted from the client to the cloud. Based on the query information, the cloud can determine from the database the data structure required for the operation function performed when executing the structured query language corresponding to the query information, that is, the database information that matches the structured query language, and can be transmitted to the interactive interface of the corresponding client for display. The cloud can generate prompt information corresponding to the structured query language based on at least the database information, and can be transmitted to the interactive interface of the corresponding client for display. The cloud can use the prompt information to prompt the dialogue model to generate the corresponding required structured query language, and can be transmitted to the interactive interface of the corresponding client for display. Considering that related technologies only generate structured query languages based on the mapping between natural language and structured query languages, which may be out of touch with reality and difficult to apply, the present disclosure can further model the database information corresponding to the structured information, avoiding the abnormal situations that occur in the above-mentioned related technologies, thereby achieving the purpose of improving the accuracy of the structured information to be generated and the degree of fit with actual applications, thereby achieving the technical effect of effectively generating structured query languages and solving the technical problem of being unable to effectively generate structured query languages.
[0309] Example 7
[0310] An embodiment of the present disclosure may provide an electronic device that may include a memory and a processor. Figure 16 is a block diagram of an electronic device according to a method for generating a structured query language in accordance with an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0311] As shown in FIG16 , device 1600 includes a computing unit 1601, which can perform various appropriate actions and processes based on a computer program stored in a read-only memory (ROM) 1602 or a computer program loaded from a storage unit 1608 into a random access memory (RAM) 1603. RAM 1603 may also store various programs and data required for the operation of device 1600. Computing unit 1601, ROM 1602, and RAM 1603 are interconnected via a bus 1604. An input / output (I / O) interface 1605 is also connected to bus 1604.
[0312] Various components in device 1600 are connected to I / O interface 1605, including: input unit 1606, such as a keyboard, mouse, etc.; output unit 1604, such as various types of displays, speakers, etc.; storage unit 1608, such as a magnetic disk, optical disk, etc.; and communication unit 16010, such as a network card, modem, wireless communication transceiver, etc. Communication unit 16010 allows device 1600 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0313] The computing unit 1601 can be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 1601 performs the various methods and processes described above, such as the method for generating a structured query language. For example, in some embodiments, the method for generating a structured query language can be implemented as a computer software program that is tangibly contained in a machine-readable medium, such as a storage unit 1608. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 1600 via the ROM 1602 and / or the communication unit 1609. When the computer program is loaded into RAM 1603 and executed by computing unit 1601, one or more steps of the structured query language generation method described above may be performed. Alternatively, in other embodiments, computing unit 1601 may be configured to perform the structured query language generation method in any other appropriate manner (e.g., via firmware).
[0314] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard parts (ASSPs), system on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0315] The embodiments of the present disclosure may provide a computer program, which, when executed by a processor, implements the method for generating a structured query language according to any one of the above embodiments.
[0316] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0317] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0318] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a cathode ray tube or liquid crystal display, monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0319] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include local area networks, wide area networks, and the Internet.
[0320] A computer system may include a client device and a server. The client device and server are generally remote from each other and typically interact via a communication network. The client device and server relationship arises through computer programs running on the respective computers and having a client device-server relationship with each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.
[0321] It should be noted that the serial numbers of the above-mentioned embodiments of the present disclosure are only for description and do not represent the advantages or disadvantages of the embodiments.
[0322] In the above embodiments of the present disclosure, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0323] In the several embodiments provided in this disclosure, 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 units is only a logical function division. In actual implementation, there may be other division methods. 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.
[0324] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0325] In addition, the functional units in the various embodiments of the present disclosure may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0326] 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 disclosure, 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. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the various embodiments of the present disclosure. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a read-only memory random access memory, a mobile hard disk, a magnetic disk or an optical disk.
[0327] The above is only a preferred embodiment of the present disclosure. 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 disclosure. These improvements and modifications should also be regarded as within the scope of protection of the present disclosure.
Claims
1. A method for generating a structured query language, wherein: Applied in the cloud, including: Detecting query information to be converted from a client, wherein the query information is used to represent the semantics of a structured query language to be converted; Acquire database information matching the structured query language to be converted, wherein the database information is used to represent a data structure required to execute an operation function corresponding to the structured query language to be converted in a database; generating prompt information based at least on the database information; The prompt information is input into a dialogue model, and the query information and the database information in the prompt information are analyzed using the dialogue model to output the structured query language.
2. The method according to claim 1, wherein: Obtaining database information that matches the structured query language to be converted, including: Determining the operation function type corresponding to the structured query language to be generated; The database information matching the operation function type is obtained.
3. The method according to claim 1, wherein: Generating prompt information based at least on the database information includes: The operation function and the database information are combined to generate the prompt information using an information generation template, wherein the information generation template is used to represent a rule for generating the prompt information in a query scenario corresponding to the structured query language.
4. The method according to claim 1, wherein: The method further comprises: Determine, in a query information sample set, a query information sample with the highest similarity to the query information, and determine, in a structured query language sample set, a structured query language sample corresponding to the query information sample, wherein the query information sample set and the structured query language sample set are used to train the dialogue model, and the query information sample is used to represent the semantics of the structured query language sample; Generating prompt information at least based on the database information includes: generating the prompt information based on the structured query language sample, the query information sample and the database information.
5. The method according to claim 4, wherein: Determining, from the query information sample set, a query information sample with the highest similarity to the query information, including: The query information sample is determined in the query information sample set by using a similarity model, wherein the similarity model is used to determine output data having the highest similarity to the input data.
6. The method according to any one of claims 1 to 5, wherein: The method further comprises: The structured query language is output to the client.
7. A method for generating a model, wherein: include: Obtaining a database information sample set corresponding to a structured query language sample set; Inputting the database information sample set into an initial dialogue model, and analyzing the database information sample set using the initial dialogue model, and outputting a query information sample set corresponding to the structured query language sample set, wherein the initial dialogue model is trained based on at least the initial structured query language sample set, and the query information samples in the query information sample set are used to represent the semantics of the corresponding structured query language samples in the structured query language sample set; Based on the database information sample set and the query information sample set, the large model is trained to obtain a dialogue model, wherein the dialogue model is used to analyze the query information and database information in the prompt information to generate a structure The structured query language is used for representing the semantics of the structured query language, and the database information is used for representing the data structure required for executing the operation function corresponding to the structured query language in the database.
8. The method according to claim 7, wherein: The method further comprises: Classifying the database information sample set according to the operation function corresponding to the structured query language sample set in the database; Analyzing the database information sample set by using the initial dialogue model and outputting the query information sample set corresponding to the structured query language sample set includes: analyzing the classified database information sample set by using the initial dialogue model and outputting the query information sample set corresponding to the structured query language sample set.
9. The method according to claim 8, wherein: Based on the database information sample set and the query information sample set, the large model is trained to obtain a dialogue model, including: Based on the classified database information sample set and the query information sample set, supervised training is performed on the large model to obtain the dialogue model.
10. The method according to claim 7, wherein: The method further comprises: The initial dialogue model is trained based on the initial structured query language sample set of data types matching different operation functions.
11. A method for generating a structured query language, wherein: include: Detecting query information received in the interactive interface, wherein the query information is used to represent the semantics of a structured query language to be generated; In response to the inquiry information, displaying database information matching the structured query language to be generated in the interactive interface, wherein the database information is used to represent a data structure required to execute an operation function corresponding to the structured query language to be generated in the database; On the interactive interface, displaying prompt information generated at least based on the database information; The prompt information is input into a dialogue model, and the structured query language obtained by analyzing the query information and the database information in the prompt information by using the dialogue model is displayed on the interactive interface.
12. The method according to claim 11, wherein: Displaying database information matching the structured query language to be generated in the interactive interface includes: Determining the operation function type corresponding to the structured query language to be generated; The database information matching the operation function type is displayed in the interactive interface.
13. The method according to claim 11, wherein: On the interactive interface, prompt information generated at least based on the database information is displayed, including: The operation function and the database information are input into an information generation template, and the generated prompt information is displayed on the interactive interface, wherein the information generation template is used to represent a rule for generating the prompt information in a query scenario corresponding to the structured query language.
14. The method according to claim 11, wherein: The method further comprises: Determine, in a query information sample set, a query information sample with the highest similarity to the query information, and determine, in a structured query language sample set, a structured query language sample corresponding to the query information sample, wherein the query information sample set and the structured query language sample set are used to train the dialogue model, and the query information sample is used to represent the semantics of the structured query language sample; Displaying prompt information generated at least based on the database information on the interactive interface includes: displaying the prompt information generated based on the structured query language sample, the query information sample and the database information on the interactive interface.
15. The method according to claim 14, wherein: The method further comprises: In response to a modification operation performed on the interactive interface, the query information sample set is modified.
16. A method for generating a structured query language, wherein: include: Responding to multimodal information received in the dialogue interface, wherein the multimodal information includes query information corresponding to the structured query language to be generated, the query information being used to represent the semantics of the structured query language to be generated; Displaying database information matching the structured query language to be generated in the dialogue interface, wherein the database information is used to represent a data structure required for executing an operation function corresponding to the converted structured query language in the database; On the dialogue interface, displaying prompt information generated at least based on the database information; Inputting the prompt information into a dialogue model, and using the dialogue model to analyze the query information and the database information in the prompt information, and outputting the structured query language; The response information generated based on the structured query language is displayed on the dialogue interface.
17. The method according to claim 16, wherein: The type of the multimodal information includes at least one of the following: text information containing character information, video frame information containing frame image information, and audio information; the type of the reply information includes at least one of the following: text information, image information, video information, and voice information.
18. A method for generating a structured query language, wherein: include: Detecting the query information to be converted by calling a first interface, wherein the first interface includes a first parameter, a parameter value of the first parameter is the query information, and the query information is used to represent the semantics of the structured query language to be converted; Acquire database information matching the structured query language to be converted, wherein the database information is used to represent a data structure required to execute an operation function corresponding to the structured query language to be converted in a database; generating prompt information based at least on the database information; Inputting the prompt information into a dialogue model, and using the dialogue model to analyze the query information and the database information in the prompt information, and outputting the structured query language; The structured query language is output by calling a second interface, wherein the second interface includes a second parameter, and a parameter value of the second parameter is the structured query language.
19. A system for generating structured query language, wherein: include: An input terminal, used for inputting query information to be converted, wherein the query information is used to represent the semantics of the structured query language to be converted; A processing end, used for acquiring database information matching the structured query language to be converted, and generating prompt information based at least on the database information, wherein the database information is used for representing a data structure required for executing an operation function corresponding to the structured query language to be converted in a database; The model inference end is used to input the prompt information into the dialogue model, and use the dialogue model to analyze the query information and the database information in the prompt information, and output the structured query language.
20. An electronic device, wherein: include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the method described in any one of claims 1 to 18 are implemented.
21. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, implement the steps of the method according to any one of claims 1 to 18.
22. A computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 13.
Citation Information
Patent Citations
Method for establishing pre-training language model and semantic analysis method and device
CN114547329A
Data processing method, device and equipment and computer readable storage medium
CN116821103A
Improved NL2SQL method based on generative large language model
CN116821168A
NL2SQL method based on LLM multi-table adaptive selection
CN117112732A
Cited By
Method and system for accurately converting large-model natural language into SQL (Structured Query Language) based on multi-modal fusion
CN121579514A
Generating SQL queries from natural language requests
US20260111428A1