A model training method and device, and related equipment

By generating a sandbox and encrypting the key during model training and deleting the data after the usage period ends, the problem of training data leakage is solved, and data security and model stability are improved.

CN123179385APending Publication Date: 2026-11-27CHINA MOBILE ZIJIN INNOVATION INST CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611670714.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-27
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

During model training, training data is at risk of leakage, resulting in low data security. This is especially true in scenarios involving multi-source data, streaming data, and cross-domain collaborative participation. Training data may be leaked during the access phase and leave traces in data cache, gradient information, and parameter increments, making it difficult to effectively prevent data leakage and model contamination.

Method used

By generating a sandbox and a key, data is encrypted and trained within the sandbox, generating a parameter data chain. This ensures that the training data is securely processed within the sandbox, and the sandbox and key are deleted after the usage period ends, thus preventing data leakage.

Benefits of technology

It effectively prevents the leakage and theft of training data during model training, improves data security, reduces the risk of model contamination by abnormal data, and achieves secure data storage and processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123179385A_ABST
    Figure CN123179385A_ABST
Patent Text Reader

Abstract

The application provides a model training method and device and related equipment, and relates to the technical field of data processing. The method comprises the following steps: in the case that a task request is received, a sandbox and a key corresponding to the task request are generated, and the use cycle duration of the sandbox is determined; training data is acquired, and the training data is imported into the memory of the sandbox; training is performed in the sandbox based on the key and the training data, and a training gradient is obtained, which is used for updating the parameters of a model; the training gradient and a parameter segment are output by the sandbox, and the parameter segment is used for representing relevant data involved in the calculation of the training gradient; a parameter data chain is generated based on the parameter segment, and the parameter data chain is used for storing relevant data involved in the calculation of training gradients of different rounds; after the training gradient is output by the sandbox, or in the case that the duration after the sandbox is generated reaches the use cycle duration, the sandbox, the key and all data in the sandbox are deleted. The application can improve the security of data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, specifically to a model training method, apparatus, and related equipment. Background Technology

[0002] In model training, to protect the security of training data, security verification is usually required during the training process before sending training data for model training. However, in actual training scenarios involving source data, streaming data, sensitive data, and cross-domain collaborative model training, the training data is stored on the disk of the training device. This not only poses a risk of leakage during the access phase but may also leave traces in data caches, gradient information, optimizer states, and parameter increments, thus still posing a risk of training data leakage.

[0003] It is evident that the relevant technologies suffer from low data security due to the leakage of training data during model training. Summary of the Invention

[0004] This invention provides a model training method, apparatus, and related equipment to address the problem of low data security caused by training data leakage during model training in related technologies.

[0005] To solve the above problems, the present invention is implemented as follows: In a first aspect, embodiments of the present invention provide a model training method, comprising: Upon receiving a task request, a sandbox and key corresponding to the task request are generated, and the usage period of the sandbox is determined. The task request is used to instruct the model to be trained, and the key is used to encrypt the data during the training process. Acquire training data and import the training data into the memory of the sandbox; The model is trained within the sandbox based on the key and the training data to obtain a training gradient, which is used to update the model's parameters. The training gradient and parameter fragments are output through the sandbox, and the parameter fragments are used to characterize the relevant data involved in calculating the training gradient. Based on the parameter fragment, a parameter data chain is generated, which is used to store relevant data involved in calculating the training gradient in different rounds; After the sandbox outputs the training gradient, or if the duration after the sandbox is generated reaches the usage period, delete the sandbox, the key, and all data within the sandbox.

[0006] Secondly, embodiments of the present invention also provide a model training apparatus, comprising: The first generation module is used to generate a sandbox and key corresponding to the task request when a task request is received, and to determine the usage period of the sandbox. The task request is used to instruct the model to be trained, and the key is used to encrypt the data during the training process. An acquisition module is used to acquire training data and import the training data into the memory of the sandbox; The training module is used to train the model within the sandbox based on the key and the training data to obtain a training gradient, which is used to update the model's parameters. The output module is used to output the training gradient and parameter fragments through the sandbox, wherein the parameter fragments are used to characterize the relevant data involved in calculating the training gradient; The second generation module is used to generate a parameter data chain based on the parameter fragment, wherein the parameter data chain is used to store relevant data involved in calculating the training gradient of different rounds; The deletion module is used to delete the sandbox, the key, and all data within the sandbox after the sandbox outputs the training gradient, or when the duration after the sandbox is generated reaches the usage period duration.

[0007] Thirdly, embodiments of the present invention also provide an electronic device, including a transceiver and a processor. The processor is configured to generate a sandbox and key corresponding to the task request upon receiving a task request, and determine the usage period of the sandbox. The task request is used to instruct the model to be trained, and the key is used to encrypt the data during the training process. The transceiver is used to acquire training data and import the training data into the memory of the sandbox; The processor is further configured to train the model within the sandbox based on the key and the training data to obtain a training gradient, which is used to update the model's parameters. The processor is further configured to output the training gradient and parameter fragments through the sandbox, wherein the parameter fragments are used to characterize the relevant data involved in calculating the training gradient; The processor is further configured to generate a parameter data chain based on the parameter fragment, the parameter data chain being used to store relevant data involved in calculating training gradients for different rounds; The processor is further configured to delete the sandbox, the key, and all data within the sandbox after the sandbox outputs the training gradient, or when the duration after the sandbox is generated reaches the usage period duration.

[0008] Fourthly, embodiments of the present invention provide an electronic device, including: a processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, it implements the steps of the model training method described in the first aspect.

[0009] Fifthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the model training method described in the first aspect.

[0010] In a sixth aspect, the present invention also provides a computer program product, including computer instructions, which, when executed by a processor, implement the steps of the model training method described in the first aspect.

