Statement conversion method and device, equipment, medium and program product

By generating initial input statements and inputting statement conversion large model, the difficulty of statement conversion between databases in the prior art is solved, and the convenience of cross-database operations is achieved.

CN120218017APending Publication Date: 2025-06-27INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510285176.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-11
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

Due to the limitation of a limited rule set, the prior art cannot realize flexible conversion of statements between any two databases, which increases the difficulty of cross-database operations.

Method used

By obtaining the initial database statement and the target database sent by the user equipment, an initial input statement with a preset input format is generated, and inputting them into the pre-trained statement to convert it into the large model, and generating a target database statement that can be executed in the target database and has the same semantics.

Benefits of technology

The conversion of statements between different databases is implemented, which reduces the difficulty of cross-database operations and avoids the situation where the conversion cannot be implemented when the rules involved in the statement conversion are rules outside the finite rule set.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120218017A_ABST
    Figure CN120218017A_ABST
Patent Text Reader

Abstract

The invention discloses a statement conversion method and device, equipment, a medium and a program product, and relates to the field of artificial intelligence, and the method comprises the steps: obtaining an initial database statement and a target database sent by user equipment; generating an initial input statement according to the initial database statement and a target database; inputting the initial input statement into a pre-trained statement conversion large model to obtain a target database statement corresponding to the initial database statement output by the statement conversion large model; and returning the target database statement to the user equipment. According to the method, on one hand, the working difficulty of workers is reduced; on the other hand, the initial input statement is input into the pre-trained statement conversion large model, the target database statement corresponding to the initial database statement is obtained, statement conversion between different databases is achieved, the situation that conversion cannot be achieved when the rules related to statement conversion are rules except for a limited rule set is avoided, and the conversion efficiency is improved. And thus, the difficulty of cross-database operation is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Although various current mainstream database management systems all follow the Structured Query Language (SQL) standard, there are certain differences in grammar details, features, and extended functions. Therefore, SQL statements written for a specific database may not be directly executable in other database environments.

[0003] Currently, converting SQL statements written for a specific database into statements that can be executed in other database environments often relies on the supporting tools of the database to use a limited rule set to implement the processing and conversion of statements.

[0004] However, since the number and types of rules in the limited rule set are preset in advance, that is, they are not infinitely extended or dynamically generated, conversion cannot be achieved when the rules involved in statement conversion are outside the limited rule set, that is, flexible conversion of statements between any two databases cannot be achieved, increasing the difficulty of cross-database operations such as migrating data across databases, porting application programs, or integrating heterogeneous data sources. Summary of the Invention

[0005] The present application provides a method, device, equipment, medium and program product for statement conversion to solve the problem in the prior art that since the number and types of rules in the limited rule set are preset in advance, that is, they are not infinitely extended or dynamically generated, conversion cannot be achieved when the rules involved in statement conversion are outside the limited rule set, that is, flexible conversion of statements between any two databases cannot be achieved, increasing the difficulty of cross-database operations such as migrating data across databases, porting application programs, or integrating heterogeneous data sources.

[0006] In a first aspect, the present application provides a method for statement conversion, the method comprising:

[0007] Obtain an initial database statement and a target database sent by a user device;

[0008] Generate an initial input statement according to the initial database statement and the target database; wherein, the statement format of the initial input statement is a preset input format, and the initial input statement includes the initial database statement, the target database, and the initial database corresponding to the initial database statement;

[0009] Input the initial input statement into a pre-trained statement conversion large model to obtain the target database statement corresponding to the initial database statement output by the statement conversion large model; wherein, the target database statement is a statement that can be executed in the target database and has the same semantics as the initial database statement, and the statement conversion large model is used to determine the target database statement corresponding to the initial database statement according to the initial input statement.

[0010] Return the target database statement to the user device.

[0011] In a second aspect, the present application provides a statement conversion device, including:

[0012] An initial acquisition module, configured to acquire an initial database statement and a target database sent by a user device.

[0013] An initial statement generation module, configured to generate an initial input statement according to the initial database statement and the target database; wherein, the statement format of the initial input statement is a preset input format, and the initial input statement includes the initial database statement, the target database, and the initial database corresponding to the initial database statement.

[0014] A model input module, configured to input the initial input statement into a pre-trained statement conversion large model to obtain the target database statement corresponding to the initial database statement output by the statement conversion large model; wherein, the target database statement is a statement that can be executed in the target database and has the same semantics as the initial database statement, and the statement conversion large model is used to determine the target database statement corresponding to the initial database statement according to the initial input statement.

[0015] A sending module, configured to return the target database statement to the user device.

[0016] In a third aspect, the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the program, it implements the statement conversion method as described in the first aspect of the present application.

[0017] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the statement conversion method as described in the first aspect of the present application.

[0018] In a fifth aspect, the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the statement conversion method as described in the first aspect of the present application.

