A multi-head attention perturbation test method, device, equipment and storage medium

CN122986473APending Publication Date: 2026-10-27ELECTRIC POWER RES INST CHINA SOUTHERN POWER GRID CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611155850.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-31
Publication Date
2026-10-27

AI Technical Summary

Benefits of technology

[0056]本申请提供的多头注意力扰动测试方法、装置、设备及存储介质,通过利用多头注意力机制对来自电力系统的多模态输入数据进行处理,识别并权重化数据中的关键特征,并基于关键特征得到多头注意力输出,以及根据多头注意力输出生成针对性扰动数据;然后将针对性扰动数据输入预设电力系统人工智能模型,观察并记录预设电力系统人工智能模型的输出变化,得到模型扰动响应结果,最后基于模型扰动响应结果对预设电力系统人工智能模型进行改进或者进行安全评估,完成模型扰动测试。通过结合多头注意力和扰动测试,其中,利用多头注意力机制提取电力系统中的多模态数据特征,克服传统测试方法对单一数据类型的局限,且利用多头注意力机制分析模型决策中的关键特征,能够帮助识别模型的脆弱点,为优化和防御提供参考;通过生成针对性的扰动测试模型,增强模型抵御恶意攻击的能力,能够提高电力系统的安全性,有利于确保电力系统的稳定和安全运行。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122986473A_ABST
    Figure CN122986473A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of power systems, and provides a multi-head attention disturbance test method, device, equipment and storage medium, the method comprises the following steps: acquiring multi-modal input data from a power system; processing the multi-modal input data by using a multi-head attention mechanism, identifying and weighting key features in the data, and obtaining multi-head attention output based on the key features; generating targeted disturbance data according to the multi-head attention output; inputting the targeted disturbance data into a preset power system artificial intelligence model, observing and recording the output change of the preset power system artificial intelligence model, and obtaining a model disturbance response result; improving or performing safety evaluation on the preset power system artificial intelligence model based on the model disturbance response result, and completing model disturbance test. The application can combine multi-head attention and disturbance test to provide a comprehensive and efficient safety evaluation framework for the power system artificial intelligence model, and ensure the stable and safe operation of the power system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of power system technology, and in particular to a multi-head attention perturbation testing method, a multi-head attention perturbation testing device, a corresponding electronic device, and a corresponding computer-readable storage medium. Background Technology

[0002] In recent years, artificial intelligence (AI) technology has developed rapidly, becoming a core driving force for technological innovation and industrial transformation. Power systems widely employ AI models to improve operational efficiency, optimize resource allocation, and predict maintenance needs. However, existing AI models for power systems may exhibit vulnerabilities when faced with malicious attacks or unexpected disturbances, thus affecting their stability and security. To address these challenges and ensure the stable operation of power systems, the power industry has begun using disturbance testing to evaluate the security performance of AI models.

[0003] Perturbation testing assesses a model's robustness by introducing controlled perturbations into its input data to simulate the impact of malicious attacks or unexpected disturbances. This method simulates various attack methods an attacker might employ by adding small, carefully designed perturbations to the model's input data to test the model's response to these perturbations. If the model exhibits high sensitivity to certain designed perturbations, it may indicate vulnerabilities in those areas requiring further hardening. Perturbation testing can uncover and fix potential weaknesses in power system AI models, improving their resilience against malicious attacks.

[0004] Currently, there are various perturbation testing methods, such as perturbation testing based on adversarial attacks, including Projected Gradient Descent (PGD) and Fast Gradient Sign Method (FGSM); perturbation testing based on reinforcement learning, such as Generative Adversarial Networks (GANs) where agents learn strategies; and adaptive perturbation testing, which dynamically adjusts the perturbation strategy based on the model's response, making the testing more targeted and effective. Perturbation testing based on genetic algorithms uses genetic algorithms to generate adversarial samples, simulating the process of natural selection, continuously iterating and optimizing the perturbation to find the optimal solution that can fool the model.

[0005] However, existing perturbation testing methods typically focus on the model's input-output behavior while neglecting the model's internal decision-making process. This testing strategy fails to delve into how the model allocates attention to different parts of the input data and how these attentions affect the final decision. For example, when processing multimodal data of power systems, the model may give higher weights to certain key features that are crucial for maintaining system stability. If the testing method cannot identify and simulate the processing of these key features, it may miss assessments that are crucial to the model's robustness, resulting in a lack of understanding of the model's internal mechanisms. Furthermore, existing perturbation testing methods often focus on a single type of data during design and implementation, such as adversarial sample generation for image recognition models or text data perturbation for natural language processing models. However, power system data has multimodal characteristics, meaning that the data includes not only images and text, but also audio and time series data. These different types of data complement each other in the model's decision-making process and provide a comprehensive view of the power system's state. However, existing perturbation testing techniques often neglect the interaction and fusion of multimodal data in power systems, and traditional perturbation testing is difficult to adapt to the heterogeneity of multimodal data, has limited processing capabilities for multimodal data, and restricts the comprehensiveness and effectiveness of the test. Summary of the Invention

[0006] This application provides a multi-head attention perturbation testing method, apparatus, device, and storage medium, which can combine multi-head attention and perturbation testing to provide a comprehensive and efficient safety assessment framework for power system artificial intelligence models, ensuring the stable and safe operation of power systems.

[0007] In one aspect, this application provides a multi-head attention perturbation testing method, the method comprising:

[0008] Acquire multimodal input data from the power system;

[0009] The multi-head attention mechanism is used to process the multimodal input data, identify and weight key features in the data, and obtain multi-head attention output based on the key features;

[0010] Targeted perturbation data is generated based on the multi-head attention output;

[0011] The targeted disturbance data is input into a preset power system artificial intelligence model, and the output changes of the preset power system artificial intelligence model are observed and recorded to obtain the model disturbance response results;

[0012] Based on the model disturbance response results, the preset power system artificial intelligence model is improved or a security assessment is conducted to complete the model disturbance test.

[0013] Further, the key features include a query vector, a key vector, and a value vector; the process of using a multi-head attention mechanism to process the multimodal input data, identify and weight key features in the data, and obtain a multi-head attention output based on the key features includes:

[0014] Using a multi-head attention mechanism, the multimodal input data is mapped into a representation space of query, key, and value based on a preset linear transformation matrix, resulting in query vector, key vector, and value vector;

