Data governance method, device and electronic equipment based on pre-training model

CN122963920APending Publication Date: 2026-10-23BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611132671.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-28
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0003]相关技术中,基于LLM(Large Language Model,大语言模型)的智能代码检测方式,通过计算SQL代码与规则库中风险规则之间的文本相似度进行风险识别,但是语义相似不等于风险一致,导致识别准确度不高,另外SQL代码需与大量风险规则逐一比对,导致模型推理效率低

Benefits of technology

[0008]通过上述方法,首先获取结构化查询语言代码,通过第一机器学习模型解析结构化查询语言代码获得第一特征,并基于第一特征在规则库中进行规则召回获得第一风险规则,进而通过第二机器学习模型基于结构化查询语言代码和第一风险规则进行风险识别,获得用于表征结构化查询语言代码是否存在第一风险规则的代码风险的识别结果。采用该方法,将代码检测过程解耦为规则召回与风险识别两个环节。在规则召回阶段,采用第一机器学习模型提取多维特征并进行规则召回,以提升召回精度,降低误召及漏召概率;在风险识别阶段,基于召回结果,采用第二机器学习模型对结构化查询语言代码进行风险识别,由于召回阶段已实现风险规则的过滤与缩减,第二机器学习模型所需处理的数据规模显著减小,从而在保证识别准确度的同时,有效提升了模型推理效率。另外,第二机器学习模型专注于特定风险类型下的代码风险识别,进一步增强了识别结果的准确性和可靠性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122963920A_ABST
    Figure CN122963920A_ABST
Patent Text Reader

Abstract

A data governance method, device and electronic equipment based on a pre-trained model, relating to the technical field of computers. The method comprises: obtaining a structured query language code; parsing the structured query language code by a first machine learning model to obtain first features, and performing rule recall in a rule library based on the first features to obtain first risk rules, wherein the first features include at least one of syntax features, context features and business semantic features in the structured query language code; performing risk identification based on the structured query language code and the first risk rules by a second machine learning model to obtain a first identification result, the first identification result being used to represent whether the structured query language code has a code risk of the first risk rules, the first risk rules belonging to a first risk type, and the second machine learning model being used to detect code risks in the first risk type. Thus, the rule recall accuracy and risk identification accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This article relates to the field of computer technology, and more specifically, to a data governance method, apparatus, and electronic device based on a pre-trained model. Background Technology

[0002] In the fields of data warehousing, data analysis, and the development of various data-intensive applications, SQL (Structured Query Language) code is the core carrier of data processing and logical implementation. The quality of the code directly determines the accuracy, stability, and business impact of the data output.

[0003] Among related technologies, intelligent code detection methods based on LLM (Large Language Model) identify risks by calculating the text similarity between SQL code and risk rules in the rule base. However, semantic similarity does not equal risk consistency, resulting in low recognition accuracy. In addition, SQL code needs to be compared with a large number of risk rules one by one, resulting in low model inference efficiency. Summary of the Invention

[0004] This content section is provided to briefly introduce the ideas, which will be described in detail in the examples section later. This content section is not intended to identify key or essential features of the claimed content, nor is it intended to limit the scope of the claimed content.

[0005] Firstly, a data governance method based on pre-trained models is provided, including: Obtain the Structured Query Language code; The structured query language code is parsed by a first machine learning model to obtain a first feature, and a rule is retrieved in the rule base based on the first feature to obtain a first risk rule. The first feature includes at least one of the syntactic features, context features, and business semantic features in the structured query language code. The second machine learning model performs risk identification based on the structured query language code and the first risk rule to obtain a first identification result. The first identification result is used to characterize whether the structured query language code has a code risk according to the first risk rule. The first risk rule belongs to a first risk type. The second machine learning model is used to detect code risks under the first risk type.

[0006] Secondly, a data governance device based on a pre-trained model is provided, comprising: The retrieval module is used to retrieve Structured Query Language (SCL) code; The recall module is used to parse the structured query language code through a first machine learning model to obtain a first feature, and to perform rule recall in the rule base based on the first feature to obtain a first risk rule, wherein the first feature includes at least one of the syntactic features, context features and business semantic features in the structured query language code. The identification module is used to identify risks based on the structured query language code and the first risk rule using a second machine learning model, and obtain a first identification result. The first identification result is used to characterize whether the structured query language code has a code risk according to the first risk rule. The first risk rule belongs to a first risk type. The second machine learning model is used to detect code risks under the first risk type.

[0007] Thirdly, this disclosure provides an electronic device, including: A storage device on which computer programs are stored; A processing device for executing the computer program in the storage device to implement the steps of the method described in the first aspect.

[0008] The above method first obtains the structured query language code, then uses a first machine learning model to parse the code and obtain the first feature. Based on this first feature, rule recall is performed in the rule base to obtain the first risk rule. Finally, a second machine learning model performs risk identification based on the structured query language code and the first risk rule, obtaining an identification result that characterizes whether the structured query language code has the code risk specified by the first risk rule. This method decouples the code detection process into two stages: rule recall and risk identification. In the rule recall stage, the first machine learning model extracts multi-dimensional features and performs rule recall to improve recall accuracy and reduce false positives and false negatives. In the risk identification stage, based on the recall result, the second machine learning model identifies risks in the structured query language code. Since the risk rule has already been filtered and reduced in the recall stage, the data scale required for the second machine learning model is significantly reduced, thus effectively improving the model's inference efficiency while maintaining identification accuracy. Furthermore, the second machine learning model focuses on code risk identification under specific risk types, further enhancing the accuracy and reliability of the identification results.

[0009] Other features and advantages will be described in detail in the following examples section. Attached Figure Description

[0010] The above and other features, advantages, and aspects of this document will become more apparent when viewed in conjunction with the accompanying drawings and the following examples. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale. In the drawings: Figure 1 This is a schematic diagram illustrating an implementation environment according to an example.

[0011] Figure 2 This is a flowchart illustrating a data governance method based on a pre-trained model, as shown in an example.

[0012] Figure 3 This is a flowchart illustrating an example of SQL code risk identification.