[0019] The solution of this application is to obtain the initial database statement sent by the user device and the target database; generate an initial input statement according to the initial database statement and the target database; where the statement format of the initial input statement is a preset input format, and the initial input statement includes the initial database statement, the target database, and the initial database corresponding to the initial database statement; input the initial input statement into a pre-trained statement conversion large model to obtain the target database statement corresponding to the initial database statement output by the statement conversion large model; where the target database statement is a statement that can be executed in the target database and has the same semantics as the initial database statement, and the statement conversion large model is used to determine the target database statement corresponding to the initial database statement according to the initial input statement; return the target database statement to the user device. That is, on the one hand, the method of this application processes the initial database statement to obtain the initial input statement, which can transform the initial database statement into a statement that the statement conversion large model can read, avoiding the situation where staff manually analyze the database type of the statement and perform manual input, and reducing the work difficulty of the staff. On the other hand, by inputting the initial input statement into a pre-trained statement conversion large model, the target database statement corresponding to the initial database statement is obtained, thus realizing the conversion of statements between different databases, avoiding the situation where conversion cannot be achieved when the rules involved in statement conversion are outside the finite rule set, and further reducing the difficulty of cross-database operations. Description of the Drawings

[0020] To more clearly illustrate the technical solution of this application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as limiting the scope. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.

[0021] Figure 1 is a flowchart of a statement conversion method provided by this application;

[0022] Figure 2 is another flowchart of a statement conversion method provided by this application;

[0023] Figure 3 is a structural diagram of a statement conversion device provided by this application;

[0024] Figure 4 is a structural diagram of an electronic device provided by this application. Detailed Embodiments

[0025] To enable those skilled in the art to better understand the solution of this application, the following will clearly and completely describe the technical solution in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.

[0026] In the technical solution of this application, the acquisition, storage, use, processing, etc. of data all comply with the relevant provisions of national laws and regulations.

[0027] Figure 1 It is a schematic flowchart of a statement conversion method provided by this application. This method can be executed by a statement conversion device, and this device can be implemented in a software and / or hardware manner. In a specific embodiment, this device can be applied in an electronic device, and the electronic device can be a computer. The following embodiments will be described by taking this device applied in an electronic device as an example. Refer to Figure 1 , and the method specifically may include the following steps:

[0028] Step 101, obtain the initial database statement and the target database sent by the user device.

[0029] Specifically, the initial database statement is the initial database statement that the user needs to convert. For example, the initial database statement can be a create table statement in database A. For example, create a table named t in database A, and there is a column named x in the table, with an integer type and an auto-incrementing primary key. The target database is the database type after the statement that the user needs to convert is converted. The user device is the device of the user who needs to convert the initial database statement into the corresponding statement of the target database. The user inputs the initial database statement and the target database through the user device in the user interaction module of the electronic device executing this embodiment, and the electronic device executing this embodiment receives the initial database statement and the target database sent by the user device.

[0030] Optionally, after executing step 101, steps 11 to 12 can also be executed.

[0031] Step 11, determine the target database statement corresponding to the initial database statement in the statement conversion knowledge graph according to the initial database statement and the target database.

[0032] Specifically, the statement conversion knowledge graph is a pre-established knowledge graph that can represent the corresponding relationships between data statements in databases. That is, there are corresponding relationships between data statements of multiple databases in the statement conversion knowledge graph, which can record the syntactic differences between different database systems and the conversion rules between database statements. After obtaining the initial database statement and the target database, determine in the statement conversion knowledge graph the statement of the target database that can represent the same semantics corresponding to the initial database statement.

[0033] Exemplarily, the initial database statement is a statement in database A that means to create a table named t in database A, with a column named x in the table, the type is integer type, and it is an auto-incrementing primary key. The target database is database B. Then, through the statement conversion knowledge graph, determine the statement of the target database that can represent the same semantics corresponding to the initial database statement as to create a table named t in database B, with a column named x in the table, the type is integer type, and it is a primary key.

[0034] Optionally, the statement conversion knowledge graph is a tree-shaped knowledge graph established by taking multiple objects of multiple databases as nodes and taking the mapping rules between any two objects as edges to connect multiple nodes.

[0035] Specifically, the nodes represent various objects in different databases, such as data types, SQL statements, functions, and constraints. The edges represent the mapping rules between the nodes, that is, how to convert an object in one database into an object in another database. Through the connection of nodes and edges, a hierarchical, tree-like structure is formed to represent complex conversion logic. The resulting statement conversion knowledge graph is to take objects in different databases as nodes, such as data types, syntax, and functions, etc., and take the mapping rules between these objects as the edges connecting the nodes, thereby constructing a tree-shaped structure. The statement conversion knowledge graph can be used to guide how to convert a statement in one database into a statement in another database. By determining the statement of the target database corresponding to the initial database statement through the statement conversion knowledge graph, the conversion result can be directly obtained when performing simple statement conversions, thereby improving the efficiency and accuracy of statement conversions.

[0036] Step 12, if the target database statement does not exist in the statement conversion knowledge graph, determine to execute step 102.