[0015] The attention weights of each attention head are calculated based on the query vector, the key vector, and the dimension of the key vector, respectively.

[0016] The output of each attention head is calculated based on the attention weights and the value vector, respectively.

[0017] The outputs of each attention head are concatenated to obtain the final multi-head attention output.

[0018] Furthermore, for query vectors, key vectors, and value vectors, the following are included:

[0019] Feature extraction and embedding transformation are performed on the multimodal input data to obtain an embedding vector sequence of the same dimension;

[0020] Using a multi-head attention mechanism, the embedded vector sequence is mapped into a query vector, a key vector, and a value vector based on a preset linear transformation matrix; wherein each row corresponds to an element in the sequence, and each column corresponds to a feature dimension; the query vector and the key vector are used to calculate relevance, and the value vector is used to aggregate information; each attention head has an independent preset linear transformation matrix, and the mapping features corresponding to different types of data are determined by the preset linear transformation matrix independently learned by each attention head.

[0021] Furthermore, the step of generating targeted perturbation data based on the multi-head attention output includes:

[0022] Starting from zero perturbation, the gradient of the loss function with respect to the multi-head attention output is calculated iteratively multiple times, and the perturbation vector is updated along the ascending direction of the gradient;

[0023] After each update of the perturbation vector, a truncation operation is performed on each dimension component of the perturbation vector to control the perturbation vector within a preset range, thereby obtaining targeted perturbation data.

[0024] Further, the step of inputting the targeted disturbance data into a preset power system artificial intelligence model, observing and recording the output changes of the preset power system artificial intelligence model, and obtaining the model disturbance response result includes:

[0025] The targeted disturbance data is input into a preset power system artificial intelligence model. The prediction results, confidence level, attention weight, and any abnormal behavior of the preset power system artificial intelligence model are observed, and the corresponding output changes are recorded. The output changes are used to indicate the change between the output of the preset power system artificial intelligence model under the targeted disturbance data and the output of the preset power system artificial intelligence model under normal data.

[0026] The model perturbation response result is generated based on the output change.

[0027] Furthermore, the step of improving the preset power system artificial intelligence model or conducting a security assessment based on the model disturbance response results includes:

[0028] When the model disturbance response result indicates that the preset power system artificial intelligence model is vulnerable to the output change, the preset power system artificial intelligence model is improved.

[0029] When the model disturbance response result shows that the preset power system artificial intelligence model does not exhibit vulnerability to the output change, a security assessment is performed on the preset power system artificial intelligence model.

[0030] Furthermore, the improvement of the preset power system artificial intelligence model includes:

[0031] Identify potential weaknesses in the preset power system artificial intelligence model, provide feedback data to the preset power system artificial intelligence model under different operating conditions to address these potential weaknesses, and improve the preset power system artificial intelligence model based on the feedback data.

[0032] On the other hand, this application provides a multi-head attention perturbation testing device, the device comprising:

[0033] The input data acquisition module is used to acquire multimodal input data from the power system;

[0034] The multi-head attention output module is used to process the multimodal input data using a multi-head attention mechanism, identify and weight key features in the data, and obtain multi-head attention output based on the key features;

[0035] The perturbation data generation module is used to generate targeted perturbation data based on the multi-head attention output;

[0036] The disturbance response result generation module is used to input the targeted disturbance data into a preset power system artificial intelligence model, observe and record the output changes of the preset power system artificial intelligence model, and obtain the model disturbance response result;

[0037] The model disturbance test module is used to improve the preset power system artificial intelligence model or conduct a security assessment based on the model disturbance response results, and to complete the model disturbance test.

[0038] Furthermore, the key features include a query vector, a key vector, and a value vector; the multi-head attention output module includes:

[0039] The mapping submodule is used to map the multimodal input data into a representation space of query, key, and value based on a preset linear transformation matrix using a multi-head attention mechanism, to obtain query vector, key vector, and value vector;

[0040] The attention weight calculation submodule is used to calculate the attention weight of each attention head based on the query vector, the key vector, and the dimension of the key vector, respectively.

[0041] The multi-head attention output submodule is used to calculate the output of each attention head based on the attention weight and the value vector respectively; and to concatenate the outputs of each attention head to obtain the final multi-head attention output.

[0042] Furthermore, the mapping submodule includes:

[0043] The mapping unit is used to extract features and embed them into the multimodal input data to obtain a sequence of embedding vectors of the same dimension. Using a multi-head attention mechanism, the embedding vector sequence is mapped into query vectors, key vectors, and value vectors based on a preset linear transformation matrix. Each row corresponds to an element in the sequence, and each column corresponds to a feature dimension. The query vector and the key vector are used to calculate relevance, and the value vector is used to aggregate information. Each attention head has an independent preset linear transformation matrix, and the mapping features corresponding to different types of data are determined by the preset linear transformation matrix independently learned by each attention head.

[0044] Furthermore, the disturbance data generation module includes:

[0045] The perturbation data generation submodule is used to calculate the gradient of the loss function with respect to the multi-head attention output multiple times starting from zero perturbation, and update the perturbation vector along the rising direction of the gradient; after each update of the perturbation vector, a truncation operation is performed on each component of the perturbation vector to control the perturbation vector within a preset range, thereby obtaining targeted perturbation data.

[0046] Furthermore, the disturbance response result generation module includes:

[0047] The disturbance response result generation submodule is used to input the targeted disturbance data into a preset power system artificial intelligence model, observe the prediction results, confidence level, attention weight, and any abnormal behavior of the preset power system artificial intelligence model, and record the corresponding output changes; the output changes are used to indicate the change between the output of the preset power system artificial intelligence model under the targeted disturbance data and the output of the preset power system artificial intelligence model under normal data; and generate the model disturbance response result based on the output changes.

[0048] Furthermore, the model perturbation testing module includes:

[0049] The model improvement submodule is used to improve the preset power system artificial intelligence model when the model disturbance response result shows that the preset power system artificial intelligence model is vulnerable to the output change;

[0050] The model safety assessment submodule is used to perform a safety assessment on the preset power system artificial intelligence model when the model disturbance response result shows that the preset power system artificial intelligence model does not show vulnerability to the output change.

[0051] Furthermore, the model improvement submodule includes:

[0052] The weakness improvement unit is used to identify potential weaknesses of the preset power system artificial intelligence model, provide feedback data to the preset power system artificial intelligence model under different operating conditions based on the potential weaknesses, and improve the preset power system artificial intelligence model based on the feedback data.

[0053] In another aspect, this application also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements any of the multi-head attention perturbation testing methods described above.

[0054] In another aspect, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements any of the described multi-head attention perturbation testing methods.

[0055] In another aspect, this application also provides a computer program product containing instructions that, when run on a computer, cause the computer to perform the multi-head attention perturbation testing method described in the above aspects.

[0056] The multi-head attention perturbation testing method, apparatus, equipment, and storage medium provided in this application process multimodal input data from a power system using a multi-head attention mechanism. This process identifies and weights key features in the data, generates multi-head attention output based on these features, and produces targeted perturbation data based on the multi-head attention output. The targeted perturbation data is then input into a preset power system artificial intelligence model. Changes in the output of the preset power system artificial intelligence model are observed and recorded to obtain the model's perturbation response results. Finally, the preset power system artificial intelligence model is improved or a security assessment is performed based on the model's perturbation response results, completing the model perturbation test. By combining multi-head attention and perturbation testing, the multi-head attention mechanism extracts multimodal data features from the power system, overcoming the limitations of traditional testing methods on single data types. Furthermore, the analysis of key features in model decision-making using the multi-head attention mechanism helps identify model vulnerabilities, providing a reference for optimization and defense. By generating a targeted perturbation test model, the model's ability to resist malicious attacks is enhanced, improving the security of the power system and contributing to ensuring its stable and safe operation. Attached Figure Description

[0057] Figure 1 This is a schematic diagram of the framework for multi-head attention perturbation testing based on an artificial intelligence model of a power system provided in an embodiment of this application;

[0058] Figure 2 This is a flowchart illustrating the steps of a multi-head attention perturbation testing method provided in an embodiment of this application;

[0059] Figure 3 This is a flowchart of the multi-head attention mechanism perturbation test provided in the embodiments of this application;

[0060] Figure 4 This is a schematic diagram of the multi-head attention mechanism processing provided in the embodiments of this application;

[0061] Figure 5 This is a structural block diagram of a multi-head attention perturbation testing device provided in an embodiment of this application;

[0062] Figure 6 This is a structural block diagram of an electronic device provided in an embodiment of this application;

[0063] Figure 7 This is a structural block diagram of a computer-readable storage medium provided in an embodiment of this application. Detailed Implementation

[0064] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0065] Existing perturbation testing methods typically assume that all models are sensitive to specific types of perturbations, or that the effects of perturbations are linear and predictable. They fail to consider the individual differences of AI models and the specific needs of application scenarios, and cannot adjust the intensity and direction of perturbations according to the specific characteristics and behaviors of the models. This results in potentially coarse testing that cannot accurately simulate and defend against complex attacks, lacking fine-grained control. Furthermore, existing perturbation testing methods often focus on the model's input-output behavior, neglecting the model's internal decision-making process. This testing strategy cannot delve into how the model allocates attention to different parts of the input data and how these attentions influence the final decision. For example, when processing multimodal data from power systems, the model may assign higher weights to certain key features that are crucial for maintaining system stability. If the testing method cannot identify and simulate the processing of these key features, it may miss crucial assessments of the model's robustness, revealing a deficiency in understanding the model's internal mechanisms. Furthermore, existing perturbation testing methods often focus on a single type of data during design and implementation, such as adversarial sample generation for image recognition models or text data perturbation for natural language processing models. However, power system data has multimodal characteristics, meaning that the data includes not only images and text, but also audio and time series data. These different types of data complement each other in the model's decision-making process and provide a comprehensive view of the power system's state. However, existing perturbation testing techniques often neglect the interaction and fusion of multimodal data in power systems, and traditional perturbation testing is difficult to adapt to the heterogeneity of multimodal data, has limited processing capabilities for multimodal data, and restricts the comprehensiveness and effectiveness of the test.

[0066] As mentioned above, current research on disturbance testing is still in its developmental stage. Many testing methods cannot dynamically adapt to real-time changes in the power system, resulting in a lack of timeliness and accuracy in test results in rapidly changing power grid environments. Furthermore, existing technologies lack the ability to dynamically adjust disturbance strategies, which limits the depth and breadth of testing.

[0067] To address the shortcomings of existing technologies in processing multimodal data, improving model robustness, and gaining a deeper understanding of the model's internal mechanisms, embodiments of this application, through meticulous control of the intensity and direction of perturbations, can accurately simulate and defend against complex attacks, thereby enhancing the model's ability to identify and resist malicious attacks and unexpected perturbations. Furthermore, embodiments of this application utilize a multi-head attention mechanism to deeply mine and understand the model's internal decision-making process. This not only helps to more accurately identify potential security threats but also provides guidance for model optimization and hardening. By combining multi-head attention and perturbation testing, a comprehensive and efficient security assessment framework can be provided for power system artificial intelligence models, ensuring the stable and safe operation of the power system.

[0068] Reference Figure 1 This illustration shows a framework diagram of multi-head attention perturbation testing based on a power system artificial intelligence model provided in an embodiment of this application. It primarily improves the robustness of the power system artificial intelligence model by combining a multi-head attention mechanism with perturbation testing, ensuring its stability and security in the face of various complex challenges and potential threats.

[0069] like Figure 1 As shown, this involves acquiring multimodal data, processing data using a multi-head attention mechanism, generating targeted perturbations based on the multi-head attention output, testing the perturbation input model, and conducting a security assessment.

[0070] This application embodiment utilizes a multi-head attention mechanism to uniformly analyze multimodal data such as images, text, and traffic, enhancing the model's adaptability and processing capabilities in complex environments, and providing a more comprehensive approach compared to traditional single-data-type testing. Based on the output of the attention mechanism, this application embodiment generates controllable micro-perturbations to accurately identify model vulnerabilities, improving model robustness and offering greater targeting compared to existing fixed or simple perturbation strategies. Furthermore, this application embodiment employs a multi-head attention mechanism to deeply analyze the model's decision-making process, accurately identifying potential weaknesses and providing more effective guidance for optimization and defense, thereby improving security performance.

[0071] Specifically, refer to Figure 2 The diagram illustrates a flowchart of a multi-head attention perturbation testing method provided in an embodiment of this application, which may specifically include the following steps:

[0072] Step S201: Obtain multimodal input data from the power system.

[0073] The training of artificial intelligence models for power systems relies on various data, including multiple modalities such as images, text, and flow rates. In some embodiments of this application, such as... Figure 3As shown, it can receive multimodal input data from the power system, including images, text, audio, and flow information, to preprocess the multimodal input data and provide a data foundation for subsequent model perturbation testing.

[0074] Step S202: The multi-head attention mechanism is used to process the multimodal input data, identify and weight key features in the data, and obtain the multi-head attention output based on the key features.

[0075] Training artificial intelligence models for power systems relies on diverse data, including multiple modalities such as images, text, and flow rates. This data is central to the model's learning process but is also vulnerable to attack. Attackers can inject malicious data into the dataset to implant backdoors and interfere with the model's predictions. Because power system AI data is diverse, encompassing various types such as images, text, and flow rates, and these different data types differ significantly in format and processing requirements, data preprocessing becomes more difficult, making it more challenging to extract useful information from this data and defend against potential data contamination.

[0076] In the complex environment of power systems, models need to process and analyze large amounts of information from different data sources and make fast and accurate decisions based on this information. To achieve this, multi-head attention mechanisms can be used to delve into the internal workings of the models.

[0077] In this embodiment of the application, in order to achieve effective data analysis and decision support, this embodiment of the application adopts a multi-head attention mechanism to comprehensively analyze image, text and traffic data, so as to unify the processing and understanding of these multimodal data, ensure their semantic consistency and complementarity, improve the comprehensiveness and accuracy of data processing, and thus provide a comprehensive and accurate information foundation for the power system.

[0078] In some embodiments of this application, for example Figure 3 The multi-head attention mechanism shown can be used to process multimodal input data, identify and weight key features in the data, and achieve comprehensive analysis of data input from different modalities.

[0079] Optionally, a multi-head attention mechanism can simultaneously focus on visual features in image data, semantic information in text data, and behavioral patterns in traffic data, assigning a different "head" to each data modality, with each head learning to capture a different set of features. This parallel processing approach can greatly improve the model's efficiency in understanding and processing data.

[0080] Specifically, a multi-head attention mechanism can be used to map multimodal input data into a representation space of query, key, and value based on a preset linear transformation matrix, resulting in query vector, key vector, and value vector. Then, the attention weights of each attention head can be calculated based on the dimensions of the query vector, key vector, and key vector, respectively. The outputs of each attention head can be calculated based on the attention weights and value vectors, respectively. Finally, the outputs of each attention head are concatenated to obtain the final multi-head attention output.

[0081] In multi-head attention mechanisms, the processing of different types of data is uniform yet distinguishable. Before entering the multi-head attention mechanism, data from different modalities can undergo corresponding feature extraction and embedding transformations, and then be uniformly mapped to a feature space of the same dimension.

[0082] In practical applications, such as Figure 4 As shown, firstly, feature extraction and embedding transformation can be performed on multimodal input data (such as images, text, and traffic time series) to obtain embedding vector sequences of the same dimension.

[0083] For example, for image data, visual feature maps can be extracted using convolutional neural networks and then flattened into vector sequences. Specifically, visual features can be extracted using CNN, ViT, or image patch encoders to obtain vector sequences reflecting information such as device appearance, infrared temperature distribution, abnormal hotspots, and texture edges. Each vector corresponds to an image patch. For text data, each word can be mapped to a vector using a word embedding layer. Semantic features can be extracted using word segmentation, word embedding, or pre-trained language models to obtain vector sequences reflecting information such as alarm keywords, fault descriptions, and semantic relationships in maintenance records. For traffic or time-series data, trend features can be extracted using sliding windows, linear mapping, 1D-CNN, or recurrent networks to obtain vector sequences reflecting voltage, current, oil temperature, load changes, abnormal peaks, and time correlations. Specifically, sensor readings at each time point can be concatenated into vectors.

[0084] The features of the different modalities mentioned above, after dimension alignment, are uniformly represented as the input sequence. Specifically, embedding vectors from different modalities can be sequentially concatenated into a single overall input sequence. Its dimensions are The total input sequence It can be entered into a multi-head attention mechanism as a set of multimodal data, so that the multi-head attention mechanism can then perform cross-modal correlation analysis on these features. This allows the model to focus on important features within a single modality, as well as capture the corroborating relationships between images, text, traffic, or time-series data.

[0085] Subsequently, a multi-head attention mechanism can be used to process a set of multimodal data. Perform dimensional transformation, such as Figure 4 As shown, this is specifically manifested by embedding a vector sequence based on a preset linear transformation matrix. Mapping to query vectors, key vectors, and value vectors to handle multimodal data. The different modalities contained therein are mapped to the same weight dimension.

[0086] Optionally, it can be achieved using three sets of linear transformation matrices. , , (Each head has its own independent set) the entire sequence Simultaneously, it is mapped into the representation space of query (Q), key (K), and value (V), resulting in the corresponding query vector, key vector, and value vector.

[0087] For example, it can be specifically represented as:

[0088] , , .

[0089] In the formula, , and The weight matrix is ​​a learnable matrix, and its dimensions are pre-defined according to the design requirements of the multi-head attention mechanism. For example, if the input data is multimodal data... The dimension is The dimension of the key vector is The dimension of the value vector is ,but , ; .

[0090] Optionally, at the start of model training, these weight matrices can be given initial values ​​using random initialization (such as Xavier initialization or Kaiming initialization).

[0091] During the overall training process of the artificial intelligence model of the power system, these weight matrices can be continuously updated through backpropagation and gradient descent algorithms, which is reflected in the input multimodal data. Specifically, it refers to the sequence of embedding vectors obtained from feature extraction and embedding transformation. Perform forward propagation and calculate the loss between the predicted result and the true label, then adjust in the opposite direction of the gradient of the loss function. , and The value of is determined to minimize the prediction error.

[0092] In practical applications, after multiple rounds of iterative training, these weight matrices can adaptively map the input data to the optimal query. ),key( ) and value ( ) represents space.

[0093] Each row corresponds to an element in the sequence (such as an image patch, word, or time point), and each column corresponds to a feature dimension. This mapping process essentially projects the original embedding vectors onto a new feature space, allowing the query vector and key vector to be used to calculate relevance, and the value vector to be used to aggregate information.