[0013] Figure 4 This is a flowchart illustrating a rule-based recall method, as shown in an example.

[0014] Figure 5 This is a schematic diagram of the structure of a data governance device based on a pre-trained model, as illustrated by an example.

[0015] Figure 6 This is a schematic diagram of the structure of an electronic device according to an example. Detailed Implementation

[0016] The following description will be given in more detail with reference to the accompanying drawings. While certain scenarios are shown in the drawings, it should be understood that this document can be implemented in various forms and should not be construed as limited to the scenarios described herein. Rather, these scenarios are provided to provide a more thorough and complete understanding of this document. It should be understood that the accompanying drawings and the scenarios depicted are for illustrative purposes only and are not intended to limit the scope of this document.

[0017] It should be understood that the steps described in the method may be performed in different orders and / or in parallel. Furthermore, the method may include additional steps and / or omit the steps shown. The scope of this document is not limited in this respect.

[0018] The term "comprising" and its variations can be open-ended, meaning "including but not limited to". The term "based on" can mean "at least partially based on". The term "one case" means "at least one case"; the term "another case" means "at least one additional case"; the term "some cases" means "at least some cases". Definitions of other terms will be given in the following description.

[0019] It should be noted that the concepts of "first" and "second" are only used to distinguish different devices, modules or units, and are not used to limit the order of the functions performed by these devices, modules or units or their interdependencies.

[0020] It should be noted that the modifiers “one” and “multiple” can be illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as “one or more”.

[0021] The names of messages or information exchanged between multiple devices are for illustrative purposes only and are not intended to limit the scope of these messages or information.

[0022] It is understandable that the data involved in the technical solution (including but not limited to the data itself, the acquisition or use of the data) should comply with the requirements of relevant regulations.

[0023] In related technologies, LLM-based intelligent code detection methods input the SQL code to be detected into a large language model. The large language model uses RAG (Retrieval-Augmented Generation) technology to compare the SQL code with each risk rule in the rule base one by one, finding relevant risk rules based on text similarity, thereby achieving risk identification. However, "text similarity" does not equal "logical relevance." It is difficult to accurately understand the structured syntax and business semantics of SQL code. Its ability to identify synonymous heterogeneous (different spellings but the same logic) or heterogeneous (similar spellings but different logics) code fragments is limited, resulting in low recall accuracy and serious false positives and false negatives. In addition, large language models perform inference based on a large number of rules, and the input tokens are huge, resulting in low inference efficiency and excessive time consumption. At the same time, it can also distract the model's attention, thereby reducing the recognition accuracy.

[0024] In view of this, this content provides a data governance method, apparatus, and electronic device based on a pre-trained model to solve the above-mentioned technical problems.

[0025] The data governance method based on pre-trained models provided in this content can be executed by electronic devices, which can be provided as at least one of terminals and servers. Figure 1 This is an exemplary schematic diagram illustrating an implementation environment; see [link / reference]. Figure 1 The implementation environment includes: terminal 101 and server 102.

[0026] For example, a code development application can be installed on terminal 101. The application's development interface receives SQL code input from the user. In response to a user-triggered SQL code detection operation, the application sends the SQL code to server 102 and receives the identification result returned by server 102. Server 102 provides background services for the code development application, such as performing risk detection on the SQL code.

[0027] In one scenario, server 102 can obtain the SQL code sent by terminal 101, parse the SQL code using a first machine learning model to obtain code features, and perform rule recall in the rule base based on the code features. Then, a second machine learning model can perform risk identification based on the structured query language code and the recalled risk rules to obtain identification results, and return the identification results to terminal 101 so that the user can optimize the SQL code based on the identification results.

[0028] In another scenario, terminal 101 can parse the SQL code using a first machine learning model to obtain code features, and then perform rule recall in the rule base based on the code features. The SQL code and the recalled risk rules are then sent to server 102, where server 102 uses a second machine learning model to perform risk identification based on the structured query language code and the recalled risk rules, and returns the identification results to terminal 101.

[0029] In other words, terminal 101 can be responsible for the front-end display, while server 102 can be responsible for the back-end data processing. Alternatively, terminal 101 can be responsible for some of the data processing. The specific configuration can be set according to requirements, and there are no restrictions on this.

[0030] Terminal 101 can be at least one of the following devices: smartphone, smartwatch, desktop computer, laptop, virtual reality terminal, augmented reality terminal, wireless terminal, and laptop computer. Terminal 101 has communication capabilities and can access wired or wireless networks. Terminal 101 can refer to one of multiple terminals, and those skilled in the art will understand that the number of such terminals can be more or less. Server 102 can be a single physical server, a server cluster composed of multiple physical servers, or a distributed file system. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and artificial intelligence platforms.

[0031] For example, server 102 and terminal 101 are connected directly or indirectly via wired or wireless communication, without limitation.

[0032] Optionally, the number of servers 102 can be more or less, and there is no limitation thereto. Of course, servers 102 may also include other functional servers to provide more comprehensive and diversified services. Server 102 undertakes the main computing work, and terminal 101 undertakes the secondary computing work; or, server 102 undertakes the secondary computing work, and terminal 101 undertakes the main computing work; or, server 102 or terminal 101 can each undertake computing work independently, and there is no limitation thereto.

[0033] Figure 2 This is a flowchart illustrating an exemplary data governance method based on a pre-trained model. For example... Figure 2 As shown, the method may include the following steps: S201: Obtain the Structured Query Language code.

[0034] For example, Structured Query Language code (hereinafter referred to as SQL code) may include one or more structured query statements (hereinafter referred to as SQL statements).

[0035] In one scenario, obtaining Structured Query Language (SCL) code includes: obtaining initial code, which comprises multiple structured query statements; splitting the multiple structured query statements to obtain at least one code fragment, and using each code fragment as SCL code; wherein each code fragment comprises one or more structured query statements.

[0036] For example, SQL code containing multiple SQL statements can be split and processed separately, which can effectively improve the accuracy of rule recall and the accuracy and efficiency of risk identification results. A threshold can be set, for example, if the number of rows in multiple SQL statements exceeds a preset value, code splitting will be triggered, and the number of rows in each split SQL code will be less than or equal to the preset value. The specific value can be set according to needs and there is no restriction on it.