[0037] Specifically, if the target database statement does not exist in the statement conversion knowledge graph, that is, the statement knowledge content in the statement conversion knowledge graph cannot cover the information of the initial database statement. For example, the knowledge graph does not cover the statement corresponding to the semantics of the initial database statement in the target database. In this case, step 102 is determined to be executed. This embodiment can directly obtain the conversion result through the statement conversion knowledge graph when performing simple statement conversion. When the statement conversion knowledge graph cannot directly obtain the conversion result, the initial database statement is input into the statement conversion large model for statement conversion, thus avoiding the situation that directly using the statement conversion large model for simple statement conversion instead increases the conversion duration, and further improving the efficiency of statement conversion.

[0038] Step 102: Generate an initial input statement according to the initial database statement and the target database.

[0039] Among them, the statement format of the initial input statement is a preset input format. The initial input statement includes the initial database statement, the target database, and the initial database corresponding to the initial database statement.

[0040] Specifically, the preset input format is a format that is pre-set in the input statement conversion large model and is convenient for the large model to understand. For example, in the lightweight preset input format, it includes the database statement before conversion, the database corresponding to the database statement before conversion, and the target database for conversion. Determining the initial database according to the initial database statement, and then generating an initial input statement including the initial database statement, the target database, and the initial database corresponding to the initial database statement according to the initial database, the initial database statement, and the target database can facilitate the large model to obtain and understand the initial database statement, and improve the efficiency of statement conversion.

[0041] Step 103: Input the initial input statement into the pre-trained statement conversion large model to obtain the target database statement corresponding to the initial database statement output by the statement conversion large model.

[0042] Among them, the target database statement is a statement that can be executed in the target database and has the same semantics as the initial database statement. The statement conversion large model is used to determine the target database statement corresponding to the initial database statement according to the initial input statement.

[0043] Specifically, the target database statement is a statement that can be executed in the target database and has the same semantics as the initial database statement, that is, a statement that can achieve the same goal in the target database as the initial database statement can achieve in the initial database. The statement conversion large model is an open-source large language model used to determine the target database statement corresponding to the initial database statement according to the initial input statement, that is, a large language model that has been fine-tuned after being trained using the database statement conversion relationship, so that the model can determine the statement corresponding to the semantics of the statement in the target database according to the initial input statement. Input the initial input statement into the pre-trained statement conversion large model, and the statement conversion large model can obtain the corresponding target database statement according to the input of the initial input statement.

[0044] Exemplarily, the initial database statement is a statement in database A that means to create a table named t in database A, and there is a column named x in the table, with an integer type and is an auto-incrementing primary key. The target database is database B. Generate the initial input statement from the initial database, the initial database statement, and the target database. After inputting the initial input statement into the statement conversion large model, the target database statement is obtained, which means to create a table named t in the B database statement, and there is a column named x in the table, with an integer type and is the primary key.

[0045] Optionally, before performing step 104, steps 31 to 33 can also be performed.

[0046] Step 31, extract the first syntax structure of the initial database statement and the second syntax structure of the target database statement, and calculate the similarity between the first syntax structure and the second syntax structure; and, determine the first semantic information of the initial database statement and the second semantic information of the target database statement, and determine the degree of consistency between the first semantic information and the second semantic information; and, determine the first data source information of the initial database statement and the second data source information of the target database statement, and determine the degree of consistency between the first data source information and the second data source information.

[0047] Specifically, the syntax structure refers to the components and structure of a statement. For example, keywords, data types, table structures, etc. in an SQL statement. Exemplarily, the syntax structure includes creating table t, x being of integer type, etc. After extracting the first syntax structure and the second syntax structure, calculate the similarity between the first syntax structure and the second syntax structure by comparing the two syntax structures. For example, the similarity can be calculated by calculating the similarity of a tree-like data structure. Exemplarily, the similarity can be calculated by a neural network model that combines a tree structure and a long short-term memory network (Tree-Structured Long Short-Term Memory, Tree-LSTM).

[0048] Semantic information refers to the actual function or meaning of a statement, such as the function of a data type, the function of a constraint, and the function of a table structure. By determining whether the functions of two statements in the corresponding database are equivalent, the degree of consistency between the first semantic information and the second semantic information can be determined.

[0049] Data source information refers to the source of data in a statement, such as the name of a database table, the version of a database, and the context of data. By determining whether the first data source information and the second data source information come from the same context or business logic, the degree of consistency between the first data source information and the second data source information is verified. Exemplarily, the business entity represented by the created table t in the initial database is the same as the business entity represented by the created table t in the target database, that is, the degree of consistency between the first data source information and the second data source information is determined.

[0050] Step 32, if the similarity between the first syntax structure and the second syntax structure is greater than or equal to the similarity threshold, and the degree of consistency between the first semantic information and the second semantic information meets the preset semantic consistency condition, and the degree of consistency between the first data source information and the second data source information meets the preset source consistency condition, then it is determined to execute step 104.