[0011] In this embodiment of the invention, upon receiving a task request, a sandbox and key corresponding to the task request are generated, and the usage period of the sandbox is determined. The task request is used to instruct the model to be trained, and the key is used to encrypt the data during the training process. Training data is acquired and imported into the memory of the sandbox. Training is performed within the sandbox based on the key and the training data to obtain a training gradient, which is used to update the model parameters. The training gradient and parameter fragments are output through the sandbox, and the parameter fragments are used to characterize the relevant data involved in calculating the training gradient. A parameter data chain is generated based on the parameter fragments, and the parameter data chain is used to store the relevant data involved in calculating the training gradient in different rounds. After the sandbox outputs the training gradient, or when the usage period after the sandbox is generated reaches the specified usage period, the sandbox, the key, and all data within the sandbox are deleted. In this way, by generating a sandbox and training the model within it, the leakage of training data during training is avoided. When the sandbox outputs training gradients, or when the sandbox has been generated for the required duration, the sandbox, the key, and all data within it are deleted, preventing the data within the sandbox from being stolen, thereby further improving data security. Attached Figure Description

[0012] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 This is a flowchart of a model training method provided in an embodiment of the present invention; Figure 2 This is an overall schematic diagram of a model training method provided in an embodiment of the present invention; Figure 3 This is a schematic diagram illustrating the calculation of training gradients using n intermediate gradients, provided in an embodiment of the present invention. Figure 4 This is a schematic diagram of data tracing and rollback via a parameter data chain provided in an embodiment of the present invention; Figure 5 This is a structural diagram of a model training device provided in an embodiment of the present invention; Figure 6 This is a structural diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

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

[0015] It should be noted that as large-scale models are increasingly applied in enterprise knowledge services, intelligent agent collaboration, data analysis, and decision support, related security issues have gradually expanded from traditional data access control and call auditing to the model training or fine-tuning process. In scenarios involving multi-source data, streaming data, sensitive data, and cross-domain collaborative fine-tuning, training data may not only be at risk of leakage during the access phase, but may also leave traces in data caches, gradient information, optimizer states, and parameter increments, leading to the risk of training data leakage.

[0016] Furthermore, anomalous or low-reliability data can also affect global model parameters through gradient updates, causing model capability contamination. Therefore, relying solely on safety controls during the model invocation phase is insufficient to cover issues such as data residue, gradient diffusion, opaque parameter sources, and difficulty in rolling back the impact of anomalous data during the fine-tuning training phase.

[0017] To address this issue, this invention proposes a model training method to solve the problem of training data leakage and the potential contamination of the model by abnormal data, thereby improving data security.

[0018] Please see Figure 1 and Figure 2 , Figure 1 This is a flowchart of a model training method provided in an embodiment of the present invention. Figure 2 This is an overall schematic diagram of model training provided by an embodiment of the present invention, as shown below. Figure 1 and Figure 2As shown, it includes the following steps: Step 101: Upon receiving a task request, generate a sandbox and key corresponding to the task request, and determine the usage period of the sandbox. The task request is used to instruct the model to be trained, and the key is used to encrypt the data during the training process.

[0019] The above task request is a request to train the model. The task request can be to fine-tune the training of an existing model or to train the newly built model as a whole.

[0020] The aforementioned sandbox is a one-time isolated computing domain. This domain includes independent processes, independent memory namespaces, task-level access control, and lifecycle management. This allows tasks, data, and runtime boundaries to be bound within the same sandbox, achieving isolation from the outside world during model training and preventing data leakage. Furthermore, when generating the sandbox, an identifier (SID) can be generated, which can be bound to the task request, enabling the sandbox to be identified based on its identifier.

[0021] The aforementioned key is bound to the sandbox and is valid only within this task. It is used to encrypt temporary objects, log digests, and necessary intermediate caches. It should be understood that the key is not written to long-term storage but rather remains consistent with the sandbox's lifecycle, being deleted synchronously when the sandbox is subsequently deleted. This prevents data leakage caused by decryption of data leaked within the sandbox, effectively improving data security.

[0022] In this process, temporary data during model training is stored in encrypted form using a key, and the key is destroyed synchronously after the task is completed. This ensures that even if residual ciphertext is obtained, the plaintext cannot be retrieved without the key. By combining key destruction with memory zeroing and temporary area erasure, the risks of logical recovery and media residue are reduced, further enhancing data security.

[0023] The usage period mentioned above refers to the duration of the sandbox and key. If the usage period is exceeded, the sandbox and key need to be deleted to promptly remove the data inside the sandbox and prevent data leakage caused by the sandbox existing for too long.

[0024] In some implementations, the duration of the usage cycle can be determined based on the data's trust level and the task strategy.

[0025] In some implementations, the cycle duration T is used. destroy It can be calculated using the following formula: T destroy =min(T task_end , T create +TTL i , Tpolicy_trigger ); In the formula, T task_end T represents the normal completion time of the model training task. create +TTL i T represents the upper limit of the sandbox's usage period. create The time to create a sandbox, TTL. i Indicates the lifespan of the sandbox, T policy_trigger This indicates the duration of forced deletion corresponding to the task strategy.

[0026] Step 102: Obtain training data and import the training data into the memory of the sandbox.

[0027] The training data mentioned above is used to train the model. The training data can be data carried in the task request, or the task request can have a storage address for the training data set, and the training data can be obtained according to the storage address.

[0028] It should be understood that when importing training data into the sandbox, the training data is directly imported into the sandbox's memory instead of being written to disk, in order to avoid leaving any traces of the training data on the disk and thus improve the security of the training data.

[0029] In some embodiments, during the data import sandbox phase, external training data enters the sandbox memory queue and / or data buffer in the form of data blocks. The system receiving the training data only generates summaries, labels, and necessary statistical information for the data blocks. This way, the original training data is not written to persistent disk, improving data security. Specifically, the summary calculation can involve concatenating and combining metadata such as data source, timestamp, and channel identifier, followed by hash calculation, to obtain the database summary.

[0030] Step 103: Train the model within the sandbox based on the key and the training data to obtain the training gradient, which is used to update the model parameters.

[0031] It should be understood that training within a sandbox can prevent the leakage of training data, thereby effectively improving data security.

[0032] In some implementations, a model fine-tuning execution module can be configured in the system. This module can only access the training data and trainable parameter copies of the current task within the sandbox and perform forward, backward, and intermediate result processing in a constrained environment to obtain the training gradient.

[0033] In this embodiment, the sandbox is bound to the task, data level, key, and usage period, so that the data cannot exist outside the sandbox. Even if intermediate variables are generated during the training process, they can only be read within the access control scope of the sandbox, thereby effectively improving the security of the data.

[0034] Step 104: Output the training gradient and parameter fragment through the sandbox. The parameter fragment is used to characterize the relevant data involved in calculating the training gradient.