[0037] like Figure 3 As shown, SQL code can be preprocessed, such as splitting the above-mentioned fragments, removing comments, removing extra spaces, etc. The specific settings can be configured according to needs, and there are no restrictions on this.

[0038] S202: Parse the structured query language code using the first machine learning model to obtain the first feature, and perform rule recall in the rule base based on the first feature to obtain the first risk rule. The first feature includes at least one of the syntactic features, context features, and business semantic features in the structured query language code.

[0039] Among them, syntactic features represent the syntactic structure attributes in the structured query language code, context features represent the attribute information of the data objects operated by the structured query language code, and business semantic features represent the information required to determine whether the structured query language code conforms to business rules.

[0040] In one scenario, the method further includes: syntactic features including at least one of preset keywords, function parameters, and operators; contextual features including at least one of preset table naming patterns, field naming patterns, metadata attributes, and call information of custom functions; and business semantic features including at least one of preset indicator caliber information, time window information, and filtering condition information.

[0041] For example, syntactic features, contextual features, and business semantic features that the model needs to recognize can be pre-defined, such as keywords like "CASE WHEN," "UNION," and "COUNT," function parameters representing function call patterns like "preset function start position parameter" and "date difference function," and "+," "-," etc. Operators such as " / ", table naming patterns such as "main_name" and "_1d", field naming patterns, metadata attributes such as partition fields and lifecycles, call information of specific UDFs (User-Defined Functions), indicator caliber information required to detect whether the statistical calibers of numerators and denominators are aligned, time window information required to detect whether the time range is consistent with the business caliber, logical deletion flags, invalid state data, and other filtering condition information required to detect the integrity of filtering can be set according to requirements and there are no restrictions on this.

[0042] like Figure 3 As shown, the first machine learning model extracts features from the SQL code and performs pattern-by-pattern precise matching on the SQL code. (Refer to...) Figure 4 It can parse SQL code to obtain multi-dimensional features such as syntax features, context features, and business semantic features, and then traverse the rule base to recall rules, so as to achieve accurate triggering and recall of risk rules, thereby improving the efficiency and accuracy of risk identification.

[0043] For features that can be directly extracted from SQL code, the SQL code can be parsed to obtain the corresponding features, such as syntax features, table naming patterns, field naming patterns, user-defined function call information, explicit filter conditions in the SQL code, indicator fields, and time ranges. Furthermore, after parsing the SQL code, other features can be further obtained based on the parsed information. For example, based on table names and field names in the SQL code, corresponding metadata attributes can be obtained. Based on field names in the SQL code, business indicator information and time field definition information corresponding to the field names can be obtained. This can be queried from database definitions, indicator dictionaries, or data dictionaries without restriction.

[0044] S203: Risk identification is performed based on the structured query language code and the first risk rule using the second machine learning model to obtain the first identification result. The first identification result is used to characterize whether the structured query language code has the code risk of the first risk rule. The first risk rule belongs to the first risk type. The second machine learning model is used to detect the code risk under the first risk type.

[0045] For example, if the SQL code is split into multiple code fragments, the first identification result can be determined based on the identification results corresponding to the multiple code fragments. That is, the first identification result includes the identification results corresponding to the multiple code fragments. The first machine learning model and the second machine learning model can be different large language models. For example, the first machine learning model is a pre-trained large language model used for feature extraction and rule recall, while the second machine learning model is a large language model trained separately for different risk types, capable of risk identification for specific risk types.

[0046] For example, the first machine learning model is trained as follows: a first initial model and a first structured query language sample code labeled with a first label are obtained, where the first label represents the risk rule corresponding to the first structured query language sample code; the first initial model is trained based on the first structured query language sample code to obtain the trained first machine learning model.

[0047] During training, loss can be calculated based on the risk rules output by the initial model and the labeled risk rules. The model parameters are then adjusted based on the loss calculation results until the preset training completion conditions are met, resulting in the first trained machine learning model. The initial model can be a large language model, and there are no restrictions on this.

[0048] For example, the second machine learning model is trained as follows: a second initial model and second structured query language sample codes labeled with second tags are obtained, where the second tags represent the recognition results corresponding to the second structured query language sample codes; the second initial model is trained based on the second structured query language sample codes to obtain the trained second machine learning model.

[0049] During training, loss can be calculated based on the recognition results output by the second initial model and the labeled recognition results. The model parameters can then be adjusted based on the loss calculation results until the preset training completion conditions are met, resulting in the first machine learning model that has been trained. The first initial model can be a large language model, and there are no restrictions on this.

[0050] Furthermore, different models can be trained separately for different types of code risks, and the trained models are used to specifically identify code risks of the corresponding types.

[0051] The training methods for the first and second machine learning models mentioned above can be determined according to requirements, and there are no restrictions on them.

[0052] In one scenario, the method further includes: responding to a first identification result characterizing a code risk of a first risk rule in a structured query language code, wherein the first identification result includes at least one of a risk level, a risk description, a code location, a result confidence level, contextual information, and third data, wherein the code location indicates the location of the risk code in the structured query language code, the contextual information includes metadata and / or data lineage information associated with the structured query language code, and the third data includes the reasoning logic of a second machine learning model in the risk identification process.

[0053] For example, the first identification result includes at least one of the following: risk level, risk description, code location, result confidence, contextual information, and the reasoning logic of the second machine learning model in the risk identification process. The risk level can be a pre-defined risk level of the first risk rule; the risk description can be a natural language description of the code risk of the first risk rule; the code location can be the specific location of the risk code in the structured query language code, such as line number or code fragment identifier; the result confidence can be the confidence score of the second machine learning model for the output risk identification result; and the reasoning logic can be the specific reasoning process of the second machine learning model in risk identification. These can be set according to requirements and are not limited. This allows for a multi-dimensional description of the code risk of SQL code, improving the readability and understandability of the results.

