Model repairing method and device, nonvolatile storage medium and electronic equipment
By obtaining the output value fluctuation information and loss function of the deep learning model, determining the fault area and using parameter slices for repair, the problem of failure in the existing technology cannot be discovered and accurately located in a timely manner, and the fault repair efficiency is improved.
Patent Information
- Application Number
- CN202510663038.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-21
- Publication Date
- 2025-09-02
AI Technical Summary
In the prior art, it is impossible to timely discover and accurately locate the model fault areas during the model operation, resulting in low fault repair efficiency.
By obtaining the output value fluctuation information of the target model in the preset sliding window, using the loss function to determine the gradient amplitude of the model parameter, accurately locate the damaged model layer, and repair it based on the parameter slice.
It realizes accurate positioning and efficient repair of model faults, improving the efficiency of fault repair.
Smart Images

Figure CN120579591A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of deep learning models, and specifically, to a model repair method, device, non-volatile storage medium and electronic device. Background Art
[0002] To repair model failures, related technologies typically employ methods such as deploying redundant servers, mirroring systems, and data backup to achieve single-point fault tolerance. However, this approach is unable to promptly detect model failures and accurately locate the faulty area during model operation. This results in low fault repair efficiency in related technologies.
[0003] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0004] The embodiments of the present application provide a model repair method, device, non-volatile storage medium and electronic device to at least solve the technical problem of low fault repair efficiency caused by the inability to accurately locate the model fault area in the related art.
[0005] According to one aspect of an embodiment of the present application, a model repair method is provided, including: obtaining output value fluctuation information of a target model within a preset sliding window, and determining whether the target model has an abnormality based on the output value fluctuation information; when it is determined that the target model has an abnormality based on the output value fluctuation information, determining the model parameter gradient amplitude of each layer in the target model through a loss function; determining a model layer whose model parameter gradient amplitude is greater than a first preset amplitude threshold as a damaged model layer, and repairing the damaged model layer based on parameter slices corresponding to the damaged model layer, wherein the parameter slices include sub-matrices obtained after slicing the model parameter matrix of the target model.
[0006] Optionally, determining the output value fluctuation information of the target model within a preset sliding window includes: determining the output value mean and output value variance of the target model within the preset sliding window, wherein the output value fluctuation information includes the output value mean and output value variance; determining an output value threshold based on the output value mean and output value variance in the output value fluctuation information; determining whether the target model has an abnormality based on the output value fluctuation information, including: determining that the target model has an abnormality when the output value of the target model at a preset time is greater than the output value threshold.
[0007] Optionally, repairing the damaged model layer based on the parameter slices corresponding to the damaged model layer includes: when the damage type of the damaged model layer is parameter damage, determining the weight coefficients of the respective parameter slices corresponding to the damaged model layer; determining the calculation results obtained by multiplying the respective parameter slices and the respective weight coefficients; determining the replacement parameters of the damaged model layer based on the respective calculation results, and using the replacement parameters to replace the original parameters in the damaged model layer.
[0008] Optionally, determining the weight coefficients of each parameter slice corresponding to the damaged model layer includes: taking the minimization of the deviation between the replacement parameters and the parameters of the damaged model layer when it is not damaged as the optimization goal, and determining the weight coefficients corresponding to each parameter slice corresponding to the damaged model layer.
[0009] Optionally, after determining the replacement parameters of the damaged model layer based on each calculation result and replacing the original parameters in the damaged model layer with the replacement parameters, the method also includes: determining the model parameter gradient amplitude of the damaged model layer; when the model parameter gradient amplitude of the damaged model layer still indicates that there is an abnormality in the damaged model layer, iteratively updating the weight coefficient according to the preset learning rate and preset gradient direction, and replacing the parameters of the damaged model layer according to the updated weight coefficient after each round of iterative update, until the model parameter gradient amplitude of the damaged model layer shows that there is no abnormality in the damaged model layer.
[0010] Optionally, repairing the damaged model layer according to the parameter slice corresponding to the damaged model layer includes: when the damage type of the damaged model layer is that the neuron module in the model layer is damaged, using a spare neuron module to replace the neuron module in the damaged model layer, wherein the activation function of the spare neuron module is the same as the activation function of the neuron module in the damaged model layer; determining and loading the neuron module parameters of the spare neuron module according to the parameter slice corresponding to the damaged model layer.
[0011] Optionally, repairing the damaged model layer based on the parameter slice corresponding to the damaged model layer includes: replacing the model parameters in the damaged model layer with the parameters stored in the parameter slice; after replacing the model parameters, determining again whether the damaged model layer is successfully repaired based on the gradient amplitude of the model parameters of the damaged model layer, and if it is confirmed that the repair is not successful, replacing the neuron module in the damaged model layer, and updating the parameters of the neuron module using the parameters stored in the parameter slice.
[0012] Optionally, repairing the damaged model layer based on the parameter slices corresponding to the damaged model layer includes: when the number of damaged model layers is multiple and there is an association relationship between the damaged model layers, determining the replacement model layer based on the pre-trained sub-model corresponding to the target model layer, and using the subsequent replacement model layer to replace the damaged model layer; determining and loading the model parameters of the replacement model layer based on the parameter slices corresponding to the damaged model layer.
[0013] Optionally, the target model includes a distributed model, wherein each model layer of the distributed model is stored in a different node, and any node stores parameter slices corresponding to the model layer of an adjacent node, as well as parameter slices corresponding to the model layer of any node itself; the method also includes: when the model layer in any node is a damaged model layer, any node obtains the parameter slices corresponding to the damaged model layer in any node from the adjacent nodes of the any node, and repairs the damaged model layer based on the parameter slices corresponding to the damaged model layer.
[0014] Optionally, after repairing the damaged model layer based on the parameter slices corresponding to the damaged model layer, the method also includes: after the damaged model layer is repaired, recalculating the model parameter gradient amplitude of the damaged model layer; when the recalculated model parameter gradient amplitude is not greater than a second preset threshold, determining that the damaged model layer is successfully repaired, wherein the second preset threshold is a threshold determined based on the model parameter gradient amplitude of the damaged model layer when it is undamaged.
[0015] According to another aspect of an embodiment of the present application, a model repair device is also provided, including: a first processing module, used to obtain output value fluctuation information of a target model within a preset sliding window, and determine whether the target model has an abnormality based on the output value fluctuation information; a second processing module, used to determine the model parameter gradient amplitude of each layer in the target model through a loss function when it is determined that the target model has an abnormality based on the output value fluctuation information; a third processing module, used to determine that a model layer whose model parameter gradient amplitude is greater than a first preset amplitude threshold is a damaged model layer, and repair the damaged model layer based on the parameter slice corresponding to the damaged model layer, wherein the parameter slice includes a sub-matrix obtained after slicing the model parameter matrix of the target model.
[0016] According to another aspect of an embodiment of the present application, a non-volatile storage medium is provided, in which a program is stored. When the program is executed, the device where the non-volatile storage medium is located is controlled to execute the model repair method.
[0017] According to another aspect of an embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the processor is configured to run a program stored in the memory, wherein the model repair method is executed when the program is run.
[0018] According to another aspect of an embodiment of the present application, a computer program product is further provided, including a computer program, which implements the model repair method when executed by a processor.
[0019] In an embodiment of the present application, the output value fluctuation information of the target model within a preset sliding window is obtained, and whether the target model has an abnormality is determined based on the output value fluctuation information; when it is determined that the target model has an abnormality based on the output value fluctuation information, the model parameter gradient amplitude of each layer in the target model is determined by a loss function; the model layer whose model parameter gradient amplitude is greater than a first preset amplitude threshold is determined to be a damaged model layer, and the damaged model layer is repaired based on the parameter slice corresponding to the damaged model layer, wherein the parameter slicing includes slicing the model parameter matrix of the target model to obtain a sub-matrix, and the damaged model layer is determined by determining the model parameter gradient amplitude of each layer, thereby achieving the purpose of accurately locating the fault area, thereby realizing the technical effect of improving the fault repair efficiency, and further solving the technical problem of low fault repair efficiency caused by the inability to accurately locate the model fault area in the related technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0021] Figure 1 1 is a schematic diagram of the structure of a computer terminal (mobile terminal) provided according to an embodiment of the present application;
[0022] Figure 2 This is a flow chart of a model repair method provided according to an embodiment of the present application;
[0023] Figure 3 This is a flow chart of a model repair process provided according to an embodiment of the present application;
[0024] Figure 4 It is a structural schematic diagram of a model repair device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] Currently, during the actual deployment of deep learning models, they may be affected by factors such as hardware failures, software errors, and external attacks, resulting in damage to some parameters or structures. In order to improve the reliability and robustness of deep learning model deployment and large-scale distributed systems, related technologies mainly adopt the following methods:
[0028] 1. Backup mechanism: At the hardware level, such as servers and storage systems, single point failure tolerance is achieved by deploying redundant servers, mirroring systems, and data backup.
[0029] Existing issues: Insufficient real-time self-repair capabilities require additional hardware resources and complex synchronization mechanisms, making them difficult to scale in cost-constrained scenarios such as edge computing. The inability to proactively detect and repair damage during model execution can lead to performance degradation or instability in the early stages of damage.
[0030] 2. Model retraining and online adaptive adjustment. When a model experiences abnormal output or performance degradation, some systems use online retraining or parameter fine-tuning to restore model performance. This approach adjusts model parameters through global optimization, aiming to restore expected performance.
[0031] Existing problems: Insufficient targeted and local repair capabilities. Existing retraining methods are often global, making it difficult to efficiently and accurately recover damage to local areas in the model, resulting in local failures that may spread and affect overall performance.
[0032] In summary, while relevant technologies have been applied in areas such as redundant backup and retraining adjustments, they generally suffer from issues such as insufficient real-time performance, high recovery costs, inaccurate local repairs, and a lack of distributed collaboration. This patent addresses these technical challenges by designing self-repair capabilities for model deployment, drawing on the self-repair mechanisms of biological cells when damaged. This patent proposes a bio-inspired model self-repair deployment solution that further enhances the model's reliability and self-healing capabilities through multiple redundant encodings, real-time damage detection, and local self-repair algorithms.
[0033] In order to solve the above problems, relevant solutions are provided in the embodiments of the present application, which are described in detail below.
[0034] According to an embodiment of the present application, a method embodiment of a model repair method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0035] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing a model repair method. Figure 1 As shown, the computer terminal 10 (or mobile device 10) may include one or more (illustrated as 102a, 102b, ..., 102n) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.
[0036] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuitry may be a single independent processing module, or may be incorporated in whole or in part into any of the other components of the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuitry serves as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0037] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the model repair method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the above-mentioned model repair method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0038] The transmission device 106 is configured to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by the communications provider of the computer terminal 10. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0039] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0040] In the above operating environment, the embodiment of the present application provides a model repair method, such as Figure 2 As shown, the method includes the following steps:
[0041] Step S202: Obtain output value fluctuation information of the target model within a preset sliding window, and determine whether the target model has an abnormality based on the output value fluctuation information;
[0042] In some embodiments of the present application, during the training phase of the target model, the key model parameters of the target model can be redundantly encoded and stored so that timely recovery can be performed when the model is damaged. When encoding and storing, the model parameter matrix W of the target model can be decomposed into k slices, satisfying:
[0043]
[0044] where α i is the weight coefficient, W i is the sub-matrix after slicing.
[0045] For each shard, m redundant shards can be set for the shard, so that when a shard is damaged, its spare redundant chip can be used to complete the repair process.
[0046] As an optional implementation, the model parameter matrix can also be encoded using Reed-Solomon encoding, where the redundancy parameter during encoding = RS-Encode(W,m) (m is the number of redundant slices). In this way, the model parameter matrix is encoded into k slices and m redundant slices as backup.
[0047] In the technical solution provided in step S202, the step of determining the output value fluctuation information of the target model within a preset sliding window includes: determining the output value mean and output value variance of the target model within the preset sliding window, wherein the output value fluctuation information includes the output value mean and output value variance; and determining an output value threshold based on the output value mean and output value variance in the output value fluctuation information. The step of determining whether the target model is abnormal based on the output value fluctuation information includes: determining that the target model is abnormal when the output value of the target model at a preset time is greater than the output value threshold.
[0048] In the embodiment of the present application, a dynamic baseline detection method can be used to determine whether the target model has a fault. The specific method is to use a sliding window to calculate the output mean μ of the target model within the sliding window. t and variance Triggering a 3σ abnormal alarm. The calculation formulas for the output mean and variance are as follows:
[0049]
[0050] In the above formula, T represents the sliding window size, t represents the time point corresponding to the model output, and y i is the output of the model.
[0051] In some embodiments of the present application, when the output y_(t+1) of the model at time t+1 exceeds the range of μ_t±3σ_t, it is confirmed that the model has a fault and an abnormal alarm is triggered.
[0052] Step S204: when it is determined that the target model has an abnormality based on the output value fluctuation information, the gradient amplitude of the model parameters of each layer in the target model is determined by using the loss function;
[0053] In the technical solution provided in step S204, the loss function of the target model can be used to sequentially calculate the model parameter gradient amplitude of each layer to determine the damaged model layer.
[0054] Step S206, determine that the model layer whose model parameter gradient amplitude is greater than the first preset amplitude threshold is a damaged model layer, and repair the damaged model layer according to the parameter slice corresponding to the damaged model layer, wherein the parameter slice includes a sub-matrix obtained after slicing the model parameter matrix of the target model.
[0055] As an optional implementation, the following formula may be used to determine whether a model layer is a damaged model layer:
[0056]
[0057] In the above formula, K is a preset coefficient, and the value can be set by yourself, for example, 10. is the average value of the historical model parameter gradient amplitude of the model layer, is the model parameter gradient of the model layer, is the model parameter gradient amplitude of the model layer. That is the first preset amplitude threshold mentioned above.
[0058] In the technical solution provided in step S206, the step of repairing the damaged model layer based on the parameter slices corresponding to the damaged model layer includes: when the damage type of the damaged model layer is parameter damage, determining the weight coefficients of each parameter slice corresponding to the damaged model layer; determining the calculation results obtained by multiplying each parameter slice and the respective weight coefficients; determining the replacement parameters of the damaged model layer based on each calculation result, and using the replacement parameters to replace the original parameters in the damaged model layer.
[0059] In some embodiments of the present application, when the damage type is parameter damage, the model layer can be repaired using the following formula after the parameter slice corresponding to the model layer is determined:
[0060]
[0061] In the above formula, l is the total number of parameter slices corresponding to the model layer, W repaired is the calculated replacement parameter.
[0062] In some embodiments of the present application, the step of determining weight coefficients for each parameter slice corresponding to the damaged model layer includes determining weight coefficients for each parameter slice corresponding to the damaged model layer with minimizing the deviation between the replacement parameters and the parameters of the intact damaged model layer as an optimization objective. The weight coefficients may be determined using a least squares method.
[0063] The specific formula for optimizing the objective function is as follows:
[0064]
[0065] In the above formula, W original is the model parameter of the damaged model layer before damage, β i is the weight coefficient. As an optional implementation, after the model training is completed and the model is confirmed to be intact, the least squares method can be used to determine the set of weight coefficients corresponding to each model layer according to the above-mentioned optimization objective function, wherein the weight coefficient set includes the weight coefficients of each parameter slice that has an association relationship with the model layer. For models that are updated in real time, the set of weight coefficients corresponding to each model layer can be re-determined after each model update. The above-mentioned association relationship can be that part of the parameters of the model layer are stored in the parameter slice, or the data stored in the parameter slice can be used to calculate and restore the parameters of the model layer. The association relationship between the model layer and each parameter slice can be determined when the parameter slice is determined.
[0066] In some embodiments of the present application, repairing a damaged model layer based on parameter slices corresponding to the damaged model layer includes: when the damage type of the damaged model layer is that a neuron module in the model layer is damaged, replacing the neuron module in the damaged model layer with a spare neuron module, wherein the activation function of the spare neuron module is the same as the activation function of the neuron module in the damaged model layer; determining and loading the neuron module parameters of the spare neuron module based on the parameter slices corresponding to the damaged model layer.
[0067] In some embodiments of the present application, the step of repairing the damaged model layer based on the parameter slice corresponding to the damaged model layer includes: replacing the model parameters in the damaged model layer with the parameters stored in the parameter slice; after replacing the model parameters, determining again whether the damaged model layer is successfully repaired based on the gradient amplitude of the model parameters of the damaged model layer, and if it is confirmed that the repair is not successful, replacing the neuron module in the damaged model layer, and updating the parameters of the neuron module using the parameters stored in the parameter slice.
[0068] Optionally, the spare neuron module can be expressed as follows:
[0069]
[0070] In the above formula w i is the parameter slice, f() is the activation function, which is consistent with the activation function of the damaged neuron module. B is the bias term of the activation function, which is also consistent with the damaged neuron module.
[0071] As an optional implementation, repairing the damaged model layer based on the parameter slices corresponding to the damaged model layer includes: when the number of damaged model layers is multiple and there is an association relationship between the damaged model layers, determining the replacement model layer based on the pre-trained sub-model corresponding to the target model layer, and using the subsequent replacement model layer to replace the damaged model layer; determining and loading the model parameters of the replacement model layer based on the parameter slices corresponding to the damaged model layer.
[0072] As an optional implementation, after repairing the damaged model layer based on the parameter slices corresponding to the damaged model layer, the method also includes: after the damaged model layer is repaired, recalculating the model parameter gradient amplitude of the damaged model layer; when the recalculated model parameter gradient amplitude is not greater than a second preset threshold, determining that the damaged model layer is successfully repaired, wherein the second preset threshold is a threshold determined based on the model parameter gradient amplitude of the damaged model layer when it is undamaged.
[0073] In some embodiments of the present application, after determining the replacement parameters of the damaged model layer based on each calculation result and replacing the original parameters in the damaged model layer with the replacement parameters, the method also includes: determining the model parameter gradient amplitude of the damaged model layer; when the model parameter gradient amplitude of the damaged model layer still indicates that there is an abnormality in the damaged model layer, iteratively updating the weight coefficient according to a preset learning rate and a preset gradient direction, and replacing the parameters of the damaged model layer according to the updated weight coefficient after each round of iterative update, until the model parameter gradient amplitude of the damaged model layer shows that there is no abnormality in the damaged model layer.
[0074] The repair verification judgment conditions can be defined as follows:
[0075]
[0076] In the above formula, γ is the preset tolerance coefficient, and the specific value can be set by yourself, such as 1.2. is the model parameter gradient amplitude of the damaged model layer after repair, is the model parameter gradient amplitude of the damaged model layer before damage.
[0077] If the above repair verification judgment conditions are met, the repair is considered successful. Otherwise, iterative repair is continued. In each round of iteration, the weight coefficient of each parameter slice is adjusted using the following formula:
[0078] β new =β old +ε·Δβ
[0079] In the above formula, β new is the weight coefficient used in this round of iteration, β old is the weight coefficient of the previous iteration, ε is the learning rate, and Δβ is the gradient direction.
[0080] In a practical application scenario, assuming that a convolution kernel in the target model is damaged, the abnormality of the target model can be determined based on the abnormal peak in the output feature map of the target model. Then, the damaged convolution kernel with abnormal parameter gradient amplitude is determined by gradient analysis. Then, multiple parameter slices corresponding to the damaged convolution kernel are loaded from redundant storage, assuming there are three, namely {K1, K2, K3}. The transpose of β = [0.6, 0.3, 0.1] is obtained by the least squares method, so that K repaired =0.6K1+0.3K2+0.1K3.
[0081] After verification, the repaired convolution kernel parameter gradient amplitude is confirmed to be 1.1 times the pre-fault parameter gradient amplitude, which is within the allowable range. If not, the repair is considered complete. Otherwise, the iterative repair is continued, and the weight coefficient of the parameter slice is updated in each iteration.
[0082] In some embodiments of the present application, the target model includes a distributed model, wherein each model layer of the distributed model is stored in a different node, and any node stores parameter slices corresponding to the model layer of the adjacent node, as well as parameter slices corresponding to the model layer of the arbitrary node itself; the method also includes: in the case where the model layer in any node is a damaged model layer, the arbitrary node obtains the parameter slices corresponding to the damaged model layer in the arbitrary node from the adjacent node of the arbitrary node, and repairs the damaged model layer based on the parameter slices corresponding to the damaged model layer.
[0083] The content stored in each node can be expressed as the following formula:
[0084] S i ={W i ,RS(W i-1 ),RS(W i+1 )}
[0085] In the above formula, RS() represents redundant coding, W i Represents the model parameter matrix slice of this node, W i-1 and W i+1 is the model parameter matrix slice of adjacent nodes i-1 and i+1.
[0086] In some embodiments of the present application, there is also provided a Figure 3 The model repair process shown includes the following steps:
[0087] Step S302, continuously performing damage detection on the target model;
[0088] Step S304: if the target model is confirmed to be damaged, locate the damaged position in the target model;
[0089] Step S306: repairing the damaged location according to the damage type of the damaged location, wherein the damage type of the damaged location includes structural damage and local parameter damage, and the structural damage includes neuron damage and damage to multiple convolutional layers with associated relationships;
[0090] Step S308 , verifying the repair result, and re-executing the repair process if the verification fails until the verification passes, wherein the weight coefficients of the parameter slices used in the repair process are updated each time the repair is performed.
[0091] The method adopts the method of obtaining the output value fluctuation information of the target model within a preset sliding window, and determining whether the target model has an abnormality based on the output value fluctuation information; when it is determined that the target model has an abnormality based on the output value fluctuation information, determining the model parameter gradient amplitude of each layer in the target model through the loss function; determining the model layer whose model parameter gradient amplitude is greater than the first preset amplitude threshold as the damaged model layer, and repairing the damaged model layer based on the parameter slice corresponding to the damaged model layer, wherein the parameter slice includes the sub-matrix obtained after slicing the model parameter matrix of the target model, and determining the damaged model layer by determining the model parameter gradient amplitude of each layer, thereby achieving the purpose of accurately locating the fault area, thereby realizing the technical effect of improving the fault repair efficiency, and further solving the technical problem of low fault repair efficiency caused by the inability to accurately locate the model fault area in the related technology.
[0092] The method provided in the embodiments of this application performs redundant encoding of model parameters and structures during the model training phase, and stores this redundant information within the model or in distributed nodes. If the model becomes corrupted, the damaged portion can be restored by decoding the redundant information. Compared to static backups, multiple replica storage, deploying redundant servers, mirroring systems, and data backup, this solution offers low storage overhead and efficient resource utilization.
[0093] In addition, the method provided in the embodiment of the present application realizes real-time damage detection and positioning of the model, continuously monitors the operating status of the model, and triggers the repair process.
[0094] Furthermore, the method provided in the embodiments of this application uses least squares to solve for redundant sharding coefficients, repair locally damaged parameters, dynamically replace damaged neurons, or call upon pre-trained backup subnets to repair damaged structures. This enables multiple rounds of iterative repair to improve the success rate of self-repair, enabling model self-repair and restart in a short period of time. Furthermore, in a distributed environment, nodes share redundant information and compensate for local damage through an efficient collaborative mechanism, further enhancing the reliability and self-healing capabilities of the overall system.
[0095] An embodiment of the present application provides a model repair device. Figure 4 This is a schematic diagram of the structure of the device. Figure 4 It can be seen that the device includes: a first processing module 40, which is used to obtain the output value fluctuation information of the target model within a preset sliding window, and determine whether the target model has an abnormality based on the output value fluctuation information; a second processing module 42, which is used to determine the model parameter gradient amplitude of each layer in the target model through a loss function when it is determined that the target model has an abnormality based on the output value fluctuation information; a third processing module 44, which is used to determine that the model layer whose model parameter gradient amplitude is greater than the first preset amplitude threshold is a damaged model layer, and repair the damaged model layer based on the parameter slice corresponding to the damaged model layer, wherein the parameter slice includes a sub-matrix obtained after slicing the model parameter matrix of the target model.
[0096] In some embodiments of the present application, the step of the first processing module 40 determining the output value fluctuation information of the target model within a preset sliding window includes: determining the output value mean and output value variance of the target model within the preset sliding window, wherein the output value fluctuation information includes the output value mean and output value variance; determining the output value threshold based on the output value mean and output value variance in the output value fluctuation information; the step of the first processing module 40 determining whether the target model has an abnormality based on the output value fluctuation information includes: when the output value of the target model at a preset time is greater than the output value threshold, determining that the target model has an abnormality.
[0097] In some embodiments of the present application, the step of the third processing module 44 repairing the damaged model layer based on the parameter slices corresponding to the damaged model layer includes: when the damage type of the damaged model layer is parameter damage, determining the weight coefficients of each parameter slice corresponding to the damaged model layer; determining the calculation results obtained by multiplying each parameter slice and its respective weight coefficient; determining the replacement parameters of the damaged model layer based on each calculation result, and using the replacement parameters to replace the original parameters in the damaged model layer.
[0098] In some embodiments of the present application, the step in which the third processing module 44 determines the weight coefficients of each parameter slice corresponding to the damaged model layer includes: using the least squares method to minimize the deviation between the replacement parameters and the parameters of the damaged model layer when it is not damaged as the optimization goal, and determining the weight coefficients corresponding to each parameter slice corresponding to the damaged model layer.
[0099] In some embodiments of the present application, after determining the replacement parameters of the damaged model layer based on each calculation result and replacing the original parameters in the damaged model layer with the replacement parameters, the third processing module 44 is also used to: determine the model parameter gradient amplitude of the damaged model layer; when the model parameter gradient amplitude of the damaged model layer still indicates that there is an abnormality in the damaged model layer, iteratively update the weight coefficient according to the preset learning rate and the preset gradient direction, and replace the parameters of the damaged model layer according to the updated weight coefficient after each round of iterative update, until the model parameter gradient amplitude of the damaged model layer shows that there is no abnormality in the damaged model layer.
[0100] In some embodiments of the present application, the step of the third processing module 44 repairing the damaged model layer based on the parameter slice corresponding to the damaged model layer includes: when the damage type of the damaged model layer is that the neuron module in the model layer is damaged, using a spare neuron module to replace the neuron module in the damaged model layer, wherein the activation function of the spare neuron module is the same as the activation function of the neuron module in the damaged model layer; determining and loading the neuron module parameters of the spare neuron module based on the parameter slice corresponding to the damaged model layer.
[0101] In some embodiments of the present application, the step of the third processing module 44 repairing the damaged model layer based on the parameter slice corresponding to the damaged model layer includes: replacing the model parameters in the damaged model layer with the parameters stored in the parameter slice; after replacing the model parameters, determining again whether the damaged model layer is successfully repaired based on the gradient amplitude of the model parameters of the damaged model layer, and if it is confirmed that the repair is not successful, replacing the neuron module in the damaged model layer, and updating the parameters of the neuron module using the parameters stored in the parameter slice.
[0102] In some embodiments of the present application, the step of the third processing module 44 repairing the damaged model layer based on the parameter slices corresponding to the damaged model layer includes: when the number of damaged model layers is multiple and there is an association relationship between the damaged model layers, determining the replacement model layer based on the pre-trained sub-model corresponding to the target model layer, and using the subsequent replacement model layer to replace the damaged model layer; determining and loading the model parameters of the replacement model layer based on the parameter slices corresponding to the damaged model layer.
[0103] In some embodiments of the present application, the target model includes a distributed model, wherein each model layer of the distributed model is stored in a different node, and any node stores parameter slices corresponding to the model layers of adjacent nodes, as well as parameter slices corresponding to the model layer of the node itself; a model repair device can be deployed in each node. If a model layer in any node is damaged, the node obtains the parameter slices corresponding to the damaged model layer in the node from its adjacent nodes, and repairs the damaged model layer based on the parameter slices corresponding to the damaged model layer.
[0104] In some embodiments of the present application, after repairing the damaged model layer based on the parameter slices corresponding to the damaged model layer, the model repair device is further used to: recalculate the model parameter gradient amplitude of the damaged model layer after the damaged model layer is repaired; and determine that the damaged model layer has been repaired successfully when the recalculated model parameter gradient amplitude is not greater than a second preset threshold, wherein the second preset threshold is a threshold determined based on the model parameter gradient amplitude of the damaged model layer when it is not damaged.
[0105] It should be noted that the various modules in the above-mentioned model repair device can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.
[0106] According to an embodiment of the present application, a non-volatile storage medium is also provided, in which a program is stored, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the following model repair method: obtaining the output value fluctuation information of the target model within a preset sliding window, and determining whether the target model has an abnormality based on the output value fluctuation information; when it is determined that the target model has an abnormality based on the output value fluctuation information, determining the model parameter gradient amplitude of each layer in the target model through a loss function; determining the model layer whose model parameter gradient amplitude is greater than a first preset amplitude threshold as a damaged model layer, and repairing the damaged model layer based on the parameter slice corresponding to the damaged model layer, wherein the parameter slice includes a sub-matrix obtained after slicing the model parameter matrix of the target model.
[0107] According to another aspect of an embodiment of the present application, an electronic device is also provided, including a memory and a processor, the processor being used to run a program stored in the memory, wherein the following model repair method is executed when the program is running: obtaining output value fluctuation information of a target model within a preset sliding window, and determining whether the target model has an abnormality based on the output value fluctuation information; when it is determined that the target model has an abnormality based on the output value fluctuation information, determining the model parameter gradient amplitude of each layer in the target model through a loss function; determining a model layer whose model parameter gradient amplitude is greater than a first preset amplitude threshold as a damaged model layer, and repairing the damaged model layer based on parameter slices corresponding to the damaged model layer, wherein the parameter slices include sub-matrices obtained after slicing the model parameter matrix of the target model.
[0108] According to another aspect of an embodiment of the present application, a computer program product is also provided, including a computer program, which implements the following model repair method when executed by a processor: obtaining output value fluctuation information of a target model within a preset sliding window, and determining whether the target model has an abnormality based on the output value fluctuation information; when it is determined that the target model has an abnormality based on the output value fluctuation information, determining the model parameter gradient amplitude of each layer in the target model through a loss function; determining a model layer whose model parameter gradient amplitude is greater than a first preset amplitude threshold as a damaged model layer, and repairing the damaged model layer based on parameter slices corresponding to the damaged model layer, wherein the parameter slices include sub-matrices obtained after slicing the model parameter matrix of the target model.
[0109] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0110] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0111] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0112] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0113] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the relevant technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0114] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A model repair method, characterized in that: include: Obtaining output value fluctuation information of a target model within a preset sliding window, and determining whether the target model has an abnormality based on the output value fluctuation information; When it is determined that the target model has an abnormality according to the output value fluctuation information, determining the gradient amplitude of the model parameters of each layer in the target model by using a loss function; Determine the model layer whose model parameter gradient amplitude is greater than the first preset amplitude threshold as a damaged model layer, and repair the damaged model layer based on the parameter slice corresponding to the damaged model layer, wherein the parameter slice includes a sub-matrix obtained after slicing the model parameter matrix of the target model.
2. The model repair method according to claim 1, characterized in that: Determining output value fluctuation information of a target model within a preset sliding window, comprising: determining an output value mean and an output value variance of the target model within the preset sliding window, wherein the output value fluctuation information includes the output value mean and the output value variance; and determining an output value threshold value based on the output value mean and the output value variance in the output value fluctuation information; Determining whether the target model has an abnormality according to the output value fluctuation information includes: determining that the target model has an abnormality when the output value of the target model at a preset time is greater than the output value threshold.
3. The model repair method according to claim 1, characterized in that: Repairing the damaged model layer according to the parameter slice corresponding to the damaged model layer includes: In a case where the damage type of the damaged model layer is parameter damage, determining a weight coefficient of each of the parameter slices corresponding to the damaged model layer; Determine a calculation result obtained by multiplying each of the parameter slices by their respective weight coefficients; Determine replacement parameters of the damaged model layer according to each of the calculation results, and use the replacement parameters to replace the original parameters in the damaged model layer.
4. The model repair method according to claim 3, characterized in that: Determining the weight coefficients of the parameter slices corresponding to the damaged model layer includes: Taking minimizing the deviation between the replacement parameters and the parameters of the damaged model layer when it is not damaged as an optimization goal, the weight coefficients corresponding to the respective parameter slices corresponding to the damaged model layer are determined.
5. The model repair method according to claim 3, characterized in that: After determining replacement parameters of the damaged model layer according to each of the calculation results and replacing original parameters in the damaged model layer with the replacement parameters, the method further includes: determining a model parameter gradient amplitude of the damaged model layer; When the model parameter gradient amplitude of the damaged model layer still indicates that there is an abnormality in the damaged model layer, the weight coefficient is iteratively updated according to the preset learning rate and the preset gradient direction, and the parameters of the damaged model layer are replaced according to the updated weight coefficient after each round of iterative update until the model parameter gradient amplitude of the damaged model layer shows that there is no abnormality in the damaged model layer.
6. The model repair method according to claim 1, characterized in that: Repairing the damaged model layer according to the parameter slice corresponding to the damaged model layer includes: In a case where the damage type of the damaged model layer is that a neuron module in the model layer is damaged, replacing the neuron module in the damaged model layer with a spare neuron module, wherein the activation function of the spare neuron module is the same as the activation function of the neuron module in the damaged model layer; The neuron module parameters of the spare neuron module are determined and loaded according to the parameter slice corresponding to the damaged model layer.
7. The model repair method according to claim 1, characterized in that: Repairing the damaged model layer according to the parameter slice corresponding to the damaged model layer includes: Replacing the model parameters in the damaged model layer with the parameters stored in the parameter slice; After replacing the model parameters, it is determined again whether the damaged model layer is successfully repaired based on the model parameter gradient amplitude of the damaged model layer. If it is confirmed that the repair is not successful, the neuron module in the damaged model layer is replaced, and the parameters of the neuron module are updated using the parameters stored in the parameter slice.
8. The model repair method according to claim 1, characterized in that: Repairing the damaged model layer according to the parameter slice corresponding to the damaged model layer includes: When there are multiple damaged model layers and there is an association relationship between the damaged model layers, a replacement model layer is determined according to the pre-trained sub-model corresponding to the target model layer, and the damaged model layer is replaced with the replacement model layer; The model parameters of the replacement model layer are determined and loaded according to the parameter slice corresponding to the damaged model layer.
9. The model repair method according to claim 1, characterized in that: The target model includes a distributed model, wherein each model layer of the distributed model is stored in a different node, and any node stores parameter slices corresponding to the model layer of an adjacent node and a parameter slice corresponding to the model layer of the node itself; the method further includes: In the case that the model layer in the arbitrary node is a damaged model layer, the arbitrary node obtains the parameter slice corresponding to the damaged model layer in the arbitrary node from the adjacent nodes of the arbitrary node, and repairs the damaged model layer according to the parameter slice corresponding to the damaged model layer.
10. The model repair method according to claim 1, characterized in that: After repairing the damaged model layer according to the parameter slices corresponding to the damaged model layer, the method further includes: After the damaged model layer is repaired, recalculating the model parameter gradient amplitude of the damaged model layer; When the model parameter gradient amplitude calculated again is not greater than the second preset threshold, it is determined that the damaged model layer is repaired successfully, wherein the second preset threshold is a threshold determined based on the model parameter gradient amplitude of the damaged model layer when it is undamaged.
11. A model repair device, characterized in that: include: A first processing module is configured to obtain output value fluctuation information of a target model within a preset sliding window, and determine whether the target model has an abnormality based on the output value fluctuation information; a second processing module, configured to determine, when it is determined based on the output value fluctuation information that the target model has an abnormality, a model parameter gradient amplitude of each layer in the target model by using a loss function; The third processing module is used to determine that the model layer whose model parameter gradient amplitude is greater than the first preset amplitude threshold is a damaged model layer, and repair the damaged model layer according to the parameter slice corresponding to the damaged model layer, wherein the parameter slice includes a sub-matrix obtained after slicing the model parameter matrix of the target model.
12. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the model repair method according to any one of claims 1 to 10.
13. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is configured to run a program stored in the memory, wherein the model repair method according to any one of claims 1 to 10 is executed when the program is run.
14. A computer program product, characterized in that The invention comprises a computer program, which implements the model repairing method according to any one of claims 1 to 10 when being executed by a processor.