[0051] Specifically, the similarity threshold refers to the similarity value at which the similarity between the preset first syntactic structure and the second syntactic structure meets the accuracy requirements of the large model conversion result. For example, the similarity threshold is 0.95. If the similarity between the first syntactic structure and the second syntactic structure is greater than or equal to the similarity threshold, it is determined that the syntactic structure of the target database statement meets the accuracy requirements of the large model conversion result, and at this time, step 104 is determined to be executed. The preset semantic consistency condition refers to the degree of consistency between the preset first semantic information and the second semantic information that meets the accuracy requirements of the large model conversion result. For example, the preset semantic consistency condition is that the first semantic information and the second semantic information are completely consistent, and a solver that can find a solution that meets the conditions under given constraints is used to prove whether the first semantic information and the second semantic information are consistent. If the degree of consistency between the first semantic information and the second semantic information meets the preset semantic consistency condition, it is determined that the semantic information of the target database statement meets the accuracy requirements of the large model conversion result, and at this time, step 104 is determined to be executed. The preset source consistency condition refers to the degree of consistency between the preset first data source information and the second data source information that meets the accuracy requirements of the large model conversion result. For example, the preset source consistency condition is that the first data source information and the second data source information are completely consistent, which can be to compare the column-level lineage and data conversion paths of the two statements. For example, both statements come from the same business logic or context, and the data sources are consistent. If the degree of consistency between the first data source information and the second data source information meets the preset source consistency condition, it is determined that the source information of the target database statement meets the accuracy requirements of the large model conversion result, and at this time, step 104 is determined to be executed, that is, the target database statement is returned to the user device. The above three judgment methods can be judged separately or combined, that is, as long as any one condition is met, the execution of step 104 can be triggered, or multiple conditions need to be met simultaneously to trigger the execution of step 104. This solution does not make any restrictions on this.

[0052] Step 33, if the similarity between the first syntactic structure and the second syntactic structure is less than the similarity threshold, and the degree of consistency between the first semantic information and the second semantic information does not meet the preset semantic consistency condition, and the degree of consistency between the first data source information and the second data source information does not meet the preset source consistency condition, then a statement conversion error message is sent to the user device.

[0053] Specifically, if the similarity between the first grammatical structure and the second grammatical structure is less than the similarity threshold, and the degree of consistency between the first semantic information and the second semantic information does not meet the preset semantic consistency condition, and the degree of consistency between the first data source information and the second data source information does not meet the preset source consistency condition, it indicates that the grammatical structure, semantic information, or source information of the target database statement does not meet the accuracy requirements of the large model conversion result. At this time, an error message for statement conversion is sent to the user device to indicate that an error has occurred in the large model conversion, which is convenient for the staff to handle. By verifying the similarity or consistency between the initial database statement and the target database statement, it is ensured that during the conversion of the database statement by the large model, the functions and behaviors of the target database statement can be kept consistent with the initial database statement, and timely feedback is provided when they are inconsistent, thereby improving the accuracy and practicality of the large model for statement conversion.

[0054] Step 104: Return the target database statement to the user device.

[0055] Specifically, after obtaining the target database statement, the target database statement is returned to the user device so that the user can obtain the converted statement, thereby facilitating the completion of subsequent database operations.

[0056] Optionally, after executing Step 104, Steps 41 to 43 can also be executed.

[0057] Step 41: Receive the evaluation of the large model conversion result returned by the user device.

[0058] Specifically, after returning the target database statement to the user device, the user can evaluate the large model conversion result and return the evaluation of the large model conversion result to the electronic device executing this embodiment, and the electronic device receives this evaluation of the large model conversion result.

[0059] Exemplarily, the evaluation of the large model conversion result may include the score of the large model conversion result.

[0060] Step 42: If the evaluation of the large model conversion result does not meet the preset evaluation requirements, obtain the target statement corresponding to the initial database statement sent by the user device.

[0061] Specifically, the preset evaluation requirements are the requirements that should be met for determining the correctness of the large model conversion result set in advance. For example, the preset evaluation requirement is that the score of the large model conversion result is greater than the score threshold. The target statement is the statement corresponding to the semantics of the initial database statement determined by the user based on human experience in the target database. When the evaluation of the large model conversion result does not meet the preset evaluation requirements, the user sends the target statement to the electronic device executing this embodiment through the user device, and the electronic device executing this embodiment receives this target statement.

[0062] Step 43: Adjust the target model parameters of the statement conversion large model according to the initial database statement, the target database, and the target statement, so that the statement conversion large model can obtain the target statement based on the initial database statement and the target database.

[0063] Specifically, adjust the target model parameters of the statement conversion large model according to the initial database statement, the target database, and the target statement. For example, fine-tune the learning rate of the large model to improve the accuracy of the output result of the large model, so that the statement conversion large model can obtain the target statement based on the initial database statement and the target database. When the evaluation of the conversion result of the large model does not meet the preset evaluation requirements, adjust the model parameters of the large model according to the target statement sent by the user device, so that the adjusted large model can obtain the target statement based on the initial database statement and the target database, further improving the accuracy of the output result of the large model, and thus further improving the efficiency of statement conversion based on the large model.