[0094] Next, for each attention head, the attention weights of each attention head can be calculated to reflect the relationships between different data points. For example... Figure 4 The scaled dot product attention shown mainly reflects the process of calculating attention weights for each attention head. For example, the specific formula for calculating attention weights can be expressed as:

[0095] ;

[0096] In the formula, and It corresponds to the query and key in the header; It is the dimension of the key vector. Used to scale the dot product to prevent gradient vanishing. It should be noted that the header itself is independent. , , As mentioned above , and Essentially, they are all learnable linear mapping matrices, not manually specified with specific values, but automatically learned during model training through backpropagation and gradient descent; and the corresponding heads and Based on the head's own independence , , The results are obtained from calculations. This application does not limit the scope of the embodiments described herein.

[0097] So, the output of each attention head It is a weighted sum of attention weights and values, which can be specifically expressed as: .

[0098] Furthermore, the output of all heads They are pieced together and passed through a linear layer After transformation, the final multi-head attention output can be obtained. For example, it can be specifically represented as follows: .

[0099] Each attention head has an independent preset linear transformation matrix, and the mapping features corresponding to different types of data are determined by the preset linear transformation matrix learned independently by each attention head.

[0100] Because each head has an independent , , It can learn different projection directions, thus focusing on different feature patterns. For example, in a power system scenario, the projection matrix of the first 1 might cause the feature vector of the high-temperature color region in the image patch to be... and The projection of head 2 generates a large dot product in space, thus assigning high attention weights; the projection of head 3 may make the vectors of keywords such as "oil temperature alarm" in the text highly relevant; the projection of head 3 may highlight the continuous rising temporal pattern in the flow data. Therefore, the mapping features corresponding to different types of data are adaptively determined by the weight matrix independently learned by each head, rather than being manually specified. One head may specifically capture texture edges in images, another head captures semantic entities in text, and a third head captures slope changes in flow. These features are all implicit in... , , In the numerical distribution, the attention weights of each attention head are calculated through attention weight calculation. This becomes a weighted aggregated representation of the features that the head is interested in. Finally, the outputs of all heads are concatenated to obtain an overall representation that integrates multimodal and multi-view features, which is the final multi-head attention output. .

[0101] In the embodiments of this application, the multi-head attention mechanism can not only improve the model's ability to process complex power system data, but also enhance the model's robustness and accuracy when facing multimodal data.

[0102] Step S203: Generate targeted perturbation data based on the multi-head attention output.

[0103] like Figure 3 As shown, after calculating and outputting the attention score, adversarial perturbations can be generated. Specifically, targeted perturbations can be generated based on the output of the multi-head attention mechanism to test the model's response to perturbations of different types and intensities.

[0104] Optionally, based on the output of the multi-head attention mechanism, embodiments of this application may design perturbations to simulate the strategies that attackers may employ. These perturbations are controllable, small, and difficult-to-detect changes to mislead the model's decision-making process and enhance the model's stability and robustness in complex environments.

[0105] In some embodiments of this application, the goal of perturbation generation is to maximize the model loss, and the perturbation can be updated using the gradient ascent direction.

[0106] Specifically, regarding the output of multi-head attention mechanisms The perturbation can be generated using the Projected Gradient Descent (PGD) method. In practice, iterative calculations of the loss function on the multi-head attention output can begin with zero perturbation and proceed multiple times. The gradient is calculated, and the perturbation vector is updated along the ascending direction of the gradient. After each update of the perturbation vector, a truncation operation can be performed on each component of the perturbation vector to control the perturbation vector within a preset interval, such as... Within this, targeted perturbation data is obtained. Specifically, the truncation operation performed on each dimension of the perturbation vector ensures that it satisfies... This ensures that the perturbation does not exceed the preset maximum perturbation budget. This method effectively identifies the model's sensitivity to small changes, improving the coverage and attack strength of perturbation testing.

[0107] For example, the obtained targeted perturbation data is the optimal perturbation that maximizes the difference in model predictions. Specifically, it can be expressed as:

[0108] ;

[0109] In the formula, It is the model's prediction function; It is a loss function; This represents the true or target label corresponding to the input sample, and can be used to measure the difference between the model output and the true label.

[0110] Optionally, to limit the strength of the disturbance, a constraint can also be introduced:

[0111] ;

[0112] In the formula, This is a predefined perturbation budget that can be used to control the maximum strength of the perturbation. It should be noted that this constraint applies both to the intermediate perturbations after each PGD iteration and to the final optimal perturbation. In other words, The optimal perturbation is obtained by searching within the constraints, rather than maximizing the loss without limit.

[0113] In practical applications, the control of disturbance intensity is reflected in the generation of the optimal disturbance. Controlling the perturbation direction does not mean manually specifying a fixed direction, but rather dynamically determining the direction most likely to cause errors or amplify discrepancies in the model output based on the gradient of the current loss function with respect to the perturbation variable in each PGD iteration. This application's embodiments do not impose any limitations on this.

[0114] In the embodiments of this application, a series of adversarial perturbations generated can help identify potential weaknesses in the power system artificial intelligence model, thereby testing the robustness of the power system artificial intelligence model and enhancing the model's defense capabilities.

[0115] Step S204: Input the targeted disturbance data into the preset power system artificial intelligence model, observe and record the output changes of the preset power system artificial intelligence model, and obtain the model disturbance response results.

[0116] Power systems are highly complex networks that need to operate under diverse environmental conditions, such as extreme weather, temperature variations, and load changes, all of which can affect model performance. Artificial intelligence models for power systems require high robustness to ensure the stable and safe operation of the power system under various conditions.

[0117] In some embodiments of this application, the following can be performed: Figure 3 The model test shown can be specifically manifested as inputting targeted disturbance data into a preset power system artificial intelligence model, observing and recording the output changes of the preset power system artificial intelligence model, in order to evaluate the robustness of the model.

[0118] Specifically, targeted disturbance data can be input into a preset power system artificial intelligence model, and the prediction results, confidence level, attention weight, and any abnormal behavior of the preset power system artificial intelligence model can be observed. The corresponding output changes can be recorded to generate model disturbance response results based on the output changes.

