Test case-based model training method, anomaly detection method and energy storage equipment
Through a model training method based on test cases, combined with large language model, federated learning and knowledge distillation technology, a lightweight anomaly detection model is generated, which solves the real-time problem under the computing power performance limit of energy storage equipment and realizes efficient anomaly detection.
Patent Information
- Application Number
- CN202510611391.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-12
- Publication Date
- 2025-08-15
AI Technical Summary
Due to the limited computing power performance of energy storage equipment, it is difficult to meet the real-time requirements of abnormal detection. The existing technology can't meet the real-time requirements through cloud deployment models.
A model training method based on test cases is adopted, a large language model is used to generate test cases, the initial model is deployed and the test cases are executed, the model parameters are adjusted based on the abnormal detection results, the model is aggregated through federated learning, and the model is compressed through knowledge distillation technology to adapt to the computing power performance of energy storage equipment, and a lightweight abnormality detection model is generated.
It realizes the real-time requirements of energy storage equipment while ensuring the accuracy of abnormal detection, and improves the generalization ability and abnormal detection coverage of the model.
Smart Images

Figure CN120494136A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of anomaly detection of energy storage devices, and in particular relates to a model training method based on test cases, an anomaly detection method, an energy storage device, an electronic device, and a computer-readable storage medium. Background Art
[0002] Currently, due to the limitations of the computing power of energy storage devices, energy storage devices generally upload data to the cloud, and the anomaly detection model deployed in the cloud performs anomaly detection, which is difficult to meet the real-time detection needs of some anomalies of energy storage devices. Summary of the Invention
[0003] This application aims to solve at least one of the technical problems existing in the prior art. To this end, this application proposes a model training method based on test cases, anomaly detection method, energy storage device, electronic device, and computer-readable storage medium, which can meet the real-time requirements of anomaly detection for energy storage devices while ensuring anomaly detection accuracy.
[0004] In a first aspect, the present application provides a test case-based model training method for training an anomaly detection model, wherein the anomaly detection model is used to detect anomalies of an energy storage device. The method includes generating a test case for testing the energy storage device based on a large language model; deploying an initial model to the energy storage device and executing the test case, wherein the test case is used to control the energy storage device and at least one of the devices associated with the energy storage device to perform corresponding operations; adjusting the model parameters of the initial model based on the anomaly detection result of the initial model and the test result of the test case; aggregating the model parameters of the initial models of each of the energy storage devices based on federated learning technology to generate a global model; and compressing the global model based on knowledge distillation technology to obtain the anomaly detection model.
[0005] In a second aspect, the present application provides an anomaly detection method. The method is applied to an energy storage device, wherein the energy storage device is equipped with an anomaly detection model trained using the above-mentioned model training method. The method comprises: obtaining operating data of the energy storage device; and performing anomaly detection based on the operating data to obtain an anomaly detection result.
[0006] In a third aspect, the present application provides an energy storage device, which is deployed with an anomaly detection model trained by the above-mentioned model training method, and the anomaly detection model is used to perform anomaly detection based on the operating data of the energy storage device to obtain anomaly detection results.
[0007] In a fourth aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned model training method or anomaly detection method when executing the program.
[0008] In a fifth aspect, the present application provides a non-transitory computer-readable storage medium on which a computer program is stored, which implements the above-mentioned model training method or anomaly detection method when executed by a processor.
[0009] The test case-based model training method, anomaly detection method, energy storage device, electronic device and computer-readable storage medium provided in the embodiments of the present application can quickly generate a variety of test cases through a large language model to meet the testing requirements of the energy storage device.
[0010] The test results from executing test cases on the energy storage device can be used as training data for the initial model deployed on the energy storage device. Combined with the anomaly detection results of the initial model, local training of the energy storage device can be achieved. Because the large language model can generate a rich set of test cases, it can cover more abnormal scenarios and improve the generalization ability of the trained model.
[0011] After the initial model training reaches convergence, the model parameters of the initial model of each energy storage device can be transmitted to the cloud, and the cloud will implement model aggregation based on federated learning to obtain a global model with high anomaly detection accuracy and coverage.
[0012] Afterwards, in order to adapt to the computing power performance of the energy storage device, the global model is compressed into a lightweight anomaly detection model through knowledge distillation technology, thereby ensuring that the model can be deployed to the energy storage device to realize energy storage device anomaly detection, thereby meeting the real-time anomaly detection needs of the energy storage device while ensuring the accuracy of anomaly detection.
[0013] Additional aspects and advantages of the embodiments of the present application will be given in part in the description below, and in part will become obvious from the description below, or will be learned through practice of the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0015] Figure 1 This is a schematic diagram of an application scenario of the model training method provided in an embodiment of the present application;
[0016] Figure 2 This is a first flow chart of the model training method provided in an embodiment of the present application;
[0017] Figure 3 Schematic diagram of a scenario of anomaly detection method provided in an embodiment of the present application;
[0018] Figure 4 This is a second flow chart of the model training method provided in an embodiment of the present application;
[0019] Figure 5 This is a schematic diagram of the first process of the anomaly detection method provided in an embodiment of the present application;
[0020] Figure 6 This is a second flow chart of the anomaly detection method provided in an embodiment of the present application;
[0021] Figure 7 This is a module diagram of the model training device provided in an embodiment of the present application;
[0022] Figure 8 This is a schematic diagram of a module of an anomaly detection device provided in an embodiment of the present application;
[0023] Figure 9 is a schematic structural diagram of an electronic device provided in an embodiment of the present application; and
[0024] Figure 10 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] The following describes in detail embodiments of the present application. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and should not be understood as limiting the present application.
[0026] See also Figure 1 , Figure 1 101 is an application scenario diagram of a model training method provided in an embodiment of the present application. The application scenario provided in the present application includes a terminal device 101, a server 102, and an energy storage device 103. The model training method provided in the present application can be executed by at least one of the terminal device 101, the server 102, and the energy storage device 103.
[0027] Among them, the terminal device can be: a mobile phone, a computer, a wearable device (such as AR (Augmented Reality goggles) glasses, VR (Virtual Reality) glasses, XR (Extended Reality) glasses, a head-mounted display, etc.), security equipment, smart home equipment, a robot, and other devices that can be installed with a photoelectric sensing system. The embodiments of this application do not limit this.
[0028] The terminal device may be integrated with a client, which may be a client capable of displaying data information such as text, images, audio, and video, including but not limited to a device control client associated with the energy storage device to enable communication and control of the energy storage device. The client may be a standalone client or an embedded sub-client integrated into a client (e.g., a social networking client), without limitation.
[0029] The terminal device can communicate with the energy storage device to obtain the operating information of the energy storage device.
[0030] The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The embodiments of this application do not limit this.
[0031] Energy storage equipment is a device used to store energy. It can store energy when there is excess energy and release the stored energy when needed to meet the needs of various application scenarios.
[0032] Optionally, the energy storage device may be a portable energy storage device. A portable energy storage device is a small energy storage system with a built-in lithium-ion battery that can provide a stable AC / DC voltage output and has the characteristics of large capacity, high power, safety, and portability.
[0033] The server can also communicate with the energy storage device to obtain the operating information of the energy storage device.
[0034] It should be noted that Figure 1 The number of terminal devices and servers is only for example, and the number of terminal devices and servers can be more or less, which is not limited here. The terminal devices and servers can be directly or indirectly connected via wired or wireless communication, which is not limited here.
[0035] The model training method involved in this application can be implemented based on cloud technology.
[0036] Among them, cloud technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data calculation, storage, processing and sharing.
[0037] Cloud technology is a general term for network technologies, information technologies, integration technologies, management platform technologies, and application technologies based on the cloud computing business model. It can form a resource pool that can be used flexibly and conveniently on demand. Cloud computing technology will become a crucial support. Backend services for technical network systems, such as video websites, image websites, and more portals, require extensive computing and storage resources. With the rapid development and application of the internet industry, every item will likely have its own unique identifier, requiring transmission to backend systems for logical processing. Different levels of data will be processed separately, and data from various industries will require a strong system backend, which can only be achieved through cloud computing.
[0038] The model training method of this application can be implemented based on cloud computing. Cloud computing is a computing model that distributes computing tasks across a resource pool consisting of a large number of computers, enabling various application systems to obtain computing power, storage space, and information services as needed. The network that provides resources is called a "cloud." The resources in the "cloud" appear to users to be infinitely scalable and can be accessed at any time, used on demand, expanded at any time, and paid for on a per-use basis.
[0039] As a provider of cloud computing infrastructure, a cloud computing resource pool (referred to as a cloud platform, generally referred to as an IaaS (Infrastructure as a Service) platform) is established. Various types of virtual resources are deployed in the resource pool for external customers to choose and use. The cloud computing resource pool mainly includes: computing devices (virtualized machines, including operating systems), storage devices, and network devices.
[0040] The model training method in the embodiments of the present application can be executed by an electronic device, which can be at least one of a server and a terminal device. That is, the method can be executed by the server or the terminal device alone, or by the server and the terminal device together. Therefore, the execution entity of each step will not be repeated below.
[0041] It should be noted that in the examples of the model training method below, the server executing the model training method is used as an example for explanation. Based on their understanding of the following, those skilled in the art can apply the model training method provided in the embodiments of the present application to other types of scenarios (such as terminal devices; or terminal devices and servers cooperating to execute the model training method).
[0042] Based on the above introduction, the present invention provides a model training method, which is described in detail below:
[0043] See also Figure 2A model training method provided in an embodiment of the present application is implemented by steps 011 to 015, which are described in detail below.
[0044] Step 011: Generate test cases for testing energy storage devices based on the large language model.
[0045] Among them, the large language model is a natural language processing model based on deep learning, which has the characteristics of large parameter scale, strong language understanding and generation capabilities, etc.
[0046] For example, large language models can be OpenAI's GPT series, Google's BERT, Baidu's Wenxin Yiyan, Alibaba's Tongyi Qianwen, etc.
[0047] Among them, a test case is a set of inputs, execution conditions and expected results designed to test the functions, performance, reliability and other aspects of software, systems or products.
[0048] In this application, test cases are used to test various functions, performance, reliability, etc. of energy storage devices.
[0049] Taking a large language model as an example, here are some ideas and examples for designing test cases:
[0050] For example, to design a test case for the functional test of an energy storage device, you can quickly generate the test case by inputting: "Generate a data reporting test for an energy storage device in a high-temperature, high-latency environment, and simulate a man-in-the-middle attack." into the large language model.
[0051] For example, design a test case that "simulates communication between energy storage devices and the cloud, sets different conditions, and injects 50ms network delay at the same time."
[0052] In this way, complex test cases are automatically generated through natural language descriptions based on a large language model. The test case generation efficiency is high, and test cases covering more test scenarios of energy storage devices can be generated.
[0053] Step 012: Deploy the initial model to the energy storage device and execute test cases, where the test cases are used to control the energy storage device and at least one of the devices associated with the energy storage device to perform corresponding operations.
[0054] The initial model is a model that has not been trained or has been preliminarily trained for anomaly detection. The anomaly detection accuracy and anomaly coverage of the initial model are generally low.
[0055] For example, the initial model can be a long short-term memory network (LSTM), a recurrent neural network (RNN), a feed-forward neural network (FFNN), a convolutional neural network (CNN), etc.
[0056] Specifically, before executing the test case, the initial model can be deployed to the energy storage device to utilize the data when executing the test case to train the initial model.
[0057] After the initial model is deployed, the energy storage device can be tested and the initial model can be trained by executing test cases.
[0058] It is understandable that to implement the test of the energy storage device, it may be necessary not only to control the energy storage device to perform corresponding operations, but also to control devices associated with the energy storage device to perform corresponding operations.
[0059] For example, when conducting reliability testing of firmware upgrades for energy storage devices in an environment with network fluctuations (such as 5G network fluctuations, WIFI network fluctuations, etc.), in addition to controlling the energy storage devices to perform firmware upgrade operations, it is also necessary to control the network management equipment to adjust network parameters to simulate the network fluctuation environment.
[0060] Generally, when a test case is executed, the type of exception that occurs is generally certain. The test results after executing the test case can indicate whether there is an exception and the type of exception.
[0061] Regardless of whether the energy storage device has an abnormality, training samples for initial model training can be obtained.
[0062] For example, when performing reliability testing on a firmware upgrade of an energy storage device in an environment with network fluctuations (such as 5G network fluctuations, Wi-Fi network fluctuations, etc.), the anomaly is the network fluctuation anomaly, and training samples corresponding to the network fluctuation anomaly can be obtained.
[0063] Alternatively, during the data reporting test, if data reporting is interrupted or slow, a training sample with abnormal data reporting may be obtained; and if data reporting is normal, a training sample without abnormalities may be obtained.
[0064] In this way, by deploying the initial model to the energy storage device and then executing the test cases, training samples corresponding to various anomalies can be obtained.
[0065] Step 013: Based on the anomaly detection results of the initial model and the test results of the test case, adjust the model parameters of the initial model.
[0066] Specifically, when executing the test case, the initial model will perform anomaly detection based on the operating data of the energy storage device, thereby obtaining anomaly detection results, such as whether an anomaly exists and the type of anomaly.
[0067] After executing the test case, the test case has an expected running result. If the actual test result does not match the expected running result, the test fails, thereby completing the test of the energy storage device.
[0068] At the same time, the test results can also characterize the abnormal conditions of the energy storage equipment, such as whether there is an abnormality and the type of abnormality.
[0069] Optionally, operating data of the energy storage device after executing the test case may be obtained; and a test result of the test case may be determined based on the operating data.
[0070] The test result may include whether the energy storage device was tested. Alternatively, if the energy storage device has an anomaly that causes the test to fail, the test result may also include anomaly information.
[0071] Specifically, after executing the test case, if there is no abnormality in the energy storage device, the operating data of the energy storage device is consistent with the operating data expected by the test case. If there is an abnormality in the energy storage device, the operating data of the energy storage device is inconsistent with the operating data expected by the test case. Based on the difference between the operating data of the energy storage device and the operating data expected by the test case, the abnormal information of the energy storage device (such as the abnormality type) can be quickly determined.
[0072] In this way, the test results after executing the test case can quickly determine whether there is an anomaly and the type of anomaly. The anomaly information in the test results can be used as the label value of the training sample, and the anomaly detection results obtained by the initial model test can be used as the prediction value.
[0073] The model loss is calculated using the predicted and labeled values. Model parameters (such as weights and biases) are then adjusted based on the loss, causing the gradient of the initial model to decrease. As test cases are continuously executed, the gradient of the initial model continues to decrease until convergence.
[0074] Step 014: Based on the federated learning technology, the model parameters of the initial models of each energy storage device are aggregated to generate a global model.
[0075] Federated learning is an emerging machine learning technology that allows for collaborative learning among multiple parties while protecting their data privacy. The following is a detailed introduction to federated learning:
[0076] Traditional machine learning methods typically require all data to be centralized on a central server for training. However, in many real-world scenarios, data is often dispersed across different institutions or users, and cannot be directly shared due to privacy and security regulations. Federated learning was proposed to address these issues, enabling all participants to jointly train a global model without leaking local data.
[0077] How Federated Learning Works:
[0078] Data isolation and local training: Each node participating in federated learning (e.g., different organizations or devices) retains its own data locally and does not transfer data. Each node trains the model on the local dataset and calculates the model's gradients or parameter updates.
[0079] Encrypted communication and parameter aggregation: Each node sends the model update information obtained from local training to a central server (or other aggregation node) via encrypted communication. After receiving these updates, the central server uses a specific aggregation algorithm (such as average aggregation) to merge them into a global model update and sends the updated global model back to each node.
[0080] Model update and iteration: After receiving the global model update, each node uses it to update the local model and then continues the next round of training on the local data, repeating the above process until the model converges or reaches the preset stopping condition.
[0081] Specifically, using federated learning technology, the model parameters of each energy storage device's initial model (e.g., one that has been trained locally to convergence) can be transmitted to a cloud server, thereby aggregating the model parameters of each initial model to generate a global model. Since only the model parameters are transmitted, the privacy protection requirements of the device can be met.
[0082] Step 015: Based on the knowledge distillation technology, compress the global model to obtain the anomaly detection model.
[0083] Knowledge distillation is a technology that achieves model compression and optimization by transferring knowledge from a large teacher model to a small student model. Using knowledge distillation to compress a large cloud-based AI model into an edge-deployable version typically involves the following steps:
[0084] Determine the teacher and student model architecture: Choose a small student model architecture suitable for edge devices, such as lightweight networks like MobileNet and ShuffleNet. These models have simple structures, few parameters, and can run efficiently on edge devices. Also, identify a large AI model in the cloud as the teacher model.
[0085] Extracting Teacher Model Knowledge: After training on a large amount of data, the teacher model accumulates a wealth of knowledge. This knowledge includes not only model parameters but also data feature representations and output distributions. For example, in image classification tasks, the teacher model's feature extraction methods for various types of images and its prediction of probability distributions for different categories are crucial knowledge.
[0086] Select a distillation algorithm: Choose an appropriate distillation algorithm based on the type of knowledge. For example, in response-based knowledge distillation, the student model directly learns the final output of the teacher model, allowing the student model to imitate the output probability distribution of the teacher model. A common method is to use the soft label of the teacher model as supervision information when training the student model, so that the student model can learn the classification boundaries and uncertainty information of the teacher model. Feature-based knowledge distillation allows the student model to learn the feature representation of the intermediate layer of the teacher model, which helps the student model capture more complex patterns and structures in the data. Relationship-based knowledge distillation, the student model learns the relationship between different data samples in the representation space of the teacher model, so that the student model can adapt to changes in the input distribution.
[0087] Training the student model: When training the student model, the knowledge of the teacher model is used as a supervisory signal and combined with the student model's loss function. For example, in response-based knowledge distillation, the KL divergence is used to measure the difference between the student model's output distribution and the teacher model's soft label distribution. This is used as part of the loss function and weighted summed with the student model's original classification loss (such as cross-entropy loss) to obtain the final loss function. The backpropagation algorithm is used to update the student model's parameters so that it gradually learns the knowledge of the teacher model.
[0088] Model Evaluation and Optimization: After training is complete, the distilled student model is evaluated, such as by calculating metrics like accuracy and recall on the test set. Performance metrics like inference time and memory usage on the edge device are also measured. If model performance does not meet requirements, the distillation algorithm hyperparameters can be adjusted, such as adjusting the weights of the loss function or changing the temperature parameter, and training and evaluation can be repeated. Alternatively, the student model architecture can be fine-tuned, such as by increasing or decreasing the number of network layers or adjusting the convolution kernel size, to further optimize model performance.
[0089] Deploy to edge devices: Deploy the evaluated and optimized student model to the edge device. During deployment, select an appropriate model deployment framework, such as TensorFlowLite or PyTorch, based on the edge device's hardware platform and operating system. Convert the model to the appropriate format and perform necessary optimizations, such as quantization and pruning, to further improve the model's operational efficiency on the edge device.
[0090] Specifically, after obtaining the global model, since the model parameters of the global model are generally large, if the global model is directly deployed to the edge device (such as the energy storage device of this application), the energy storage device may be difficult to meet the deployment requirements, and the computing power of the energy storage device is limited. Even if the global model is deployed, it may be difficult to meet the computing power required for the operation of the global model.
[0091] Therefore, the global model is compressed through knowledge distillation technology to obtain a lightweight anomaly detection model with low parameter volume and computing power requirements, thereby meeting the model deployment requirements of energy storage equipment.
[0092] Because the global model's anomaly detection accuracy and coverage (i.e., generalization capability) are both high, the anomaly detection model after knowledge distillation also has high anomaly detection accuracy and generalization capability. Furthermore, when deployed on energy storage devices, this lightweight anomaly detection model can meet the energy storage device's real-time anomaly detection needs.
[0093] See also Figure 3 In one example, each device (such as energy storage equipment) performs local preliminary training through the federated learning client, uploads the desensitized model parameters to the federated learning server, aggregates the initial global model, and then lightweights the initial model (such as compression based on knowledge distillation technology) to deploy it on each device.
[0094] Then, the generative AI (i.e., large language model) generates and executes various test cases to train the initial model of each device. After training, the model parameters are transmitted to the server again. The server aggregates and generates a global model. After the global model is lightweight, the anomaly detection model is obtained and deployed on each device to realize anomaly detection of each device.
[0095] The test case-based model training method provided in the embodiment of the present application can quickly generate a variety of test cases through a large language model to meet the testing requirements of energy storage equipment.
[0096] The test results from executing test cases on the energy storage device can be used as training data for the initial model deployed on the energy storage device. Combined with the anomaly detection results of the initial model, local training of the energy storage device can be achieved. Because the large language model can generate a rich set of test cases, it can cover more abnormal scenarios and improve the generalization ability of the trained model.
[0097] After the initial model training reaches convergence, the model parameters of the initial model of each energy storage device can be transmitted to the cloud, and the cloud will implement model aggregation based on federated learning to obtain a global model with high anomaly detection accuracy and coverage.
[0098] Afterwards, in order to adapt to the computing power performance of the energy storage device, the global model is compressed into a lightweight anomaly detection model through knowledge distillation technology, which can then be deployed to the energy storage device to realize energy storage device anomaly detection, thereby meeting the real-time anomaly detection needs of the energy storage device while ensuring the accuracy of anomaly detection.
[0099] In some embodiments, see Figure 4 , the model training method also includes:
[0100] Step 016: Set up the network environment required for the test case.
[0101] Specifically, current test cases generally only implement the control of energy storage devices, resulting in low test scenario coverage.
[0102] Therefore, by building the network environment required for test cases, we can cover more test scenarios, generate richer test cases, and improve the testing results of energy storage devices. Richer test cases can also cover more abnormal scenarios, thereby improving the anomaly detection accuracy and generalization ability of the ultimately deployed anomaly detection model.
[0103] For example, existing solutions cannot generate network fluctuation and device failure models that match real-world scenarios in real time. This application can achieve network fluctuation and device failure models that match real-world scenarios by building the network environment required for test cases.
[0104] Please refer again Figure 4 Optionally, step 016: Building the network environment required for the test case, including:
[0105] Step 0161: Generate network data corresponding to the anomaly tested by the simulated test case based on the generative adversarial network;
[0106] Step 0162: Based on the network data, control the software-defined network controller to adjust network parameters so that the network environment matches the test case.
[0107] Among them, Generative Adversarial Network (GAN) is a deep learning model. Its basic principle is:
[0108] A GAN consists of two main components: a generator and a discriminator. The generator's goal is to produce samples that look like real data, while the discriminator's task is to distinguish whether the input sample is real data or fake data generated by the generator. Both are trained through an adversarial game, continuously optimizing their parameters until the generator can produce sufficiently realistic samples that the discriminator cannot distinguish between real and fake.
[0109] The software-defined network (SDN) controller can adjust the device communication environment in real time by collecting network information, analyzing network status, and issuing control instructions. The following is a detailed introduction:
[0110] (1) Collecting network information
[0111] The SDN controller communicates with switches, routers, and other devices in the network to collect various network information, including link status, device load, and traffic distribution. For example, the controller can periodically send probe messages to devices to obtain link bandwidth usage, latency, packet loss rate, and other indicators.
[0112] The controller can also monitor traffic information in the network to understand the size and direction of traffic generated by different applications or users, so as to fully understand the operation status of the network.
[0113] (2) Analyze network status
[0114] Based on the collected network information, the SDN controller uses corresponding algorithms and models to analyze the network status. For example, it can determine whether there are areas of network congestion by analyzing traffic distribution and assess whether a device is overloaded or idle based on device load information.
[0115] The controller can also predict network traffic trends and prepare for resource allocation in advance. For example, based on historical traffic data and current business needs, it can predict traffic growth in a specific area within a certain time period, providing a basis for real-time adjustments to the device communication environment.
[0116] (3) Issue control instructions
[0117] When the SDN controller detects an anomaly in the network or requires optimization, it issues control instructions to network devices to adjust their communication environment. For example, if congestion is detected on a link, the controller can update flow table entries to redirect some traffic to other idle links, achieving balanced traffic distribution.
[0118] The controller can also dynamically adjust the device's operating mode or assign different tasks based on the device's load. For example, it can shift non-critical traffic from overloaded devices to idle devices to improve resource utilization and communication efficiency across the entire network.
[0119] Through the above methods, the SDN controller can perceive network changes in real time and adjust the device communication environment in a timely manner, thereby improving the flexibility, reliability and performance of the network and better meeting the communication needs in different application scenarios.
[0120] Specifically, through the pre-trained generative adversarial network, network data corresponding to the simulated test cases can be generated.
[0121] For example, when conducting reliability tests on firmware upgrades of energy storage devices under network fluctuations (such as 5G network fluctuations, WIFI network fluctuations, etc.), the generative adversarial network can generate a network traffic fluctuation curve (a type of the above-mentioned network data) of the energy storage device under network fluctuations.
[0122] After the network data is generated, the network parameters of the software-defined network controller can be controlled based on the network data to match the network environment with the test case.
[0123] For example, based on the above-mentioned network traffic fluctuation curve, the SDN controller can adjust the parameters of the network equipment at the corresponding moment (such as the uplink rate limit parameters and downlink rate limit parameters of the router) so that the network traffic curve when the energy storage device updates the firmware is consistent with the network traffic fluctuation curve generated by the generative adversarial network, thereby realizing the construction of a network fluctuation environment.
[0124] In some embodiments, the number of times a test case is executed is positively correlated with the occurrence frequency of anomalies corresponding to the test case.
[0125] Understandably, different anomalies occur at varying frequencies during energy storage device operation. Some anomalies occur frequently, while others may not even occur until the energy storage device is scrapped. Therefore, when training the model, it is important to focus on learning the anomalies that occur most frequently.
[0126] Therefore, when generating test cases, the number of times the test cases are executed can be determined based on the frequency of occurrence of the anomalies covered by the test cases. For example, the higher the frequency of occurrence of the anomalies, the more times the corresponding test cases are executed. As a result, the more frequent the anomalies, the more training samples are generated, and reinforcement learning of frequently occurring anomalies is achieved, giving priority to ensuring the recognition rate of frequently occurring anomalies.
[0127] In some embodiments, when executing a test case, feedback information of the energy storage device is obtained; when it is determined based on the feedback information that the energy storage device does not meet the test conditions of the test case, execution of the test case is stopped.
[0128] Specifically, the execution of a test case requires the energy storage device to meet the corresponding execution conditions. Therefore, when executing a test case, feedback information from the energy storage device can be obtained to determine whether the test case can be executed normally. If not, the test case execution is stopped and the energy storage device performs the corresponding processing before executing the test case again. Alternatively, other test cases can be executed.
[0129] For example, if the test case is a stress test, a large amount of data related to the energy storage device's operation, such as voltage, current, temperature, and charge / discharge status, must be collected, stored, and processed in real time during the stress test. Storing and processing this data requires a certain amount of memory. Insufficient memory can lead to data loss, reduced acquisition frequency, or slower processing speeds, affecting the accurate assessment of energy storage device performance. Therefore, stress testing is suspended when memory overflow is detected.
[0130] See also Figure 5 The present application also provides an anomaly detection method applied to an energy storage device, wherein the energy storage device is deployed with an anomaly detection model trained by the model training method according to any of the above embodiments, and the method comprises:
[0131] Step 021: Obtaining operating data of the energy storage device;
[0132] Step 022: Perform anomaly detection based on the operating data to obtain anomaly detection results.
[0133] Specifically, after the anomaly detection model is trained, it can be deployed to the energy storage device. Once the anomaly detection model is deployed on the energy storage device, the anomaly detection model can detect anomalies based on the operating data of the energy storage device during its operation, thereby obtaining anomaly detection results.
[0134] For example, when it is detected in real time that the data of a certain sensor deviates from the normal range by more than 3σ, the sensor is determined to be abnormal.
[0135] In this way, the anomaly detection model can detect anomalies of the energy storage device in real time, thereby meeting the real-time requirements of anomaly detection of the energy storage device.
[0136] See also Figure 6 Optionally, step 022: performing anomaly detection based on the operating data to obtain an anomaly detection result, including:
[0137] Step 0221: When the computing power required for reasoning based on the operating data is greater than the computing power of the energy storage device, upload the operating data to the cloud for reasoning via the cloud;
[0138] Step 0222: Based on the inference results sent from the cloud, perform anomaly detection to obtain anomaly detection results.
[0139] Specifically, due to the limitations of the computing power performance of the energy storage device, the detection of some anomalies requires a high amount of computing power, resulting in a slow anomaly detection speed of the anomaly detection model of the energy storage device. During the reasoning process of the anomaly detection model, if the energy storage device exhibits an anomaly again, the energy storage device may be unable to detect the anomaly in real time, thereby affecting the real-time performance of the anomaly detection of the energy storage device.
[0140] Therefore, if the computing power required for reasoning based on operating data exceeds that of the energy storage device, or if real-time performance is not a high priority, the operating data can be uploaded to the cloud for inference. The energy storage device receives the inference results from the cloud for subsequent anomaly detection, thereby quickly obtaining anomaly detection results.
[0141] Optionally, the inference result on the cloud may be an anomaly detection result, or may be an inference result of one of multiple inference tasks in the anomaly detection process.
[0142] During the cloud-based inference process, the anomaly detection model of the energy storage device can also perform anomaly detection of the energy storage device simultaneously, thereby ensuring the timeliness of anomaly detection of the energy storage device.
[0143] According to the method described in the above embodiment, the present application embodiment also provides a model training device 300 for executing the steps in the above model training method. Figure 7 , Figure 7 : is a module diagram of a model training device 300 provided in an embodiment of the present application. The model training device 300 includes:
[0144] A generating module 301 is used to generate test cases for testing energy storage devices based on a large language model;
[0145] A deployment module 302 is configured to deploy the initial model to the energy storage device and execute a test case, wherein the test case is configured to control at least one of the energy storage device and a device associated with the energy storage device to perform a corresponding operation;
[0146] An adjustment module 303 is configured to adjust model parameters of the initial model based on anomaly detection results of the initial model and test results of the test case;
[0147] Aggregation module 304, configured to aggregate model parameters of initial models of various energy storage devices based on federated learning technology to generate a global model;
[0148] The compression module 305 is used to compress the global model based on the knowledge distillation technology to obtain an anomaly detection model.
[0149] It should be noted that the specific details of each module unit in the above-mentioned model training device have been described in detail in the embodiment of the above-mentioned model training method and will not be repeated here.
[0150] According to the method described in the above embodiment, the present application embodiment also provides an anomaly detection model 400 for executing the steps in the above anomaly detection method. Figure 8 , Figure 84 is a schematic diagram of the modules of the anomaly detection model 400 provided in an embodiment of the present application. The anomaly detection model 400 includes:
[0151] An acquisition module 401 is used to acquire operating data of an energy storage device;
[0152] The anomaly detection module 402 is used to perform anomaly detection based on the operating data to obtain an anomaly detection result.
[0153] It should be noted that the specific details of each module unit in the above-mentioned anomaly detection model have been described in detail in the embodiment of the above-mentioned anomaly detection method and will not be repeated here.
[0154] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0155] In some embodiments, the model training device or anomaly detection model in the embodiments of the present application can be implemented in hardware, such as an electronic device or a component in an electronic device, such as an integrated circuit or chip; the model training device or anomaly detection model can also be implemented in software, such as as an application installed in an electronic device.
[0156] In some embodiments, the energy storage device of the present application includes an anomaly detection model trained by the model training method of any of the above-mentioned embodiments, and the anomaly detection model is used to perform anomaly detection based on the operating data of the energy storage device to obtain anomaly detection results.
[0157] Optionally, the energy storage device includes a controller, which can execute various processes of the embodiment of the above-mentioned abnormality detection method and achieve the same technical effect. To avoid repetition, it will not be described here.
[0158] In some embodiments, see Figure 9 , Figure 9 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Electronic device 500 includes a processor 501 and a memory 502. Memory 502 stores a computer program 503 that can be executed on processor 501. When executed by processor 501, program 503 implements the various processes of the embodiment of the above-mentioned model training method and can achieve the same technical effects. To avoid repetition, it will not be repeated here.
[0159] See also Figure 10 , Figure 10 Schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. The electronic device can be a terminal or a server. Exemplarily, the electronic device 700 includes a central processing unit (CPU) 701, a system memory 704 including a random access memory (RAM) 702 and a read-only memory (ROM) 703, and a system bus 705 connecting the system memory 704 and the central processing unit 701.
[0160] In some embodiments, the electronic device 700 may also include a basic input / output system (BIOS) 706 for facilitating information transmission between various components within the computer, and a large-capacity storage device 707 for storing an operating system 713, a client 714, and other program modules 715.
[0161] In some embodiments, the basic input / output system 706 includes a display 708 for displaying information and an input device 709 such as a touch panel or other input device for user input of information. A touch panel is also called a touch screen. A touch panel may include two parts: a touch device and a touch controller. Other input devices may include, but are not limited to, a physical keyboard, function keys (such as a volume control button, an on / off button, etc.), a trackball, a mouse, and a joystick, which are not described in detail here.
[0162] The display 708 and input device 709 are both connected to the CPU 701 via an input / output controller 710 connected to the system bus 705. The basic input / output system 706 may also include an input / output controller 710 for receiving and processing input from a touch panel, other input devices, etc. Similarly, the input / output system 706 may also include output devices, such as a display screen, a printer, or other types of output devices.
[0163] The mass storage device 707 is connected to the central processing unit 701 via a mass storage controller (not shown) connected to the system bus 705. The mass storage device 707 and its associated computer-readable media provide non-volatile storage for the electronic device 700. In other words, the mass storage device 707 may include a computer-readable medium (not shown) such as a hard disk or a Compact Disc Read-Only Memory (CD-ROM) drive.
[0164] According to various embodiments of the present application, the electronic device 700 can also be connected to a remote computer on a network via a network such as the Internet. That is, the electronic device 700 can be connected to the network 717 via the network interface unit 716 connected to the system bus 705, or the network interface unit 716 can be used to connect to other types of networks or remote computer systems (not shown).
[0165] An embodiment of the present application also provides a non-transitory computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the various processes of the embodiment of the above-mentioned model training method and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0166] The processor may be the processor in the electronic device in the above embodiment. The computer readable storage medium may be a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0167] Computer-readable media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), flash memory or other solid-state memory technology, CD-ROM, Digital Versatile Disc (DVD) or other optical storage, tape cassettes, magnetic tape, disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that computer storage media are not limited to the above.
[0168] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the aforementioned model training method. The processor may be a processor in the electronic device described in the aforementioned embodiment. When executed by the processor, the computer program implements the various processes of the aforementioned model training method embodiment, achieving the same technical effects. To avoid repetition, these processes are not described here.
[0169] It is understandable that in the specific implementation of this application, data related to user identity or characteristics is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
Claims
1. A model training method based on test cases, characterized in that: For training an anomaly detection model, the anomaly detection model is used to detect anomalies of an energy storage device, and the method includes: generating test cases for testing the energy storage device based on the large language model; deploying an initial model to the energy storage device and executing the test case, wherein the test case is used to control at least one of the energy storage device and a device associated with the energy storage device to perform a corresponding operation; Adjusting model parameters of the initial model based on the anomaly detection result of the initial model and the test result of the test case; Based on federated learning technology, aggregating model parameters of the initial models of the energy storage devices to generate a global model; Based on the knowledge distillation technology, the global model is compressed to obtain the anomaly detection model.
2. The model training method according to claim 1, characterized in that Before executing the test case, the method further includes: Build the network environment required for the test case.
3. The model training method according to claim 2, characterized in that The network environment required to build the test case includes: Generate network data corresponding to the simulated test case based on a generative adversarial network; Based on the network data, the software-defined network controller is controlled to adjust network parameters so that the network environment matches the test case.
4. The model training method according to claim 1, characterized in that The method further comprises: Obtaining operating data of the energy storage device after executing the test case; A test result of the test case is determined based on the running data.
5. The model training method according to claim 1, characterized in that The number of times the test case is executed is positively correlated with the frequency of occurrence of the exception corresponding to the test case.
6. The model training method according to claim 1, characterized in that Also includes: When executing the test case, obtaining feedback information of the energy storage device; If it is determined based on the feedback information that the energy storage device does not meet the test condition of the test case, execution of the test case is stopped.
7. A method for detecting anomalies, characterized in that: Applied to an energy storage device, the energy storage device is deployed with an anomaly detection model trained by the method according to any one of claims 1 to 6, the method comprising: Obtaining operating data of the energy storage device; Based on the operating data, anomaly detection is performed to obtain an anomaly detection result.
8. The anomaly detection method according to claim 7, wherein: The performing anomaly detection based on the operating data to obtain an anomaly detection result includes: When the computing power required for reasoning based on the operating data is greater than the computing power of the energy storage device, uploading the operating data to the cloud for reasoning via the cloud; Based on the inference result sent by the cloud, anomaly detection is performed to obtain the anomaly detection result.
9. An energy storage device, characterized in that: The energy storage device is deployed with an anomaly detection model trained by the method according to any one of claims 1 to 6, and the anomaly detection model is used to perform anomaly detection based on the operating data of the energy storage device to obtain an anomaly detection result.
10. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method according to any one of claims 1 to 8 is implemented.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.