[0064] In the solution of this application, obtain the initial database statement and the target database sent by the user device; generate an initial input statement according to the initial database statement and the target database; wherein, the statement format of the initial input statement is the preset input format, and the initial input statement includes the initial database statement, the target database, and the initial database corresponding to the initial database statement; input the initial input statement into the pre-trained statement conversion large model to obtain the target database statement corresponding to the initial database statement output by the statement conversion large model; wherein, the target database statement is a statement that can be executed in the target database and has the same semantics as the initial database statement, and the statement conversion large model is used to determine the target database statement corresponding to the initial database statement according to the initial input statement; return the target database statement to the user device. That is, on the one hand, processing the initial database statement to obtain the initial input statement can transform the initial database statement into a statement that the statement conversion large model can read, avoiding the situation where staff manually analyze the database type of the statement and perform manual input, reducing the work difficulty of the staff. On the other hand, by inputting the initial input statement into the pre-trained statement conversion large model, the target database statement corresponding to the initial database statement is obtained, thus realizing the conversion of statements between different databases, avoiding the situation where conversion cannot be achieved when the rules involved in statement conversion are outside the finite rule set, and further reducing the difficulty of cross-database operations.

[0065] Figure 2 It is a schematic diagram of the training process of the statement conversion large model of the statement conversion method provided by this application. In this embodiment, Figure 1 On the basis of the embodiments and various optional implementation solutions shown, the steps of training the statement conversion large model are described in detail. As Figure 2As shown, the method may include the following steps:

[0066] Step 201, obtain a training input statement.

[0067] Among them, the training input statement is a statement in the training statement library, and the statement format of the training input statement is a preset input format. The training input statement includes a training initial database statement, a training target database, and a training initial database corresponding to the training initial database statement.

[0068] Specifically, the training statement library stores a large number of cross-database SQL statement pairs with known corresponding relationships, such as database statement pairs covering various query types, syntax features, specific database extensions, etc., thus forming a rich training data set. The statement format of the training input statement is a preset input format, which is consistent with the format of the initial input statement, so that the statement format during the training of the large model is consistent with the statement format in subsequent applications, thereby improving the accuracy of the output result of the large model. Obtaining the training input statement is to randomly obtain an input statement in the training statement library that includes a training initial database statement, a training target database, and a training initial database corresponding to the training initial database statement.

[0069] Step 202, input the training input statement into the large model to be trained, and obtain the training target database statement output by the large model to be trained.

[0070] Specifically, the large model to be trained can be any open-source large model. Inputting the training input statement into the large model to be trained can obtain the training target database statement output by the large model to be trained.

[0071] Step 203, adjust the target model parameters of the large model to be trained according to the training target statement corresponding to the training initial database statement and the training target database statement, and obtain the large model to be trained with adjusted parameters.

[0072] Among them, the training target statement is a statement that can be executed in the training target database and has the same semantics as the training initial database statement.

[0073] Specifically, the statement corresponding to the training initial database statement that can be executed in the training target database and has the same semantics as the training initial database statement. Therefore, adjusting the target model parameters of the large model to be trained according to the training target statement corresponding to the training initial database statement and the training target database statement, such as adjusting the learning rate of the large model, can obtain the large model to be trained with adjusted parameters.

[0074] Optionally, the target model parameters include the learning rate.

[0075] Specifically, the target model parameter is determined as the learning rate because complex tasks require a smaller learning rate. A smaller learning rate can avoid the situation of damaging the existing language understanding ability of the large model when the learning rate is large. Selecting a smaller learning rate can ensure the stability of the training process of the large model while avoiding overfitting.

[0076] Step 204: Use the large model to be trained with adjusted parameters as the new large model to be trained, and use at least one statement in the training statement library that has not been input into the large model to be trained as the new training input statement. Return to execute Step 202 until the preset iteration end condition is reached, and use the large model to be trained with adjusted parameters as the statement conversion large model.

[0077] Specifically, use the large model to be trained with adjusted parameters as the new large model to be trained, and use at least one statement in the training statement library that has not been input into the large model to be trained as the new training input statement. Return to the step of inputting the training input statement into the large model to be trained until the preset iteration end condition is reached. For example, the preset iteration end condition can be to stop training when a certain cut-off condition is reached, that is, stop the returned step. The cut-off condition can be that the number of training rounds reaches the preset number of rounds, or the training loss is lower than a certain value, etc. At this time, the large model to be trained with adjusted parameters obtained is the statement conversion large model.

[0078] The solution of this application adjusts the target model parameters of the large model to be trained by training the training target statements corresponding to the initial database statements and the training target database statements, enabling it to learn the statement conversion rules between different databases, thereby improving the accuracy, generalization ability, and adaptability of statement conversion, and enabling it to better meet the requirements in practical applications.