[0054] It should be understood that the data governance method based on pre-trained models provided in this content can identify and intercept risks before SQL code is deployed to the production environment, fundamentally reducing data pollution, business interruptions, and problem response losses caused by defects entering the production environment. At the same time, code developers can obtain immediate and accurate feedback loops, which helps to standardize coding behavior, improve SQL code quality, and ensure the accuracy of data output and the stability of business system operation from the source.

[0055] The above method decouples the code detection process into two stages: rule recall and risk identification. In the rule recall stage, a first machine learning model extracts multi-dimensional features and performs rule recall to improve recall accuracy and reduce the probability of false positives and false negatives. In the risk identification stage, based on the recall results, a second machine learning model identifies risks in structured query language code. Since risk rules have already been filtered and reduced in the recall stage, the data scale required for the second machine learning model is significantly reduced, thus effectively improving model inference efficiency while maintaining identification accuracy. Furthermore, the second machine learning model focuses on code risk identification under specific risk types, further enhancing the accuracy and reliability of the identification results.

[0056] In one scenario, risk rules in the rule base are obtained as follows: initial risk rules described in natural language are acquired; the initial risk rules are understood by a third machine learning model to obtain structured risk rules. The structured risk rules include a first prompt word and a recall strategy described in natural language. The first prompt word is used for risk inference by the second machine learning model during risk identification. The recall strategy includes at least one of the syntactic features, contextual features, and business semantic features of the initial risk rules.

[0057] For example, the initial risk rules can be historical risk rules or rules written in natural language by domain experts; there are no restrictions. A third machine learning model understands the initial risk rules and processes them into structured risk rules according to a pre-defined rule template. This third machine learning model can be a pre-trained large language model capable of extracting features from SQL code.

[0058] For example, the third machine learning model is trained as follows: a third initial model and sample risk rules described in natural language are obtained, the sample risk rules are labeled with a third label, and the third label represents the structured risk rule corresponding to the sample risk rule; the third initial model is trained based on the sample risk rules to obtain the trained third machine learning model.

[0059] During training, loss can be calculated based on the structured risk rules output by the third initial model and the labeled structured risk rules. The model parameters are then adjusted based on the loss calculation results until the preset training completion conditions are met, resulting in a trained third machine learning model. The third initial model can be a large language model; there are no restrictions on this. Specific training methods can be set according to requirements; there are no restrictions on this as well.

[0060] For example, a structured risk rule may include a rule identifier, rule name, risk type, risk level, explicit recall strategy, and rule inference prompt (first prompt). For example, the risk rule "Rule identifier: 001; Rule name: CASE WHEN condition order error leads to logical error; Risk type: SQL semantic correctness; Risk level: High; Recall strategy: This rule should be triggered when the SQL statement contains multiple CASE WHEN clauses and multiple WHEN condition branches; Rule inference prompt: Avoid multiple WHEN branch conditions being completely identical, and improper ordering of the same field, etc."

[0061] For example, during the risk identification process, if the SQL code contains multiple CASE WHEN clauses and multiple WHEN condition branches, the first machine learning model recalls the aforementioned rules. If the multiple WHEN branch conditions in the SQL code are completely identical or in the wrong order under the same field, then the second machine learning model outputs an identification result indicating that the SQL has a code risk.

[0062] This transforms domain experts' understanding of SQL code risks into a series of recall conditions that can be precisely executed by machines, incorporating syntactic, contextual, and business semantic features. This enables efficient and accurate convergence of relevant risk rules. Specifically, by configuring a structured, explicit recall strategy for each risk rule, including syntactic, contextual, and business semantic features, the input SQL code can be used for precise rule recall.

[0063] It should be understood that by using contextual information such as metadata (e.g., table lifecycle, partition information, and field business classification tags) and data lineage (field-level upstream and downstream dependencies) as structured features of risk rules, it is easier to understand the history and business meaning of data during rule recall and risk identification, thereby improving the ability to identify deep business logic risks.

[0064] It's worth noting that the rule base adopts a structured and decoupled definition approach. When new risk identification capabilities need to be expanded, structured risk rules can be added according to a predefined format, thus adapting to ever-changing business needs.

[0065] In one scenario, rule recall is performed in the rule base based on the first feature to obtain the first risk rule, including: determining the risk rule in the rule base that corresponds to the recall strategy and the first feature as the first risk rule.

[0066] For example, such as Figure 4 As shown, each risk rule in the rule base is traversed, meaning the features extracted from the SQL code are matched one by one with the recall strategy of each risk rule. If a match is successful, the rule is added to the candidate rule set; otherwise, it is skipped. This process continues until all risk rules have been traversed, and the candidate rule set (i.e., the first risk rule) is output. The recall strategy can include at least one of the following: matching conditions based on syntax features, matching conditions based on context features, and matching conditions based on business features. If the features extracted from the SQL code satisfy the matching conditions corresponding to a certain risk rule, the rule is considered a successful match, and that risk rule is recalled.

[0067] It should be understood that the matching conditions between features and recall strategies can be set according to needs, such as exact matching, fuzzy matching, regular expression matching, semantic matching, rule matching, etc., without any restrictions. For example, for syntactic features, exact matching can be set. For instance, if the SQL code includes the field name "XX", then risk rules whose recall strategies include the field name "XX" can be recalled. For example, for filter condition information, semantic matching can be performed. For instance, risk rules whose semantic similarity matches the filter condition information can be recalled. The recall condition can be a risk rule with a semantic similarity greater than a preset threshold, or it can be the risk rule with the highest semantic similarity among the first preset number of such rules, etc., without any restrictions.

[0068] Therefore, before performing the second machine learning model inference, the massive full rule base is efficiently converged into a highly relevant candidate rule set, which effectively reduces the amount of token input for a single recognition task. This not only significantly reduces the computational overhead and time consumption in the subsequent inference stage, but also avoids distracting the model's attention. While ensuring recognition accuracy, it effectively improves the model's inference efficiency.