[0035] It should be understood that training gradients or parameter increments generated within the sandbox cannot be directly written into the global model. Instead, they must be reviewed and approved before being output uniformly to further improve data security. Therefore, in this embodiment, training gradients and parameter fragments are output through the sandbox. The training gradients can be used to update the model parameters, thereby achieving model training. The parameter fragments represent the relevant data involved in calculating the training gradients, and a parameter data chain can be constructed based on the parameter fragments to facilitate subsequent querying of relevant data.

[0036] In some implementations, data such as data summaries, risk values, and level labels can also be output to facilitate subsequent auditing of the model training process.

[0037] In addition, raw data, plaintext intermediate samples, and unapproved gradients are not allowed to be taken directly out of the sandbox to avoid data leakage.

[0038] Step 105: Generate a parameter data chain based on the parameter fragment, wherein the parameter data chain is used to store relevant data involved in calculating the training gradients of different rounds.

[0039] The aforementioned parameter data chain stores relevant data involved in calculating training gradients in different rounds, so that historical intermediate gradients and historical second risk values ​​can be obtained through the parameter data chain during subsequent model training, or data auditing can be performed through the parameter data chain.

[0040] Step 106: After the sandbox outputs the training gradient, or if the duration after the sandbox is generated reaches the usage period, delete the sandbox, the key, and all data within the sandbox.

[0041] It should be understood that when a task ends or a policy is triggered (i.e., the usage period is reached), the system needs to delete the sandbox, the key, and all data within the sandbox, perform memory zeroing, clear the buffer, and destroy the task-level key, and generate an auditable destruction certificate to avoid data leakage.

[0042] The destruction proof does not save the original data, but only contains a summary of the destruction process log, which can be used to prove that the destruction action has been executed according to the policy.

[0043] In this embodiment of the invention, upon receiving a task request, a sandbox and key corresponding to the task request are generated, and the usage period of the sandbox is determined. The task request is used to instruct the model to be trained, and the key is used to encrypt the data during the training process. Training data is acquired and imported into the memory of the sandbox. Training is performed within the sandbox based on the key and the training data to obtain a training gradient, which is used to update the model parameters. The training gradient and parameter fragments are output through the sandbox, and the parameter fragments are used to characterize the relevant data involved in calculating the training gradient. A parameter data chain is generated based on the parameter fragments, and the parameter data chain is used to store the relevant data involved in calculating the training gradient in different rounds. After the sandbox outputs the training gradient, or when the usage period after the sandbox is generated reaches the specified usage period, the sandbox, the key, and all data within the sandbox are deleted. In this way, by generating a sandbox and training the model within it, the leakage of training data during training is avoided. When the sandbox outputs training gradients, or when the sandbox has been generated for the required duration, the sandbox, the key, and all data within it are deleted, preventing the data within the sandbox from being stolen, thereby further improving data security.

[0044] In one embodiment, the training data is training data from at least one source, and the step of training within the sandbox based on the key and the training data to obtain the training gradient includes: Calculate a first risk value for the training data from each of the at least one source; The grade label of the training data from each source is determined based on the first risk value of the training data from each source. The training data from the at least one source is respectively imported into n gradient computation spaces, which are mutually isolated computation spaces within the sandbox. Different gradient computation spaces in the n gradient computation spaces import training data with different level labels, and a gradient computation space imports training data from different sources with the same level label. n is a positive integer greater than or equal to 1. Within the n gradient calculation spaces, the model is trained based on the imported training data to obtain n intermediate gradients; The training gradient is calculated based on the n intermediate gradients.

[0045] It should be understood that the training data comes from different sources and has varying levels of risk. To avoid high-risk data significantly interfering with the model training results, this embodiment of the invention introduces a differentiation mechanism. Specifically, it determines the level labels for training data from different sources and then imports the training data with different level labels into different gradient calculation spaces. This allows for the calculation of n intermediate gradients within n gradient calculation spaces. The training gradient can then be calculated based on these n intermediate gradients, avoiding the mixing of training data with different risks during training. This approach mitigates the impact of high-risk training data and improves the reliability of the final calculated training gradient.

[0046] The aforementioned first risk value is used to characterize the risk level of the training data from the corresponding source. It can be achieved by pre-configuring a source table and assigning different first risk values ​​to different source tables. For example, for known safe sources, the first risk value is low risk; for unknown sources, the first risk value is high risk.

[0047] In one embodiment, the training data from the at least one source includes training data from a first source, and calculating a first risk value for the training data from each of the at least one source includes: Obtain hierarchical feature data of the training data from the first source in multiple dimensions, wherein the multiple dimensions include source authentication results, data type, sensitive field hit status, historical reputation, integrity summary and at least two dimensions from the business scenario; The hierarchical feature data of the multiple dimensions are normalized respectively to obtain the normalized scores of the multiple dimensions. The normalized scores of the multiple dimensions are weighted to obtain the first risk value of the training data from the first source.

[0048] The first source mentioned above can be any one of the at least one sources. In this embodiment, the first source is taken as an example. The first risk value of the training data of each source in the at least one source can be calculated in the above manner.

[0049] Specifically, the first risk value can be calculated using the following formula: ; In the formula, R data Indicates the first risk value, s m Let α represent the normalized score of the m-th dimension. m This represents the weight coefficient of the m-th dimension, where M is the total number of dimensions in the training data.

[0050] Furthermore, after obtaining the first risk value, the level label of the training data is determined based on the first risk value. In some implementations, a preset risk value range can be configured, and the training data can be mapped to the corresponding level label by using the first risk value and the preset risk value range.

[0051] Different level labels correspond to different training permissions, usage period limits, and task strategies. The actual number of level labels can be expanded according to the number of task strategies.

[0052] In some implementations, to ensure that the classification results can continue to be used in subsequent control, unified data tags can be generated. These data tags can be represented as follows: tag i ={sid,L i ,R data ,ttl i ,destroy_policy i ,source_hash i}; Among them, tag i Let L represent the data label of the training data from the i-th source, sid represent the sandbox identifier, and L represent the data label of the training data from the i-th source. i R indicates a rating label. data Indicates the first risk value, ttl i Indicates the usage period, destroy_policy i Indicates the task strategy, source_hash i This indicates a source summary, which is used to trace the source of the data later.

