Risk prediction method, device and equipment based on distributed control system
By performing multimodal feature extraction and multi-task model analysis on the code submission data of the distributed control system, the objectivity and accuracy issues of risk assessment in existing technologies have been resolved, enabling more accurate risk prediction and visualization results, and improving the reliability of project management.
Patent Information
- Application Number
- CN202511024159.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-24
- Publication Date
- 2025-11-07
AI Technical Summary
The risk assessment of existing distributed control systems lacks objectivity and accuracy, relies on human experience and project management communication feedback, and insufficient data leads to inaccurate assessments.
By extracting multimodal features from code submission data of distributed control systems, and using a multi-task model composed of a self-attention mechanism model and a graph neural network model, the probability and impact level of code change risks are predicted, and risk contribution analysis is performed to finally generate visualized risk prediction results.
It improves the accuracy and reliability of risk prediction, helping developers identify and respond to high-risk code changes.
Smart Images

Figure CN120909646A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of computers, which can be used in the technical field of financial technology, especially in the technical field of distributed technology, and specifically relate to a risk prediction method, device and equipment based on a distributed control system. BACKGROUND
[0002] In software development project management, accurate assessment of project risks is of great significance to ensure the smooth progress of the project, optimize resource allocation and reduce potential losses.
[0003] Existing risk assessment of distributed control systems is mostly based on manual experience or communication feedback from various roles in project management, such as expert assessment and brainstorming, which may be influenced by the opinions of supervisors and lack objectivity and accuracy. Some methods require detailed project information and data support, but in actual projects, sufficient data and information may not be available. SUMMARY
[0004] The present application provides a risk prediction method, device and equipment based on a distributed control system to improve the accuracy and reliability of risk prediction.
[0005] According to an aspect of the present application, a risk prediction method based on a distributed control system is provided, which comprises:
[0006] Multi-modal feature extraction is performed on code submission data obtained from a target distributed control system to obtain multi-modal code features of the code submission data; wherein the multi-modal code features include code structure features, code semantic features and code timing features;
[0007] Based on a multi-task model, the code change risk probability and change risk impact level of the code submission data are determined according to the multi-modal code features; wherein the multi-task model is composed of a self-attention mechanism model and a graph neural network model;
[0008] According to the code change risk probability and the change risk impact level, risk contribution analysis is performed on the multi-modal code features to obtain feature contribution of the multi-modal code features;
[0009] The code change risk probability, the change risk impact level and the feature contribution are visually integrated to obtain a risk prediction result of the code submission data.
[0010] According to another aspect of the present application, a risk prediction device based on a distributed control system is provided, which comprises:
[0011] The feature extraction module is configured to perform multi-modal feature extraction on the code commit data obtained from the target distributed control system to obtain multi-modal code features of the code commit data, wherein the multi-modal code features include code structure features, code semantic features, and code timing features.
[0012] The risk prediction module is configured to determine a code change risk probability and a change risk impact level of the code commit data based on the multi-modal code features according to a multi-task model, wherein the multi-task model is composed of a self-attention mechanism model and a graph neural network model.
[0013] The contribution analysis module is configured to perform risk contribution analysis on the multi-modal code features according to the code change risk probability and the change risk impact level to obtain feature contributions of the multi-modal code features.
[0014] The result generation module is configured to visually integrate the code change risk probability, the change risk impact level, and the feature contributions to obtain a risk prediction result of the code commit data.
[0015] According to another aspect of the present application, an electronic device is provided, which includes:
[0016] one or more processors;
[0017] a memory configured to store one or more programs;
[0018] When the one or more programs are executed by the one or more processors, the one or more processors implement any one of the risk prediction methods based on a distributed control system provided by the embodiments of the present application.
[0019] According to another aspect of the present application, a computer readable storage medium is provided, which stores a computer program, and the program is executed by a processor to implement any one of the risk prediction methods based on a distributed control system provided by the embodiments of the present application.
[0020] According to another aspect of the present application, a computer program product is provided, which includes a computer program, and the computer program is executed by a processor to implement any one of the risk prediction methods based on a distributed control system provided by the embodiments of the present application.
[0021] The application obtains multi-modal code features of the code submission data by multi-modal feature extraction on the code submission data obtained from the target distributed control system; wherein the multi-modal code features include code structure features, code semantic features and code timing features; based on a multi-task model, the code change risk probability and the change risk impact level of the code submission data are determined according to the multi-modal code features; wherein the multi-task model is composed of a self-attention mechanism model and a graph neural network model; according to the code change risk probability and the change risk impact level, risk contribution degree analysis is performed on the multi-modal code features to obtain feature contribution degrees of the multi-modal code features; the code change risk probability, the change risk impact level and the feature contribution degrees are visually integrated to obtain the risk prediction result of the code submission data. The above technical solution is helpful to improve the accuracy and reliability of risk prediction by extracting the multi-modal code features of the code submission data and performing risk prediction by the multi-task module. BRIEF DESCRIPTION OF DRAWINGS
[0022] Figure 1 is a flowchart of a risk prediction method based on a distributed control system according to an embodiment of the application;
[0023] Figure 2 is a flowchart of a risk prediction method based on a distributed control system according to an embodiment of the application;
[0024] Figure 3 is a structural schematic diagram of a risk prediction device based on a distributed control system according to an embodiment of the application;
[0025] Figure 4 is a structural schematic diagram of an electronic device implementing a risk prediction method based on a distributed control system according to an embodiment of the application. DETAILED DESCRIPTION
[0026] In order to enable personnel in the technical field to better understand the application scheme, the technical solutions in the embodiments of the application will be described clearly and completely below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only a part of the embodiments of the application, not all the embodiments. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor should be within the scope of protection of the application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and in the above drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not have to be limited to only those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] In addition, it should also be noted that in the technical solutions of the present application, the collection, storage, use, processing, transmission, provision and disclosure of the code submission data and the multi-modal code features and other related data involved in the technical solutions comply with the relevant legal regulations and do not violate public order and good customs.
[0029] Embodiment one
[0030] Figure 1 is a flowchart of a risk prediction method based on a distributed control system according to the first embodiment of the present application. The present embodiment can be applied to the case of predicting project risks in software development project management, and can be executed by a risk prediction device based on a distributed control system. The risk prediction device based on a distributed control system can be realized in the form of hardware and / or software, and can be configured in a computer device, such as a server. As shown in the figure, the method comprises: Figure 1
[0031] S110, multi-modal feature extraction is performed on the code submission data obtained from the target distributed control system to obtain multi-modal code features of the code submission data; wherein the multi-modal code features include code structure features, code semantic features and code timing features.
[0032] In this embodiment, the target distributed control system refers to a control system with a distributed architecture, which is commonly used for multiple independent control units to collaborate through a network to complete the control task of the system; in this system, multiple control units (such as sensors, actuators, controllers, etc.) are distributed in different locations and work collaboratively through a communication network. Code submission data refers to code-related data submitted through the interface of the distributed control system, which can include submission records, code change content, submission messages, change rhythm, code comments, etc. Multi-modal code features refer to useful features extracted from different types of information or data sources. Code structure features refer to the hierarchy, modularization degree, function, dependency between classes, loop structure, etc. of the code; structure features help to assess the complexity of the code and the coupling degree between modules. Code semantic features refer to the logic and functional meaning of the code, such as the implementation purpose and execution flow of each piece of code; semantic features are usually extracted through static analysis (such as lexical and syntactic analysis) and dynamic analysis (such as the behavior during code execution). Code timing features refer to the time characteristics of code submission, such as submission frequency, submission time interval, periodicity, etc.; by analyzing the submission mode of the code, potential risk points can be predicted, such as frequent emergency submissions that may cause problems.
[0033] Optionally, the code structure of the code submission data obtained from the target distributed control system is parsed to obtain code structure features of the code submission data; text semantic extraction is performed on the code submission data to obtain code semantic features of the code submission data; timing and spatial feature extraction is performed on the code submission data to obtain code timing features of the code submission data; the code structure features, code semantic features and code timing features are integrated to obtain multi-modal code features of the code submission data.
[0034] Further, the code structure of the code submission data obtained from the target distributed control system is parsed to obtain code structure features of the code submission data, which can be abstract syntax tree analysis of the code submission data obtained from the target distributed control system to obtain a code syntax tree, and the code syntax tree is attached with dynamic context features; the code syntax tree includes function declaration nodes, variable definition nodes and control structure nodes; through a static analysis tool, a code dependency graph is determined according to the code submission data; the embedding features of the code syntax tree and the edge features of the code dependency graph are aligned in latitude through a feature projection matrix to obtain the code structure features of the code submission data.
[0035] In this embodiment, the code syntax tree refers to the hierarchical representation of the source code, which shows the syntax structure of the code; in code change analysis, the abstract syntax tree helps to extract the structural information of the code, such as function and control structure nodes, for further analysis. Dynamic context features refer to information about the behavior of the code obtained through dynamic analysis during code execution; these features are not limited to the static structure of the code (such as function definition, module dependency, etc.), but are obtained by observing the behavior of the code in different contexts (such as different inputs, system state or execution path) during actual execution. Feature projection matrix is used to map different types of features to the same dimension to integrate and compare features from different sources; this is particularly important when dealing with code syntax tree embedding features and edge features of code dependency graph, which can ensure the consistency of the dimensions of different types of features, facilitating the input and processing of the model. Static analysis tools are software tools used to analyze code without running the code; these tools read the source code or intermediate code (such as bytecode) and perform structural analysis to identify potential problems, defects, code style issues or security vulnerabilities; static analysis tools can help developers check the quality and reliability of the code without running the program.
[0036] For example, by using a static analysis tool, the code dependency graph can be determined based on the code commit data; the tool scans your source code and analyzes the structure of the code, such as modules, classes, methods, packages, etc., and identifies the dependencies between them; for example, analyze the dependencies between classes, method call relationships, library imports, etc.; the static analysis tool extracts dependency information between modules; each module usually has some external dependencies (such as libraries, interfaces) and internal dependencies (call relationships between modules), which are recorded; the tool generates a dependency graph based on the scanning results, usually a graphical representation; nodes represent modules or classes, and edges represent dependencies; the tool can also add different labels to each dependency to identify different types of dependencies (such as direct dependencies, indirect dependencies, strong dependencies, weak dependencies, etc.).
[0037] S120, based on the multi-task model, determines the code change risk probability and change risk impact level of the code commit data according to the multi-modal code features; wherein the multi-task model is composed of a self-attention mechanism model and a graph neural network model.
[0038] In this embodiment, the multi-task model refers to a machine learning model that can learn multiple related tasks simultaneously, rather than focusing on only one task. The code change risk probability refers to the probability of predicting that a certain code change will cause problems; for example, if a certain code submission modifies the core part of the system, it may cause system crashes or errors. The change risk impact level refers to the evaluation of the impact of the change, i.e. if the code change causes problems, the consequences are minor, medium or serious. The self-attention mechanism model is a model for processing sequence data (such as text, code, time series), which allows the model to adaptively adjust the weights based on the relationship between each input element and other elements when processing each input element, so as to focus on the most important information; in code risk assessment, the self-attention mechanism can help the model identify and focus on the code fragments that contribute most to risk prediction. The graph neural network model is a deep learning method model that is particularly suitable for processing graph structure data (such as network structure, social relationship, dependency relationship between code modules, etc.); it can be used to analyze the dependency relationship between code modules or functions, helping to identify which modules or code lines are most likely to cause risks when changed.
[0039] Optionally, branch one of the multi-task model based on the self-attention mechanism model uses code semantic features and code time sequence features to perform risk probability prediction and obtain the code change risk probability; branch two of the multi-task model based on the graph neural network model uses code structure features to perform impact degree prediction and obtain the change risk impact level; through joint loss function optimization, the task weights of branch one and branch two of the multi-task model are balanced, and the final required code change risk probability and change risk impact level are obtained.
[0040] In this embodiment, joint loss function optimization refers to optimizing multiple objective functions (or loss functions) in the process of training a machine learning or deep learning model, and optimizing multiple tasks or multiple objectives by designing and optimizing the weighted combination of multiple objective functions (or loss functions); in this way, a unified goal is used to balance different tasks or objectives.
[0041] S130, according to the code change risk probability and the change risk impact level, risk contribution analysis is performed on the multi-modal code features to obtain the feature contribution of the multi-modal code features.
[0042] In this embodiment, risk contribution analysis refers to evaluating the contribution of different features (such as code structure, semantic and time sequence features) to code change risk; through this analysis, it can be determined which code features (such as complex functions, frequent submissions, serious module dependencies, etc.) play a key role in risk prediction, thereby helping developers focus on solving these high-risk problems. Feature contribution refers to the contribution of different features (such as code structure, semantic and time sequence features) to code change risk.
[0043] Exemplarily, the contribution of each feature in the multi-modal code features to the prediction result is quantified by using a tool for interpreting the machine learning model to obtain the feature contribution degree of the multi-modal code features.
[0044] In S140, the code change risk probability, the change risk impact level and the feature contribution degree are visually integrated to obtain the risk prediction result of the code submission data.
[0045] In this embodiment, the risk prediction result refers to a result of presenting all risk assessment results (such as the change risk probability, the change risk impact level and the feature contribution degree) in the form of a graph or a chart.
[0046] Exemplarily, the risk prediction result can be visually displayed in the form of a risk heat map, a dependency graph and a time series graph. The risk heat map is used to display the risk level of each module or code line in the system, and different risk levels are usually represented by different color depths. The dependency graph is used to display the dependency relationship between code modules or functions and mark the high-risk modules. The time series graph is used to display the submission history and the related risk changes, which can help identify the submission mode or the frequently occurring risk fluctuations.
[0047] In the embodiments of the present application, multi-modal feature extraction is performed on the code submission data obtained from the target distributed control system to obtain multi-modal code features of the code submission data. The multi-modal code features include code structure features, code semantic features and code time sequence features. Based on a multi-task model, the code change risk probability and the change risk impact level of the code submission data are determined according to the multi-modal code features. The multi-task model is composed of a self-attention mechanism model and a graph neural network model. The risk contribution degree of the multi-modal code features is analyzed according to the code change risk probability and the change risk impact level to obtain the feature contribution degree of the multi-modal code features. The code change risk probability, the change risk impact level and the feature contribution degree are visually integrated to obtain the risk prediction result of the code submission data. The above technical solution helps to improve the accuracy and reliability of risk prediction by extracting the multi-modal code features of the code submission data and performing risk prediction by the multi-task model.
[0048] Embodiment Two
[0049] Figure 2is a flowchart of a risk prediction method based on a distributed control system according to Embodiment Two of the present application. Based on the technical solutions of the above-mentioned embodiments, the present embodiment refines the "determining the code change risk probability and the change risk impact level of the code submission data based on the multi-task model and the multi-modal code features" into "determining the candidate risk probability of the code submission data based on the self-attention mechanism model and the code semantic features and the code timing features; determining the candidate impact level of the code submission data based on the graph neural network model and the code structure features; optimizing the candidate risk probability and the candidate impact level through the joint loss function optimization to obtain the code change risk probability and the change risk impact level of the code submission data". It should be noted that the parts not described in detail in the embodiments of the present application can be referred to the related descriptions of other embodiments. For example, Figure 2 As shown in FIG. 11, the method comprises the following steps.
[0050] In S210, multi-modal feature extraction is performed on the code submission data obtained from the target distributed control system to obtain multi-modal code features of the code submission data.
[0051] In S220, the self-attention mechanism model is used to determine the candidate risk probability of the code submission data based on the code semantic features and the code timing features.
[0052] In the present embodiment, the candidate risk probability refers to the risk probability that the code submission may bring to a certain extent based on the semantic, timing and other features of the code when the code submission data is analyzed; for example, a certain code submission may contain errors or cause performance problems, and the candidate risk probability represents the possibility of such risk.
[0053] Optionally, the self-attention mechanism model is used to horizontally splice the code semantic features and the code timing features to obtain at least one candidate feature matrix; the position encoder in the self-attention mechanism model is used to perform timing encoding on the at least one candidate feature matrix based on the sequence of submission timestamps in the code timing features to obtain a target feature matrix; wherein the timing encoding includes absolute position encoding and relative time interval encoding; the self-attention mechanism model is used to determine the candidate risk probability of the code submission data based on the target feature matrix.
[0054] In this embodiment, transverse concatenation refers to connecting multiple feature vectors (or matrices) by columns. Here, transverse concatenation is to concatenate the semantic features and timing features of the code together to form a synthetic feature matrix as the input of the self-attention mechanism model; the result of concatenation is usually a multi-dimensional matrix containing features from different sources. The candidate feature matrix is a matrix obtained by concatenating multiple features (such as the semantic features and timing features of the code); it is the input matrix of the self-attention mechanism model, containing multiple aspects of features of the code for subsequent analysis. The position encoder is used to provide position information for each element in the sequence; because the self-attention mechanism itself cannot capture the order of the sequence, the position encoder adds position information so that the model can understand the relative position of the elements. The commit timestamp sequence refers to a set of timestamp data related to code commits, usually indicating the order and time of code commits in a distributed control system. The target feature matrix refers to the final feature matrix obtained by performing timing encoding (including absolute position encoding and relative time interval encoding) on the candidate feature matrix; it contains code features with time information and will be used as input for further processing by the self-attention mechanism model to predict the risk of code commit data. Absolute position encoding refers to providing each code commit data with its absolute position on the time axis. Relative time interval encoding is used to capture the time interval between code commits, which can help the model understand the time dependence of code commits, whether some commits occur frequently in a short period of time or there is a long interval between commits.
[0055] For example, based on the self-attention mechanism model, determining the candidate risk probability of the code commit data according to the target feature matrix can be inputting the target feature matrix into the multi-head self-attention layer of the self-attention mechanism model for feature enhancement processing, and implementing bidirectional gated recurrent unit on the feature sequence output by the last layer of the multi-head self-attention layer for timing feature refinement; performing parallel operation of global average pooling and maximum pooling on the refined feature sequence, and inputting the parallel pooling result into the multi-layer perceptron containing the regularization layer, and finally outputting the candidate risk probability value in the range of [0, 1] through the mathematical logic function.
[0056] In this embodiment, the multi-head self-attention layer is an extension of the self-attention mechanism, which learns the dependencies between different subspaces in the input sequence by parallel computing multiple attention heads; each head captures different features, and finally these features are spliced to further improve the expression ability of the model. The bidirectional gated recurrent unit is a recurrent neural network that processes input sequences in a bidirectional manner (forward and backward), which enables the model to capture not only forward information but also reverse information. The process of temporal feature refinement is to extract useful temporal information from the input sequence and optimize or enhance it through a certain model or mechanism. Global average pooling is a pooling technique that reduces the dimension by averaging each feature map (or time step). Max pooling is another pooling technique that reduces the dimension of the data by selecting the maximum value in the feature map region. The regularization layer is a mechanism that prevents overfitting of the model by adding regularization techniques. The multilayer perceptron is a common feedforward neural network composed of multiple fully connected layers; it is used to further process the pooled features and output. The mathematical logic function is a function that maps any real number to 0 to 1, thereby producing a probability output.
[0057] S230, based on the graph neural network model, determining the candidate influence level of the code submission data according to the code structure features.
[0058] In this embodiment, the candidate influence level represents the size or severity of the impact of the code change on the system; generally, the higher the influence level, the greater the impact of the code change on the system, and the more serious the consequences.
[0059] Optionally, the graph neural network model adopts a double-level hybrid graph convolution architecture; the first layer of the double-level hybrid graph convolution architecture adopts a multi-head graph attention network; and the second layer adopts an edge feature enhanced graph isomorphic network.
[0060] In this embodiment, the double-level hybrid graph convolution architecture refers to an architecture that combines two different levels of graph convolution network. The multi-head graph attention network is a graph neural network that assigns different attention weights between each node and its neighbors through the graph attention mechanism; multi-head attention is to parallelly compute multiple attention heads to further enhance the expression ability of the model. In this network, each node learns how to interact with other nodes and adjusts the strength of information transmission according to the importance of neighbors. The graph isomorphic network is a graph convolution-based network model that emphasizes the structural information between nodes and can effectively handle the similarity between different graph structures. Edge feature enhancement refers to the fact that in the graph isomorphic network, not only the features of the nodes are relied on, but also the feature information of the edges is introduced, so that the model can consider the relationship between the nodes and the strength of the connection, thereby enhancing the expression ability of the model.
[0061] Further, based on the multi-head graph attention network, the attention weights between nodes in the code structure feature are determined according to the candidate node features in the code structure feature; based on the graph isomorphism network, the target node features are obtained according to the candidate node features of each node in the code structure feature, and the candidate edge features and the attention weights between the nodes; the target node features are subjected to density-based three-cluster clustering to obtain the candidate impact levels of the code submission data.
[0062] In the embodiment, the attention weight refers to the connection between each node and its neighbor, and the multi-head graph attention network learns the attention weight according to the features between the nodes to control the strength of information transmission; the edge with higher weight will transmit more information. The candidate node feature refers to the potential feature related to the node; these features can be syntax features, variable types, operators, etc. in the code. The edge feature refers to the feature of the connection relationship between the nodes in the graph; in the code structure graph, the edge can represent the interaction or dependency relationship between different nodes; for example, a function can depend on the output of another function, and this relationship can be captured through the edge feature. The density-based three-cluster clustering refers to a clustering method, which is usually used for grouping or classifying data; the code submission data can be divided into three categories according to the density of the node features: for example, low impact, medium impact, and high impact.
[0063] S240, the candidate risk probability and the candidate impact level are optimized to obtain the code change risk probability and the change risk impact level of the code submission data through joint loss function optimization.
[0064] S250, according to the code change risk probability and the change risk impact level, the risk contribution degree analysis of the multi-modal code feature is performed to obtain the feature contribution degree of the multi-modal code feature.
[0065] S260, the code change risk probability, the change risk impact level and the feature contribution degree are visualized and integrated to obtain the risk prediction result of the code submission data.
[0066] The embodiment of the application extracts multi-modal features from the code submission data obtained from the target distributed control system to obtain multi-modal code features of the code submission data; determines candidate risk probabilities of the code submission data based on a self-attention mechanism model according to code semantic features and code timing features; determines candidate impact levels of the code submission data based on a graph neural network model according to code structure features; optimizes the candidate risk probabilities and the candidate impact levels through joint loss function optimization to obtain code change risk probabilities and change risk impact levels of the code submission data; analyzes risk contribution degrees of the multi-modal code features according to the code change risk probabilities and the change risk impact levels to obtain feature contribution degrees of the multi-modal code features; and visualizes and integrates the code change risk probabilities, the change risk impact levels and the feature contribution degrees to obtain risk prediction results of the code submission data. The above technical solution extracts multi-modal code features of code submission data and performs risk prediction through multi-task modules, which helps to improve the accuracy and reliability of risk prediction.
[0067] Embodiment three
[0068] Figure 3 is a structural schematic diagram of a risk prediction device based on a distributed control system according to the third embodiment of the application, which can be applicable to the case of predicting project risks in software development project management. The risk prediction device based on a distributed control system can be realized in the form of hardware and / or software, and can be configured in a computer device, such as a server. As shown in the figure, the device includes: Figure 3
[0069] The feature extraction module 310 is configured to extract multi-modal features from the code submission data obtained from the target distributed control system to obtain multi-modal code features of the code submission data. The multi-modal code features include code structure features, code semantic features and code timing features.
[0070] The risk prediction module 320 is configured to determine code change risk probabilities and change risk impact levels of the code submission data based on a multi-task model according to the multi-modal code features. The multi-task model is composed of a self-attention mechanism model and a graph neural network model.
[0071] The contribution degree analysis module 330 is configured to analyze risk contribution degrees of the multi-modal code features according to the code change risk probabilities and the change risk impact levels to obtain feature contribution degrees of the multi-modal code features.
[0072] The result generation module 340 is configured to visualize and integrate the code change risk probabilities, the change risk impact levels and the feature contribution degrees to obtain risk prediction results of the code submission data.
[0073] The embodiment of the application extracts the multi-modal code features of the code submission data by performing multi-modal feature extraction on the code submission data obtained from the target distributed control system, wherein the multi-modal code features include code structure features, code semantic features, and code timing features; based on a multi-task model, the code change risk probability and the change risk impact level of the code submission data are determined according to the multi-modal code features; wherein the multi-task model is composed of a self-attention mechanism model and a graph neural network model; the risk contribution degree of the multi-modal code features is analyzed according to the code change risk probability and the change risk impact level, and the feature contribution degree of the multi-modal code features is obtained; the code change risk probability, the change risk impact level, and the feature contribution degree are visualized and integrated to obtain the risk prediction result of the code submission data. The above technical solution helps to improve the accuracy and reliability of risk prediction by extracting the multi-modal code features of the code submission data and performing risk prediction by the multi-task module.
[0074] Optionally, the risk prediction module 320 includes:
[0075] The risk probability determination unit is configured to determine the candidate risk probability of the code submission data based on the self-attention mechanism model according to the code semantic features and the code timing features.
[0076] The impact level determination unit is configured to determine the candidate impact level of the code submission data based on the graph neural network model according to the code structure features.
[0077] The result optimization unit is configured to optimize the candidate risk probability and the candidate impact level by a joint loss function to obtain the code change risk probability and the change risk impact level of the code submission data.
[0078] Optionally, the risk probability determination unit is specifically configured to:
[0079] Based on the self-attention mechanism model, the code semantic features and the code timing features are horizontally spliced to obtain at least one candidate feature matrix.
[0080] The position encoder in the self-attention mechanism model is used to perform timing encoding on the at least one candidate feature matrix according to the submission timestamp sequence in the code timing features to obtain a target feature matrix; wherein the timing encoding includes absolute position encoding and relative time interval encoding.
[0081] Based on the self-attention mechanism model, the candidate risk probability of the code submission data is determined according to the target feature matrix.
[0082] Optionally, the graph neural network model adopts a double-level hybrid graph convolution architecture; the first layer of the double-level hybrid graph convolution architecture adopts a multi-head graph attention network; the second layer adopts an edge feature enhanced graph isomorphism network; correspondingly, the influence level determination unit is specifically used for:
[0083] Based on the multi-head graph attention network, the attention weights between the nodes in the code structure feature are determined according to the candidate node features in the code structure feature;
[0084] Based on the graph isomorphism network, the target node features are obtained according to the candidate node features of each node in the code structure feature, and the candidate edge features and attention weights between the nodes;
[0085] The target node features are subjected to density-based three-cluster clustering to obtain the candidate influence levels of the code submission data.
[0086] Optionally, the feature extraction module 310 includes:
[0087] The structure feature determination unit is configured to perform code structure analysis on the code submission data obtained from the target distributed control system to obtain code structure features of the code submission data.
[0088] The semantic feature determination unit is configured to perform text semantic extraction on the code submission data to obtain code semantic features of the code submission data.
[0089] The time sequence feature determination unit is configured to perform time sequence and spatial feature extraction on the code submission data to obtain code time sequence features of the code submission data.
[0090] The feature integration unit is configured to integrate the code structure features, the code semantic features and the code time sequence features to obtain multi-modal code features of the code submission data.
[0091] Optionally, the structure feature determination unit is specifically configured to:
[0092] Perform abstract syntax tree analysis on the code submission data obtained from the target distributed control system to obtain a code syntax tree of the code submission data, and attach dynamic context features to the code syntax tree; the code syntax tree includes function declaration nodes, variable definition nodes and control structure nodes.
[0093] Determine a code dependency graph according to the code submission data through a static analysis tool.
[0094] Align the embedding features of the code syntax tree and the edge features of the code dependency graph through a feature projection matrix to obtain code structure features of the code submission data.
[0095] The risk prediction device based on a distributed control system provided in this application can execute the risk prediction method based on a distributed control system provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects for executing each risk prediction method based on a distributed control system.
[0096] According to embodiments of this application, this application also provides an electronic device, a readable storage medium, and a computer program product.
[0097] Example 4
[0098] Figure 4 This is a schematic diagram of the structure of an electronic device 410 implementing the risk prediction method based on a distributed control system according to embodiments of this application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital 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 present application described and / or claimed herein.
[0099] like Figure 4 As shown, the electronic device 410 includes at least one processor 411 and a memory, such as a read-only memory (ROM) 412 or a random access memory (RAM) 413, communicatively connected to the at least one processor 411. The memory stores computer programs executable by the at least one processor. The processor 411 can perform various appropriate actions and processes based on the computer program stored in the ROM 412 or loaded from storage unit 418 into the RAM 413. The RAM 413 may also store various programs and data required for the operation of the electronic device 410. The processor 411, ROM 412, and RAM 413 are interconnected via a bus 414. An input / output (I / O) interface 415 is also connected to the bus 414.
[0100] Multiple components in electronic device 410 are connected to I / O interface 415, including: input unit 416, such as keyboard, mouse, etc.; output unit 417, such as various types of displays, speakers, etc.; storage unit 418, such as disk, optical disk, etc.; and communication unit 419, such as network card, modem, wireless transceiver, etc. Communication unit 419 allows electronic device 410 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0101] The processor 411 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 411 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processors, controllers, microcontrollers, and the like. The processor 411 performs various methods and processes described above, such as the distributed control system-based risk prediction method.
[0102] In some embodiments, the distributed control system-based risk prediction method can be implemented as a computer program tangibly embodied in a computer readable storage medium, such as the storage unit 418. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 410 via the ROM 412 and / or the communication unit 419. When the computer program is loaded onto the RAM 413 and executed by the processor 411, one or more steps of the distributed control system-based risk prediction method described above can be performed. Alternatively, in other embodiments, the processor 411 can be configured as the distributed control system-based risk prediction method by any other appropriate means, such as by means of firmware.
[0103] Various implementations of the systems and techniques described above herein can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0104] A computer program for implementing the methods of the present application can be written in any combination of one or more programming languages. The computer program can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the computer program, when executed by the processor of the machine, produces an apparatus the functions / operations specified in the flowcharts and / or block diagrams. The computer program can execute entirely on a machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
[0105] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store the computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0106] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; 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 acoustic, speech, or tactile input.
[0107] The systems and techniques described herein can be implemented in a computing system that includes a back end component, e.g., as a data server, or that includes a middleware component, e.g., an application server, or that includes a front end component, e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described herein, or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0108] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. A server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, and solves the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.
[0109] It should be understood that the various forms of flow shown above can be re-ordered, added to, or deleted from without departing from the scope of the present disclosure. For example, the steps recited in the present disclosure can be executed in parallel, executed in sequence, or executed in different orders, as long as the desired results of the technical solutions of the present disclosure can be achieved, and the present disclosure is not limited herein.
[0110] The specific implementation described above does not constitute a limitation on the scope of protection of the present application. 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 replacements, and improvements made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A risk prediction method based on a distributed control system, characterized by, The method comprises the following steps: Multi-modal feature extraction is performed on the code submission data obtained from the target distributed control system to obtain multi-modal code features of the code submission data; wherein the multi-modal code features include code structure features, code semantic features and code timing features; Based on a multi-task model, the code change risk probability and the change risk impact level of the code submission data are determined according to the multi-modal code features; wherein the multi-task model is composed of a self-attention mechanism model and a graph neural network model; According to the code change risk probability and the change risk impact level, the risk contribution degree of the multi-modal code features is analyzed to obtain the feature contribution degree of the multi-modal code features; The code change risk probability, the change risk impact level and the feature contribution degree are visualized and integrated to obtain the risk prediction result of the code submission data.
2. The method of claim 1, wherein, Based on a multi-task model, the code change risk probability and the change risk impact level of the code submission data are determined according to the multi-modal code features, comprising: Based on the self-attention mechanism model, the candidate risk probability of the code submission data is determined according to the code semantic features and the code timing features; Based on the graph neural network model, the candidate impact level of the code submission data is determined according to the code structure features; Through joint loss function optimization, the candidate risk probability and the candidate impact level are optimized to obtain the code change risk probability and the change risk impact level of the code submission data.
3. The method of claim 2, wherein, Based on the self-attention mechanism model, the candidate risk probability of the code submission data is determined according to the code semantic features and the code timing features, comprising: Based on the self-attention mechanism model, the code semantic features and the code timing features are transversely spliced to obtain at least one candidate feature matrix; Through the position encoder in the self-attention mechanism model, the at least one candidate feature matrix is time series encoded according to the submission timestamp sequence in the code timing features to obtain a target feature matrix; wherein the time series encoding includes absolute position encoding and relative time interval encoding; Based on the self-attention mechanism model, the candidate risk probability of the code submission data is determined according to the target feature matrix.
4. The method of claim 2, wherein, The graph neural network model adopts a double-level hybrid graph convolution architecture; the first layer of the double-level hybrid graph convolution architecture adopts a multi-head graph attention network; the second layer adopts an edge feature enhanced graph isomorphism network; accordingly, based on the graph neural network model, the candidate impact level of the code submission data is determined according to the code structure features, comprising: Based on the multi-head graph attention network, the attention weight between nodes in the code structure features is determined according to the candidate node features in the code structure features; Based on the graph isomorphism network, the target node features are obtained according to the candidate node features of each node in the code structure features, and the candidate edge features and the attention weight between nodes; The target node features are subjected to density-based three-cluster clustering to obtain the candidate impact level of the code submission data.
5. The method of claim 1, wherein, The multi-modal feature extraction is performed on the code commit data obtained from the target distributed control system to obtain multi-modal code features of the code commit data, including: The code commit data obtained from the target distributed control system is subjected to code structure analysis to obtain code structure features of the code commit data; The code commit data is subjected to text semantic extraction to obtain code semantic features of the code commit data; The code commit data is subjected to time sequence and space feature extraction to obtain code time sequence features of the code commit data; The code structure features, the code semantic features and the code time sequence features are integrated to obtain the multi-modal code features of the code commit data.
6. The method of claim 5, wherein, The code commit data obtained from the target distributed control system is subjected to code structure analysis to obtain code structure features of the code commit data, including: The code commit data obtained from the target distributed control system is subjected to abstract syntax tree analysis to obtain a code syntax tree of the code commit data, and dynamic context features are attached to the code syntax tree; the code syntax tree includes function declaration nodes, variable definition nodes and control structure nodes; A code dependency graph is determined according to the code commit data by a static analysis tool; The embedding features of the code syntax tree and the edge features of the code dependency graph are latitude-aligned through a feature projection matrix to obtain the code structure features of the code commit data.
7. A risk prediction apparatus based on a distributed control system, characterized by, It includes: A feature extraction module is configured to perform multi-modal feature extraction on code commit data obtained from a target distributed control system to obtain multi-modal code features of the code commit data; wherein the multi-modal code features include code structure features, code semantic features and code time sequence features; A risk prediction module is configured to determine a code change risk probability and a change risk impact level of the code commit data based on a multi-task model according to the multi-modal code features; wherein the multi-task model is composed of a self-attention mechanism model and a graph neural network model; A contribution analysis module is configured to perform risk contribution analysis on the multi-modal code features according to the code change risk probability and the change risk impact level to obtain feature contributions of the multi-modal code features; A result generation module is configured to visually integrate the code change risk probability, the change risk impact level and the feature contributions to obtain a risk prediction result of the code commit data.
8. An electronic device, comprising: It includes: One or more processors; Memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the distributed control system-based risk prediction method of any one of claims 1-6.
9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the distributed control system-based risk prediction method of any one of claims 1-6.
10. A computer program product comprising a computer program which, when executed by a processor, implements the distributed control system-based risk prediction method according to any one of claims 1-6.
10. A computer program product comprising a computer program which, when executed by a processor, implements the distributed control system-based risk prediction method according to any one of claims 1-6.