[0069] It should be understood that the rule recall process focuses not only on the syntactic features of the SQL code itself, but also on the contextual features and business semantic features of the SQL code. Compared with simple text similarity identification methods, it can effectively improve the recall accuracy and recall complex risk rules that are difficult to discover in the past and depend on business scenarios (such as consistency of indicator standards, data filtering integrity, etc.), thereby improving the accuracy of risk identification.

[0070] In one scenario, there are multiple first risk rules and multiple first risk types, where each first risk rule belongs to a first risk type, and different first risk rules may belong to the same or different first risk types. A second machine learning model is used to identify risks based on structured query language code and the first risk rules to obtain a first identification result. This includes: for each of the multiple first risk types, inputting the structured query language code and a set of first rules into the second machine learning model corresponding to the first risk type to obtain a second identification result. The set of first rules includes the first risk rules under the first risk type. The second identification result is used to characterize whether the structured query language code has a code risk corresponding to a first risk rule. The second machine learning model corresponding to the first risk type is configured with a corresponding second prompt word, which is used to instruct the corresponding second machine learning model to detect code risks under the first risk type. Based on the obtained multiple second identification results, a first identification result is generated. Multiple second machine learning models corresponding to multiple first risk types are processed in parallel, and each second machine learning model is configured with a different second prompt word.

[0071] For example, risk rules in the rule base can be categorized according to different risk types. Each risk type can include one or more risk rules, and the risk rules differ for different risk types. Furthermore, different large language models can be pre-trained, each designed to identify code risks of a specific risk type. For instance, SQL code samples and risk rules under a specific risk type can be input as training data into the large language model to train its ability to identify risks of a specific risk type.

[0072] Reference Figure 3 After accurate rule recall, the process enters the multi-model concurrent invocation stage. An agent can be understood as a risk analysis execution unit encapsulating a specific large language model and dedicated prompts. Different agents are used to identify different types of code risks. A mapping table between preset risk types and agents (or a second machine learning model) can be maintained. Based on this mapping table, recall rules can be statically mapped to the agent best suited to handle that type of code risk according to its risk type. For example, an agent handling syntax problems can use a large language model with stronger code capabilities, while an agent handling business terminology problems can use a large language model with stronger reasoning capabilities. The specific configuration can be tailored to requirements and is not restricted.

[0073] Assuming, such as Figure 3As shown, the rules are divided into different sets according to the risk type corresponding to the recall rules. Assuming rule set G1, rule set G2, and rule set G3, the multi-model concurrent call processing can be handled by the dispatcher breaking down the rules into multiple parallel task packages based on the mapping table. Each task package can contain SQL code and the corresponding rule set, and then be sent asynchronously to the corresponding agent. For example, the task package corresponding to rule set G1 is sent to agent A1, the task package corresponding to rule set G2 is sent to agent A2, and the task package corresponding to rule set G3 is sent to agent A3.

[0074] After receiving the task, each agent executes model inference in parallel. Each large language model focuses on the security identification of a specific risk type and outputs the identification results to a unified result queue, awaiting processing by the subsequent "reflection and verification" layer. This decouples the single, massive LLM inference task into multiple lightweight, specialized parallel tasks, thus ensuring high efficiency and professional depth of identification at the architectural level.

[0075] In one scenario, a risk identification is performed using a second machine learning model based on the structured query language code and the first risk rule to obtain a first identification result. This includes: inputting the structured query language code, the first risk rule, and contextual information into the second machine learning model to obtain the first identification result; the contextual information includes metadata and / or data lineage information associated with the structured query language code.

[0076] For example, contextual information associated with Structured Query Language (SQL) code can also be input into a second machine learning model. Each task package can contain SQL code, a set of rules corresponding to the SQL code, and contextual information associated with the SQL code, enabling context-driven deep risk identification. Contextual information can be obtained during the rule retrieval phase, allowing the risk identification phase to utilize this information to understand the true business meaning of the SQL code within the data chain, thus achieving deep risk identification in complex business scenarios.

[0077] The contextual information can include metadata such as the table's lifecycle, field business classifications, and partitioning information, as well as data lineage information such as upstream and downstream processing chains and field-level upstream and downstream dependencies. This allows for the identification and detection of code risks at the code logic level, effectively improving the machine learning model's ability to identify deep business logic risks. Furthermore, the machine learning model can extract contextual information from existing data governance information and convert it into structured knowledge during training; there are no restrictions on this.

[0078] In one scenario, the method further includes: verifying the first identification result using a fourth machine learning model based on the structured query language code, the first risk rule, and the first association information to obtain a first verification result; and, in response to the first verification result indicating that the first identification result has not passed verification, correcting the first identification result based on the first verification result to obtain a corrected first identification result; wherein the first association information includes at least one of the context information associated with the structured query language code, first data, and second data, the context information includes metadata and / or data lineage information associated with the structured query language code, the first data is intermediate data of the first machine learning model in the rule recall process, and the second data is intermediate data of the second machine learning model in the risk identification process.

[0079] For example, the fourth machine learning model can be a pre-trained large language model capable of validating and correcting the recognition results. The recognition results can include one or more of the following: risk description, code location with code risk, result confidence level, risk level, reasoning logic, and contextual support (contextual information).

[0080] For example, the fourth machine learning model is trained as follows: A fourth initial model and a first sample labeled with a fourth label are obtained. The first sample includes a third structured query language sample code, second association information, a second risk rule corresponding to the third structured query language sample code, and a third identification result. The second association information includes at least one of the sample context information of the third structured query language sample code, the first sample data, and the second sample data. The context sample information includes metadata and / or data lineage information associated with the third structured query language sample code. The first sample data is intermediate data used by the first machine learning model in the process of recalling the second risk rule, and the second sample data is intermediate data used by the second machine learning model inferring the third identification result. The fourth label represents the verification result of the third identification result. The fourth initial model is trained based on the first sample to obtain the trained fourth machine learning model.

[0081] During training, loss can be calculated based on the validation results output by the fourth initial model and the labeled validation results. The model parameters are then adjusted based on the loss calculation results until the preset training completion conditions are met, resulting in the trained fourth machine learning model. The fourth initial model can be a large language model; there are no restrictions on this. The specific training method can be set according to requirements and is also unrestricted.