[0053] It should be understood that after obtaining the grade labels of training data from different sources, the data is then scheduled to the gradient calculation space of the corresponding sandbox according to the grade labels. Specifically, if the same batch of training data contains data with multiple grade labels, it is first split according to the grade labels and then entered into the corresponding gradient calculation space to ensure consistency in subsequent isolation and control.

[0054] Furthermore, after importing training data from at least one source into n gradient computation spaces, the model is trained based on the imported training data in each of the n gradient computation spaces to obtain n intermediate gradients. This avoids discovering risks only during the training phase and also prevents training data with different level labels from being mixed and computed in the same gradient space.

[0055] Wherein, there are n gradient computation spaces G1, G2, ..., G n The corresponding level labels are L1, L2, ..., L nThe training data is configured such that each space has its own independent memory context, independent CUDA stream, independent process, and virtualization instance to ensure that Gi can only access the gradient cache of its own space and cannot read or write to Gi. j The gradient cache is defined in the model, where i ≠ j. This constraint ensures that gradients generated from different levels of data are separated during the generation phase, rather than being filtered post-processed after the gradients have been mixed.

[0056] Specifically, after entering the training phase, the training data is first split according to the level label, and an independent gradient calculation space is allocated to the training data of different level labels. The training data of each level label can simultaneously carry the level label, data risk value and source summary, to establish a unified context for subsequent risk control and audit trail.

[0057] During isolated computation, n gradient computation spaces can share read-only model backbone parameters to ensure consistency of basic capabilities; however, trainable incremental parameters, gradient caches, and optimizer states are kept isolated across spaces to avoid direct mixing of data at different levels during the backpropagation stage.

[0058] Subsequently, each gradient space undergoes backpropagation to generate its own gradient, resulting in n intermediate gradients. Since cross-space read / write caching or direct modification of global model parameters is not possible, the impact of high-risk data is confined to its local space. Training gradients can then be calculated based on the risk level and the n intermediate gradients.

[0059] In one embodiment, calculating the training gradient based on the n intermediate gradients includes: Calculate at least one of the following for each of the n intermediate gradients: gradient entropy index, parameter drift index, and outlier ratio index. The gradient entropy index is used to characterize the distribution of the corresponding intermediate gradient in different intervals. The parameter drift index is used to characterize the deviation of the gradient direction of the corresponding intermediate gradient from the historical gradient direction. The outlier ratio index is used to characterize the data fluctuation in the corresponding intermediate gradient. Based on at least one of the gradient entropy index, the parameter drift index, and the outlier ratio index for each intermediate gradient, calculate the second risk value for each intermediate gradient. Determine m intermediate gradients, wherein the second risk value of the m intermediate gradients is less than the first set threshold of the corresponding gradient computation space, where m is a positive integer greater than or equal to 1 and m is less than or equal to n; Calculate the weight coefficients of the corresponding intermediate gradients based on the second risk values ​​of the m intermediate gradients; The training gradient is calculated based on the m intermediate gradients and their corresponding weight coefficients.

[0060] It should be understood that since the training data used to calculate different intermediate gradients carries varying risks, the calculated intermediate gradients will also differ. Therefore, it is necessary to evaluate the calculated intermediate gradients to determine whether to use the intermediate gradients obtained from different gradient computation spaces. Thus, in this embodiment, a second risk value is calculated, and the intermediate gradients used to finally calculate the training gradients are determined based on this second risk value.

[0061] In some implementations, each gradient computation space independently calculates risk indicators such as gradient entropy, parameter drift, and outlier ratio, and synthesizes a second risk value for the current space to determine whether the intermediate gradient of the space meets the conditions for entering the subsequent computation of training gradients.

[0062] Specifically, such as Figure 3 As shown, each gradient computation space shares the backbone parameters of the model and performs isolated computations to obtain n intermediate gradients. A second risk value is then calculated to determine whether the intermediate gradients from this gradient computation space are needed to compute the training gradients.

[0063] Specifically, the gradient entropy metric can be a tensor of the intermediate gradient. The scalar value is divided into K intervals, and the probability of each interval is calculated. And calculate the gradient entropy index. : ; In the formula, It is a constant. A higher value indicates a more dispersed and unstable gradient distribution, which may indicate high noise in the input data or the presence of abnormal perturbations.

[0064] As for the parameter drift index, it can be maintained by an exponential moving average of the historical safe gradient direction. And calculate the current normalization direction. To calculate the parameter drift index : ; ; in the formula The closer it is to 1, the greater the difference between the current update direction and the historical security trend, and the more attention needs to be paid to potential poisoning or abnormal samples that may cause directional mutations.

[0065] For the outlier ratio metric, the intermediate gradient can be calculated. mean and standard deviation , To form the gradient vector gradient components, If the outlier is the coefficient for determining anomalies, then the outlier ratio index is... for: ; In the formula, The higher the value, the more abnormal peaks appear in the parameter dimensions, which may have a disproportionate impact on local parameters.

[0066] Furthermore, after calculating the gradient entropy index, the parameter drift index, and the outlier ratio index, based on at least one of the gradient entropy index, parameter drift index, and outlier ratio index for each intermediate gradient, a second risk value for each intermediate gradient is calculated, which can be expressed by the following formula: ; ; In the formula, Let be the historical exponential moving average of the gradient entropy index in the calculation space of the i-th gradient. For the i-th gradient, calculate the historical exponential moving average of the parameter drift index in the computation space. Let be the historical exponential moving average of the outlier proportion index in the calculation space for the i-th gradient. , , These are the weighting coefficients. This is the second risk value.

[0067] After calculating the second risk value of each intermediate gradient, m intermediate gradients are determined by a first set threshold so that the training gradient can be calculated from the m intermediate gradients.

[0068] In some implementations, the first set threshold may be a pre-set fixed value.

[0069] In some implementations, the first set threshold can be calculated using the mean and standard deviation of the historical second risk values ​​in the gradient computation space, specifically expressed by the following formula: ; In the formula, Set a threshold for the first one. This is the average of the second-highest historical risk values. This is the standard deviation of the second-highest historical risk value. These are the weighting coefficients.