[0119] The output change primarily indicates the difference between the output of the preset power system AI model under targeted disturbance data and the output of the preset power system AI model under normal data. In practical applications, the model's disturbance response results can be generated by comparing its performance on normal and disturbance data.

[0120] Step S205: Based on the model disturbance response results, improve the preset power system artificial intelligence model or conduct a safety assessment to complete the model disturbance test.

[0121] In one case, such as Figure 3As shown, when the model's disturbance response results indicate that the preset power system AI model does not exhibit vulnerability to output changes, a security assessment can be performed on the preset power system AI model. For example, a prediction robustness assessment can be conducted. This involves comparing whether the model's prediction results change under normal and disturbance inputs, including accuracy reduction, fault category misclassification, alarm misses, attack success rate, and robustness accuracy.

[0122] In another case, such as Figure 3 As shown, when the model disturbance response results indicate that the preset power system artificial intelligence model is vulnerable to output changes, the preset power system artificial intelligence model can be improved.

[0123] Specifically, if the model exhibits vulnerability, a model weakness identification process can be performed to identify potential weaknesses in the preset power system AI model, namely, the model's weaknesses when facing specific attack types. Feedback data on the preset power system AI model under different operating conditions can then be used to address these potential weaknesses, and the preset power system AI model can be improved based on the feedback data.

[0124] Specifically, the assessment evaluates the adaptability and accuracy of a pre-defined artificial intelligence model for the power system under different operating conditions. For example, the model is input with normal samples, and the baseline output is recorded, including the predicted category, the confidence score of the correct category, the loss value, the attention weight, and the contribution of each modality. Then, PGD perturbation samples are generated on the same samples, and the above indicators are recorded again. Finally, the difference before and after the perturbation is calculated to form the safety assessment result.

[0125] Improvement measures can be tailored to address the weaknesses identified in the model based on its performance, such as adjusting the model architecture, enhancing the diversity of training data, or introducing new defense mechanisms to improve the overall robustness of the model and thus ensure the safety and stability of the power system.

[0126] In practical applications, there is a clear causal relationship between the specific response results revealed by the model and the corresponding improvement measures.

[0127] Taking a power transformer fault diagnosis model as an example, assuming that the normal input includes infrared thermal imaging, maintenance record text, and SCADA (Supervisory Control And Data Acquisition) oil temperature time series data, the model outputs an overheating probability of 0.92. The method provided in this application provides the following targeted perturbations: reducing the temperature of the hottest spot in the infrared image by 2°C, changing "oil temperature alarm" in the text to "oil temperature normal," and reducing the temperature of the last three sampling points on the oil temperature time series curve by 1.5°C, with all perturbation amplitudes controlled within a preset threshold ε.

[0128] If the model output overheat probability drops sharply to 0.31 after perturbation, meaning the perturbation test found that the model reduced the overheat probability from 0.92 to 0.31 when the oil temperature value decreased by only 1.5℃, it indicates that the prediction results are extremely sensitive to small changes in temperature values. Furthermore, when the perturbation test observed that the phrase "oil temperature alarm" in the text was replaced with "oil temperature normal," the model's confidence level dropped from 0.88 to 0.45. At the same time, the multi-head attention weight distribution shifted significantly, with attention weights shifting heavily from other modalities to the text head. For example, the image head weight decreased from 0.5 to 0.2, while the text head weight increased from 0.3 to 0.6. This response of the attention weight distribution indicates that the text modality has excessive dominance and the model is vulnerable to fake text injection attacks. By comparing the prediction results, confidence scores, and attention weights before and after the perturbation, three specific weaknesses of the model can be identified: First, it is overly sensitive to small changes in temperature values; a decrease of only 1.5℃ can reverse the fault determination, indicating that the model lacks robustness to temperature trends or temporal context. Second, the text modality has too much dominance; simply changing "oil temperature alarm" to "oil temperature normal" dominates the entire decision, and the model is still misled by false text even if the image and flow data still suggest an overheated state. Third, other modalities cannot effectively compensate when the image modality is weakened. When the perturbation test found that the attention weight of the image header decreased, even if the text header weight increased, the model output changed from correct to incorrect. That is, although the text header increased after the image header weight decreased, the prediction was incorrect. This failure of intermodal compensation indicates that the model has not learned the cross-modal verification mechanism and has not learned cross-modal consistency verification.

[0129] These weaknesses are precisely located by comparing the output differences between normal data and perturbation data, which can then provide a clear direction for model hardening, such as adding random noise to temperature values ​​during training, introducing adversarial text perturbations, and increasing cross-modal contrastive loss.

[0130] For example, to address the first weakness mentioned above, an improvement could be to add random smoothing or Gaussian noise to the temperature sensor values ​​in the training data, forcing the model to learn the overall trend of temperature changes rather than absolute values. To address the second weakness, an improvement could be to introduce a cross-modal contrastive loss function, requiring that the attention outputs of the image, text, and traffic modalities remain consistent during training, while also adding adversarial text perturbation samples to the training. To address the third weakness, an improvement could be to adjust the model architecture by adding a cross-modal gating unit after the multi-head attention layer. This unit dynamically adjusts the output contribution weight of each modality based on the confidence of other modalities, thereby preventing the entire decision from collapsing when a single modality is attacked.

[0131] Through the above step-by-step mapping from response results to improvement measures, the embodiments of this application can provide targeted security hardening solutions for power system artificial intelligence models, rather than generalized general suggestions.

[0132] It should be noted that due to significant differences in task type, input modality, model structure, application scenario, and security requirements among different power system artificial intelligence models, their vulnerability manifestations are not entirely the same. For example, image-based tasks may primarily manifest as prediction reversal after key visual regions are disturbed; text-based tasks may manifest as misjudgments due to changes in alarm semantics; and flow or time-series tasks may manifest as the masking of local peaks, trend changes, or abnormal patterns. It is difficult to use a fixed strategy to cover all models and all application scenarios. Furthermore, the embodiments of this application do not presuppose a uniform vulnerability type, but rather provide an adaptable vulnerability discovery approach for different models through a multi-head attention perturbation testing framework. Specifically, based on the input modality, changes in attention weights, changes in prediction results, and business risk requirements of the model under test, the changes in model output, confidence, attention distribution, and modality contribution before and after perturbation can be analyzed to identify potential weaknesses of the model in specific tasks and scenarios.

