A processing method and device of a query statement conversion model, equipment and medium
Patent Information
- Application Number
- CN202610490141.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-14
- Publication Date
- 2026-08-18
AI Technical Summary
[0006]本发明提供了一种查询语句转换模型的处理方法、装置、设备及介质,以解决传统数据库迁移时过于依赖人工经验的问题
[0013] This invention introduces scenario-specific labels to annotate target sample query statements, enabling the model to learn conversion rules under different syntax transformation types, performance optimization requirements, business scenario characteristics, and query complexity during training. This improves the model's adaptability to diverse conversion scenarios. Simultaneously, a vocabulary mapping table is used to supervise the model's output, ensuring that the model learns conversion rules that conform to the syntactic correspondence between the source and target databases. This achieves high-quality automatic conversion of query statements, reducing manual intervention and avoiding omissions, semantic changes, and performance issues caused by manual operations. It also improves the accuracy, consistency, and efficiency of database query statement conversion during database migration.
Smart Images

Figure CN122594322A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database migration technology, and in particular to a method, apparatus, device, and medium for processing query statement conversion models. Background Technology
[0002] Against the backdrop of rapid development in information technology, core business systems of enterprises generally adopt mature relational databases as the foundation for data storage and management. As the nation's requirements for self-reliance and control over information technology continue to rise, more and more enterprises are gradually replacing the databases in their core systems with domestically produced database products. Although domestic databases maintain a high degree of compatibility with existing databases at the standard SQL syntax level, the existing databases have developed numerous unique functions, syntax structures, execution logics, and optimization mechanisms over their long development process. These features are not directly supported by domestic databases, making a smooth transition impossible through simple syntax replacement during actual migration.
[0003] Currently, database migration is primarily done manually. Technical personnel must painstakingly search through all code snippets involving database operations within the application, relying on their experience to determine if incompatible syntax or potential risks exist, and then manually modify and adapt them. Subsequently, extensive testing is required to verify the correctness of the modified functionality and the stability of the system. This process is highly dependent on the experience level of the implementers; different personnel have varying levels of understanding of database syntax differences and different grasp of business logic, resulting in poor replicability and difficulty in consistently ensuring quality during the migration process.
[0004] In practice, manual migration methods often present three prominent problems. First, database operation statements are widely distributed and diverse in form within the code, making it easy to miss some during manual searches. This results in incompatible statements not being identified and modified, potentially leading to functional defects. Second, when modifying syntax issues, insufficient understanding of semantic differences between databases may alter the original business logic while adjusting the statement structure, causing functional abnormalities. Third, while existing databases may have internal optimization mechanisms in specific scenarios, and some syntax may be functionally compatible with domestic databases, in actual production environments, if the data volume reaches a certain scale, performance issues may arise due to differences in execution plans or optimization paths, even leading to slow database response or service interruptions. Because stress testing environments cannot fully simulate real data scale and access patterns, such performance issues often only surface after the system goes live, posing significant risks to business continuity and system stability.
[0005] In summary, existing manual database migration methods have significant shortcomings in terms of efficiency, accuracy, and reliability. There is an urgent need to introduce more systematic and automated methods and mechanisms to improve the standardization of the migration process and the controllability of the results. Summary of the Invention
[0006] This invention provides a method, apparatus, device, and medium for processing query statement transformation models to solve the problem of excessive reliance on manual experience during traditional database migration.
[0007] According to one aspect of the present invention, a method for processing a query statement transformation model is provided, comprising: The original sample query statement in the query statement sample pair is segmented into words to obtain the original segmented word sequence, and the original segmented word sequence is input into the encoder in the initial sequence model to generate the source semantic vector; The target sample query statements containing scenario-specific tags in the query statement sample pairs are segmented to obtain the target segmentation sequence; the scenario-specific tags include at least one of the following: syntax transformation type tags, performance optimization type tags, business scenario tags, and query complexity tags of the sample pairs; The source semantic vector and the target word segmentation sequence are input into the decoder of the initial sequence model to obtain the model output. The initial sequence model is then trained based on the vocabulary mapping table between the source database and the target database, the model output, and the target sample query statement to obtain the query statement conversion model.
[0008] According to another aspect of the present invention, a processing apparatus for a query statement transformation model is provided, comprising: The source statement encoding module is used to segment the original sample query statement in the query statement sample pair to obtain the original segmented word sequence, and input the original segmented word sequence into the encoder in the initial sequence model to generate the source semantic vector; The target statement preprocessing module is used to segment the target sample query statements containing scenario-specific tags in the query statement sample pairs to obtain the target segmented word sequence; the scenario-specific tags include at least one of the following: syntax transformation type tags, performance optimization type tags, business scenario tags, and query complexity tags of the sample pairs; The decoding training module is used to input the source semantic vector and the target word segmentation sequence into the decoder of the initial sequence model, obtain the model output result, and train the initial sequence model according to the vocabulary mapping table between the source database and the target database, the model output result, and the target sample query statement to obtain the query statement conversion model.
[0009] According to another aspect of the present invention, a computer program product is provided, comprising a computer program that, when executed by a processor, implements a processing method for a query statement transformation model according to any embodiment of the present invention.
[0010] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the query statement transformation model processing method according to any embodiment of the present invention.
[0011] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the query statement transformation model processing method according to any embodiment of the present invention.
[0012] According to another aspect of the present invention, a computer program product is provided, comprising a computer program / instructions that, when executed by a processor, implement a query statement transformation model processing method as described in any embodiment of the present invention.
[0013] This invention introduces scenario-specific labels to annotate target sample query statements, enabling the model to learn conversion rules under different syntax transformation types, performance optimization requirements, business scenario characteristics, and query complexity during training. This improves the model's adaptability to diverse conversion scenarios. Simultaneously, a vocabulary mapping table is used to supervise the model's output, ensuring that the model learns conversion rules that conform to the syntactic correspondence between the source and target databases. This achieves high-quality automatic conversion of query statements, reducing manual intervention and avoiding omissions, semantic changes, and performance issues caused by manual operations. It also improves the accuracy, consistency, and efficiency of database query statement conversion during database migration.
[0014] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a flowchart of a query statement conversion model processing method provided in an embodiment of the present invention; Figure 2 This is a flowchart of a query statement conversion model processing method provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of a processing device for a query statement conversion model provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of an electronic device that implements the query statement conversion model processing method of the present invention. Detailed Implementation
[0017] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0018] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0019] Figure 1This is a flowchart illustrating a query statement conversion model processing method provided in an embodiment of the present invention. This embodiment is applicable to situations where, during data migration, query statements written based on the source database syntax are automatically converted into target statements conforming to the target database syntax specifications. This method can be executed by a query statement conversion model processing device, which can be implemented in hardware and / or software and can be configured in an electronic device with corresponding data processing capabilities. Figure 1 As shown, the method includes: S110. The original sample query statement in the query statement sample pair is segmented into words to obtain the original segmented word sequence, and the original segmented word sequence is input into the encoder in the initial sequence model to generate the source semantic vector.
[0020] The query sample pairs include original sample queries from the source database and target sample queries adapted for the target database. Query statements, such as SQL (Structured Query Language) statements, include various data query statements in Data Query Language (DQL), CRUD operations statements in Data Manipulation Language (DML), and database object-related statements such as stored procedures and function calls, covering core business scenarios in finance, general industries, and other sectors. In financial business scenarios, transaction-related queries can retrieve key information such as transaction records and details; data statistics queries can efficiently aggregate, calculate, and analyze massive amounts of financial data, providing data support for business decisions; and batch processing queries can achieve centralized processing of large-scale financial business data, improving business processing efficiency. The original sample query statements include at least one of the following: function call queries, pagination queries, aggregation calculation queries, or stored procedure queries. There may be syntax incompatibility, function name differences, and heterogeneous execution logic between the query statements in the source and target databases.
[0021] The original query statements in the query statement sample pair are segmented into words to obtain the original word segmentation sequence. This original word segmentation sequence is then input into the encoder of the initial sequence model to generate the source semantic vector. For example, the initial sequence model can be a BART (Bidirectional and Auto-Regressive Transformers) model. The BART model is a sequence-to-sequence generative pre-trained deep learning model that can generate corresponding output text from input text.
[0022] Optionally, the original sample query statement is segmented to obtain an original segmented sequence, including: splitting the original sample query statement based on the list of grammatical elements in the source database to obtain initial grammatical units; if the length of any initial grammatical unit is greater than a preset threshold, then the initial grammatical unit is split based on the grammatical boundary identifiers predefined for the source database to obtain the original segmented sequence; the grammatical boundary includes at least one of clause boundary, subquery boundary, function boundary, logical operation boundary, or statement termination boundary.
[0023] Preprocessing of the original sample query statements includes: removing invalid query statements and retaining valid business statements. Specifically, this involves removing test queries (such as `select 1 from dual`), empty statements, and redundant comment statements; standardizing the format of query statements, such as unifying keyword case (e.g., converting all keywords to uppercase), unifying spaces / newline characters, and removing redundant parentheses to avoid format differences causing the model to learn irrelevant features; and retaining business semantic identifiers, such as table names, field names, and aliases, to ensure that the business meaning is not changed after model conversion.
[0024] For niche syntax incompatibility scenarios encountered during enterprise migration (such as special functions and custom stored procedures), scenario-based corpus enhancement can be performed due to the limited actual corpus size. Specifically, this can include syntax rule replacement: based on the syntax mapping rules between the source and target databases, similar syntax replacements can be performed on existing corpora, such as replacing the parameter forms of `regexp_substr` with the corresponding parameter forms of `regexp_matches`; business parameter replacement: while preserving the syntax structure of the query statement, table names / field names / parameter values can be replaced (e.g., replacing `where id=100` with `where id=200`), generating new paired corpora; and complexity enhancement: simple SQL can be nested appropriately to generate complex SQL corpora, such as nesting simple pagination queries into multi-table join pagination queries, adapting to complex enterprise business scenarios.
[0025] The syntax element list is a predefined set of all identifiable syntax components supported by the source database. It is used to accurately break down the original query statement into its smallest syntactic units, such as keywords, function names, table names, field names, operators, and parameter values, during the statement parsing process. Based on the syntax element list of the source database, the preprocessed original sample query statement is broken down into initial syntactic units. For example, the original sample query statement `select regexp_substr(col,'\\d+') from tabwhere rownum<=10` can be broken down into `[select,regexp_substr,(,col,'\\d+',),from,tab,where,rownum,<=,10]` according to the syntax element list.
[0026] If the length of any initial syntactic unit exceeds a preset threshold, the initial syntactic unit is split based on predefined syntactic boundary markers for the source database to obtain the original word segmentation sequence. Syntactic boundaries include at least one of clause boundaries, subquery boundaries, function boundaries, logical operation boundaries, or statement termination boundaries. Clause boundaries include the end of the SELECT clause, the end of the FROM clause, the beginning or end of the WHERE clause, the beginning or end of the GROUP BY clause, and the beginning or end of the ORDER BY clause. Subquery boundaries include the subquery start marker (or subquery end marker), and are only valid when there are no nested subqueries or the nesting level is shallow. Function boundaries include the function start marker (or function parameter end marker), i.e., the complete end position of a single function call. Logical operation boundaries include the logical operators (AND, OR) in the WHERE clause, serving as optional boundaries for segmentation. Statement termination boundaries include the semicolon (SQL statement end marker). This is achieved by splitting at natural syntactic boundaries, such as the end of a subquery or function call. Ensure that each segment is semantically independent and can be executed independently or combined into a complete original SQL statement through simple join operations. Divide the excessively long SQL statement into segments according to the determined split points, generating multiple relatively short SQL statement fragments. These fragments can be executed separately or combined for execution according to business needs.
[0027] By performing hierarchical word segmentation on the original sample query statements, the statements are first split into initial syntactic units such as keywords, function names, table names, and field names based on the list of syntactic elements in the source database, ensuring the integrity of basic syntactic elements. For initial syntactic units exceeding a preset threshold in length, a secondary split is performed based on syntactic boundary markers such as clause boundaries, subquery boundaries, function boundaries, logical operation boundaries, or statement termination boundaries. This avoids the problem of the model being unable to effectively learn long-distance dependencies due to excessively long single syntactic units, and ensures that the split subsequences retain complete syntactic and semantic boundaries, preventing semantic fragmentation. This approach can obtain word segments with appropriate granularity and clear boundaries while ensuring syntactic and semantic integrity, providing high-quality input for subsequent semantic extraction by the encoder and generation by the decoder, thereby improving the training effect and conversion accuracy of the query statement conversion model.
[0028] It can also use the BPE (Byte Pair Encoding) algorithm to segment custom function names, table names, etc., to build a vocabulary. The vocabulary is used to segment enterprise-defined names to balance vocabulary size and semantic integrity, avoiding vocabulary explosion caused by enterprise-defined naming. The list of syntax elements and the vocabulary are independent of each other but are used together in the processing flow. It can also perform syntax-level completion on very short SQL (such as simple queries), only completing mask markers and not adding invalid syntax units to avoid the model learning redundant features. S120. Target segmentation sequence is obtained by segmenting the target sample query statement containing scene-specific tags in the query statement sample pair.
[0029] The target query statement in the query statement sample pair includes scenario-specific tags. Scenario-specific tags include at least one of the following: syntax transformation type tag, performance optimization type tag, business scenario tag, and query complexity tag. The syntax transformation type tag marks the core transformation type of the target query statement, such as syntax compatibility transformation, function mapping transformation, data type transformation, pagination statement transformation, etc.; the performance optimization tag indicates the optimization direction of the target query statement, such as index optimization, pagination rewriting, etc.; the business scenario tag marks the business scenario to which the target query statement belongs, such as transaction query, data statistics, batch accounting, report generation, etc., allowing the model to learn the query statement transformation preferences under different business scenarios; the query complexity tag marks the syntax complexity of the target query statement, such as single-table query, nested query, multi-table join, stored procedure, etc., assisting the model in making differentiated transformations for different complexities. Scenario-specific tags can be appended to the beginning of the target query statement as an input prefix for the decoder, guiding the direction of the decoder's output generation and letting the decoder know which rules to follow when generating the output.
[0030] The target sample query statement is segmented to obtain the target segmented word sequence. The segmentation process can refer to the original sample query statement. Based on the list of grammatical elements in the target database, the target sample query statement is split to obtain initial grammatical units. If the length of any initial grammatical unit is greater than a preset threshold, the initial grammatical unit is split based on the predefined grammatical boundary identifier for the target database to obtain the target segmented word sequence. The grammatical boundary includes at least one of the following: clause boundary, subquery boundary, function boundary, logical operation boundary, or statement termination boundary.
[0031] S130. Input the source semantic vector and the target word segmentation sequence into the decoder of the initial sequence model, obtain the model output, and train the initial sequence model according to the vocabulary mapping table between the source database and the target database, the model output, and the target sample query statement to obtain the query statement conversion model.
[0032] A lexical mapping table is a pre-built set of mappings that records the correspondence between syntactic elements in a source database and a target database. Because different database products differ in function names, keywords, built-in functions, data types, and syntactic structures, a clear mapping is needed to guide the conversion when performing direct syntactic substitution. The lexical mapping table stores this mapping. For example, the REGEXP_SUBSTR function in the source database may need to be mapped to the REGEXP_EXTRACT function in the target database, and the ROWNUM pseudo-column may need to be mapped to the LIMIT or ROW_NUMBER() window function, etc. The lexical mapping table is pre-built by domain experts based on the syntactic differences between the two databases, covering multiple dimensions such as function mapping, keyword mapping, operator mapping, data type mapping, and special syntactic structure mapping. It serves as a crucial knowledge foundation for subsequent model training and conversion processes.
[0033] The source semantic vector and the target word segmentation sequence are input into the decoder of the initial sequence model. The decoder interacts and decodes the source semantic vector and the target word segmentation sequence based on an attention mechanism to generate the output result. The initial sequence model is trained based on a pre-constructed vocabulary mapping table, the model output result, and the target sample query statement. Specifically, since there are grammatical differences between the source database and the target database, a clear correspondence is needed as the basis for direct grammatical conversion. The vocabulary mapping table serves as the carrier of this correspondence and provides supervision signals for model training.
[0034] During training, the model's output, i.e., the predicted sequence, is compared with the actual target sample query statements, and the difference between the two is calculated as part of the loss function. Simultaneously, the correctness of the grammatical mappings in the model's output is verified using a vocabulary mapping table, ensuring that the model learns transformation rules that conform to the mapping relationships. The parameters of the initial sequence model are continuously adjusted through backpropagation, causing the model to gradually converge, ultimately resulting in a fully trained query statement transformation model. During the inference phase, the query statement transformation model can generate target statements that conform to the grammatical specifications of the target database based on the input source database query statements, achieving automated conversion of database query statements.
[0035] This invention introduces scenario-specific labels to annotate target sample query statements, enabling the model to learn conversion rules under different syntax transformation types, performance optimization requirements, business scenario characteristics, and query complexity during training. This improves the model's adaptability to diverse conversion scenarios. Simultaneously, a vocabulary mapping table is used to supervise the model's output, ensuring that the model learns conversion rules that conform to the syntactic correspondence between the source and target databases. This achieves high-quality automatic conversion of query statements, reducing manual intervention and avoiding omissions, semantic changes, and performance issues caused by manual operations. It also improves the accuracy, consistency, and efficiency of database query statement conversion during database migration.
[0036] In one optional implementation, the method further includes: segmenting the current query statement input by the user to obtain a current segmentation sequence, and inputting the current segmentation sequence into the encoder in the query statement conversion model to generate a current semantic vector; segmenting the current scene text input by the user to obtain a current scene sequence; the current scene text includes at least one of the following: a syntax conversion type, a performance optimization type, a business scenario, and query complexity specified by the user; inputting the current semantic vector and the current scene sequence into the decoder in the query statement conversion model to obtain the model output result, and generating a query statement conversion result based on the vocabulary mapping table between the source database and the target database and the model output result.
[0037] When a user inputs the current query, the input query is segmented into words to obtain a current word sequence. This current word sequence is then input into the encoder of the pre-trained query conversion model. The encoder extracts semantic features to generate a current semantic vector. The current scenario text input by the user is also segmented to obtain a current scenario sequence. This current scenario text includes at least one of the following user-specified conversion types: syntax conversion type, performance optimization type, business scenario, and query complexity. These factors guide the model to generate appropriate conversion results for specific application scenarios. For example, syntax conversion types include syntax compatibility conversion, function mapping conversion, data type conversion, and pagination statement conversion, instructing the model to adopt corresponding conversion strategies. Performance optimization types include index optimization and pagination rewriting, guiding the model to generate target statements with better performance. Business scenarios include transaction queries, data statistics, batch accounting, and report generation, enabling the model to generate query statements that conform to specific business scenarios. Query complexity includes single-table queries, nested queries, multi-table joins, and stored procedures, allowing the model to adopt different generation strategies for different levels of complexity. The current semantic vector and the current scene sequence are input into the decoder in the query statement conversion model to obtain the model output. Based on the pre-built vocabulary mapping table between the source database and the target database and the model output, the final query statement conversion result is generated.
[0038] By introducing the current scene text input by the user as the input of the decoder, the model can combine information such as specific syntax conversion type, performance optimization requirements, business scenario characteristics and query complexity during the conversion process to generate conversion results that are more in line with the actual application scenario. This improves the targeting and flexibility of query statement conversion and avoids the adaptation problems that may occur in different scenarios with a single conversion strategy.
[0039] Optionally, the current semantic vector and the current scene sequence are input into the decoder in the query statement conversion model to obtain the model output. Based on the vocabulary mapping table between the source and target databases and the model output, a query statement conversion result is generated. This includes: inputting the current semantic vector and the current scene sequence into the decoder in the query statement conversion model; the decoder calculates the initial probability distribution of the next word based on the current semantic vector, the current scene sequence, and the generated word sequence; performing grammatical element recognition based on the initial probability distribution of the next word to obtain the next grammatical element category; extracting target database-specific grammatical rule constraints that match the next grammatical element category from the vocabulary mapping table between the source and target databases; correcting the initial probability distribution based on the grammatical rule constraints to obtain a predicted probability distribution; and generating the next word based on the predicted probability distribution.
[0040] The decoder receives the current semantic vector output by the encoder as the global context, and takes the generated word sequence as input. The current scene sequence is the word sequence obtained after segmenting the user-input current scene text. The decoder uses multiple Transformer decoding layers to calculate and output the initial probability distribution of the next word based on the source sentence semantic information provided by the current semantic vector, the scene feature information provided by the current scene sequence, and the generated word sequence. For example, the current scene sequence is used as the prefix input to the decoder, participating in the decoder's self-attention calculation together with the generated word sequence; simultaneously, the current semantic vector is used as the context input to the decoder's cross-attention mechanism, enabling the decoder to simultaneously perceive the source sentence semantic information and the user-specified scene features when generating each word.
[0041] Syntactic element identification is performed based on the initial probability distribution of the next word to determine the syntactic element category to which the next word belongs. The syntactic element category includes at least one of the following: keyword, function name, data type, and operator.
[0042] Based on the determined grammatical element category, the pre-built lexical mapping table between the source and target databases is queried to extract the target database-specific grammatical rule constraints that match that grammatical element category. The lexical mapping table stores the correspondence between the source and target databases for various grammatical elements, such as keyword mapping, function mapping, and data type mapping.
[0043] For example, if the next grammatical element category is a keyword, the target database keyword set corresponding to the source database keyword is extracted from the vocabulary mapping table, such as ROWNUM in the source database corresponding to LIMIT or OFFSET in the target database; if it is a function name, the target database function set corresponding to the source database function is extracted, such as NVL in the source database corresponding to COALESCE in the target database.
[0044] Based on the extracted grammatical rules, a lexical mapping table constraint mask is constructed to correct the initial probability distribution of the next lexical unit. Specifically, the decoder output layer maintains a candidate lexical unit set, denoted by size V. The lexical mapping table constraint mask is a weight vector whose dimension matches the size V of the candidate lexical unit set, where each element corresponds to a candidate lexical unit, indicating the allowed generation weight of that candidate lexical unit in the current generation step. The correction strategy is as follows: For lexical elements of the target database that explicitly correspond to those in the lexical mapping table, their weight in the probability distribution is increased, making them more likely to be selected. For lexical elements that do not belong to the target database grammatical elements in the lexical mapping table and have no actual grammatical meaning, or lexical elements that are exclusive to the source database but have no corresponding mapping, their probability weight is reduced or their probability is set to zero to suppress their generation. For general lexical elements that are not explicitly covered in the lexical mapping table but conform to the grammatical specifications of the target database, their original probabilities are kept unchanged. Through the above correction process, the corrected prediction probability distribution is obtained.
[0045] Based on the corrected predicted probability distribution, the term with the highest probability is selected as the next term to be generated and added to the already generated sequence. This process of generating the next term is repeated until a sentence end marker is generated, resulting in the complete query statement transformation.
[0046] By incorporating the current scenario sequence into the word-by-word meta-generation process of the decoder, the model can generate conversion results that better match actual application scenarios based on user-specified grammar conversion types, performance optimization types, business scenarios, and query complexity, thus improving the targeting and flexibility of query statement conversion. Simultaneously, combined with the hard constraint mechanism of the vocabulary mapping table, the model is forced to prioritize matching the target database's grammar elements in the vocabulary mapping table at each generation step, suppressing the generation of meta-elements that do not conform to the target database's grammar rules. This ensures that the generated conversion results strictly conform to the target database's grammar rules. This effectively avoids the model generating source database-specific grammar elements without corresponding mappings, solving the grammar incompatibility problem at its source, improving the accuracy and reliability of query statement conversion, and reducing the workload of subsequent manual correction.
[0047] Figure 2 This is a flowchart of a query statement transformation model processing method provided by an embodiment of the present invention. This embodiment is an optimization and improvement based on the above embodiment. Figure 2 As shown, the method includes: S210. The original sample query statement in the query statement sample pair is segmented into words to obtain the original segmented word sequence, and the original segmented word sequence is input into the encoder in the initial sequence model to generate the source semantic vector.
[0048] S220. Target segmentation sequence is obtained by segmenting the target sample query statement containing scene-specific tags in the query statement sample pair.
[0049] Scenario-specific tags include at least one of the following: syntax transformation type tags for sample pairs, performance optimization type tags, business scenario tags, and query complexity tags.
[0050] S230. Input the source semantic vector and the target word segmentation sequence into the decoder in the initial sequence model, obtain the model output, and correct the model output based on the vocabulary mapping table between the source database and the target database to generate a predicted query statement.
[0051] Optionally, the source semantic vector and the target word segmentation sequence are input into the decoder in the initial sequence model to obtain the model output. The model output is then corrected based on the vocabulary mapping table between the source database and the target database to generate a predicted query statement. This includes: using the source semantic vector as the global context and inputting the target word segmentation sequence into the decoder in the initial sequence model; the decoder outputs the initial probability distribution of the next word based on the source semantic vector, the target word segmentation sequence, and the generated word sequence; performing grammatical element identification based on the initial probability distribution of the next word to obtain the next grammatical element category; extracting target database-specific grammatical rule constraints that match the next grammatical element category from the vocabulary mapping table between the source database and the target database; correcting the initial probability distribution based on the grammatical rule constraints to obtain a predicted probability distribution; and generating the next word based on the predicted probability distribution.
[0052] The source semantic vector output by the encoder is used as the global context, while the target word segmentation sequence is used as the input to the decoder. The target word segmentation sequence includes the word sequence obtained after segmenting the target sample query statement. The decoder, through multiple Transformer decoding layers, calculates and outputs the initial probability distribution of the next word based on the semantic information of the source statement provided by the source semantic vector, the structural information of the target statement provided by the target word segmentation sequence, and the currently generated word sequence. The initial probability distribution reflects the probability of each candidate word being selected for generation at the current generation progress.
[0053] After obtaining the initial probability distribution of the next word, the decoder performs grammatical element recognition based on this initial probability distribution to determine the grammatical element category to which the next word belongs. The grammatical element category includes, but is not limited to, keywords, function names, data types, and operators, and is used to guide subsequent mapping constraint operations.
[0054] The decoder, based on the identified next grammatical element category, queries a pre-built lexical mapping table between the source and target databases, and extracts the target database-specific grammatical rule constraints that match that grammatical element category from the lexical mapping table. The lexical mapping table pre-stores the correspondence between the source and target databases for various grammatical elements, such as keyword mappings, function mappings, and data type mappings.
[0055] For example, if the next grammatical element category is a keyword, the target database keyword set corresponding to the source database keyword is extracted from the vocabulary mapping table, such as ROWNUM in the source database corresponding to LIMIT or OFFSET in the target database; if it is a function name, the target database function set corresponding to the source database function is extracted, such as NVL in the source database corresponding to COALESCE in the target database.
[0056] Based on the extracted grammatical rules, the decoder modifies the initial probability distribution of the next lexical unit. Specifically, the decoder output layer maintains a candidate lexical unit set, denoted by size V. A lexical mapping table constraint mask is constructed, which is a weight vector whose dimension matches the size V of the candidate lexical unit set. Each element corresponds to a candidate lexical unit, indicating the allowed generation weight of that candidate lexical unit in the current generation step.
[0057] Based on the extracted grammatical rule constraints, a lexical mapping table constraint mask is constructed, and the initial probability distribution is modified as follows: For grammatical elements from the target database that explicitly correspond to those in the lexical mapping table, their probability weights are increased to make them more likely to be selected; for grammatical elements that are specific to the source database but have no corresponding mapping in the lexical mapping table, or for grammatical elements that do not conform to the grammatical specifications of the target database, their probability weights are reduced or their probabilities are set to zero to suppress their generation; for grammatical elements that are not explicitly covered in the lexical mapping table but conform to the general grammatical specifications of the target database, their original probabilities are kept unchanged. Through the above modifications, the modified prediction probability distribution is obtained.
[0058] The decoder selects the word with the highest probability as the next word to be generated based on the corrected prediction probability distribution, and adds it to the sequence of generated words. This process of generating the next word is repeated, generating subsequent words in sequence, until the sentence end marker is generated, resulting in a complete predicted query statement.
[0059] By introducing a vocabulary mapping table to correct the decoder's output during training, the model can learn the conversion rules that conform to the grammatical correspondence between the source and target databases when generating target sentences. This strengthens the model's ability to fit the mapping relationships in the vocabulary mapping table, thereby improving the conversion accuracy and grammatical regularity of the trained query sentence conversion model.
[0060] S240. Based on the vocabulary mapping table, calculate the model loss according to the predicted query statement and the target sample query statement, and use the model loss to train the initial sequence model to obtain the query statement transformation model.
[0061] Optionally, based on a vocabulary mapping table, the model loss is calculated according to the predicted query statement and the target sample query statement, and the model loss is used to train the initial sequence model to obtain a query statement transformation model. This includes: calculating a first loss term based on the predicted query statement and the target sample query statement; calculating a second loss term based on the vocabulary mapping table and the predicted query statement; calculating a total loss based on the first and second loss terms, and using the total loss to train the initial sequence model to obtain a query statement transformation model.
[0062] Step 1: Calculate the first loss term based on the predicted query and the target sample query. Specifically, calculate the cross-entropy loss between the predicted query and the target sample query. The cross-entropy loss measures how well the model-generated predicted query matches the actual target sample query at the lexical level, ensuring the overall correctness of the generated sequence in terms of syntactic structure and semantic logic.
[0063] Step Two: Based on the vocabulary mapping table, calculate the second loss term according to the predicted query statement. Specifically, iterate through all the tokens generated by the predicted query statement and check whether each token exists in the set of legal grammatical elements specified by the target database side of the vocabulary mapping table. If the generated token does not conform to the mapping requirements in the vocabulary mapping table, for example, generating the source database-specific function NVL instead of the target database's corresponding COALESCE, then the corresponding penalty loss is increased. The second loss term serves as an auxiliary loss to force the model to strictly adhere to the grammatical element equivalence mapping rules between the source and target databases during the generation process, thereby reducing the syntax error rate.
[0064] Step 3: Calculate the total loss based on the first and second loss items. Specifically, the formula for calculating the total loss is shown in Formula (1) below: Total loss = First loss term + λ × Second loss term (1); Wherein, λ is the balancing coefficient, which is used to adjust the weight of the second loss term in the total loss, so that the model can strengthen its adherence to the word mapping rules while ensuring the overall generation quality.
[0065] An optimizer (such as AdamW) is used to backpropagate and update the encoder, decoder, and word embedding layer parameters of the initial sequence model based on the total loss. The model parameters are continuously adjusted through the gradient descent algorithm, so that the total loss is gradually reduced.
[0066] Repeat steps one through three above, iteratively performing multiple rounds of training until the total loss on the validation set converges, meaning the model performance reaches a stable state, thus completing the training of the query statement transformation model.
[0067] By constructing a dual-objective loss function, both syntax generation loss and vocabulary matching loss are optimized simultaneously during model training. The first loss term ensures the correctness of the generated statements in terms of overall syntactic structure and semantic logic; the second loss term acts as an auxiliary constraint, forcing the model to learn and adhere to the syntactic element mapping rules between the source and target databases, avoiding the generation of syntactic elements that do not conform to the target database's specifications. The synergistic effect of these two factors enables the trained query statement transformation model to maintain overall statement correctness while possessing accurate syntactic mapping capabilities, thus improving the accuracy and reliability of database query statement transformation.
[0068] This invention encodes the original sample query statement to generate a source semantic vector, and segments the target sample query statement containing scenario-specific tags to obtain a target segmented word sequence. This allows the model to learn conversion rules under diverse scenarios, such as syntax transformation type, performance optimization type, business scenario, and query complexity, during training. By inputting the source semantic vector and target segmented word sequence into the decoder, and combining the vocabulary mapping table between the source and target databases to correct the model's output, the generated predicted query statement is ensured to conform to the grammatical specifications of the target database. Furthermore, a bi-objective loss function is constructed based on the vocabulary mapping table to train the model, ensuring the overall grammatical structure and semantic logic correctness while strictly adhering to the cross-database grammatical element equivalence mapping rules. This achieves automated conversion of database query statements, significantly reducing manual intervention and avoiding omissions, semantic changes, and performance issues caused by manual operations, effectively improving the accuracy, consistency, and efficiency of SQL conversion during database migration.
[0069] Figure 3 This is a schematic diagram of the structure of a processing device for a query statement conversion model provided in an embodiment of the present invention. Figure 3 As shown, the device includes: The source statement encoding module 310 is used to segment the original sample query statement in the query statement sample pair to obtain the original segmented word sequence, and input the original segmented word sequence into the encoder in the initial sequence model to generate the source semantic vector. The target statement preprocessing module 320 is used to segment the target sample query statements containing scenario-specific tags in the query statement sample pairs to obtain a target segmentation sequence; the scenario-specific tags include at least one of the following: syntax conversion type tags, performance optimization type tags, business scenario tags, and query complexity tags of the sample pairs; The decoding training module 330 is used to input the source semantic vector and the target word segmentation sequence into the decoder in the initial sequence model, obtain the model output result, and train the initial sequence model according to the vocabulary mapping table between the source database and the target database, the model output result, and the target sample query statement to obtain the query statement conversion model.
[0070] The query statement conversion model processing device provided in the embodiments of the present invention can execute the query statement conversion model processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0071] Optional, the decoding training module includes: The constraint decoding generation unit is used to input the source semantic vector and the target word segmentation sequence into the decoder in the initial sequence model, obtain the model output result, and correct the model output result according to the vocabulary mapping table between the source database and the target database to generate a predicted query statement. The dual-objective optimization training unit is used to calculate the model loss based on the vocabulary mapping table, the predicted query statement, and the target sample query statement, and to train the initial sequence model using the model loss to obtain the query statement transformation model.
[0072] Optionally, the constraint decoding generation unit is specifically used to take the source semantic vector as the global context and input the target word segmentation sequence into the decoder in the initial sequence model. The decoder outputs the initial probability distribution of the next word based on the source semantic vector, the target word segmentation sequence, and the generated word sequence. Based on the initial probability distribution of the next word, the unit performs grammatical element identification to obtain the category of the next grammatical element. It extracts the target database-specific grammatical rule constraints that match the category of the next grammatical element from the lexical mapping table between the source database and the target database. Based on the grammatical rule constraints, the unit corrects the initial probability distribution to obtain a predicted probability distribution and generates the next word based on the predicted probability distribution.
[0073] Optionally, the dual-objective optimization training unit is specifically used to calculate a first loss term based on the predicted query statement and the target sample query statement; calculate a second loss term based on the vocabulary mapping table and the predicted query statement; calculate the total loss based on the first loss term and the second loss term, and use the total loss to train the initial sequence model to obtain the query statement transformation model.
[0074] Optionally, the source statement encoding module includes a source statement preprocessing unit. The source statement preprocessing unit is used to split the original sample query statement based on the list of syntax elements in the source database to obtain initial syntax units. If the length of any initial syntax unit is greater than a preset threshold, the initial syntax unit is split based on the syntax boundary identifier predefined for the source database to obtain the original word segmentation sequence. The syntax boundary includes at least one of clause boundary, subquery boundary, function boundary, logical operation boundary, or statement termination boundary.
[0075] Optionally, the device also includes: The current statement encoding module is used to segment the current query statement input by the user to obtain the current segmented word sequence, and input the current segmented word sequence into the encoder in the query statement conversion model to generate the current semantic vector; The scene information processing module is used to segment the current scene text input by the user to obtain the current scene sequence; the current scene text includes at least one of the following: user-specified syntax conversion type, performance optimization type, business scenario, and query complexity. The scene-aware decoding and generation module is used to input the current semantic vector and the current scene sequence into the decoder in the query statement conversion model, obtain the model output result, and generate the query statement conversion result based on the vocabulary mapping table between the source database and the target database and the model output result.
[0076] Optionally, the scene-aware decoding and generation module is specifically used to input the current semantic vector and the current scene sequence into the decoder in the query statement conversion model. The decoder calculates the initial probability distribution of the next word based on the current semantic vector, the current scene sequence, and the generated word sequence; performs grammatical element recognition based on the initial probability distribution of the next word to obtain the next grammatical element category; extracts the target database-specific grammatical rule constraints that match the next grammatical element category from the lexical mapping table between the source database and the target database; corrects the initial probability distribution based on the grammatical rule constraints to obtain the predicted probability distribution, and generates the next word based on the predicted probability distribution.
[0077] The query statement conversion model processing apparatus described in further detail can also execute the query statement conversion model processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0078] According to embodiments of the present invention, the present invention also provides an electronic device, a readable storage medium, and a computer program product.
[0079] Figure 4 A schematic diagram of an electronic device 40 that can be used to implement embodiments of the present invention 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 processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0080] like Figure 4As shown, the electronic device 40 includes at least one processor 41 and a memory, such as a read-only memory 42 or a random access memory 43, communicatively connected to the at least one processor 41. The memory stores computer programs executable by the at least one processor. The processor 41 can perform various appropriate actions and processes based on the computer program stored in the read-only memory 42 or loaded from storage unit 48 into the random access memory 43. The random access memory 43 may also store various programs and data required for the operation of the electronic device 40. The processor 41, read-only memory 42, and random access memory 43 are interconnected via a bus 44. An input / output interface 45 is also connected to the bus 44.
[0081] Multiple components in electronic device 40 are connected to input / output interface 45, including: input unit 46, such as keyboard, mouse, etc.; output unit 47, such as various types of monitors, speakers, etc.; storage unit 48, such as disk, optical disk, etc.; and communication unit 49, such as network card, modem, wireless transceiver, etc. Communication unit 49 allows electronic device 40 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0082] Processor 41 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 41 include, but are not limited to, central processing units, graphics processing units, various special-purpose artificial intelligence computing chips, various processors running machine learning model algorithms, digital signal processors, and any suitable processor, controller, microcontroller, etc. Processor 41 performs the various methods and processes described above, such as the query statement transformation model processing method.
[0083] In some embodiments, the query statement transformation model processing method can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 48. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 40 via read-only memory 42 and / or communication unit 49. When the computer program is loaded into random access memory 43 and executed by processor 41, one or more steps of the query statement transformation model processing method described above can be performed. Alternatively, in other embodiments, processor 41 can be configured to perform the query statement transformation model processing method by any other suitable means (e.g., by means of firmware).
[0084] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays, application-specific integrated circuits (ASICs), application-specific standard products (ASICs), systems-on-a-chip (SoCs), payload programmable logic devices, computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0085] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0086] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory, read-only memory, erasable programmable read-only memory, optical fibers, portable compact disk read-only memory, optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0087] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a cathode ray tube, liquid crystal display, or monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, 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 sound input, voice input, or tactile input).
[0088] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0089] A computing system can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product within the cloud computing service system to address the shortcomings of traditional physical hosts and virtual private servers, such as high management difficulty and weak business scalability.
[0090] 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 invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0091] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for processing query statement transformation models, characterized in that, include: The original sample query statement in the query statement sample pair is segmented into words to obtain the original segmented word sequence, and the original segmented word sequence is input into the encoder in the initial sequence model to generate the source semantic vector; The target sample query statements containing scenario-specific tags in the query statement sample pairs are segmented to obtain the target segmentation sequence; the scenario-specific tags include at least one of the following: syntax transformation type tags, performance optimization type tags, business scenario tags, and query complexity tags of the sample pairs; The source semantic vector and the target word segmentation sequence are input into the decoder of the initial sequence model to obtain the model output. The initial sequence model is then trained based on the vocabulary mapping table between the source database and the target database, the model output, and the target sample query statement to obtain the query statement conversion model.
2. The method according to claim 1, characterized in that, The source semantic vector and the target word segmentation sequence are input into the decoder of the initial sequence model to obtain the model output. The initial sequence model is then trained based on the vocabulary mapping table between the source and target databases, the model output, and the target sample query statement to obtain a query statement conversion model, including: The source semantic vector and the target word segmentation sequence are input into the decoder in the initial sequence model to obtain the model output result. The model output result is then corrected according to the vocabulary mapping table between the source database and the target database to generate a predicted query statement. Based on the vocabulary mapping table, the model loss is calculated according to the predicted query statement and the target sample query statement, and the model loss is used to train the initial sequence model to obtain the query statement transformation model.
3. The method according to claim 2, characterized in that, The source semantic vector and the target word segmentation sequence are input into the decoder of the initial sequence model to obtain the model output. The model output is then corrected based on the vocabulary mapping table between the source database and the target database to generate a predicted query statement, including: The source semantic vector is used as the global context, and the target word segmentation sequence is input into the decoder in the initial sequence model. The decoder outputs the initial probability distribution of the next word based on the source semantic vector, the target word segmentation sequence, and the generated word sequence. Based on the initial probability distribution of the next word, the grammatical element is identified to obtain the category of the next grammatical element; Extract the target database-specific grammatical rule constraints that match the next grammatical element category from the lexical mapping table between the source database and the target database; The initial probability distribution is modified according to the grammatical rules to obtain the predicted probability distribution, and the next word is generated based on the predicted probability distribution.
4. The method according to claim 2, characterized in that, The step of calculating the model loss based on the vocabulary mapping table, the predicted query statement, and the target sample query statement, and then using the model loss to train the initial sequence model to obtain the query statement transformation model, includes: Calculate the first loss term based on the predicted query statement and the target sample query statement; Based on the vocabulary mapping table, a second loss term is calculated according to the predicted query statement; The total loss is calculated based on the first loss term and the second loss term, and the total loss is used to train the initial sequence model to obtain the query statement transformation model.
5. The method according to claim 1, characterized in that, The original sample query statement is segmented to obtain the original segmented word sequence, including: Based on the list of syntax elements in the source database, the original sample query statement is split to obtain initial syntax units; If the length of any initial grammatical unit is greater than a preset threshold, the initial grammatical unit is split based on the grammatical boundary identifiers predefined for the source database to obtain the original word segmentation sequence; the grammatical boundary includes at least one of clause boundary, subquery boundary, function boundary, logical operation boundary or statement termination boundary.
6. The method according to any one of claims 1-5, characterized in that, The method further includes: The current query input by the user is segmented into words to obtain the current word segmentation sequence, and the current word segmentation sequence is input into the encoder in the query transformation model to generate the current semantic vector; The current scene text input by the user is segmented into words to obtain the current scene sequence; the current scene text includes at least one of the following: user-specified syntax conversion type, performance optimization type, business scenario, and query complexity. The current semantic vector and the current scene sequence are input into the decoder in the query statement conversion model to obtain the model output result. Based on the vocabulary mapping table between the source database and the target database and the model output result, the query statement conversion result is generated.
7. The method according to claim 6, characterized in that, The process of inputting the current semantic vector and the current scene sequence into the decoder of the query statement conversion model, obtaining the model output, and generating the query statement conversion result based on the vocabulary mapping table between the source database and the target database and the model output result includes: The current semantic vector and the current scene sequence are input into the decoder in the query statement conversion model. The decoder calculates the initial probability distribution of the next word based on the current semantic vector, the current scene sequence, and the generated word sequence. Based on the initial probability distribution of the next word, the grammatical element is identified to obtain the category of the next grammatical element; Extract the target database-specific grammatical rule constraints that match the next grammatical element category from the lexical mapping table between the source database and the target database; The initial probability distribution is modified according to the grammatical rules to obtain the predicted probability distribution, and the next word is generated based on the predicted probability distribution.
8. A processing apparatus for a query statement conversion model, characterized in that, The device includes: The source statement encoding module is used to segment the original sample query statement in the query statement sample pair to obtain the original segmented word sequence, and input the original segmented word sequence into the encoder in the initial sequence model to generate the source semantic vector; The target statement preprocessing module is used to segment the target sample query statements containing scenario-specific tags in the query statement sample pairs to obtain the target segmented word sequence; the scenario-specific tags include at least one of the following: syntax transformation type tags, performance optimization type tags, business scenario tags, and query complexity tags of the sample pairs; The decoding training module is used to input the source semantic vector and the target word segmentation sequence into the decoder of the initial sequence model, obtain the model output result, and train the initial sequence model according to the vocabulary mapping table between the source database and the target database, the model output result, and the target sample query statement to obtain the query statement conversion model.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and a memory communicatively connected to the at least one processor; The memory stores a computer program that can be executed by the at least one processor, which is then executed by the at least one processor to enable the at least one processor to perform the query statement transformation model processing method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute the processing method of the query statement transformation model according to any one of claims 1-7.