[0079] Figure 3 It is a structural schematic diagram of a statement conversion device provided by this application, and this device is applicable to execute the statement conversion method provided by this application. As Figure 3 shown, this device may specifically include:

[0080] An initial acquisition module 301, configured to acquire an initial database statement and a target database sent by a user device.

[0081] An initial statement generation module 302, configured to generate an initial input statement according to the initial database statement and the target database; wherein, the statement format of the initial input statement is a preset input format, and the initial input statement includes the initial database statement, the target database, and the initial database corresponding to the initial database statement.

[0082] The model input module 303 is configured to input the initial input statement into a pre-trained statement conversion large model to obtain a target database statement corresponding to the initial database statement output by the statement conversion large model; wherein, the target database statement is a statement that can be executed in the target database and has the same semantics as the initial database statement, and the statement conversion large model is used to determine the target database statement corresponding to the initial database statement according to the initial input statement.

[0083] The sending module 304 is configured to return the target database statement to the user device.

[0084] In one embodiment, the device further includes: a determination module, configured to, after the initial acquisition module 301 acquires the initial database statement and the target database sent by the user device, determine the target database statement corresponding to the initial database statement in the statement conversion knowledge graph according to the initial database statement and the target database; if the target database statement does not exist in the statement conversion knowledge graph, determine to execute the step of "generating an initial input statement according to the initial database statement and the target database".

[0085] In one embodiment, the statement conversion knowledge graph of the determination module is a tree-shaped knowledge graph established by using multiple objects of multiple databases as nodes and using the mapping rules between any two of the objects as edges to connect the multiple nodes.

[0086] In one embodiment, the device further includes: a judgment module, configured to, before the sending module 304 returns the target database statement to the user device, extract the first syntax structure of the initial database statement and the second syntax structure of the target database statement, and calculate the similarity between the first syntax structure and the second syntax structure; and determine the first semantic information of the initial database statement and the second semantic information of the target database statement, and determine the degree of consistency between the first semantic information and the second semantic information; and determine the first data source information of the initial database statement and the second data source information of the target database statement, and determine the degree of consistency between the first data source information and the second data source information; if the similarity between the first syntax structure and the second syntax structure is greater than or equal to a similarity threshold, and the degree of consistency between the first semantic information and the second semantic information meets a preset semantic consistency condition, and the degree of consistency between the first data source information and the second data source information meets a preset source consistency condition, then determine to execute the step of "returning the target database statement to the user device"; if the similarity between the first syntax structure and the second syntax structure is less than the similarity threshold, and the degree of consistency between the first semantic information and the second semantic information does not meet the preset semantic consistency condition, and the degree of consistency between the first data source information and the second data source information does not meet the preset source consistency condition, then send a statement conversion error message to the user device.

[0087] In one embodiment, the device further includes: an adjustment module, configured to, after the sending module 304 returns the target database statement to the user device, receive the large model conversion result evaluation returned by the user device; if the large model conversion result evaluation does not meet the preset evaluation requirements, then obtain the target statement corresponding to the initial database statement sent by the user device; adjust the target model parameters of the statement conversion large model according to the initial database statement, the target database, and the target statement, so that the statement conversion large model can obtain the target statement according to the initial database statement and the target database.

[0088] In one embodiment, the device further includes: a statement conversion large model training module, configured to obtain a training input statement; wherein, the training input statement is a statement in a training statement library, the statement format of the training input statement is the preset input format, and the training input statement includes a training initial database statement, a training target database, and a training initial database corresponding to the training initial database statement; input the training input statement into the large model to be trained, and obtain a training target database statement output by the large model to be trained; adjust the target model parameters of the large model to be trained according to the training target statement corresponding to the training initial database statement and the training target database statement, and obtain the large model to be trained with adjusted parameters; wherein, the training target statement is a statement that can be executed in the training target database and has the same semantics as the training initial database statement; use the large model to be trained with adjusted parameters as the new large model to be trained, use at least one statement in the training statement library that has not been input into the large model to be trained as the new training input statement, and return to execute the step of "inputting the training input statement into the large model to be trained, and obtaining a training target database statement output by the large model to be trained", until a preset iteration end condition is reached, and use the large model to be trained with adjusted parameters as the statement conversion large model.