[0133] In this embodiment, the multi-head attention mechanism can deeply analyze the model's decision-making characteristics, more accurately identify potential weaknesses, and provide guidance for optimization and defense.

[0134] In this embodiment, a multi-head attention mechanism is used to process multimodal input data from a power system, identify and weight key features in the data, obtain multi-head attention output based on these key features, and generate targeted disturbance data based on the multi-head attention output. Then, the targeted disturbance data is input into a preset power system artificial intelligence model, and the output changes of the preset power system artificial intelligence model are observed and recorded to obtain the model disturbance response results. Finally, the preset power system artificial intelligence model is improved or a security assessment is performed based on the model disturbance response results, completing the model disturbance test. By combining multi-head attention and disturbance testing, the multi-head attention mechanism extracts multimodal data features from the power system, overcoming the limitations of traditional testing methods on single data types. Furthermore, the multi-head attention mechanism analyzes key features in model decision-making, helping to identify model vulnerabilities and providing a reference for optimization and defense. By generating a targeted disturbance test model, the model's ability to resist malicious attacks is enhanced, improving the security of the power system and ensuring its stable and safe operation.

[0135] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of this application.

[0136] Reference Figure 5 The diagram shows a structural block diagram of a multi-head attention perturbation testing device provided in an embodiment of this application, which may specifically include the following modules:

[0137] The input data acquisition module 501 is used to acquire multimodal input data from the power system;

[0138] The multi-head attention output module 502 is used to process multimodal input data using a multi-head attention mechanism, identify and weight key features in the data, and obtain multi-head attention output based on the key features;

[0139] The perturbation data generation module 503 is used to generate targeted perturbation data based on the multi-head attention output;

[0140] The disturbance response result generation module 504 is used to input targeted disturbance data into a preset power system artificial intelligence model, observe and record the output changes of the preset power system artificial intelligence model, and obtain the model disturbance response result.

[0141] The model disturbance test module 505 is used to improve or conduct safety assessments on the preset power system artificial intelligence model based on the model disturbance response results, and to complete the model disturbance test.

[0142] In some embodiments of this application, key features include query vector, key vector, and value vector; the multi-head attention output module 502 may include the following sub-modules:

[0143] The mapping submodule is used to map multimodal input data into a representation space of query, key, and value based on a preset linear transformation matrix using a multi-head attention mechanism, to obtain query vector, key vector, and value vector;

[0144] The attention weight calculation submodule is used to calculate the attention weight of each attention head based on the query vector, key vector, and the dimension of the key vector, respectively.

[0145] The multi-head attention output submodule is used to calculate the output of each attention head based on the attention weight and value vector respectively; the outputs of each attention head are concatenated to obtain the final multi-head attention output.

[0146] In some embodiments of this application, the mapping submodule may include the following units:

[0147] The mapping unit is used to extract features and embed them into multimodal input data, resulting in a sequence of embedding vectors of the same dimension. Utilizing a multi-head attention mechanism, the embedding vector sequence is mapped into query vectors, key vectors, and value vectors based on a pre-defined linear transformation matrix. Each row corresponds to an element in the sequence, and each column corresponds to a feature dimension. The query vector and key vector are used to calculate relevance, while the value vector is used to aggregate information. Each attention head has an independent pre-defined linear transformation matrix, and the mapping features corresponding to different types of data are determined by the pre-defined linear transformation matrix independently learned by each attention head.

[0148] In some embodiments of this application, the disturbance data generation module 503 may include the following sub-modules:

[0149] The perturbation data generation submodule is used to calculate the gradient of the loss function with respect to the multi-head attention output multiple times starting from zero perturbation, and update the perturbation vector along the ascending direction of the gradient. After each update of the perturbation vector, a truncation operation is performed on each component of the perturbation vector to control the perturbation vector within a preset range, thereby obtaining targeted perturbation data.

[0150] In some embodiments of this application, the disturbance response result generation module 504 may include the following sub-modules:

[0151] The disturbance response result generation submodule is used to input targeted disturbance data into a preset power system artificial intelligence model, observe the prediction results, confidence level, attention weight, and any abnormal behavior of the preset power system artificial intelligence model, and record the corresponding output changes; the output changes are used to indicate the changes between the output of the preset power system artificial intelligence model under targeted disturbance data and the output of the preset power system artificial intelligence model under normal data; and generate the model disturbance response result based on the output changes.

[0152] In some embodiments of this application, the model perturbation test module 505 may include the following sub-modules:

[0153] The model improvement submodule is used to improve the preset power system artificial intelligence model when the model disturbance response result shows that the preset power system artificial intelligence model is vulnerable to output changes;

[0154] The model safety assessment submodule is used to conduct a safety assessment of the preset power system artificial intelligence model when the model disturbance response result shows that the preset power system artificial intelligence model does not show vulnerability in output changes.

[0155] In some embodiments of this application, the model improvement submodule may include the following units:

[0156] The weakness improvement unit is used to identify potential weaknesses in the preset power system artificial intelligence model, provide feedback data to the preset power system artificial intelligence model under different operating conditions to address the potential weaknesses, and improve the preset power system artificial intelligence model based on the feedback data.

[0157] In this embodiment, a multi-head attention mechanism is used to process multimodal input data from a power system, identify and weight key features in the data, obtain multi-head attention output based on these key features, and generate targeted disturbance data based on the multi-head attention output. Then, the targeted disturbance data is input into a preset power system artificial intelligence model, and the output changes of the preset power system artificial intelligence model are observed and recorded to obtain the model disturbance response results. Finally, the preset power system artificial intelligence model is improved or a security assessment is performed based on the model disturbance response results, completing the model disturbance test. By combining multi-head attention and disturbance testing, the multi-head attention mechanism extracts multimodal data features from the power system, overcoming the limitations of traditional testing methods on single data types. Furthermore, the multi-head attention mechanism analyzes key features in model decision-making, helping to identify model vulnerabilities and providing a reference for optimization and defense. By generating a targeted disturbance test model, the model's ability to resist malicious attacks is enhanced, improving the security of the power system and ensuring its stable and safe operation.

