Query statement generation method and device, equipment and storage medium
By using preselected training query statements to generate the model distillation training dataset, training the target query statement generation model, solving the problem that ordinary users find it difficult to generate effective database query statements, and achieving efficient and convenient database query.
Patent Information
- Application Number
- CN202411885971.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-19
AI Technical Summary
In the prior art, database query statements usually require professional knowledge to be written, and it is difficult for ordinary users to generate effective query statements, resulting in inconvenience in database query.
At least two preselected training query statements are used to generate models, and high-quality training data is generated by distilling the training data set, and the target query statement generation model is trained to improve the accuracy of query statement generation model.
It realizes the generation of more accurate and high-quality query statements, allowing ordinary users to easily query the database and improves the convenience of database query.
Smart Images

Figure CN119719323A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, specifically to the field of artificial intelligence technology such as database query, machine learning, natural language processing, and large models, and in particular to a method, device, equipment, and storage medium for generating a query statement. Background Art
[0002] The database is a widely used and important software system that can automatically manage and maintain data and ensure the security and validity of data.
[0003] The database provides the functions of querying and retrieving data, which can easily obtain the required data information. The database administrator needs to select the appropriate query method and retrieval tool according to the needs, construct the query statement, and perform the database query. In the prior art, the database query statement is usually implemented using the Structured Query Language (SQL). Summary of the invention
[0004] The present disclosure provides a method, apparatus, device and storage medium for generating a query statement.
[0005] According to one aspect of the present disclosure, a method for training a query sentence generation model is provided, comprising:
[0006] At least two pre-selected query statements are used to generate a model and distill a training data set; each of the training data in the training data set includes a user's query text and a first query statement constructed based on the query text, and the first query statement is used to query a database;
[0007] Based on the training data set, a target query statement generation model is trained.
[0008] According to another aspect of the present disclosure, a method for generating a query statement is provided, comprising:
[0009] Get the user's query text;
[0010] Based on the query text, a pre-trained query statement generation model is used to generate a query statement, wherein the query statement is used to query a database, and the query statement generation model is a query statement generation model trained according to the aspects described above and any possible implementation method.
[0011] According to another aspect of the present disclosure, a training device for a query sentence generation model is provided, comprising:
[0012] A distillation module, configured to generate a model using at least two pre-selected query statements for training, and to distill a training data set; each of the training data in the training data set includes a user's query text and a first query statement constructed based on the query text, wherein the first query statement is used to query a database;
[0013] The training module is used to train the target query statement generation model based on the training data set.
[0014] According to another aspect of the present disclosure, a device for generating a query statement is provided, comprising:
[0015] The acquisition module is used to obtain the user's query text;
[0016] A generation module is used to generate a query statement based on the query text using a pre-trained query statement generation model, wherein the query statement is used to query a database, and the query statement generation model is a query statement generation model trained according to the aspects described above and any possible implementation method.
[0017] According to yet another aspect of the present disclosure, there is provided an electronic device, including:
[0018] at least one processor; and
[0019] a memory communicatively connected to the at least one processor; wherein,
[0020] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any possible implementation manner and the aspects described above.
[0021] According to yet another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method of the above-mentioned aspect and any possible implementation manner.
[0022] According to yet another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements the above-mentioned aspects and the method of any possible implementation manner.
[0023] According to the technology disclosed in the present invention, the accuracy of the trained target query sentence generation model can be effectively improved.
[0024] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0026] Figure 1 is a schematic diagram according to a first embodiment of the present disclosure;
[0027] Figure 2 is a schematic diagram according to a second embodiment of the present disclosure;
[0028] Figure 3 is a schematic diagram according to a third embodiment of the present disclosure;
[0029] Figure 4 is a schematic diagram according to a fourth embodiment of the present disclosure;
[0030] Figure 5 is a schematic diagram according to a fifth embodiment of the present disclosure;
[0031] Figure 6 is a schematic diagram according to a sixth embodiment of the present disclosure;
[0032] Figure 7 The block diagram is a block diagram of an electronic device for implementing the method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0033] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0034] Obviously, the described embodiments are only part of the embodiments of the present disclosure, but not all of them. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present disclosure.
[0035] It should be noted that the terminal devices involved in the embodiments of the present disclosure may include but are not limited to mobile phones, personal digital assistants (PDAs), wireless handheld devices, tablet computers and other smart devices; display devices may include but are not limited to personal computers, televisions and other devices with display functions.
[0036] In addition, the term "and / or" in this article is only a description of the association relationship between the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0037] In the prior art, query statements such as SQL statements used to query a database require personnel with professional database knowledge to write them. Ordinary users do not have the ability to write SQL statements, and the database does not support query statements in text form input by ordinary users. This makes database query very inconvenient.
[0038] Figure 1 is a schematic diagram according to the first embodiment of the present disclosure; Figure 1 As shown, this embodiment provides a method for training a query statement generation model, which may specifically include the following steps:
[0039] S101, using at least two pre-selected query statements to generate a model, and distilling a training data set; each training data in the training data set includes a user's query text and a first query statement constructed based on the query text, and the first query statement is used to query a database;
[0040] S102: Based on the training data set, a target query statement generation model is trained.
[0041] The execution subject of the query statement generation model training method of this embodiment may be a query statement generation model training device, and the device may be an electronic entity or a software integrated application.
[0042] In this embodiment, since at least two query generation models are pre-trained and have powerful query generation models, a high-quality training data set can be obtained by using at least two pre-trained query generation models to distill the training data set. When the training data set is used to train the target query generation model, the accuracy of the query generation model can be effectively improved.
[0043] The query statement generation model training method of this embodiment, by adopting the training data set distilled from at least two query statement generation models to train the target query statement generation model, can effectively improve the accuracy of the trained target query statement generation model, so that the generated query statement generation model can generate more accurate and higher quality query statements.
[0044] Figure 2 is a schematic diagram according to the second embodiment of the present disclosure; the training method of the query sentence generation model of this embodiment, in the above Figure 1 Based on the technical solutions of the embodiments shown in the figure, the technical solutions of the present disclosure are further described in more detail. Figure 2 As shown, this embodiment provides a method for training a query statement generation model, which may specifically include the following steps:
[0045] S201, obtaining multiple candidate query statement generation models;
[0046] The multiple candidate query statement generation models in this embodiment are pre-trained models.
[0047] S202, determining the computing performance, logical understanding performance, analysis performance, time reasoning performance, and instruction compliance performance of each candidate query statement generation model;
[0048] In this embodiment, a preset test set may be used to test various aspects of performance of each candidate query statement generation model. For example, in order to determine the computing performance, logical understanding performance, analysis performance, time reasoning performance, and instruction compliance performance of each candidate query statement generation model, corresponding test samples may be configured in the test set accordingly to achieve the determination of the corresponding performance.
[0049] In addition, optionally, a pre-trained large model can also be used to determine various performances of each candidate query statement generation model. For example, for each candidate query statement generation model, the predicted query statement generated by the candidate query statement generation model for the query text of each test sample in the test set can be obtained, and the predicted query statement and the target query statement of each test sample can be input into the large model together. The large model can comprehensively determine various aspects of the performance of the candidate query statement generation model based on the processing results of the test set processed by the candidate query statement generation model.
[0050] According to the above method, it is possible to accurately and effectively determine the computing performance, logical understanding performance, analysis performance, time reasoning performance and instruction compliance performance of each candidate query statement generation model.
[0051] S203, from a plurality of candidate query statement generation models, obtaining at least two of the candidate query statement generation model with the highest computing performance, the candidate query statement generation model with the highest logical understanding performance, the candidate query statement generation model with the highest analysis performance, the candidate query statement generation model with the highest temporal reasoning performance, and the candidate query statement generation model with the highest instruction compliance performance, to obtain at least two query statement generation models;
[0052] In this embodiment, according to the requirements, at least two of the candidate query statement generation models with the highest computing performance, the highest logical understanding performance, the highest analysis performance, the highest temporal reasoning performance, and the highest instruction compliance performance can be obtained from multiple candidate query statement generation models to distill the training data set. The more query statement generation models are selected, the higher the quality of the distilled training data set.
[0053] Preferably, all models of the alternative query statement generation model with the highest computing performance, the alternative query statement generation model with the highest logical understanding performance, the alternative query statement generation model with the highest analysis performance, the alternative query statement generation model with the highest temporal reasoning performance, and the alternative query statement generation model with the highest instruction compliance performance can be selected for distillation of the training data set.
[0054] In this embodiment, by adopting the above method, it is obtained that each query statement generation model has the highest performance in one aspect, which provides effective support for the subsequent distillation of high-quality training data sets.
[0055] S204, using at least two query statements to generate a model and distilling a training data set;
[0056] Since the query statement generation model with the highest performance in all aspects integrates the highest performance in all aspects, the query statement generation model with the highest performance in all aspects can be used to distill the optimal training data. In this embodiment, each training data in the distilled training data set includes a user's query text and a query statement constructed based on the query text, and the query statement is used to query the database.
[0057] This step still takes the use of at least two query statement generation models and the distillation training data set as an example. The at least two query statement generation models include: at least two of the query statement generation model with the highest computing performance, the query statement generation model with the highest logical understanding performance, the query statement generation model with the highest analysis performance, the query statement generation model with the highest time reasoning performance, and the query statement generation model with the highest instruction compliance performance. In practical applications, at least three or more of them can also be selected, the principle is the same, and no further details are given here.
[0058] For example, when this step is implemented specifically, it may include the following steps:
[0059] (1) Obtain query text;
[0060] (2) Based on the query text, each query statement generation model is used to generate a corresponding third query statement;
[0061] The query text of this embodiment may be collected online, or constructed in other ways, which is not limited here.
[0062] (3) Using a pre-trained evaluation model to determine the attribute value of each query statement;
[0063] The evaluation model is a pre-trained neural network model. When the evaluation model is used, a query statement is input into the model, and the model can predict an attribute value of the query statement. The higher the attribute value, the higher the quality of the query statement.
[0064] (4) The third query statement with the highest attribute value and the corresponding query text are obtained as distillation training data and stored in the training data set.
[0065] In this embodiment, when distilling the training data set, a query statement generation model with the highest performance in all aspects is adopted, which can effectively ensure that the distilled training data are the best training data, thereby effectively improving the quality of the distilled training data set.
[0066] S205, training a target query statement generation model based on a training data set;
[0067] The specific training method can refer to the supervised training method, and the query text of each training data in the training data set is input into the target query statement generation model, and the target query statement generation model can predict and output the predicted query statement based on the input information; then, based on the predicted query statement and the query statement annotated in the training data, the parameters of the target query statement generation model are adjusted so that the predicted query statement and the annotated query statement tend to be consistent. Using multiple training data in the training data set, the target query statement generation model is continuously trained until the model converges to obtain the target query statement generation model.
[0068] In this embodiment, since each piece of training data in the adopted training data set is distilled from the query statement generation model with the highest performance in all aspects, using the training data set to train the target query statement generation model can enable the target query statement generation model to learn the performance of each query statement generation model with the highest performance in all aspects, thereby training the target query statement to be a query statement generation model with the highest comprehensive performance.
[0069] S206, using the trained target query statement to generate a model, and obtaining training data with prediction errors from the training data set;
[0070] S207, constructing a positive and negative sample pair based on the training data with prediction errors, where the positive sample is the training data, and the negative sample is the training data obtained by replacing the first query statement in the positive sample with the second query statement with prediction error generated by the target query statement generation model;
[0071] S208. Use positive and negative sample pairs to generate a model for the target query sentence and perform reinforcement learning training.
[0072] For example, the direct preference optimization (DPO) reinforcement learning method can be used to further optimize the target query statement generation model to ensure that the target query statement generation model can efficiently learn the weak links and significantly improve its ability to learn the knowledge that has not been mastered.
[0073] In the above training method of this embodiment, at least two query generation models can be used as teacher models, and the target query generation model can be used as a student model. The training data set distilled by at least two query generation models is the training data set with the best quality selected by the teacher model, so the student model is trained by using the training data set, so that the student model can learn the performance of the teacher model.
[0074] In this embodiment, the supervised training of steps 204-S205 and the reinforcement learning training of steps S206-S208 can be repeated for multiple rounds of iterative training, so that the target query statement generation model can approach or even surpass a single query statement generation model, thereby obtaining a more efficient target query statement generation model.
[0075] The query statement generation model training method of this embodiment can further effectively improve the accuracy of the trained target query statement generation model by adopting two training methods, namely supervised training and reinforcement learning training, to train the query statement generation model.
[0076] Figure 3 is a schematic diagram according to the third embodiment of the present disclosure; Figure 3 As shown, this embodiment provides a method for generating a query statement, which may specifically include the following steps:
[0077] S301, obtaining a user's query text;
[0078] S302: Based on the query text, a pre-trained query statement generation model is used to generate a query statement, which is used to query the database.
[0079] In this embodiment, a pre-trained query statement generation model is used. Figure 1 or Figure 2The target query sentence generation model in the illustrated embodiment.
[0080] The execution subject of the query statement generation method of this embodiment may be a query statement generation device, which may be an electronic entity, or a software integrated application, or may also be an intelligent entity. When used, the device may generate a professional query statement based on the user's query text, and the query statement is used to query the database. For example, the query statement may be an SQL statement.
[0081] The technical solution of this embodiment can support ordinary users without database expertise to query the database. Specifically, the user query text is used to generate corresponding professional query statements using the query statement generation model pre-trained in this embodiment. Based on the generated query statement, the database can be queried.
[0082] The query statement generation method of this embodiment can accurately and efficiently generate query statements according to the user's query text, thereby enabling any user to query the database.
[0083] Figure 4 is a schematic diagram according to a fourth embodiment of the present disclosure; Figure 4 As shown, this embodiment provides a training device 400 for a query statement generation model, including:
[0084] A distillation module 401 is used to generate a model using at least two pre-selected query statements for training, and distill a training data set; each of the training data in the training data set includes a user's query text and a first query statement constructed based on the query text, and the first query statement is used to query a database;
[0085] The training module 402 is used to train the target query statement generation model based on the training data set.
[0086] The training device 400 for the query statement generation model of this embodiment implements the implementation principle and technical effect of the training of the query statement generation model by adopting the above-mentioned modules, which is the same as the implementation of the above-mentioned related method embodiments. For details, please refer to the records of the above-mentioned related method embodiments, which will not be repeated here.
[0087] Figure 5 is a schematic diagram according to the fifth embodiment of the present disclosure; the training device 500 of the query sentence generation model of this embodiment, in the above Figure 4 Based on the technical solutions of the embodiments shown in the figure, the technical solutions of the present disclosure are further described in more detail. Figure 5 As shown, the query sentence generation model training device 500 of this embodiment includes the above Figure 4Modules with the same name and function are shown: a distillation module 501 and a training module 502 .
[0088] In this embodiment, at least two query statement generation models include: a query statement generation model with the highest computing performance, a query statement generation model with the highest logical understanding performance, a query statement generation model with the highest analysis performance, a query statement generation model with the highest time reasoning performance, and at least two of the query statement generation model with the highest instruction compliance performance.
[0089] like Figure 5 As shown, the query statement generation model training device 500 of this embodiment further includes a model acquisition module 503, which is used to:
[0090] Obtain multiple candidate query statement generation models;
[0091] Determining the computing performance, logical understanding performance, analysis performance, time reasoning performance, and instruction compliance performance of each of the candidate query statement generation models;
[0092] From the multiple alternative query statement generation models, obtain at least two of the alternative query statement generation model with the highest computing performance, the alternative query statement generation model with the highest logical understanding performance, the alternative query statement generation model with the highest analysis performance, the alternative query statement generation model with the highest temporal reasoning performance, and the alternative query statement generation model with the highest instruction compliance performance as the at least two query statement generation models.
[0093] Further optionally, if Figure 5 As shown, in one embodiment of the present disclosure, the training device 500 for query sentence generation model further includes: a sample pair construction module 504, which is used to:
[0094] The trained target query statement is used to generate a model, and training data with prediction errors is obtained from the training data set;
[0095] Based on the mispredicted training data, a positive and negative sample pair is constructed, wherein the positive sample is the training data, and the negative sample is the training data obtained by replacing the first query statement in the positive sample with the second mispredicted query statement generated by the target query statement generation model.
[0096] Further optionally, in one embodiment of the present disclosure, the training module 502 is further configured to:
[0097] The positive and negative sample pairs are used to generate a model for the target query sentence and perform reinforcement learning training.
[0098] Further optionally, in one embodiment of the present disclosure, the distillation module 501 is used to:
[0099] Obtaining the query text;
[0100] Based on the query text, using each of the query statement generation models to generate a corresponding third query statement;
[0101] Using a pre-trained evaluation model to obtain attribute values of each of the third query statements;
[0102] The third query statement with the highest attribute value and the corresponding query text are obtained as distilled training data and stored in the training data set.
[0103] The training device 500 for the query statement generation model of this embodiment implements the implementation principle and technical effect of the training of the query statement generation model by adopting the above-mentioned modules, which is the same as the implementation of the above-mentioned related method embodiments. For details, please refer to the records of the above-mentioned related method embodiments, which will not be repeated here.
[0104] Figure 6 is a schematic diagram according to the sixth embodiment of the present disclosure; Figure 6 As shown, this embodiment provides a query statement generation device 600, including:
[0105] The acquisition module 601 is used to acquire the user's query text;
[0106] The generation module 602 is used to generate a query statement based on the query text using a pre-trained query statement generation model, and the query statement is used to query the database. Figure 4 or Figure 5 The query statement generation model is trained by the query statement generation model training device of the illustrated embodiment.
[0107] The query statement generation device 600 of this embodiment, by adopting the above modules to realize the implementation principle and technical effect of query statement generation, is the same as that of the above related method embodiments. For details, please refer to the records of the above related method embodiments, which will not be repeated here.
[0108] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0109] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0110] Figure 7A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. 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 can 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.
[0111] like Figure 7 As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0112] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0113] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 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 running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as the above-mentioned methods of the present disclosure. For example, in some embodiments, the above-mentioned methods of the present disclosure may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the above-mentioned methods of the present disclosure described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the above-mentioned methods of the present disclosure in any other appropriate manner (e.g., by means of firmware).
[0114] Various implementations of the systems and techniques described above 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 products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including 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.
[0115] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0116] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0117] 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 CRT (cathode ray tube) or LCD (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).
[0118] The systems and techniques described herein may 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 with 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 may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0119] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0120] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0121] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for training a query statement generation model, comprising: Using at least two pre-selected query statements to generate a model, distill the training data set; Each of the training data in the training data set includes a user's query text and a first query statement constructed based on the query text, wherein the first query statement is used to query a database; Based on the training data set, a target query statement generation model is trained.
2. The method according to claim 1, wherein: The at least two query statement generation models include: at least two of the query statement generation model with the highest computing performance, the query statement generation model with the highest logical understanding performance, the query statement generation model with the highest analysis performance, the query statement generation model with the highest temporal reasoning performance, and the query statement generation model with the highest instruction compliance performance.
3. The method according to claim 2, wherein: Before generating the model using at least two pre-selected query statements and distilling the training data set, the method further comprises: Obtain multiple candidate query statement generation models; Determining the computing performance, logical understanding performance, analysis performance, time reasoning performance, and instruction compliance performance of each of the candidate query statement generation models; From the multiple alternative query statement generation models, obtain at least two of the alternative query statement generation model with the highest computing performance, the alternative query statement generation model with the highest logical understanding performance, the alternative query statement generation model with the highest analysis performance, the alternative query statement generation model with the highest temporal reasoning performance, and the alternative query statement generation model with the highest instruction compliance performance as the at least two query statement generation models.
4. The method according to claim 1, wherein: After training the target query statement generation model based on the training data set, the method further includes: The trained target query statement is used to generate a model, and training data with prediction errors is obtained from the training data set; Based on the mispredicted training data, a positive and negative sample pair is constructed, wherein the positive sample is the training data, and the negative sample is the training data obtained by replacing the first query statement in the positive sample with the second mispredicted query statement generated by the target query statement generation model.
5. The method according to claim 4, wherein: The training of the target query statement generation model based on the training data set includes: The positive and negative sample pairs are used to generate a model for the target query sentence and perform reinforcement learning training.
6. The method according to any one of claims 1 to 5, wherein: The method of using at least two pre-selected query statements to generate models and distilling training data sets includes: Obtaining the query text; Based on the query text, using each of the query statement generation models respectively to generate a corresponding third query statement; Using a pre-trained evaluation model to obtain the attribute value of the third query statement; The third query statement with the highest attribute value and the corresponding query text are obtained as distilled training data and stored in the training data set.
7. A method for generating a query statement, comprising: Get the user's query text; Based on the query text, a pre-trained query statement generation model is used to generate a query statement, wherein the query statement is used to query a database, and the query statement generation model is a query statement generation model trained by the method described in any one of claims 1 to 6 above.
8. A training device for a query statement generation model, comprising: A distillation module, configured to generate a model using at least two pre-selected query sentences for training, and to distill a training data set; Each of the training data in the training data set includes a user's query text and a first query statement constructed based on the query text, wherein the first query statement is used to query a database; The training module is used to train the target query statement generation model based on the training data set.
9. The device according to claim 8, wherein: The at least two query statement generation models include: a query statement generation model with the highest computing performance, a query statement generation model with the highest logical understanding performance, a query statement generation model with the highest analysis performance, a query statement generation model with the highest temporal reasoning performance, and at least two of the query statement generation model with the highest instruction compliance performance.
10. The device according to claim 9, wherein: The device also includes a model acquisition module, which is used to: Obtain multiple candidate query statement generation models; Determining the computing performance, logical understanding performance, analysis performance, time reasoning performance, and instruction compliance performance of each of the candidate query statement generation models; From the multiple alternative query statement generation models, obtain at least two of the alternative query statement generation model with the highest computing performance, the alternative query statement generation model with the highest logical understanding performance, the alternative query statement generation model with the highest analysis performance, the alternative query statement generation model with the highest temporal reasoning performance, and the alternative query statement generation model with the highest instruction compliance performance as the at least two query statement generation models.
11. The device according to claim 8, wherein: The device also includes a sample pair construction module, which is used to: The trained target query statement is used to generate a model, and training data with prediction errors is obtained from the training data set; Based on the mispredicted training data, a positive and negative sample pair is constructed, wherein the positive sample is the training data, and the negative sample is the training data obtained by replacing the first query statement in the positive sample with the second mispredicted query statement generated by the target query statement generation model.
12. The device according to claim 11, wherein The training module is also used for: The positive and negative sample pairs are used to generate a model for the target query sentence and perform reinforcement learning training.
13. The device according to any one of claims 8 to 12, wherein: The distillation module is used for: Obtaining the query text; Based on the query text, using each of the query statement generation models respectively to generate a corresponding third query statement; Using a pre-trained evaluation model to obtain attribute values of each of the third query statements; The third query statement with the highest attribute value and the corresponding query text are obtained as distilled training data and stored in the training data set.
14. A device for generating a query statement, comprising: The acquisition module is used to obtain the user's query text; A generation module is used to generate a query statement based on the query text using a pre-trained query statement generation model, wherein the query statement is used to query a database, and the query statement generation model is a query statement generation model trained by the device as described in any one of claims 8-13 above.
15. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 6 or 7.
16. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-6 or 7.
17. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 6 or 7.
Citation Information
Patent Citations
A data query method and system supporting a natural language
CN109766355A
Method and device for outputting structured query statements
CN111159220A
Automatic question-answering system based on semi-supervised learning and Text-to-SQL model
CN112287093A
Semantic retrieval model training method and device, electronic equipment and storage medium
CN115168537A
Text generation model training method and device, equipment, medium and program product
CN118277505A