[0070] Furthermore, after determining the m intermediate gradients, norm clipping can be performed on these m intermediate gradients to limit the update magnitude of a single spatial gradient, which can be expressed by the following formula: ; In the formula, This represents the intermediate gradient before clipping. This represents the upper bound of the gradient norm corresponding to the level label in the gradient computation space. The L2 norm of the local gradient, This method is used to avoid zero denominators. It does not change the main direction of the gradient, but only limits the overall magnitude of the gradient, thus preventing a disproportionate impact on the global model due to excessively large local gradients in a certain gradient space.

[0071] Furthermore, the weight coefficients of the corresponding intermediate gradients are calculated based on the second risk values ​​of the m intermediate gradients, which can be expressed by the following formula: ; In the formula, These are the weighting coefficients for the corresponding intermediate gradients. The level label representing the i-th gradient computation space The corresponding benchmark weights, Indicates the strength of risk suppression. This represents the second risk value in the current space. This represents the first set threshold for the current space. It should be understood that the higher the second risk value, the lower the gradient contribution to that space, i.e., the lower the weight coefficient of the corresponding intermediate gradient.

[0072] Furthermore, the training gradient is calculated based on the m intermediate gradients and their corresponding weight coefficients. Specifically, it can be expressed by the following formula: ; After calculating the training gradient, the model parameters are updated based on the training gradient, which can be expressed by the following formula: ; In the formula, This represents the model parameters after the t-th training round. This represents the model parameters after the (t+1)th training round.

[0073] In one embodiment, determining the m intermediate gradients includes: Determine m intermediate gradients and k intermediate gradients, wherein the second risk value of the k intermediate gradients is greater than a second set threshold, the m intermediate gradients and the k intermediate gradients are different intermediate gradients among n intermediate gradients, the second set threshold is greater than a first set threshold of the computation space of the n gradients, k is greater than or equal to 0, and k is less than or equal to n; Obtain the historical intermediate gradient and historical second risk value of the gradient calculation space corresponding to each of the k intermediate gradients from the parameter data chain. The parameter data chain includes the historical intermediate gradient and historical second risk value of different training rounds. The calculation of the weight coefficients of the corresponding intermediate gradients based on the second risk values ​​of the m intermediate gradients includes: Calculate the weight coefficients of the corresponding intermediate gradients based on the second risk values ​​of the m intermediate gradients; Calculate the weight coefficients of the corresponding historical intermediate gradients based on k historical second risk values; The calculation of the training gradient based on the m intermediate gradients and their corresponding weight coefficients includes: The training gradient is calculated based on the m intermediate gradients, the weight coefficients of the m intermediate gradients, the k historical intermediate gradients, and the weight coefficients of the k historical intermediate gradients.

[0074] It should be understood that when the training process is stable, The smaller the size, the more sensitive the system is to minor anomalies; this is especially true during the early stages of training or when the task itself fluctuates significantly. Increase the threshold while maintaining necessary fault tolerance. A second set threshold is also configured. This is used to trigger a rollback.

[0075] Specifically, when When the gradient calculation space is in a normal state, the intermediate gradients in this space are allowed to enter the subsequent calculation of training gradients.

[0076] And when When the algorithm enters Level 1 defense mode, it is considered that the intermediate gradient calculated in the gradient calculation space has a high risk. Therefore, the weights of this space should be reset to zero or submitted temporarily, and the subsequent local learning rate should be reduced to avoid affecting the final training gradient. It should be understood that the purpose of this action is to block the impact of the suspicious gradient in this round without immediately terminating the task, and to slow down the subsequent update speed.

[0077] And when When the gradient calculation space is deemed abnormal, a secondary defense is initiated. This involves considering that the intermediate gradients in the gradient calculation space are anomalous, and that historical intermediate gradients may also be anomalous. Therefore, historical intermediate gradients and historical second-risk values ​​are introduced to correct the impact of this space on model parameters during previous training epochs. Specifically, the most recent parameter fragment in the parameter data chain is queried to determine the historical intermediate gradients and historical second-risk values ​​for this space. The historical second-risk value must be less than a first predetermined threshold for this space. Furthermore, the relevant incremental parameters are rolled back to improve the accuracy of the parameters trained in the final model.

[0078] In one embodiment, the parameter fragment includes the n intermediate gradients and a second risk value for the n intermediate gradients.

[0079] It should be understood that the parameter fragment includes n intermediate gradients and n second risk values ​​of intermediate gradients. By constructing a parameter data chain through parameter fragments from different rounds, the historical intermediate gradients and historical second risk values ​​of historical training rounds can be obtained from the parameter data chain when the second risk value in a gradient computation space is greater than a second set threshold.

[0080] In this process, a parameter fragment is generated after each training step that causes a change in the parameters. This segment does not store the original training data, but only the summary information that supports auditing and rollback, including the hash of the previous segment, sandbox identifier, data block summary set, trust level, risk value, parameter increment summary, affected parameter region, timestamp, and health status. The parameter DNA segment can be represented as: ; in, This represents the hash of the parameter fragment from the previous training round. This represents a summary of the parameter increment. Indicates the affected parameter range. This indicates the health status of the segment. Specifically, if the second risk value in the gradient computation space is less than a first preset threshold, the parameter segment is considered healthy; conversely, if the second risk value is greater than the first preset threshold, the parameter segment is considered unhealthy. Subsequently, when obtaining historical intermediate gradients and historical second risk values, the health status of the parameter segment can be directly used for rapid location, thus enabling quick acquisition of historical intermediate gradients and historical second risk values.

[0081] Furthermore, after obtaining the parameter fragments, a parameter data chain can be generated through a chained process. Once the training gradients are calculated, the gradient contributions, spatial weights, risk values, sandbox identifiers, data summaries, and parameter increments involved in this round of updates are uniformly sent to the parameter data chain module as context information for recording this parameter evolution, so as to facilitate updating the parameter data chain.

[0082] The parameter data chain module then generates a summary of the parameter increments and extracts the affected parameter regions, ensuring that each update is clearly associated with "who triggered it, where it was affected, and the level of risk." After extracting the summary, the system concatenates the hash of the previous segment with the key information of the current segment to generate the hash of the updated segment that updates the current parameter data chain. ; This structure allows different update fragments to form a chain, preventing fragments from being deleted, inserted, or rearranged. After an update fragment is generated, the system also writes a health status simultaneously; if the risk in this round is normal, it is marked as a healthy fragment; if contamination is subsequently confirmed, it can be further marked as suspicious or revoked, along with a rollback summary.