[0158] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0159] This application also provides an electronic device, see embodiments thereof. Figure 6 The provided electronic device 600 includes a memory 610, a processor 620, and a computer program 611 stored in the memory 610 and capable of running on the processor 620. When the computer program 611 is executed by the processor, it implements the various processes of the above-described multi-head attention perturbation test method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0160] This application also provides a computer-readable storage medium, see embodiments thereof. Figure 7 The computer-readable storage medium 700 provides a computer program 611 stored on it. When the computer program 611 is executed by the processor, it implements the various processes of the above-described multi-head attention perturbation test method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0161] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0162] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of the embodiments of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or modules is not necessarily limited to those steps or modules explicitly listed, but may include other steps or modules not explicitly listed or inherent to these processes, methods, products, or devices. The division of modules in the embodiments of this application is merely a logical division; in actual applications, there may be other division methods. For example, multiple modules may be combined into or integrated into another system, or some features may be ignored or not performed. Additionally, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interface, and the indirect coupling or communication connection between modules may be electrical or other similar forms, none of which are limited in the embodiments of this application. Furthermore, the modules or sub-modules described as separate components may or may not be physically separated, may or may not be physical modules, or may be distributed among multiple circuit modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiments of this application.

[0163] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0164] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and modules described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0165] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between devices or modules through some interfaces, and may be electrical, mechanical, or other forms.

[0166] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0167] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium.

[0168] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.

[0169] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0170] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0171] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The functions specified in one or more boxes; these computer program instructions may also be loaded onto a computer or other programmable data processing terminal equipment to cause a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0172] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.

[0173] Finally, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.

[0174] The technical solutions provided in the embodiments of this application have been described in detail above. Specific examples have been used in the embodiments of this application to illustrate the principles and implementation methods of the embodiments of this application. The description of the above embodiments is only for the purpose of helping to understand the methods and core ideas of the embodiments of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the embodiments of this application. Therefore, the content of this specification should not be construed as a limitation on the embodiments of this application.

Claims

1. A multi-head attention perturbation testing method, characterized in that, The method includes: Acquire multimodal input data from the power system; The multi-head attention mechanism is used to process the multimodal input data, identify and weight key features in the data, and obtain multi-head attention output based on the key features; Targeted perturbation data is generated based on the multi-head attention output; The targeted disturbance data is input into a preset power system artificial intelligence model, and the output changes of the preset power system artificial intelligence model are observed and recorded to obtain the model disturbance response results; Based on the model disturbance response results, the preset power system artificial intelligence model is improved or a security assessment is conducted to complete the model disturbance test.

2. The method according to claim 1, characterized in that, The key features include query vector, key vector, and value vector; the process of using a multi-head attention mechanism to process the multimodal input data, identify and weight key features in the data, and obtain multi-head attention output based on the key features includes: Using a multi-head attention mechanism, the multimodal input data is mapped into a representation space of query, key, and value based on a preset linear transformation matrix, resulting in query vector, key vector, and value vector; The attention weights of each attention head are calculated based on the query vector, the key vector, and the dimension of the key vector, respectively. The output of each attention head is calculated based on the attention weights and the value vector, respectively. The outputs of each attention head are concatenated to obtain the final multi-head attention output.

3. The method according to claim 2, characterized in that, The method of using a multi-head attention mechanism to map the multimodal input data into query vectors, key vectors, and value vectors based on a preset linear transformation matrix includes: Feature extraction and embedding transformation are performed on the multimodal input data to obtain an embedding vector sequence of the same dimension; Using a multi-head attention mechanism, the embedded vector sequence is mapped into a query vector, a key vector, and a value vector based on a preset linear transformation matrix; wherein each row corresponds to an element in the sequence, and each column corresponds to a feature dimension; the query vector and the key vector are used to calculate relevance, and the value vector is used to aggregate information; each attention head has an independent preset linear transformation matrix, and the mapping features corresponding to different types of data are determined by the preset linear transformation matrix independently learned by each attention head.

4. The method according to claim 1, characterized in that, The step of generating targeted perturbation data based on the multi-head attention output includes: Starting from zero perturbation, the gradient of the loss function with respect to the multi-head attention output is calculated iteratively multiple times, and the perturbation vector is updated along the ascending direction of the gradient; After each update of the perturbation vector, a truncation operation is performed on each dimension component of the perturbation vector to control the perturbation vector within a preset range, thereby obtaining targeted perturbation data.

5. The method according to claim 1, characterized in that, The step of inputting the targeted disturbance data into a preset power system artificial intelligence model, observing and recording the output changes of the preset power system artificial intelligence model, and obtaining the model disturbance response results includes: The targeted disturbance data is input into a preset power system artificial intelligence model. The prediction results, confidence level, attention weight, and any abnormal behavior of the preset power system artificial intelligence model are observed, and the corresponding output changes are recorded. The output changes are used to indicate the change between the output of the preset power system artificial intelligence model under the targeted disturbance data and the output of the preset power system artificial intelligence model under normal data. The model perturbation response result is generated based on the output change.

6. The method according to claim 1 or 5, characterized in that, The improvement or security assessment of the preset power system artificial intelligence model based on the model disturbance response results includes: When the model disturbance response result indicates that the preset power system artificial intelligence model is vulnerable to the output change, the preset power system artificial intelligence model is improved. When the model disturbance response result shows that the preset power system artificial intelligence model does not exhibit vulnerability to the output change, a security assessment is performed on the preset power system artificial intelligence model.

7. The method according to claim 6, characterized in that, The improvement of the preset power system artificial intelligence model includes: Identify potential weaknesses in the preset power system artificial intelligence model, provide feedback data to the preset power system artificial intelligence model under different operating conditions to address these potential weaknesses, and improve the preset power system artificial intelligence model based on the feedback data.

8. A multi-head attention perturbation testing device, characterized in that, The device includes: The input data acquisition module is used to acquire multimodal input data from the power system; The multi-head attention output module is used to process the multimodal input data using a multi-head attention mechanism, identify and weight key features in the data, and obtain multi-head attention output based on the key features; The perturbation data generation module is used to generate targeted perturbation data based on the multi-head attention output; The disturbance response result generation module is used to input the targeted disturbance data into a preset power system artificial intelligence model, observe and record the output changes of the preset power system artificial intelligence model, and obtain the model disturbance response result; The model disturbance test module is used to improve the preset power system artificial intelligence model or conduct a security assessment based on the model disturbance response results, and to complete the model disturbance test.

9. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the multi-head attention perturbation test method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the multi-head attention perturbation test method as described in any one of claims 1 to 7.