[0082] In addition, the training completion conditions for the first to fourth machine learning models can be set according to requirements, such as the number of iterations meeting a preset number, the loss value being less than a preset value, etc., without any restrictions.

[0083] For example, SQL code, identification results, recall risk rules, and correlation information can be input into a fourth machine learning model so that the model can validate the identification results and obtain validation results characterizing the quality of the identification results. Intermediate data may include the model's thought process.

[0084] For example, the fourth machine learning model is responsible for aggregating, deduplicating, checking logical consistency, and assessing confidence for all initially identified risk points. It can also verify the rationality of the identification results with the help of contextual information and recalled inference data and risk inference data. For example, it can judge the accuracy of risk descriptions, code locations with code risks, risk levels, and remediation suggestions through quality checks, and whether the inference logic is reasonable. It can filter out identification results that lack contextual support through filtering mechanisms, thereby filtering and correcting unreliable identification results. It can also correct identification results that fail verification through correction mechanisms, such as correcting risk descriptions and code location deviations, thereby ensuring the high credibility and usability of the final output results and reducing the false positive rate.

[0085] This content provides a data governance method based on a pre-trained model, including: obtaining structured query language (SCL) code; parsing the SCL code using a first machine learning model to obtain a first feature, and performing rule retrieval in a rule base based on the first feature to obtain a first risk rule. The first feature includes at least one of syntactic features, contextual features, and business semantic features in the SCL code. The syntactic features represent the syntactic structure attributes in the SCL code, the contextual features represent the attribute information of the data objects operated on by the SCL code, and the business semantic features represent the information required to determine whether the SCL code conforms to business rules; and performing risk identification using a second machine learning model based on the SCL code, the first risk rule, and the contextual information associated with the SCL code. A first identification result is obtained, which is used to characterize whether the structured query language code has a code risk under a first risk rule. The first risk rule belongs to a first risk type. A second machine learning model is used to detect code risks under the first risk type. Contextual information includes metadata and / or data lineage information associated with the structured query language code. Risk rules in the rule base are obtained as follows: initial risk rules described in natural language are obtained; the initial risk rules are understood by a third machine learning model to obtain structured risk rules. The structured risk rules include a first prompt word and a recall strategy described in natural language. The first prompt word is used for risk inference by the second machine learning model during the risk identification process. The recall strategy includes at least one of the syntactic features, contextual features, and business semantic features of the initial risk rules.

[0086] The above method decouples the code detection process into two stages: rule recall and risk identification. In the rule recall stage, a first machine learning model extracts multi-dimensional features and performs rule recall to improve recall accuracy and reduce the probability of false positives and false negatives. In the risk identification stage, based on the recall results, a second machine learning model combines contextual information to identify risks in structured query language code. Since risk rules have already been filtered and reduced in the recall stage, the data scale required for the second machine learning model is significantly reduced, thus effectively improving model inference efficiency while maintaining identification accuracy. Furthermore, the second machine learning model focuses on code risk identification under specific risk types, further enhancing the accuracy and reliability of the identification results.

[0087] Figure 5 This is a schematic diagram of the structure of a data governance device based on a pre-trained model, as illustrated by an example. Figure 5 As shown, the data governance device 500 based on the pre-trained model includes: Module 501 is used to retrieve the Structured Query Language code; The recall module 502 is used to parse the structured query language code through a first machine learning model to obtain a first feature, and to perform rule recall in the rule base based on the first feature to obtain a first risk rule, wherein the first feature includes at least one of the syntactic features, context features and business semantic features in the structured query language code. The identification module 503 is used to identify risks based on the structured query language code and the first risk rule using a second machine learning model to obtain a first identification result. The first identification result is used to characterize whether the structured query language code has a code risk under the first risk rule. The first risk rule belongs to a first risk type. The second machine learning model is used to detect code risks under the first risk type.

[0088] Using the aforementioned device, the code detection process is decoupled into two stages: rule recall and risk identification. In the rule recall stage, a first machine learning model extracts multi-dimensional features and performs rule recall to improve recall accuracy and reduce the probability of false positives and false negatives. In the risk identification stage, based on the recall results, a second machine learning model identifies risks in structured query language code. Since risk rules have already been filtered and reduced in the recall stage, the data scale required for the second machine learning model is significantly reduced, thus effectively improving model inference efficiency while maintaining identification accuracy. Furthermore, the second machine learning model focuses on code risk identification under specific risk types, further enhancing the accuracy and reliability of the identification results.

[0089] Optionally, the risk rules in the rule base are obtained in the following way: Obtain the initial risk rules described in natural language; The initial risk rules are understood by a third machine learning model to obtain structured risk rules. The structured risk rules include a first prompt word and a recall strategy described in natural language. The first prompt word is used by the second machine learning model to perform risk inference during the risk identification process. The recall strategy includes at least one of the syntactic features, contextual features, and business semantic features of the initial risk rules.

[0090] Optionally, the recall module 502 is used for: The risk rule corresponding to the recall strategy and the first feature in the rule base is determined as the first risk rule.

[0091] Optionally, the data governance device 500 based on the pre-trained model further includes: The syntactic features include at least one of preset keywords, function parameters, and operators; the context features include at least one of preset table naming patterns, field naming patterns, metadata attributes, and custom function call information; the business semantic features include at least one of preset indicator caliber information, time window information, and filtering condition information.

[0092] Optionally, the number of the first risk rules is multiple, and the number of the first risk types is multiple, wherein each first risk rule belongs to a first risk type, and different first risk rules may belong to the same or different first risk types; the identification module 503 is used for: For each of the plurality of first risk types, the structured query language code and the first rule set are input into the second machine learning model corresponding to the first risk type to obtain a second identification result. The first rule set includes first risk rules under the first risk type. The second identification result is used to characterize whether the structured query language code has a code risk corresponding to the first risk rule. The second machine learning model corresponding to the first risk type is configured with a corresponding second prompt word. The second prompt word is used to instruct the corresponding second machine learning model to detect code risks under the first risk type. The first identification result is generated based on the multiple second identification results obtained; wherein, multiple second machine learning models corresponding to the multiple first risk types are processed in parallel, and each second machine learning model is configured with a different second prompt word.