[0083] In some implementations, when a secondary defense is triggered in a certain space, or when a problem is subsequently discovered in a batch of data, source_hash_root, sid, fragment number, etc., can be used as search criteria to locate the relevant healthy fragments on the parameter data chain. During rollback, the system prioritizes the most recent fragment with status=healthy and a normal risk value as the safe point. A fast rollback operation is achieved through saved security snapshots.

[0084] In some implementations, parameter fragments are also associated with destruction certificates for the corresponding sandbox, enabling auditors to both trace the source of parameter changes and verify whether the relevant original data has been destroyed in accordance with the policy.

[0085] Specifically, it can be like... Figure 4 As shown, after model training, the context is obtained, parameter fragments are generated, and these fragments are chained together to form a parameter data chain. If a second risk value in a gradient computation space exceeds a second set threshold, the parameter fragment is located to determine a safe point, thus enabling parameter traceability. Specifically, in cases of anomalies (such as a second risk value in a gradient computation space exceeding the second set threshold, or subsequent traceability revealing anomalous training data), relevant parameter fragments are retrieved, and the scope of impact is determined to identify the nearest healthy fragment. This facilitates precise rollback, thereby improving the accuracy of the model parameters. Subsequently, closed-loop auditing can be performed based on the parameter data chain to monitor the entire model training process.

[0086] Please see Figure 5 , Figure 5 This is a structural diagram of a model training device provided in an embodiment of the present invention, as shown below. Figure 5 As shown, the model training device 500 includes: The first generation module 501 is used to generate a sandbox and key corresponding to the task request when a task request is received, and to determine the usage period of the sandbox. The task request is used to instruct the model to be trained, and the key is used to encrypt the data during the training process. The acquisition module 502 is used to acquire training data and import the training data into the memory of the sandbox; Training module 503 is used to train the model within the sandbox based on the key and the training data to obtain training gradients, which are used to update the model parameters. Output module 504 is used to output the training gradient and parameter fragment through the sandbox, wherein the parameter fragment is used to characterize the relevant data involved in calculating the training gradient; The second generation module 505 is used to generate a parameter data chain based on the parameter fragment, wherein the parameter data chain is used to store relevant data involved in calculating the training gradient of different rounds; The deletion module 506 is used to delete the sandbox, the key, and all data within the sandbox after the sandbox outputs the training gradient, or when the duration after the sandbox is generated reaches the usage period duration.

[0087] In one embodiment, the training data is training data from at least one source, and the training module 503 includes: A first calculation submodule is used to calculate a first risk value for the training data of each of the at least one source; A determination submodule is used to determine the level label of the training data from each source based on the first risk value of the training data from each source; An import submodule is used to import training data from at least one source into n gradient computation spaces, wherein the n gradient computation spaces are mutually isolated computation spaces within the sandbox, and different gradient computation spaces import training data with different level labels, while a gradient computation space imports training data from different sources with the same level label, where n is a positive integer greater than or equal to 1. The training submodule is used to train the model based on the imported training data in the n gradient calculation spaces to obtain n intermediate gradients. The second calculation submodule is used to calculate the training gradient based on the n intermediate gradients.

[0088] In one embodiment, the training data from the at least one source includes training data from a first source, and the first computation submodule includes: The acquisition unit is used to acquire hierarchical feature data of the training data from the first source in multiple dimensions, wherein the multiple dimensions include source authentication results, data type, sensitive field hit status, historical reputation, integrity summary and at least two dimensions in the business scenario; The processing unit is used to normalize the hierarchical feature data of the multiple dimensions respectively to obtain the normalized scores of the multiple dimensions. The first calculation unit is used to weight the normalized scores of the multiple dimensions to obtain the first risk value of the training data from the first source.

[0089] In one embodiment, the second computing submodule includes: The second calculation unit is used to calculate at least one of the following for each of the n intermediate gradients: gradient entropy index, parameter drift index, and outlier ratio index. The gradient entropy index is used to characterize the distribution of the corresponding intermediate gradient in different intervals. The parameter drift index is used to characterize the deviation of the gradient direction of the corresponding intermediate gradient from the historical gradient direction. The outlier ratio index is used to characterize the data fluctuation in the corresponding intermediate gradient. The third calculation unit is used to calculate the second risk value of each intermediate gradient based on at least one of the gradient entropy index, the parameter drift index, and the outlier ratio index for each intermediate gradient. A determining unit is used to determine m intermediate gradients, wherein the second risk value of the m intermediate gradients is less than a first set threshold of the corresponding gradient computation space, where m is a positive integer greater than or equal to 1 and m is less than or equal to n; The fourth calculation unit is used to calculate the weight coefficients of the corresponding intermediate gradients based on the second risk values ​​of the m intermediate gradients. The fifth calculation unit is used to calculate the training gradient based on the m intermediate gradients and the corresponding weight coefficients of the intermediate gradients.

[0090] In one embodiment, the determining unit is specifically used for: Determine m intermediate gradients and k intermediate gradients, wherein the second risk value of the k intermediate gradients is greater than a second set threshold, the m intermediate gradients and the k intermediate gradients are different intermediate gradients among n intermediate gradients, the second set threshold is greater than a first set threshold of the computation space of the n gradients, k is greater than or equal to 0, and k is less than or equal to n; Obtain the historical intermediate gradient and historical second risk value of the gradient calculation space corresponding to each of the k intermediate gradients from the parameter data chain. The parameter data chain includes the historical intermediate gradient and historical second risk value of different training rounds. The fourth calculation unit is specifically used for: Calculate the weight coefficients of the corresponding intermediate gradients based on the second risk values ​​of the m intermediate gradients; Calculate the weight coefficients of the corresponding historical intermediate gradients based on k historical second risk values; The fifth calculation unit is specifically used for: The training gradient is calculated based on the m intermediate gradients, the weight coefficients of the m intermediate gradients, the k historical intermediate gradients, and the weight coefficients of the k historical intermediate gradients.

[0091] In one embodiment, the parameter fragment includes the n intermediate gradients and a second risk value for the n intermediate gradients.