[0089] The device of the present application obtains an initial database statement and a target database sent by a user device; generates an initial input statement according to the initial database statement and the target database; wherein, the statement format of the initial input statement is the preset input format, and the initial input statement includes the initial database statement, the target database, and an initial database corresponding to the initial database statement; input the initial input statement into a pre-trained statement conversion large model, and obtain a target database statement corresponding to the initial database statement output by the statement conversion large model; wherein, the target database statement is a statement that can be executed in the target database and has the same semantics as the initial database statement, and the statement conversion large model is configured to determine a target database statement corresponding to the initial database statement according to the initial input statement; return the target database statement to the user device. That is, for the method of the present application, on the one hand, processing the initial database statement to obtain the initial input statement can transform the initial database statement into a statement that can be read by the statement conversion large model, avoiding the situation where staff manually analyze the database type of the statement and perform manual input, and reducing the work difficulty of the staff. On the other hand, by inputting the initial input statement into a pre-trained statement conversion large model, a target database statement corresponding to the initial database statement is obtained, thereby realizing the conversion of statements between different databases, avoiding the situation where conversion cannot be achieved when the rules involved in statement conversion are outside a finite rule set, and further reducing the difficulty of cross-database operations.

[0090] The present application also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method for statement conversion provided in any of the above embodiments is implemented.

[0091] The present application also provides a computer-readable medium, on which a computer program is stored. When the program is executed by a processor, the method for statement conversion provided in any of the above embodiments is implemented.

[0092] Reference is made below Figure 4 to FIG., which shows a schematic structural diagram of an electronic device 400 suitable for implementing the present application. Figure 4 The electronic device shown is only an example and should not impose any limitation on the functions and usage scope of the present application.

[0093] As Figure 4 shown, the electronic device 400 includes a central processing unit (CPU) 401, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 402 or the program loaded from the storage section 408 into the random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The CPU 401, ROM 402, and RAM 403 are connected to each other via a bus 404. The input / output (I / O) interface 405 is also connected to the bus 404.

[0094] The following components are connected to the I / O interface 405: an input section 406 including a keyboard, a mouse, etc.; an output section 407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN card, a modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the I / O interface 405 as required. A removable medium 411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 410 as required, so that a computer program read from it can be installed into the storage section 408 as required.

[0095] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 409, and / or installed from the removable medium 411. When the computer program is executed by the central processing unit (CPU) 401, the above functions defined in the system of the present application are executed.

[0096] It should be noted that the computer-readable medium shown in the present application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, 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 above. In the present application, the computer-readable storage medium can be any tangible medium that contains or stores a program, and the program can be used by or in combination with an instruction execution system, apparatus, or device. In the present application, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries the computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and the computer-readable medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0097] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, as well as combinations of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0098] The modules and / or units described in the present application can be implemented in software or in hardware. The described modules and / or units can also be provided in a processor. For example, it can be described as: a processor includes an initial acquisition module, an initial statement generation module, a model input module, and a sending module. Among them, the names of these modules do not constitute a limitation on the module itself in some cases.

[0099] As another aspect, the present application also provides a computer-readable medium, which can be included in the device described in the above embodiments; or can exist separately without being assembled into the device. The above computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device is caused to perform the following operations:

[0100] Obtain an initial database statement and a target database sent by a user device; generate an initial input statement according to the initial database statement and the target database; wherein, the statement format of the initial input statement is a preset input format, and the initial input statement includes the initial database statement, the target database, and the initial database corresponding to the initial database statement; input the initial input statement into a pre-trained statement conversion large model to obtain a target database statement corresponding to the initial database statement output by the statement conversion large model; wherein, the target database statement is a statement that can be executed in the target database and has the same semantics as the initial database statement, and the statement conversion large model is used to determine the target database statement corresponding to the initial database statement according to the initial input statement; return the target database statement to the user device.

[0101] According to the technical solution of the present application, obtain the initial database statement sent by the user device and the target database; generate an initial input statement according to the initial database statement and the target database; wherein, the statement format of the initial input statement is a preset input format, and the initial input statement includes the initial database statement, the target database, and the initial database corresponding to the initial database statement; input the initial input statement into the pre-trained statement conversion large model to obtain the target database statement corresponding to the initial database statement output by the statement conversion large model; wherein, the target database statement is a statement that can be executed in the target database and has the same semantics as the initial database statement, and the statement conversion large model is used to determine the target database statement corresponding to the initial database statement according to the initial input statement; return the target database statement to the user device. That is, for the method of the present application, on the one hand, processing the initial database statement to obtain the initial input statement can transform the initial database statement into a statement that the statement conversion large model can read, avoiding the situation where staff manually analyze the database type of the statement and perform manual input, and reducing the work difficulty of the staff. On the other hand, by inputting the initial input statement into the pre-trained statement conversion large model, the target database statement corresponding to the initial database statement is obtained, thereby realizing the conversion of statements between different databases and avoiding the situation where conversion cannot be achieved when the rules involved in statement conversion are outside the finite rule set, and further reducing the difficulty of cross-database operations.

[0102] The embodiment of the present application also provides a computer program product, including a computer program, which when executed by a processor, implements the statement conversion method provided in any embodiment of the present application.

[0103] In the process of implementing the computer program product, the computer program code for executing the operations of the present application can be written in one or more programming languages or a combination thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed completely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network - including a local area network (LAN) or a wide area network (WAN) - or can be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).

[0104] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this application can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of this application can be achieved, and no limitation is imposed herein.

