Electric power AI safety detection model optimization method and system fusing attribution quantization and confrontation correction
By integrating attribution quantification and adversarial correction methods, the problems of black box and spurious correlation in power AI safety detection models have been solved, realizing transparency in model decision-making and autonomous optimization, reducing false alarm rate and improving operation and maintenance efficiency.
Patent Information
- Application Number
- CN202511921531.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-18
- Publication Date
- 2026-03-06
AI Technical Summary
Existing AI safety detection models in power systems suffer from problems such as black-box understanding of alarm semantics, spurious correlation learning, and a lack of automated correction methods, leading to insufficient trust from maintenance personnel and a high false alarm rate.
We employ a method that integrates attribution quantization and adversarial correction. Through structured semantic representation, hybrid attribution quantization, domain knowledge masking, and counterfactual sample generation, we can automatically diagnose model bias and perform closed-loop optimization.
It improves the transparency and trustworthiness of model decision-making, reduces the false alarm rate of environmental impact, and enhances the efficiency and robustness of model autonomous correction.
Smart Images

Figure CN121619216A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method and system for optimizing an AI-based power safety detection model that integrates attribution quantification and adversarial correction, belonging to the application of artificial intelligence in the field of cybersecurity. Background Technology
[0002] Currently, driven by the wave of new power system construction, the scale and complexity of power information infrastructure are surging, and the cybersecurity situation is becoming increasingly severe. To cope with massive and heterogeneous security data, the Power Security Operations Center (SOC) is widely introducing large-scale artificial intelligence models to automate the analysis and threat assessment of massive text alert logs from various security devices such as firewalls, intrusion detection systems (IDS), and web application firewalls (WAF). While the application of these large-scale models has greatly improved operational efficiency, the application of existing AI technology in the high-reliability power sector has exposed the following three technical bottlenecks:
[0003] (1) Black box of alarm semantic understanding: Operation and maintenance personnel cannot know whether the model judges it as a threat based on the actual attack payload in the alarm or irrelevant device IP and other information, resulting in insufficient trust in the AI judgment results;
[0004] (2) Pseudo-correlation learning based on text statistical features: In the power scenario, alarms generated by normal business operations often have fixed environmental features such as private protocol headers and specific IPs. The model is prone to mistakenly taking these high-frequency "environmental noises" as the basis for judging threats. Once the environment changes, the false alarm rate will surge.
[0005] (3) Lack of automated error correction methods for text semantics: Existing adversarial training is mostly aimed at image pixels, and lacks counterfactual sample generation and closed-loop fine-tuning mechanisms that can maintain the semantic coherence of business for discrete text data.
[0006] In existing technologies, model interpretability methods such as LIME and SHAP, and model robustness enhancement methods such as adversarial training, are usually independent of each other. The former focuses on explaining the model's decision-making basis after the fact, revealing the contribution of features but failing to proactively correct the model's inherent decision biases; the latter often involves global and blind reinforcement without clear guidance, resulting in low optimization efficiency and the potential for introducing new performance bottlenecks due to inappropriate perturbations. To address these issues, this invention constructs a power AI safety detection model optimization method that integrates attribution quantification and adversarial correction. This method enables automated root cause analysis and autonomous performance optimization of model false alarms, ultimately improving the reliability, automation level, and subjective trust of the power AI safety protection system. Summary of the Invention
[0007] This invention provides a method and system for optimizing a power AI safety detection model that integrates attribution quantification and adversarial correction. This improves the transparency and trustworthiness of model decision-making, reduces false alarms caused by environmental influences, and improves the efficiency of autonomous model correction.
[0008] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0009] An optimization method for a power AI safety detection model that integrates attribution quantization and adversarial correction includes the following steps:
[0010] Step 1: Structured semantic representation of heterogeneous security alarms in power networks. This involves transforming raw security logs from different vendors and in different formats into vector matrices that the model can understand and that contain semantic topological relationships.
[0011] Step 2: Based on the analysis of the model decision logic using hybrid attribution quantization, mathematical methods are used to accurately quantify the contribution of each token in the alarm log to the final judgment result of the model.
[0012] Step 3: Automated diagnosis of decision bias based on domain knowledge masking. By comparing the fields that the model actually focuses on with the fields that experts believe should be focused on, the system automatically determines whether the model has logical defects or biases.
[0013] Step 4: Construct adversarial examples based on counterfactual text. For models diagnosed as biased, counterfactual examples are generated by automatically modifying non-critical information in the alarm text to test and correct the model.
[0014] Step 5: Fine-tuning and optimization of the attribution regularization model closed loop. The parameters of the large model are updated using the generated correction samples. By introducing a special loss function, the attention focus of the model is forcibly corrected.
[0015] The aforementioned optimization method for power AI safety detection models that integrates attribution quantification and adversarial correction uses a hybrid attribution algorithm to analyze decision logic, utilizes domain knowledge to quantify model bias, and performs closed-loop correction optimization based on semantic counterfactual samples.
[0016] Existing threat detection models suffer from a high degree of opacity in their classification decision-making process when handling multi-source, heterogeneous security alert texts. Security operations personnel cannot accurately know which keyword or set of fields in the alert logs the model used to make a threat determination. This lack of information severely reduces the trust of operations personnel in AI detection results, leading to inefficient alert analysis and increasing the risk of human error. This application effectively improves the transparency and trustworthiness of the model's decision-making.
[0017] Due to biases in training data collection and the tendency of models to learn shortcuts, existing models are prone to learning non-causally related environmental features in alarm texts as classification criteria, rather than focusing on the true attack semantics. This pseudo-correlation causes the model's robustness to drop sharply when there are subtle changes in the power operating environment, resulting in a large number of high-weight false alarms. This application effectively reduces the model's false alarm problem caused by environmental influences.
[0018] When models are found to be biased or generate false positives, existing methods rely on time-consuming and laborious manual relabeling and full retraining, lacking targeted remediation mechanisms. For text-based alarm data, it is difficult to efficiently and automatically generate adversarial samples that can effectively test and correct the model's decision boundaries. This invention utilizes counterfactual samples as feedback signals to eliminate model bias in a targeted and efficient manner without sacrificing the model's generalization ability, achieving autonomous evolution and continuous performance optimization of the AI security detection model, and effectively improving the efficiency of the model's autonomous bias correction.
[0019] Step one above includes:
[0020] Step 101: Cleaning and unified classification mapping of multi-source heterogeneous logs. First, obtain multi-source log streams from the power network and clean the data using a pre-built regular expression engine to remove garbled characters and invalid characters. Then, establish a power network security alarm field mapping table to uniformly map private fields defined by different manufacturers to a standard field set. This step ensures the semantic consistency of the input data.
[0021] Step 102: Based on security domain knowledge, word segmentation and serialization are performed. A dedicated word segmenter vocabulary is constructed using a standard field set targeting common web attack characteristics such as power-specific network protocols, SQL injection fragments, and XSS code. Unlike general natural language processing word segmentation, this method treats common attack commands and hexadecimal opcodes as independent fields (tokens) to prevent semantic misinterpretation. Finally, the cleaned alarm text is converted into a token sequence. ,in For token;
[0022] Step 103: Fuse high-dimensional vector embeddings with location encodings, and use a BERT-like model pre-trained on a power network security corpus to transform the token sequence into a dense vector matrix. ,in For sequence length, The vector dimension is used; at the same time, positional encoding is superimposed to preserve the contextual information such as the relationship between attack commands in the alarm text. This vector matrix serves as the baseline input for subsequent attribution analysis.
[0023] In step 101 above, the multi-source log stream includes firewall logs, intrusion detection system (IDS) logs, and full-traffic probe logs, etc.
[0024] In step 101 above, the standard field set includes: Timestamp, Src / Dst_IP, Proto_Type, App_Layer_Content, and Alert_Msg.
[0025] Step two above includes:
[0026] Step 201: Calculate the fine-grained feature contribution based on the integral gradient. To capture the sensitivity of specific words or characters to the model gradient, the integral gradient value is calculated. This method constructs a baseline vector from all zeros. to the actual input vector The linear interpolation path, where This represents the high-dimensional vector embedding matrix output from step 103, containing all token semantics. The extracted vector is processed along the path. Second sampling, calculate the model output function. For input features The gradient expectation;
[0027]
[0028] in, This represents the direct contribution score for each token. Indicates the first alarm in the alarm. A vector of tokens, Represents the reference vector (usually the padding symbol). Indicates the number of samples. This indicates the sampling along the input path. Interpolation points.
[0029] Step 202: Calculate the global field importance based on Shapley values. To determine the precise contribution of each input feature, this method employs the Kernel SHAP method, treating structured data fields as participants in a cooperative game. By randomly masking a large number of fields and observing the changes in the model output, the approximate Shapley value of each field is calculated, thereby quantifying its marginal contribution and achieving a highly reliable model interpretation; define the feature set. Feature set For embedding matrix The logical division of the information it carries defines the smallest explanatory unit for our attribution analysis, for each feature. Its Shapley value The calculation formula is as follows:
[0030]
[0031] in, Indicates that it does not contain features Feature subset, Indicates the number of elements in the set. Representing a feature subset The predicted value function input into the model, Representation of features Join a subset The marginal contribution generated later. The final result. It can reflect the net contribution of the field to the model decision in the global context and eliminate the interference of correlation between features;
[0032] Step 203: Calculate the saliency scores of the fused local and global values. To balance local sensitivity and global importance, this method fuses the IG and SHAP values using a normalized weighted approach, defining a dynamic fusion formula to calculate the saliency score. The final saliency score of each token :
[0033]
[0034] in, and The integral gradient and Shapley value calculated in sub-steps 201 and 202 are respectively. and These are the sum of the integral gradient values and the sum of the Shapley values for all features, respectively. Balance coefficient (0≤ ≤1), adaptively adjusts based on the length of the alarm text (the longer the text, the higher the accuracy). The larger the value, the more emphasis is placed on local features. The sigmoid normalization function maps the scores to the [0,1] interval. Based on the scores... It can generate a visual heatmap of token contribution, marking the key areas that the model focuses on.
[0035] Step three above includes:
[0036] Step 301: Construct a power security expert attention mask. Using a built-in power attack and defense expert rule base, define logically valid and noisy feature regions for each type of alarm, such as brute-force attacks and buffer overflows. For example, for SQL injection alarms, the valid region should include URL parameters and SQL keywords in the HTTP body; while time, source port, and destination MAC address belong to the noise region. Based on this, generate a binary mask vector. In this case, the token position in the valid area is set to 1, and the noise area is set to 0.
[0037] Step 302: Measure the deviation between the model attention distribution and expert knowledge, and use the feature saliency score generated in Step 203. Normalized and expert mask Perform alignment calculations and define background dependencies. As a quantitative indicator of bias:
[0038]
[0039] This formula calculates the ratio of the model's attention falling on the noise region to the model's total attention. The closer a value is to 0, the more the model's attention is focused on... The defined effective feature regions demonstrate that the model's decisions are logically correct and robust;
[0040] Step 303: False alarm root cause classification and diagnosis triggering, setting bias threshold. ,like The model is deemed to have shortcut learning bias, meaning it over-relies on non-causal environmental features for decision-making, triggering subsequent correction processes; if However, if the prediction is wrong, it is determined that the model's feature extraction capability is insufficient or the sample labeling is incorrect, and an environment overfitting false alarm log is automatically output.
[0041] Step four above includes:
[0042] Step 401: Locate high-sensitivity non-causal tokens. Based on the calculation results of sub-step 302, the system extracts the set of tokens that are located in noisy feature regions but have abnormally high attribution scores. For example, in one false positive, the model incorrectly identified the normal private protocol header 0x68 (start character) as a malicious feature.
[0043] Step 402: Generate adversarial perturbations based on semantic constraints for the set. The tokens in the dataset are perturbed to preserve semantics, generating two types of counterfactual samples:
[0044] (1) Background replacement type: Keep the core attack payload (such as Payload) in the alarm unchanged, and replace the background information such as IP address, timestamp, and device ID by using a thesaurus or random sampling. If the model prediction result changes from "threat" to "safe", it confirms that the model is unstable.
[0045] (2) Core removal class: Keep the background information unchanged and replace the core attack payload with a harmless string. If the model still predicts "threat", it confirms that the model has serious background overfitting. This process uses BERT and other masked language models to generate fill-in-the-blank text to ensure that the generated text is still like a normal system log in terms of syntax.
[0046] Step 403: Screening and labeling of high-value correction samples. Input the generated counterfactual samples into the original model for inference, and screen out samples whose model prediction results do not match the expected logic, that is, samples whose attack features have not changed but the model has changed its judgment, or samples whose attack features are gone but the model still judges them as high-risk. Add these samples to the correction training set and automatically assign the correct labels.
[0047] Step five above includes:
[0048] Step 501: Construct the attribution alignment loss function. To fundamentally eliminate bias, the training objective not only requires the model to output the correct classification label, but also requires the model's gradient focus to regress to the expert-defined effective region. Construct a composite loss function:
[0049]
[0050] in, Represents the overall loss function. This represents the standard cross-entropy classification loss. Attribution loss is typically expressed using the L2 norm: ⊙ ; This represents an adjustable regularization hyperparameter that can be trained to achieve the best balance between ensuring high classification accuracy and eliminating model bias.
[0051] Step 502: Efficient adversarial fine-tuning of parameters. Considering the high cost of full fine-tuning of large models, this method adopts LoRA technology, inserting a trainable low-rank matrix only into the Attention layer of the model, and using the correction training set selected in step 403 for iterative training.
[0052] Step 503: Model Performance Validation and Dynamic Update. After fine-tuning, the model performance is validated using the retained test set, with a focus on evaluating cross-domain generalization ability, i.e., the detection rate on new IP segments or new devices. Once the bias metric drops below the threshold and accuracy improves, the updated model weights will be deployed to the production environment.
[0053] A power AI safety detection model optimization system that integrates attribution quantization and adversarial correction includes: a structured semantic representation module, which is used to convert raw safety logs from different manufacturers and in different formats into a vector matrix that the model can understand and that contains semantic topological relationships;
[0054] The model decision logic parsing module is used to accurately quantify the contribution of each token in the alarm log to the final judgment result of the model through mathematical means.
[0055] The automated decision bias diagnosis module is used to automatically determine whether the model has logical flaws or biases by comparing the fields that the model actually focuses on with the fields that experts believe should be focused on.
[0056] The adversarial example building module is used to generate counterfactual examples for testing and correcting models diagnosed as biased by automatically modifying non-critical information in the alert text.
[0057] The model closed-loop fine-tuning and optimization module is used to update the parameters of a large model using the generated correction samples. By introducing a special loss function, it forces the correction of the model's attention focus.
[0058] The above-mentioned mathematical methods precisely quantify the contribution of each token in the alarm log to the model's final judgment result, including:
[0059] Step 101: Cleaning and unified classification mapping of multi-source heterogeneous logs. First, obtain multi-source log streams from the power network and clean the data using a pre-built regular expression engine to remove garbled characters and invalid characters. Then, establish a power network security alarm field mapping table to uniformly map private fields defined by different manufacturers to a standard field set. This step ensures the semantic consistency of the input data.
[0060] Step 102: Based on security domain knowledge, word segmentation and serialization are performed. A dedicated word segmenter vocabulary is constructed using a standard field set targeting common web attack characteristics such as power-specific network protocols, SQL injection fragments, and XSS code. Unlike general natural language processing word segmentation, this method treats common attack commands and hexadecimal opcodes as independent fields (tokens) to prevent semantic misinterpretation. Finally, the cleaned alarm text is converted into a token sequence. ,in For token;
[0061] Step 103: Fuse high-dimensional vector embeddings with location encodings, and use a BERT-like model pre-trained on a power network security corpus to transform the token sequence into a dense vector matrix. ,in For sequence length, The vector dimension is used; at the same time, positional encoding is superimposed to preserve the contextual information such as the relationship between attack commands in the alarm text. This vector matrix serves as the baseline input for subsequent attribution analysis.
[0062] The above-mentioned mathematical methods precisely quantify the contribution of each token in the alarm log to the model's final judgment result, including:
[0063] Step 201: Calculate the fine-grained feature contribution based on the integral gradient. To capture the sensitivity of specific words or characters to the model gradient, the integral gradient value is calculated. This method constructs a baseline vector from all zeros. to the actual input vector The linear interpolation path, where This represents the high-dimensional vector embedding matrix output from step 103, containing all token semantics. The extracted vector is processed along the path. Second sampling, calculate the model output function. For input features The gradient expectation;
[0064]
[0065] in, This represents the direct contribution score for each token. Indicates the first alarm in the alarm. A vector of tokens, Represents the reference vector (usually the padding symbol). Indicates the number of samples. This indicates the sampling along the input path. Interpolation points.
[0066] Step 202: Calculate the global field importance based on Shapley values. To determine the precise contribution of each input feature, this method employs the Kernel SHAP method, treating structured data fields as participants in a cooperative game. By randomly masking a large number of fields and observing the changes in the model output, the approximate Shapley value of each field is calculated, thereby quantifying its marginal contribution and achieving a highly reliable model interpretation; define the feature set. Feature set For embedding matrix The logical division of the information it carries defines the smallest explanatory unit for our attribution analysis, for each feature. Its Shapley value The calculation formula is as follows:
[0067]
[0068] in, Indicates that it does not contain features Feature subset, Indicates the number of elements in the set. Representing a feature subset The predicted value function input into the model, Representation of features Join a subset The marginal contribution generated later. The final result. It can reflect the net contribution of the field to the model decision in the global context and eliminate the interference of correlation between features;
[0069] Step 203: Calculate the saliency scores of the fused local and global values. To balance local sensitivity and global importance, this method fuses the IG and SHAP values using a normalized weighted approach, defining a dynamic fusion formula to calculate the saliency score. The final saliency score of each token :
[0070]
[0071] in, and The integral gradient and Shapley value calculated in sub-steps 201 and 202 are respectively. and These are the sum of the integral gradient values and the sum of the Shapley values for all features, respectively. Balance coefficient (0≤ ≤1), adaptively adjusts based on the length of the alarm text (the longer the text, the higher the accuracy). The larger the value, the more emphasis is placed on local features. The sigmoid normalization function maps the scores to the [0,1] interval. Based on the scores... It can generate a visual heatmap of token contribution, marking the key areas that the model focuses on.
[0072] The above method automatically determines whether the model has logical flaws or biases by comparing the fields that the model actually focuses on with the fields that experts believe should be focused on, including:
[0073] Step 301: Construct a power security expert attention mask. Using a built-in power attack and defense expert rule base, define logically valid and noisy feature regions for each type of alarm, such as brute-force attacks and buffer overflows. For example, for SQL injection alarms, the valid region should include URL parameters and SQL keywords in the HTTP body; while time, source port, and destination MAC address belong to the noise region. Based on this, generate a binary mask vector. In this case, the token position in the valid area is set to 1, and the noise area is set to 0.
[0074] Step 302: Measure the deviation between the model attention distribution and expert knowledge, and use the feature saliency score generated in Step 203. Normalized and expert mask Perform alignment calculations and define background dependencies. As a quantitative indicator of bias:
[0075]
[0076] This formula calculates the ratio of the model's attention falling on the noise region to the model's total attention. The closer a value is to 0, the more the model's attention is focused on... The defined effective feature regions demonstrate that the model's decisions are logically correct and robust;
[0077] Step 303: False alarm root cause classification and diagnosis triggering, setting bias threshold. ,like The model is deemed to have shortcut learning bias, meaning it over-relies on non-causal environmental features for decision-making, triggering subsequent correction processes; if However, if the prediction is wrong, it is determined that the model's feature extraction capability is insufficient or the sample labeling is incorrect, and an environment overfitting false alarm log is automatically output.
[0078] For models diagnosed as biased, the above-mentioned counterfactual samples are generated to test and correct the models by automatically modifying non-critical information in the alert text, including:
[0079] Step 401: Locate high-sensitivity non-causal tokens. Based on the calculation results of sub-step 302, the system extracts the set of tokens that are located in noisy feature regions but have abnormally high attribution scores. For example, in one false positive, the model incorrectly identified the normal private protocol header 0x68 (start character) as a malicious feature.
[0080] Step 402: Generate adversarial perturbations based on semantic constraints for the set. The tokens in the dataset are perturbed to preserve semantics, generating two types of counterfactual samples:
[0081] (1) Background replacement type: Keep the core attack payload (such as Payload) in the alarm unchanged, and replace the background information such as IP address, timestamp, and device ID by using a thesaurus or random sampling. If the model prediction result changes from "threat" to "safe", it confirms that the model is unstable.
[0082] (2) Core removal class: Keep the background information unchanged and replace the core attack payload with a harmless string. If the model still predicts "threat", it confirms that the model has serious background overfitting. This process uses BERT and other masked language models to generate fill-in-the-blank text to ensure that the generated text is still like a normal system log in terms of syntax.
[0083] Step 403: Screening and labeling of high-value correction samples. Input the generated counterfactual samples into the original model for inference, and screen out samples whose model prediction results do not match the expected logic, that is, samples whose attack features have not changed but the model has changed its judgment, or samples whose attack features are gone but the model still judges them as high-risk. Add these samples to the correction training set and automatically assign the correct labels.
[0084] The above-mentioned method uses the generated correction samples to update the parameters of a large model. By introducing a special loss function, the model's attention focus is forcibly corrected, including:
[0085] Step 501: Construct the attribution alignment loss function. To fundamentally eliminate bias, the training objective not only requires the model to output the correct classification label, but also requires the model's gradient focus to regress to the expert-defined effective region. Construct a composite loss function:
[0086]
[0087] in, Represents the overall loss function. This represents the standard cross-entropy classification loss. Attribution loss is typically expressed using the L2 norm: ⊙ ; This represents an adjustable regularization hyperparameter that can be trained to achieve the best balance between ensuring high classification accuracy and eliminating model bias.
[0088] Step 502: Efficient adversarial fine-tuning of parameters. Considering the high cost of full fine-tuning of large models, this method adopts LoRA technology, inserting a trainable low-rank matrix only into the Attention layer of the model, and using the correction training set selected in step 403 for iterative training.
[0089] Step 503: Model Performance Validation and Dynamic Update. After fine-tuning, the model performance is validated using the retained test set, with a focus on evaluating cross-domain generalization ability, i.e., the detection rate on new IP segments or new devices. Once the bias metric drops below the threshold and accuracy improves, the updated model weights will be deployed to the production environment.
[0090] Any techniques not mentioned in this invention are based on existing technologies.
[0091] Compared with the prior art, the present invention has the following beneficial effects:
[0092] (1) Enhance the interpretability of large model decision analysis: By analyzing the model decision logic based on hybrid attribution quantization, the abstract neural network calculation process is transformed into a visualized key node decision analysis, so that security operation and maintenance personnel can intuitively see that the model makes judgments based on specific attack code rather than random noise, which greatly improves the efficiency of human-machine collaboration.
[0093] (2) Improve the root cause localization capability of false positives in large models: The background dependency designed in this method Indicators mathematically quantify the abstract concept of model bias, enabling the system to automatically distinguish between data quality issues and model logic issues.
[0094] (3) Enhancing the autonomous repair and optimization capabilities of large models: Unlike traditional manual retraining models, this method constructs an automated model adversarial optimization mechanism. By continuously generating counterfactual text to attack model weaknesses and performing attribution regularization repair, the model can actively remove environmental noise and has stronger robustness and anti-interference capabilities in complex power network environments. Attached Figure Description
[0095] Figure 1 This is a flowchart of the power AI safety detection model optimization method that integrates attribution quantization and adversarial correction according to the present invention. Detailed Implementation
[0096] To better understand the present invention, the following embodiments further illustrate the content of the present invention, but the content of the present invention is not limited to the following embodiments.
[0097] An optimization method for power AI safety detection model that integrates attribution quantification and adversarial correction is proposed. This method analyzes decision logic through a hybrid attribution algorithm, quantifies model bias by utilizing domain knowledge, and performs closed-loop correction optimization based on semantic counterfactual samples.
[0098] The specific steps are as follows:
[0099] Step 1: Structured semantic representation of heterogeneous security alarms in power networks;
[0100] Step 2: Analysis of model decision-making logic based on hybrid attribution quantification;
[0101] Step 3: Automated diagnosis of decision bias based on domain knowledge masking;
[0102] Step 4: Constructing adversarial examples based on counterfactual text generation;
[0103] Step 5: Fine-tuning and optimization of the attribution regularization model closed loop.
[0104] Step 1: Structured semantic representation of heterogeneous security alarms in power networks. The purpose of this step is to transform raw security logs from different vendors and in different formats into vector matrices that the model can understand and that contain semantic topological relationships.
[0105] Step 101: Cleaning and Unified Classification Mapping of Multi-Source Heterogeneous Logs. This method first acquires multi-source log streams from the power network, including those from firewalls, intrusion detection systems (IDS), and full-traffic probes. A pre-built regular expression engine is used for data cleaning to remove garbled characters and invalid strings. Subsequently, a power network security alarm field mapping table is established, uniformly mapping proprietary fields defined by different vendors to a standard field set, including: Timestamp, Src / Dst_IP (source / destination IP), Proto_Type (protocol type), App_Layer_Content (application layer content), and Alert_Msg (alarm description information). This step ensures the semantic consistency of the input data.
[0106] Step 102: Security Domain Knowledge-Based Tokenization and Serialization. A dedicated tokenizer lexicon is constructed to address common web attack characteristics such as dedicated power network protocols, SQL injection fragments, and XSS code. Unlike general natural language processing tokenization, this method treats common attack commands and hexadecimal opcodes as independent fields (tokens) to prevent semantic misinterpretation. Finally, the cleaned alarm text is converted into a token sequence. ,in For tokens.
[0107] Step 103: High-dimensional vector embedding with location encoding. Using a BERT-like model pre-trained on a power network security corpus, the token sequence is transformed into a dense vector matrix. ,in For sequence length, The vector dimension is used. Simultaneously, positional encoding is overlaid to preserve contextual information such as the relationship between attack commands in the alert text. This vector matrix serves as the baseline input for subsequent attribution analysis.
[0108] Step two: Analysis of model decision logic based on hybrid attribution quantization. This step aims to analyze the model's decision logic and use mathematical methods to accurately quantify the contribution of each token in the alarm log to the model's final judgment.
[0109] Step 201: Calculate fine-grained feature contributions based on integral gradients. To capture the sensitivity of specific words or characters to model gradients, integral gradient values are calculated. This method constructs a baseline vector from all zeros. to the actual input vector The linear interpolation path, where This represents the high-dimensional vector embedding matrix output from step 103, containing all token semantics. Extracted vector. Performed along the path. Second sampling, calculate the model output function. For input features The gradient expectation.
[0110]
[0111] in, This represents the direct contribution score for each token. Indicates the first alarm in the alarm. A vector of tokens, Represents the reference vector (usually the padding symbol). Indicates the number of samples. This indicates the sampling along the input path. Interpolation points.
[0112] Step 202: Calculate global field importance based on Shapley values. To determine the precise contribution of each input feature, this method employs the Kernel SHAP method, treating structured data fields as participants in a cooperative game. By randomly masking a large number of fields and observing the changes in the model output, an approximate Shapley value for each field is calculated, thereby quantifying its marginal contribution and achieving a highly reliable model interpretation. Define the feature set. Feature set For embedding matrix The logical division of the information it carries defines the smallest explanatory unit for our attribution analysis. For each feature... Its Shapley value The calculation formula is as follows:
[0113]
[0114] in, Indicates that it does not contain features Feature subset, Indicates the number of elements in the set. Representing a feature subset The predicted value function input into the model, Representation of features Join a subset The marginal contribution generated later. The final result. It can reflect the net contribution of the field to the model decision in the global context and eliminate the interference of correlation between features.
[0115] Step 203: Calculate the saliency scores of the fused local and global values. To balance local sensitivity and global importance, this method fuses the IG and SHAP values using a normalized weighted approach. Define a dynamic fusion formula and calculate the... The final saliency score of each token :
[0116]
[0117] in, and The integral gradient and Shapley value calculated in sub-steps 201 and 202 are respectively. and These are the sum of the integral gradient values and the sum of the Shapley values for all features, respectively. Balance coefficient (0≤ ≤1), adaptively adjusts based on the length of the alarm text (the longer the text, the higher the accuracy). The larger the value, the more emphasis is placed on local features. The sigmoid normalization function maps the scores to the [0,1] interval. Based on the scores... It can generate a visual heatmap of token contribution, marking the key areas that the model focuses on.
[0118] Step 3: Automated diagnosis of decision bias based on domain knowledge masking. This step automatically determines whether the model has logical flaws or biases by comparing the fields the model actually focuses on with the fields that experts believe should be focused on.
[0119] Step 301: Construct a power security expert attention mask. Using a built-in power attack and defense expert rule base, define logically valid and noisy feature regions for each type of alarm, such as brute-force attacks and buffer overflows. For example, for SQL injection alarms, the valid region should include URL parameters and SQL keywords in the HTTP body; while time, source port, and destination MAC address belong to the noise region. Based on this, generate a binary mask vector. In this case, the valid area corresponds to the token position and is set to 1, while the noise area is set to 0.
[0120] Step 302: Measurement of the deviation between model attention distribution and expert knowledge. The feature saliency score generated in Step 203 is then used. Normalized and expert mask Perform alignment calculations. Define background dependencies. As a quantitative indicator of bias:
[0121]
[0122] This formula calculates the ratio of the model's attention falling on the noise region to the model's total attention. The closer a value is to 0, the more the model's attention is focused on... The defined effective feature regions demonstrate that the model's decisions are logically correct and robust.
[0123] Step 303: False Alarm Root Cause Classification and Diagnostic Trigger. Set the bias threshold. .like The model is deemed to have shortcut learning bias, meaning it over-relies on non-causal environmental features for decision-making, triggering subsequent correction processes. If However, if the prediction is wrong, it is determined that the model's feature extraction capability is insufficient or the sample labeling is incorrect, and an environment overfitting false alarm log is automatically output.
[0124] Step four: Constructing adversarial examples based on counterfactual text. For models diagnosed as biased, this step generates counterfactual examples by automatically modifying non-critical information in the alert text to test and correct the model.
[0125] Step 401: Locate high-sensitivity non-causal tokens. Based on the calculation results of sub-step 302, the system extracts the set of tokens that are located in noisy feature regions but have abnormally high attribution scores. For example, in one false positive, the model incorrectly identified the normal private protocol header 0x68 (start character) as a malicious signature.
[0126] Step 402: Adversarial perturbation generation based on semantic constraints. For the set... The tokens in the dataset are perturbed to preserve semantics, generating two types of counterfactual samples:
[0127] (1) Background replacement type: Keep the core attack payload (such as payload) in the alarm unchanged, and replace the background information such as IP address, timestamp, and device ID using a thesaurus or random sampling. If the model prediction result reverses from "threat" to "safe", it confirms that the model is unstable.
[0128] (2) Core Removal Class: Keeping the background information unchanged, the core attack payload is replaced with a harmless string. If the model still predicts "threat", it confirms that the model has serious background overfitting. This process uses masked language models such as BERT to generate fill-in-the-blank text to ensure that the generated text still looks like a normal system log in terms of syntax.
[0129] Step 403: Screening and Labeling of High-Value Correction Samples. Input the generated counterfactual samples into the original model for inference. Screen samples whose model predictions do not match the expected logic, i.e., samples where the attack features remain unchanged but the model has changed its judgment, or samples where the attack features are gone but the model still classifies them as high-risk. Add these samples to the correction training set and automatically assign them the correct labels.
[0130] Step 5: Fine-tuning and optimization of the attribution-regularized model loop. This step uses the generated correction samples to update the parameters of the large model and introduces a special loss function to forcibly correct the model's attention focus.
[0131] Step 501: Construct the attribution alignment loss function. To fundamentally eliminate bias, the training objective not only requires the model to output the correct classification label, but also requires the model's gradient focus to regress to the expert-defined effective region. Construct a composite loss function:
[0132]
[0133] in, Represents the overall loss function. This represents the standard cross-entropy classification loss. Attribution loss is typically expressed using the L2 norm: ⊙ . This represents an adjustable regularization hyperparameter that can be trained to achieve the optimal balance between ensuring high classification accuracy and eliminating model bias.
[0134] Step 502: Parameter-efficient adversarial fine-tuning. Considering the high cost of full-scale fine-tuning of large models, this method uses LoRA technology, inserting a trainable low-rank matrix only into the Attention layer of the model, and iteratively training using the correction training set selected in step 403.
[0135] Step 503: Model Performance Validation and Dynamic Update. After fine-tuning, the model performance is validated using the retained test set, with a focus on evaluating cross-domain generalization ability, i.e., the detection rate on entirely new IP ranges or new devices. Once the bias metric drops below the threshold and accuracy improves, the updated model weights will be deployed to the production environment.
[0136] The above method enhances the interpretability of large-scale model decision analysis: by using a hybrid attribution quantization-based model decision logic analysis, the abstract neural network computation process is transformed into a visualized key node decision analysis, allowing security operations personnel to intuitively see that the model's judgments are based on specific attack code rather than random noise, significantly improving human-machine collaboration efficiency. It also improves the root cause localization capability of large-scale model false positives: through the background dependency designed in this method... The indicator mathematically quantifies the abstract concept of model bias, enabling the system to automatically distinguish between data quality issues and model logic problems. It enhances the autonomous repair and optimization capabilities of large models: unlike traditional manual model retraining, this method constructs an automated model adversarial optimization mechanism. By continuously generating counterfactual text to attack model weaknesses and performing attribution regularization repair, the model can proactively isolate environmental noise, exhibiting stronger robustness and anti-interference capabilities in complex power network environments.
Claims
1. A method for optimizing an electric power AI security detection model by fusing attribution quantification and adversarial rectification, characterized in that: Comprise the following steps: Step one, the structured semantic representation of heterogeneous security alarm of power network, the original security log from different manufacturers and different formats is converted into a vector matrix that can be understood by the model and contains semantic topological relationship; Step two, model decision logic analysis based on mixed attribution quantification, accurately quantify the contribution value of each token in the alarm log to the final judgment result of the model through mathematical means; Step three, decision bias automatic diagnosis based on domain knowledge mask, automatically determine whether the model has logical defects or bias by comparing the fields actually concerned by the model with the fields that experts believe should be concerned; Step four, construction of adversarial samples based on counterfactual text generation, for the model diagnosed as having bias, generate counterfactual samples by automatically modifying non-critical information in the alarm text to test and correct the model; Step five, model closed-loop fine-tuning and optimization based on attribution regularization, update the parameters of the large model using the generated bias correction samples, and force the model to correct its attention focus by introducing a special loss function.
2. The power AI security detection model optimization method of fusing attribution quantification and countermeasure correction according to claim 1, characterized in that: Step one includes: Step 101: cleaning and unified classification mapping of multi-source heterogeneous logs, first, obtain the multi-source log stream in the power network, use the pre-set regular expression engine for data cleaning, remove garbled codes and invalid characters; then, establish a field mapping table of power network security alarm, and unify the private fields defined by different manufacturers into a standard field set; Step 102: based on the security field knowledge of word segmentation and serialization, using the standard field set for the power special network protocol and the SQL injection segment and XSS code of the web attack characteristics, a special word segmentation table is constructed; common attack instructions and hexadecimal operation codes are processed as independent field tokens to prevent semantic errors from being disassembled, and finally the cleaned alarm text is converted into a token sequence wherein is a token; Step 103: Fusion of position-encoding high-dimensional vector embeddings, the token sequence is converted into a dense vector matrix using a BERT-like model pre-trained on a power grid security corpus wherein is the sequence length, is the vector dimension; at the same time, position encoding is superimposed to retain the context relationship order information of attack instructions in the alarm text, and the vector matrix serves as the benchmark input for subsequent attribution analysis.
3. The power AI security detection model optimization method of claim 2, wherein: In step 101, the multi-source log stream includes firewall logs, intrusion detection system logs and full-flow probe logs.
4. The power AI security detection model optimization method of claim 2, wherein: In step 101, the standard field set includes: Timestamp, Src / Dst_IP, Proto_Type, App_Layer_Content and Alert_Msg.
5. The power AI security detection model optimization method of claim 2, wherein: Step two includes: Step 201: Compute integral gradient-based fine-grained feature contribution, to capture the sensitivity of specific words or characters to the model gradient, compute the integral gradient value, construct a linear interpolation path from the all-zero baseline vector to the actual input vector , where denotes the high-dimensional vector embedding matrix output by step 103 containing all token semantics extracted vectors on the path, perform times sampling, and compute the gradient expectation of the model output function with respect to the input features ; , wherein, represents the direct contribution score of each token, represents the vector of the token in the alert, represents the reference vector (usually the Padding token), represents the number of samples, represents the interpolation point along the input path at which the sample is taken; Step 202: Calculate the global field importance based on Shapley value, in order to determine the accurate contribution of each input feature, the Kernel SHAP method is adopted, the structured data field is regarded as the participant in the cooperative game, the approximate Shapley value of each field is calculated by randomly masking part of the field and observing the change of the model output, so as to quantify its marginal contribution, realize high credibility model explanation; define the feature set , the feature set is a logical division of the information carried by the embedding matrix , defines the minimum explanation unit when performing attribution analysis, for each feature , the Shapley value is calculated as follows: , wherein, denotes a subset of features that does not contain the feature denotes the number of set elements, denotes a subset of features a prediction value function when inputting a model, denotes a feature joins the subset the marginal contribution generated after, the final obtained can reflect the net contribution value of the field to the model decision in the global background, eliminate the interference between features. Step 203: Calculate the fused local and global saliency scores, in order to balance the local sensitivity and global importance, the IG value and the SHAP value are fused by normalized weighting, the dynamic fusion formula is defined, and the final saliency score of the token is calculated : , where, and are the integral gradient values and Shapley values calculated in sub-steps 201 and 202, respectively, and are the integral gradient values and Shapley values of all features, respectively, is a balance coefficient (0≤ ≤1) that is used to adaptively adjust according to the length of the alarm text (the longer the text, the larger , to focus on local features), is a Sigmoid normalization function that maps the score to the [0, 1] interval; according to the score , a visual heat map of token contribution can be generated, marking the key areas of model attention.
6. The power AI security detection model optimization method of claim 5, wherein: Step three includes: Step 301: Constructing the power security expert attention mask, through the built-in power attack and defense expert rule library, defining the logical valid feature area and noise feature area for each type of alarm, and generating a binary mask vector wherein the valid area is set to 1 at the token position, and the noise area is set to 0; Step 302: Model attention distribution bias measure with expert knowledge, feature saliency score generated in step 203 Normalized with expert mask Aligning computation, define background dependency As bias quantification indicator: , The formula calculates the proportion of model attention falling in the noise region and the total model attention, The closer to 0 indicates that the model focuses almost all attention on The defined effective feature region, which indicates that the model decision is logically correct and robust; Step 303: False positive root cause classification and diagnosis trigger, set bias threshold If , it is determined that the shortcut learning bias exists in the model, that is, the model excessively relies on non-causal environmental characteristics for decision-making, and a subsequent bias correction process is triggered; if But the prediction is wrong, it is determined that the model feature extraction ability is insufficient or the sample labeling is wrong, and an environmental overfitting false positive log is automatically output.
7. The method of claim 6, wherein the method further comprises: determining a plurality of power consumption values of the power consumption of the electronic device; and determining a plurality of power consumption values of the power consumption of the electronic device based on the plurality of power consumption values of the power consumption of the electronic device. Step four includes: Step 401: Locking the high-sensitivity non-causal tokens, according to the calculation results of sub-step 302, the system extracts the token set located in the noise feature area but with an abnormally high attribution score ; Step 402: generating perturbations based on semantic constraints that preserve semantics of tokens in the set (1) Background replacement type: keep the core attack payload unchanged, use synonym dictionary or random sampling to replace background information, if the model prediction result changes from "threat" to "safe", it proves that the model is unstable; (2) Core elimination type: keep the background information unchanged, replace the core attack payload with harmless strings, if the model still predicts "threat", it proves that the model has serious background overfitting; this process uses BERT mask language model to fill in the blanks to ensure that the generated text is still a normal system log in terms of syntax structure; Step 403: screening and labeling of high-value bias correction samples, input the generated counterfactual samples into the original model for reasoning, select the samples whose model prediction result does not match the expected logic, that is, the attack features have not changed but the model has changed the judgment, or the attack features have disappeared but the model still judges as high risk, add these samples to the bias correction training set, and automatically assign the correct label.
8. The method of claim 7, wherein the method further comprises: Step five includes: Step 501: construct attribution alignment loss function, in order to fundamentally eliminate bias, the training target not only requires the model to output the correct classification label, but also requires the model's gradient focus to return to the effective area defined by experts, construct a composite loss function: , wherein, represents the overall loss function, represents the standard cross-entropy classification loss, represents the attribution loss, adopting L2 norm: ⊙ ; represents the adjustable regularization hyper-parameter, which can be trained to achieve the best balance between ensuring high classification accuracy and eliminating model bias; Step 502: Parameter-efficient adversarial fine-tuning, using LoRA to insert a trainable low-rank matrix only in the Attention layer of the model, and using the rectified training set selected in step 403 for iterative training; Step 503: model performance verification and dynamic update, after fine-tuning, the reserved test set is used to verify the model performance, focusing on the cross-domain generalization ability, that is, the detection rate on a new IP segment or a new device, when When the bias index falls below the threshold value and the accuracy is improved, the updated model weight is deployed to the production environment.
9. A power AI security detection model optimization system that fuses attribution quantification and adversarial rectification, characterized in that: Comprise: The structured semantic representation module is used to convert the original security logs from different manufacturers and different formats into vector matrices that can be understood by the model and contain semantic topological relations; The model decision logic analysis module is used to accurately quantify the contribution value of each token in the alarm log to the final judgment result of the model through mathematical means; The decision bias automatic diagnosis module is used to automatically determine whether the model has logical defects or bias by comparing the fields actually focused on by the model with the fields that experts believe should be focused on; The adversarial sample construction module is used to generate counterfactual samples to test and correct the model by automatically modifying non-critical information in the alarm text for models diagnosed as having bias; The model closed-loop fine-tuning and optimization module is used to update the parameters of the large model using the rectified samples, and to force the focus of the model's attention by introducing a special loss function.
10. The power AI safety detection model optimization system integrating attribution quantification and adversarial correction as described in claim 9, characterized in that: Accurately quantify the contribution value of each token in the alarm log to the final judgment result of the model through mathematical means, including: Step 101: Cleaning and unified classification mapping of multi-source heterogeneous logs, first, obtain the multi-source log stream in the power network, use the pre-set regular expression engine for data cleaning, remove garbled codes and invalid characters; then, establish a power network security alarm field mapping table, and map the private fields defined by different manufacturers to a standard field set; Step 102: based on the security field knowledge of word segmentation and serialization, using the standard field set for the power special network protocol and the SQL injection segment and XSS code of the web attack characteristics, a special word segmentation table is constructed; common attack instructions and hexadecimal operation codes are processed as independent field tokens to prevent semantic errors from being disassembled, and finally the cleaned alarm text is converted into a token sequence wherein is a token; Step 103: Fusion of position-encoding high-dimensional vector embeddings, the token sequence is converted into a dense vector matrix using a BERT-like model pre-trained on a power grid security corpus wherein is the sequence length, is the vector dimension; meanwhile, position encoding is superimposed to preserve the context relationship of attack instructions in the alarm text, and the vector matrix serves as the reference input for subsequent attribution analysis; Accurately quantify the contribution value of each token in the alarm log to the final judgment result of the model through mathematical means, including: Step 201: Compute integral gradient-based fine-grained feature contribution, to capture the sensitivity of specific words or characters to the model gradient, compute the integral gradient value, construct a linear interpolation path from the all-zero baseline vector to the actual input vector , where denotes the high-dimensional vector embedding matrix containing all token semantics output by step 103 extracted vectors are sampled times on the path, and the gradient expectation of the model output function with respect to the input features is calculated; , wherein, represents the direct contribution score of each token, represents the vector of the token in the alert, represents the reference vector (usually the Padding token), represents the number of samples, represents the interpolation point along the input path at which the sample is taken; Step 202: Calculate the global field importance based on Shapley value, in order to determine the accurate contribution of each input feature, the Kernel SHAP method is adopted, the structured data field is regarded as the participant in the cooperative game, the approximate Shapley value of each field is calculated by randomly masking part of the field and observing the change of the model output, so as to quantify its marginal contribution, realize high credibility model explanation; define the feature set , the feature set is a logical division of the information carried by the embedding matrix , defines the minimum explanation unit when performing attribution analysis, for each feature , the Shapley value is calculated as follows: , wherein, denotes a subset of features that does not contain the feature denotes the number of set elements, denotes a subset of features a prediction value function when inputting the model, denotes a feature joins the subset and the marginal contribution generated after, the final can reflect the net contribution value of the field to the model decision in the global background, eliminating the interference between features. Step 203: Calculate the saliency scores of the fused local and global values. To balance local sensitivity and global importance, the IG and SHAP values are fused using a normalized weighted method. A dynamic fusion formula is defined to calculate the saliency score of the fused local and global values. The final significance score of each token : , where, and are the integral gradient values and Shapley values calculated in sub-steps 201 and 202, respectively, and are the total integral gradient values and total Shapley values of all features, respectively, is a balance coefficient (0≤ ≤1) that is used to adaptively adjust according to the length of the alarm text (the longer the text, the larger , to focus on local features), is a Sigmoid normalization function that maps the score to the interval [0, 1]; according to the score , a visual heat map of token contribution can be generated to mark the key areas of model attention. Automatically determine whether the model has logical defects or bias by comparing the fields actually focused on by the model with the fields that experts believe should be focused on, including: Step 301: Constructing the power security expert attention mask, through the built-in power attack and defense expert rule library, defining the logical valid feature area and noise feature area for each type of alarm, and generating a binary mask vector wherein the valid area is set to 1 at the token position, and the noise area is set to 0; Step 302: Model attention distribution bias measure with expert knowledge, feature saliency scores generated in step 203 Normalized with expert mask Aligning computation, define background dependency As bias quantification indicator: , The formula calculates the proportion of model attention falling in the noise region to the total model attention, The closer to 0 indicates that the model focuses almost all attention on the defined valid feature region, indicating that the model decision is logically correct and robust; Step 303: False positive root cause classification and diagnosis trigger, set bias threshold If , it is determined that the shortcut learning bias exists in the decision model, that is, the model excessively relies on non-causal environmental characteristics for decision-making, and a subsequent bias correction process is triggered; if But the prediction is wrong, it is determined that the model feature extraction capability is insufficient or the sample labeling is wrong, and an environmental overfitting false positive log is automatically output. For models diagnosed as having bias, generate counterfactual samples to test and correct the model by automatically modifying non-critical information in the alarm text, including: Step 401: Locking the high-sensitivity non-causal tokens, according to the calculation results of sub-step 302, the system extracts the token set located in the noise feature area but with an abnormally high attribution score ; Step 402: generating perturbations based on semantic constraints that preserve semantics of tokens in the set (1) Background replacement type: keep the core attack payload unchanged, use a thesaurus or random sampling to replace the background information, if the model prediction result changes from "threat" to "safe", it proves that the model is unstable; (2) Core elimination type: keep the background information unchanged, replace the core attack payload with harmless strings, if the model still predicts "threat", it proves that the model has serious background overfitting; this process uses the BERT mask language model to fill in the blanks, ensuring that the generated text is still a normal system log in terms of syntax structure; Step 403: Selection and labeling of high-value rectified samples, input the generated counterfactual samples into the original model for reasoning, select samples whose model prediction results do not match the expected logic, i.e. attack features have changed but the model has changed its judgment, or attack features have disappeared but the model still judges as high-risk, add these samples to the rectified training set and automatically assign the correct label; Use the rectified samples to update the parameters of the large model, and force the focus of the model's attention by introducing a special loss function, including: Step 501: Constructing the attribution alignment loss function, in order to fundamentally eliminate bias, the training target not only requires the model to output the correct classification label, but also requires the model's gradient focus to regress to the effective area defined by the expert. A compound loss function is constructed: , wherein, represents the overall loss function, represents the standard cross-entropy classification loss, represents the attribution loss, adopting L2 norm: ⊙ ; represents the adjustable regularization hyper-parameter, which can be trained to achieve the best balance between ensuring high classification accuracy and eliminating model bias; Step 502: Parameter efficient adversarial fine-tuning, using LoRA to insert a trainable low-rank matrix only in the Attention layer of the model, and using the bias correction training set selected in step 403 for iterative training. Step 503: model performance verification and dynamic update, after fine-tuning, the reserved test set is used to verify the model performance, focusing on the cross-domain generalization ability, that is, the detection rate on a new IP segment or a new device, when When the bias index falls below the threshold value and the accuracy is improved, the updated model weight is deployed to the production environment.
Citation Information
Cited By
Multi-source decision-making and partition self-healing anti-radiation SRAM (Static Random Access Memory) storage calculation method and system
CN122088405A
A multi-source decision and partition self-healing anti-radiation SRAM computing method and system
CN122088405B
Semantic fusion and cross-view self-supervision-based log intention recognition method and system
CN122113003A