[0092] The model training apparatus provided in this embodiment of the invention can implement each process of each embodiment of the above-described model training method, with one-to-one correspondence of technical features and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0093] It should be noted that the model training device in the embodiments of the present invention can be a device, or it can be a component, integrated circuit, or chip in an electronic device.

[0094] This invention also provides an electronic device, including: a processor, a memory, and a program stored in the memory and executable on the processor, wherein the program, when executed by the processor, implements the above-described functionality. Figure 1 The various processes of the model training method embodiment shown can achieve the same technical effect, and will not be described again here to avoid repetition.

[0095] For details, see Figure 6 As shown, this embodiment of the invention also provides an electronic device, including a bus 601, a transceiver 602, an antenna 603, a bus interface 604, a processor 605, and a memory 606.

[0096] The processor 605 is configured to generate a sandbox and a key corresponding to the task request upon receiving a task request, and to determine the usage period of the sandbox. The task request is used to instruct the model to be trained, and the key is used to encrypt the data during the training process. The transceiver 602 is used to acquire training data and import the training data into the memory of the sandbox; The processor 605 is further configured to train the model within the sandbox based on the key and the training data to obtain a training gradient, which is used to update the model parameters. The processor 605 is further configured to output the training gradient and parameter fragments through the sandbox, wherein the parameter fragments are used to characterize the relevant data involved in calculating the training gradient; The processor 605 is further configured to generate a parameter data chain based on the parameter fragment, the parameter data chain being used to store relevant data involved in calculating training gradients for different rounds; The processor 605 is further configured to delete the sandbox, the key, and all data within the sandbox after the sandbox outputs the training gradient, or when the duration after the sandbox is generated reaches the usage period duration.

[0097] In one embodiment, the training data is training data from at least one source, and the step of training within the sandbox based on the key and the training data to obtain the training gradient includes: Calculate a first risk value for the training data from each of the at least one source; The grade label of the training data from each source is determined based on the first risk value of the training data from each source. The training data from the at least one source is respectively imported into n gradient computation spaces, which are mutually isolated computation spaces within the sandbox. Different gradient computation spaces in the n gradient computation spaces import training data with different level labels, and a gradient computation space imports training data from different sources with the same level label. n is a positive integer greater than or equal to 1. Within the n gradient calculation spaces, the model is trained based on the imported training data to obtain n intermediate gradients; The training gradient is calculated based on the n intermediate gradients.

[0098] In one embodiment, the training data from the at least one source includes training data from a first source, and calculating a first risk value for the training data from each of the at least one source includes: Obtain hierarchical feature data of the training data from the first source in multiple dimensions, wherein the multiple dimensions include source authentication results, data type, sensitive field hit status, historical reputation, integrity summary and at least two dimensions from the business scenario; The hierarchical feature data of the multiple dimensions are normalized respectively to obtain the normalized scores of the multiple dimensions. The normalized scores of the multiple dimensions are weighted to obtain the first risk value of the training data from the first source.

[0099] In one embodiment, calculating the training gradient based on the n intermediate gradients includes: Calculate at least one of the following for each of the n intermediate gradients: gradient entropy index, parameter drift index, and outlier ratio index. The gradient entropy index is used to characterize the distribution of the corresponding intermediate gradient in different intervals. The parameter drift index is used to characterize the deviation of the gradient direction of the corresponding intermediate gradient from the historical gradient direction. The outlier ratio index is used to characterize the data fluctuation in the corresponding intermediate gradient. Based on at least one of the gradient entropy index, the parameter drift index, and the outlier ratio index for each intermediate gradient, calculate the second risk value for each intermediate gradient. Determine m intermediate gradients, wherein the second risk value of the m intermediate gradients is less than the first set threshold of the corresponding gradient computation space, where m is a positive integer greater than or equal to 1 and m is less than or equal to n; Calculate the weight coefficients of the corresponding intermediate gradients based on the second risk values ​​of the m intermediate gradients; The training gradient is calculated based on the m intermediate gradients and their corresponding weight coefficients.

[0100] In one embodiment, determining the m intermediate gradients includes: Determine m intermediate gradients and k intermediate gradients, wherein the second risk value of the k intermediate gradients is greater than a second set threshold, the m intermediate gradients and the k intermediate gradients are different intermediate gradients among n intermediate gradients, the second set threshold is greater than a first set threshold of the computation space of the n gradients, k is greater than or equal to 0, and k is less than or equal to n; Obtain the historical intermediate gradient and historical second risk value of the gradient calculation space corresponding to each of the k intermediate gradients from the parameter data chain. The parameter data chain includes the historical intermediate gradient and historical second risk value of different training rounds. The calculation of the weight coefficients of the corresponding intermediate gradients based on the second risk values ​​of the m intermediate gradients includes: Calculate the weight coefficients of the corresponding intermediate gradients based on the second risk values ​​of the m intermediate gradients; Calculate the weight coefficients of the corresponding historical intermediate gradients based on k historical second risk values; The calculation of the training gradient based on the m intermediate gradients and their corresponding weight coefficients includes: The training gradient is calculated based on the m intermediate gradients, the weight coefficients of the m intermediate gradients, the k historical intermediate gradients, and the weight coefficients of the k historical intermediate gradients.

[0101] In one embodiment, the parameter fragment includes the n intermediate gradients and a second risk value for the n intermediate gradients.

[0102] exist Figure 6In this document, a bus architecture (represented by bus 601) is used. Bus 601 may include any number of interconnected buses and bridges, linking various circuits including one or more processors represented by processor 605 and memory represented by memory 606. Bus 601 may also link various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. Bus interface 604 provides an interface between bus 601 and transceiver 602. Transceiver 602 may be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by processor 605 is transmitted over a wireless medium via antenna 603, which further receives data and transmits data to processor 605.

[0103] Processor 605 manages bus 601 and general processing, and also provides various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. Memory 606 can be used to store data used by processor 605 during operation.

[0104] Optionally, the processor 605 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or a graphics processing unit (GPU).

[0105] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the above-described functions. Figure 1 The various processes of the corresponding model training method embodiments, which can achieve the same technical effect, will not be described again here to avoid repetition. The computer-readable storage medium mentioned includes, for example, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0106] The present invention also provides a computer program product, including computer instructions that, when executed by a processor, implement the above-described... Figure 1 The various processes of the corresponding model training method implementation examples can achieve the same technical effect, and will not be described again here to avoid repetition.