[0105] The above specific embodiments do not constitute a limitation on the protection scope of this application. Those skilled in the art should understand that various modifications, combinations, sub - combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application shall be included within the protection scope of this application.

Claims

1. A sentence conversion method, characterized in that: The method comprises: Obtaining an initial database statement and a target database sent by a user device; Generate an initial input statement according to the initial database statement and the target database; wherein the statement format of the initial input statement is a preset input format, and the initial input statement includes the initial database statement, the target database, and the initial database corresponding to the initial database statement; Input the initial input statement into a pre-trained statement conversion model to obtain a target database statement corresponding to the initial database statement output by the statement conversion model; wherein the target database statement is a statement that can be executed in the target database and has the same semantics as the initial database statement, and the statement conversion model is used to determine the target database statement corresponding to the initial database statement according to the initial input statement; The target database statement is returned to the user device.

2. The method according to claim 1, characterized in that: After obtaining the initial database statement and the target database sent by the user equipment, the method further includes: According to the initial database statement and the target database, determining in the statement conversion knowledge graph a target database statement corresponding to the initial database statement; If the target database statement does not exist in the statement conversion knowledge graph, determine to execute the step of "generating an initial input statement based on the initial database statement and the target database".

3. The method according to claim 2, characterized in that The statement conversion knowledge graph is a tree-like knowledge graph established by connecting multiple objects of multiple databases as nodes and mapping rules between any two of the objects as edges, and connecting the multiple nodes.

4. The method according to claim 1, characterized in that: Before returning the target database statement to the user device, the method further includes: Extracting a first grammatical structure of the initial database statement and a second grammatical structure of the target database statement, and calculating a similarity between the first grammatical structure and the second grammatical structure; Determining first semantic information of the initial database statement and second semantic information of the target database statement, and determining a consistency degree between the first semantic information and the second semantic information; Determine the first data source information of the initial database statement and the second data source information of the target database statement, and determine the consistency between the first data source information and the second data source information; If the similarity between the first grammatical structure and the second grammatical structure is greater than or equal to a similarity threshold, and the consistency between the first semantic information and the second semantic information satisfies a preset semantic consistency condition, and the consistency between the first data source information and the second data source information satisfies a preset source consistency condition, then determine to execute the step of "returning the target database statement to the user device"; If the similarity between the first grammatical structure and the second grammatical structure is less than the similarity threshold, and the consistency between the first semantic information and the second semantic information does not satisfy the preset semantic consistency condition, and the consistency between the first data source information and the second data source information does not satisfy the preset source consistency condition, a sentence conversion error message is sent to the user device.

5. The method according to claim 1, characterized in that The method further comprises: Receiving a large model conversion result evaluation returned by the user device; If the evaluation of the large model conversion result does not meet the preset evaluation requirements, obtaining a target statement corresponding to the initial database statement sent by the user device; The target model parameters of the statement conversion large model are adjusted according to the initial database statement, the target database and the target statement, so that the statement conversion large model can obtain the target statement according to the initial database statement and the target database.

6. The method according to claim 1, characterized in that The sentence conversion model is trained according to the following steps: Obtaining a training input statement; wherein the training input statement is a statement in a training statement library, the statement format of the training input statement is the preset input format, and the training input statement includes a training initial database statement, a training target database, and a training initial database corresponding to the training initial database statement; Input the training input sentence into the large model to be trained to obtain the training target database sentence output by the large model to be trained; According to the training target statement corresponding to the training initial database statement and the training target database statement, the target model parameters of the large model to be trained are adjusted to obtain the large model to be trained after the parameters are adjusted; wherein the training target statement is a statement that can be executed in the training target database and has the same semantics as the statement of the training initial database; The large model to be trained after the parameter adjustment is used as the new large model to be trained, and at least one statement in the training sentence library that has not been input into the large model to be trained is used as a new training input sentence, and the step of "inputting the training input sentence into the large model to be trained to obtain the training target database sentence output by the large model to be trained" is returned to execute until the preset iteration end condition is reached, and the large model to be trained after the parameter adjustment is used as the sentence conversion large model.

7. A sentence conversion device, characterized in that: The device comprises: An initial acquisition module, used to acquire an initial database statement and a target database sent by a user device; An initial statement generating module, configured to generate an initial input statement according to the initial database statement and the target database; wherein the statement format of the initial input statement is a preset input format, and the initial input statement includes the initial database statement, the target database, and the initial database corresponding to the initial database statement; A model input module, used for inputting the initial input statement into a pre-trained statement conversion model, and obtaining a target database statement corresponding to the initial database statement output by the statement conversion model; wherein the target database statement is a statement that can be executed in the target database and has the same semantics as the initial database statement, and the statement conversion model is used for determining the target database statement corresponding to the initial database statement according to the initial input statement; A sending module is used to return the target database statement to the user equipment.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the statement conversion method as described in any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the statement conversion method as described in any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the statement conversion method according to any one of claims 1 to 6.