[0093] Optionally, the identification module 503 is used for: The structured query language code, the first risk rule, and the context information are input into the second machine learning model to obtain the first recognition result; The context information includes metadata and / or data lineage information associated with the structured query language code.

[0094] Optionally, the data governance device 500 based on the pre-trained model further includes a verification module, used for: The first identification result is verified by the fourth machine learning model based on the structured query language code, the first risk rule and the first association information to obtain a first verification result. In response to the first verification result indicating that the first identification result has not been verified, the first identification result is corrected based on the first verification result to obtain a corrected first identification result. The first associated information includes at least one of the context information associated with the structured query language code, the first data, and the second data. The context information includes the metadata and / or data lineage information associated with the structured query language code. The first data is the intermediate data of the first machine learning model in the rule recall process, and the second data is the intermediate data of the second machine learning model in the risk identification process.

[0095] Optionally, the data governance device 500 based on the pre-trained model further includes a response module for: In response to the first identification result characterizing that the structured query language code has a code risk of the first risk rule, the first identification result includes at least one of risk level, risk description, code location, result confidence, context information, and third data. The code location is used to indicate the location of the risk code in the structured query language code. The context information includes metadata and / or data lineage information associated with the structured query language code. The third data includes the reasoning logic of the second machine learning model in the risk identification process.

[0096] Regarding the data governance device 500 based on the pre-trained model mentioned above, the method logic executed by each functional module has been explained in detail in the section on methods, and will not be repeated here.

[0097] Based on the same concept, a computer-readable medium is also provided, on which a computer program is stored, which, when executed by a processing device, implements the steps of any of the above-described data governance methods based on a pre-trained model.

[0098] The code detection process is decoupled into two stages: rule recall and risk identification. In the rule recall stage, a first machine learning model extracts multi-dimensional features and performs rule recall to improve recall accuracy and reduce false positives and false negatives. In the risk identification stage, based on the recall results, a second machine learning model identifies risks in structured query language code. Because risk rules have already been filtered and reduced in the recall stage, the data scale required for the second machine learning model is significantly reduced, thus effectively improving model inference efficiency while maintaining identification accuracy. Furthermore, the second machine learning model focuses on code risk identification under specific risk types, further enhancing the accuracy and reliability of the identification results.

[0099] Based on the same concept, an electronic device is also provided, which may include: A storage device on which computer programs are stored; A processing device for executing a computer program stored in a storage device to implement the steps of any of the above-described data governance methods based on a pre-trained model.

[0100] The code detection process is decoupled into two stages: rule recall and risk identification. In the rule recall stage, a first machine learning model extracts multi-dimensional features and performs rule recall to improve recall accuracy and reduce false positives and false negatives. In the risk identification stage, based on the recall results, a second machine learning model identifies risks in structured query language code. Because risk rules have already been filtered and reduced in the recall stage, the data scale required for the second machine learning model is significantly reduced, thus effectively improving model inference efficiency while maintaining identification accuracy. Furthermore, the second machine learning model focuses on code risk identification under specific risk types, further enhancing the accuracy and reliability of the identification results.

[0101] Based on the same concept, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps of any of the above-described data governance methods based on a pre-trained model.

[0102] The code detection process is decoupled into two stages: rule recall and risk identification. In the rule recall stage, a first machine learning model extracts multi-dimensional features and performs rule recall to improve recall accuracy and reduce false positives and false negatives. In the risk identification stage, based on the recall results, a second machine learning model identifies risks in structured query language code. Because risk rules have already been filtered and reduced in the recall stage, the data scale required for the second machine learning model is significantly reduced, thus effectively improving model inference efficiency while maintaining identification accuracy. Furthermore, the second machine learning model focuses on code risk identification under specific risk types, further enhancing the accuracy and reliability of the identification results.

[0103] The following is for reference. Figure 6 The diagram illustrates a structural schematic of an electronic device 600 suitable for implementing the above-described method. The terminal device may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Personal Computers), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs (Televisions), desktop computers, etc. Figure 6 The electronic device shown is merely an example and should not be construed as limiting its functionality or scope of use.

[0104] like Figure 6 As shown, electronic device 600 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. The random access memory 603 also stores various programs and data required for the operation of electronic device 600. The processing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. An input / output (I / O) interface 605 is also connected to bus 604.

[0105] Typically, the following devices can be connected to the input / output interface 605: input devices 606 including, for example, a touchscreen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 608 including, for example, magnetic tape, hard disk, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0106] In particular, depending on certain circumstances, the processes described in the flowchart above can be implemented as computer software programs. For example, a computer program product is provided, comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowchart. This computer program can be downloaded and installed from a network via communication device 609, or installed from storage device 608, or installed from read-only memory 602. When the computer program is executed by processing device 601, it performs the functions defined in the above-described methods.

[0107] It should be noted that the aforementioned computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM, or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In one case, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In another case, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. The transmitted data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (Radio Frequency), etc., or any suitable combination thereof.

[0108] In some cases, communication can be conducted using any currently known or future-developed network protocol, such as HTTP (Hypertext Transfer Protocol), and can be interconnected with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include Local Area Networks (LANs), Wide Area Networks (WANs), Internets (e.g., the Internet), and peer-to-peer networks (e.g., ad-hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0109] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0110] The aforementioned computer-readable medium carries one or more programs. When the electronic device executes the aforementioned one or more programs, the electronic device causes the following: to acquire structured query language code; to parse the structured query language code using a first machine learning model to obtain a first feature, and to perform rule retrieval in a rule base based on the first feature to obtain a first risk rule, wherein the first feature includes at least one of syntactic features, contextual features, and business semantic features in the structured query language code; and to perform risk identification based on the structured query language code and the first risk rule using a second machine learning model to obtain a first identification result, wherein the first identification result is used to characterize whether the structured query language code has a code risk under the first risk rule, the first risk rule belongs to a first risk type, and the second machine learning model is used to detect code risks under the first risk type.