[0107] In the embodiments of this invention, the terms "first," "second," etc., are used to distinguish similar object parameters and are not necessarily used to describe a specific order or sequence. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or devices. Additionally, the use of "and / or" in this application indicates at least one of the connected object parameters, such as A and / or B and / or C, representing seven possibilities: A alone, B alone, C alone, both A and B present, both B and C present, both A and C present, and A, B, and C present.

[0108] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0109] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or second terminal device, etc.) to execute the methods of the various embodiments of this application.

[0110] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A model training method, characterized in that, include: Upon receiving a task request, a sandbox and key corresponding to the task request are generated, and the usage period of the sandbox is determined. The task request is used to instruct the model to be trained, and the key is used to encrypt the data during the training process. Acquire training data and import the training data into the memory of the sandbox; The model is trained within the sandbox based on the key and the training data to obtain a training gradient, which is used to update the model's parameters. The training gradient and parameter fragments are output through the sandbox, and the parameter fragments are used to characterize the relevant data involved in calculating the training gradient. Based on the parameter fragment, a parameter data chain is generated, which is used to store relevant data involved in calculating the training gradient in different rounds; After the sandbox outputs the training gradient, or if the duration after the sandbox is generated reaches the usage period, delete the sandbox, the key, and all data within the sandbox.

2. The method as described in claim 1, characterized in that, The training data is training data from at least one source, and the step of training within the sandbox based on the key and the training data to obtain the training gradient includes: Calculate a first risk value for the training data from each of the at least one source; The grade label of the training data from each source is determined based on the first risk value of the training data from each source. The training data from the at least one source is respectively imported into n gradient computation spaces, which are mutually isolated computation spaces within the sandbox. Different gradient computation spaces in the n gradient computation spaces import training data with different level labels, and a gradient computation space imports training data from different sources with the same level label. n is a positive integer greater than or equal to 1. Within the n gradient calculation spaces, the model is trained based on the imported training data to obtain n intermediate gradients; The training gradient is calculated based on the n intermediate gradients.

3. The method as described in claim 2, characterized in that, The training data from the at least one source includes training data from a first source, and calculating a first risk value for the training data from each of the at least one source includes: Obtain hierarchical feature data of the training data from the first source in multiple dimensions, wherein the multiple dimensions include source authentication results, data type, sensitive field hit status, historical reputation, integrity summary and at least two dimensions from the business scenario; The hierarchical feature data of the multiple dimensions are normalized respectively to obtain the normalized scores of the multiple dimensions. The normalized scores of the multiple dimensions are weighted to obtain the first risk value of the training data from the first source.

4. The method as described in claim 2, characterized in that, The calculation of the training gradient based on the n intermediate gradients includes: Calculate at least one of the following for each of the n intermediate gradients: gradient entropy index, parameter drift index, and outlier ratio index. The gradient entropy index is used to characterize the distribution of the corresponding intermediate gradient in different intervals. The parameter drift index is used to characterize the deviation of the gradient direction of the corresponding intermediate gradient from the historical gradient direction. The outlier ratio index is used to characterize the data fluctuation in the corresponding intermediate gradient. Based on at least one of the gradient entropy index, the parameter drift index, and the outlier ratio index for each intermediate gradient, calculate the second risk value for each intermediate gradient. Determine m intermediate gradients, wherein the second risk value of the m intermediate gradients is less than the first set threshold of the corresponding gradient computation space, where m is a positive integer greater than or equal to 1 and m is less than or equal to n; Calculate the weight coefficients of the corresponding intermediate gradients based on the second risk values ​​of the m intermediate gradients; The training gradient is calculated based on the m intermediate gradients and their corresponding weight coefficients.

5. The method as described in claim 4, characterized in that, The determination of m intermediate gradients includes: Determine m intermediate gradients and k intermediate gradients, wherein the second risk value of the k intermediate gradients is greater than a second set threshold, the m intermediate gradients and the k intermediate gradients are different intermediate gradients among n intermediate gradients, the second set threshold is greater than a first set threshold of the computation space of the n gradients, k is greater than or equal to 0, and k is less than or equal to n; Obtain the historical intermediate gradient and historical second risk value of the gradient calculation space corresponding to each of the k intermediate gradients from the parameter data chain. The parameter data chain includes the historical intermediate gradient and historical second risk value of different training rounds. The calculation of the weight coefficients of the corresponding intermediate gradients based on the second risk values ​​of the m intermediate gradients includes: Calculate the weight coefficients of the corresponding intermediate gradients based on the second risk values ​​of the m intermediate gradients; Calculate the weight coefficients of the corresponding historical intermediate gradients based on k historical second risk values; The calculation of the training gradient based on the m intermediate gradients and their corresponding weight coefficients includes: The training gradient is calculated based on the m intermediate gradients, the weight coefficients of the m intermediate gradients, the k historical intermediate gradients, and the weight coefficients of the k historical intermediate gradients.

6. The method as described in any one of claims 4 or 5, characterized in that, The parameter fragment includes the n intermediate gradients and the second risk value of the n intermediate gradients.

7. A model training device, characterized in that, include: The first generation module is used to generate a sandbox and key corresponding to the task request when a task request is received, and to determine the usage period of the sandbox. The task request is used to instruct the model to be trained, and the key is used to encrypt the data during the training process. An acquisition module is used to acquire training data and import the training data into the memory of the sandbox; The training module is used to train the model within the sandbox based on the key and the training data to obtain a training gradient, which is used to update the model's parameters. The output module is used to output the training gradient and parameter fragments through the sandbox, wherein the parameter fragments are used to characterize the relevant data involved in calculating the training gradient; The second generation module is used to generate a parameter data chain based on the parameter fragment, wherein the parameter data chain is used to store relevant data involved in calculating the training gradient of different rounds; The deletion module is used to delete the sandbox, the key, and all data within the sandbox after the sandbox outputs the training gradient, or when the duration after the sandbox is generated reaches the usage period duration.

8. An electronic device, characterized in that, include: A processor, a memory, and a program stored in the memory and executable on the processor, wherein the program, when executed by the processor, implements the steps of the model training method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the model training method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, It includes computer instructions that, when executed by a processor, implement the steps of the model training method as described in any one of claims 1 to 6.