[0111] Computer program code for performing the above operations can be written in one or more programming languages ​​or a combination thereof. These programming languages ​​include, but are not limited to, object-oriented programming languages, as well as conventional procedural programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0112] The flowcharts and block diagrams in the accompanying figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products under various scenarios. Each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that, in some alternative cases, the functions indicated in the blocks may occur in a different order than those indicated in the figures. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0113] The modules mentioned above can be implemented in software or hardware. In some cases, the name of a module does not necessarily limit the functionality of that module.

[0114] The functions described above can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field-Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application-Specific Standard Parts (ASSPs), Systems on Chips (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.

[0115] In this context, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. 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 (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0116] The above description is merely illustrative and explains the technical principles employed. Those skilled in the art should understand that the scope of this document is not limited to the specific combinations of the above-described technical features, but should also cover any combination of the above-described technical features or their equivalents without departing from the above concept.

[0117] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. Multitasking and parallel processing may be advantageous in certain contexts. Similarly, while some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of this paper. Certain features described in the context of a single example can also be implemented in combination in a single example. Conversely, various features described in the context of a single example can also be implemented individually or in any suitable sub-combination in multiple examples.

[0118] Although this document has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims. Regarding the aforementioned apparatus, the specific manner in which the various modules perform their operations has already been described in detail in the section concerning the method, and will not be elaborated upon here.

Claims

1. A data governance method based on a pre-trained model, comprising: Obtain the Structured Query Language code; The structured query language code is parsed by a first machine learning model to obtain a first feature, and a rule is retrieved in the rule base based on the first feature to obtain a first risk rule. The first feature includes at least one of the syntactic features, context features, and business semantic features in the structured query language code. The second machine learning model performs risk identification based on the structured query language code and the first risk rule to obtain a first identification result. The first identification result is used to characterize whether the structured query language code has a code risk according to the first risk rule. The first risk rule belongs to a first risk type. The second machine learning model is used to detect code risks under the first risk type.

2. The method according to claim 1, wherein the risk rules in the rule base are obtained in the following manner: Obtain the initial risk rules described in natural language; The initial risk rules are understood by a third machine learning model to obtain structured risk rules. The structured risk rules include a first prompt word and a recall strategy described in natural language. The first prompt word is used by the second machine learning model to perform risk inference during the risk identification process. The recall strategy includes at least one of the syntactic features, contextual features, and business semantic features of the initial risk rules.

3. The method according to claim 2, wherein the step of retrieving rules from the rule base based on the first feature to obtain the first risk rule comprises: The risk rule corresponding to the recall strategy and the first feature in the rule base is determined as the first risk rule.

4. The method according to any one of claims 1-3, further comprising: The syntactic features include at least one of the following: predefined keywords, function parameters, and operators; The context features include at least one of the following: a preset table naming pattern, a field naming pattern, metadata attributes, and call information of custom functions; The business semantic features include at least one of the following: preset indicator caliber information, time window information, and filtering condition information.

5. The method according to any one of claims 1-3, wherein the number of the first risk rules is plurality, and the number of the first risk types is plurality, wherein, Each first risk rule belongs to a first risk type, and different first risk rules may belong to the same or different first risk types; The step of identifying risks based on the structured query language code and the first risk rule using a second machine learning model to obtain a first identification result includes: For each of the plurality of first risk types, the structured query language code and the first rule set are input into the second machine learning model corresponding to the first risk type to obtain a second identification result. The first rule set includes first risk rules under the first risk type. The second identification result is used to characterize whether the structured query language code has a code risk corresponding to the first risk rule. The second machine learning model corresponding to the first risk type is configured with a corresponding second prompt word. The second prompt word is used to instruct the corresponding second machine learning model to detect code risks under the first risk type. The first identification result is generated based on the multiple second identification results obtained; wherein, multiple second machine learning models corresponding to the multiple first risk types are processed in parallel, and each second machine learning model is configured with a different second prompt word.

6. The method according to any one of claims 1-3, wherein the step of performing risk identification based on the structured query language code and the first risk rule using a second machine learning model to obtain a first identification result includes: The structured query language code, the first risk rule, and the context information are input into the second machine learning model to obtain the first recognition result; The context information includes metadata and / or data lineage information associated with the structured query language code.

7. The method according to any one of claims 1-3, further comprising: The first identification result is verified by the fourth machine learning model based on the structured query language code, the first risk rule and the first association information to obtain a first verification result. In response to the first verification result indicating that the first identification result has not been verified, the first identification result is corrected based on the first verification result to obtain a corrected first identification result. The first associated information includes at least one of the context information associated with the structured query language code, the first data, and the second data. The context information includes the metadata and / or data lineage information associated with the structured query language code. The first data is the intermediate data of the first machine learning model in the rule recall process, and the second data is the intermediate data of the second machine learning model in the risk identification process.

8. The method according to any one of claims 1-3, further comprising: In response to the first identification result characterizing that the structured query language code has a code risk of the first risk rule, the first identification result includes at least one of risk level, risk description, code location, result confidence, context information, and third data. The code location is used to indicate the location of the risk code in the structured query language code. The context information includes metadata and / or data lineage information associated with the structured query language code. The third data includes the reasoning logic of the second machine learning model in the risk identification process.

9. A data governance device based on a pre-trained model, comprising: The retrieval module is used to retrieve Structured Query Language (SCL) code; The recall module is used to parse the structured query language code through a first machine learning model to obtain a first feature, and to perform rule recall in the rule base based on the first feature to obtain a first risk rule, wherein the first feature includes at least one of the syntactic features, context features and business semantic features in the structured query language code. The identification module is used to identify risks based on the structured query language code and the first risk rule using a second machine learning model, and obtain a first identification result. The first identification result is used to characterize whether the structured query language code has a code risk according to the first risk rule. The first risk rule belongs to a first risk type. The second machine learning model is used to detect code risks under the first risk type.

10. An electronic device, comprising: A storage device on which computer programs are stored; A processing device for executing the computer program in the storage device to implement the steps of the method according to any one of claims 1-8.