Method and device for updating trusted model
By adding a new parallel output layer to the original credible model and using incremental learning and contrastive learning to train the new credible model, the robustness problem when historical samples are difficult to obtain is solved, and effective recognition of new samples and stable recognition of historical samples are achieved.
Patent Information
- Application Number
- CN202210687416.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-17
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2042-06-17
AI Technical Summary
When historical samples are difficult to obtain, how to update the trusted model to ensure its robustness and stability, especially at the front end of the online fraud risk identification system, to ensure the ability to recognize new samples while maintaining the ability to recognize historical samples.
A new output layer with the same structure as the original output layer is added to the original credible model and is parallel to it. The new credible model is trained using incremental learning and contrastive learning methods. By minimizing the difference loss and maximizing the distance of the dropout augmentation vector, a new credible model is constructed to ensure the learning effect of historical samples and new samples.
The robustness of the updated trusted model is improved, ensuring the ability to recognize new samples while maintaining stability for historical samples, avoiding local optimal solutions and improving the overall performance of the model.
Smart Images

Figure CN115170136B_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of this specification relate to the field of artificial intelligence technology, and more particularly, to a method and apparatus for updating a trusted model. Background Art
[0002] With the rapid development of internet technology, users are facing various risks in their internet use. For example, various forms of fraud may occur, such as online transaction fraud, fake part-time job scams, and online dating scams. Risks such as cheating and theft may also exist. Typically, at the front end of the risk identification system, traffic first enters a trust model, which analyzes the credibility of user behavior within the traffic. Traffic deemed to be trustworthy is quickly squared, while traffic indicating untrustworthy user behavior is sent to the risk identification system for more refined risk identification. Generally speaking, the trust model can square over 90% of traffic, leaving only approximately 10% of traffic to the risk identification system for more refined identification.
[0003] Given the ever-changing nature of network risks, ensuring the stability of the trusted models at the forefront of risk identification systems, responsible for the majority of traffic releases, is crucial. On the one hand, the updating of risky behaviors requires regular updates of the trusted models to cover new samples. On the other hand, the current stable operation of the new models cannot be disrupted; that is, the updated models must still maintain their ability to identify historical samples.
[0004] Traditional approaches to obtaining trusted models often retain all historical sample data and use it in conjunction with newly added samples for modeling. This approach requires a significant amount of storage space to maintain both historical samples and the growing number of newly added samples. However, to reduce storage pressure, many systems do not retain historical samples. Therefore, when historical samples are difficult to obtain, updating the trusted model to ensure its robustness becomes a pressing issue. Summary of the Invention
[0005] One or more embodiments of this specification disclose a method and apparatus for updating a trusted model, so as to ensure the robustness of the updated trusted model when historical samples are difficult to obtain.
[0006] According to a first aspect, the present disclosure provides a method for updating a trusted model, the method comprising:
[0007] Obtaining a new sample and a label corresponding to the new sample, wherein the new sample is the user's network behavior data, and the label includes whether the behavior is trustworthy;
[0008] Input the new sample into the original trusted model, obtain and store the output of the original trusted model for the new sample as the simulated original label of the new sample;
[0009] A new output layer with the same structure as the original output layer is added to the original credible model to obtain a new credible model;
[0010] Training the new trusted model using the newly added samples, where a training objective includes minimizing a training loss, where the training loss is determined based on a first difference, a second difference, and a third difference, where the first difference is a difference between an output result of the original output layer for the newly added samples and a simulated original label of the newly added samples, the second difference is a difference between an output result of the new output layer for the newly added samples and a label corresponding to the newly added samples, and the third difference is a difference between an output result of the new output layer for the newly added samples and the simulated original label of the newly added samples;
[0011] The original output layer is removed from the new credible model obtained after training to obtain an updated credible model.
[0012] According to an achievable embodiment of the present application, the method further includes: obtaining, during the training process, a vector pair obtained by the same newly added sample in the original output layer and the new output layer as a positive sample pair, and obtaining a temporarily dropped out augmented vector of different newly added samples in the original output layer and a dropout augmented vector in the new output layer as a negative sample pair;
[0013] The training objective also includes minimizing the distance between positive sample pairs and maximizing the distance between negative sample pairs.
[0014] According to an achievable method in an embodiment of the present application, the training loss is obtained by weighting the first loss function, the second loss function, the third loss function and the fourth loss function;
[0015] The first loss function, the second loss function and the third loss function respectively reflect the first difference, the second difference and the third difference, and the fourth loss function is determined based on the distance between the positive sample pairs and the distance between the negative sample pairs.
[0016] According to an achievable method in an embodiment of the present application, the dropout ratio used to generate the dropout augmentation vector and the weighting coefficient used in the weighting process are preset hyperparameters; or,
[0017] The dropout ratio is an optimal ratio determined by grid search, and the weighting coefficient is learned as a parameter during the training process.
[0018] According to an achievable method in an embodiment of the present application, before using the newly added samples to train the new trustworthy model, the method further includes:
[0019] The parameters of the new output layer are randomly initialized, and the other model parameters use the parameters of the original credible model.
[0020] According to an achievable method in an embodiment of the present application, the model parameters of the new credible model are updated using the value of the training loss in each iteration of the training until a preset training end condition is met; wherein the model parameters include parameters of the input layer, the intermediate layer, the original output layer, and the new output layer; or,
[0021] In each round of training, the value of the training loss is used to update only the parameters of the new output layer of the new trusted model until a preset first training end condition is met; and the value of the training loss is further used to update the parameters of the input layer, the intermediate layer, the original output layer and the new output layer in the new trusted model until a preset second training end condition is met.
[0022] According to an achievable manner in an embodiment of the present application, the method further includes:
[0023] The traffic including the user's network behavior is input into the updated trust model, and a result output by the trust model regarding whether the user's network behavior is a trustworthy behavior is obtained.
[0024] In a second aspect, a device for updating a trusted model is provided, the device comprising:
[0025] a sample acquisition unit configured to acquire a newly added sample and a label corresponding to the newly added sample, wherein the newly added sample is the user's network behavior data, and the label includes whether the behavior is trustworthy;
[0026] The label simulation unit is configured to input the newly added sample into the original trusted model, obtain and store the output result of the original trusted model for the newly added sample as the simulated original label of the newly added sample;
[0027] The model building unit is configured to add a new output layer with the same structure as the original output layer and in parallel to the original credible model to obtain a new credible model;
[0028] a model training unit configured to train the new trusted model using the newly added samples, wherein a training objective includes minimizing a training loss, wherein the training loss is determined based on a first difference, a second difference, and a third difference, wherein the first difference is a difference between an output result of the original output layer for the newly added sample and a simulated original label of the newly added sample, the second difference is a difference between an output result of the new output layer for the newly added sample and a label corresponding to the newly added sample, and the third difference is a difference between an output result of the new output layer for the newly added sample and the simulated original label of the newly added sample;
[0029] The model acquisition unit is configured to remove the original output layer from the new credible model obtained after the training is completed to obtain an updated credible model.
[0030] According to a third aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method described above.
[0031] According to a fourth aspect, the present disclosure provides a computing device, comprising a memory and a processor, wherein executable code is stored in the memory, and when the processor executes the executable code, the method described above is implemented.
[0032] According to the specific embodiments provided in this application, this application discloses the following technical effects:
[0033] 1) The present disclosure adopts the idea of incremental learning, adding a new output layer with the same structure as the original output layer and parallel to the original trust model to construct a new trust model, using the original output layer to simulate the learning effect of historical samples, and using the new output layer to simulate the learning effect of new samples and historical samples, so that the trained new trust model can ensure the learning effect of new samples while still having high stability for historical samples, thereby improving the robustness of the updated trust model.
[0034] 2) The present disclosure further refers to the idea of contrastive learning, using the vectors obtained by the same new sample in the original output layer and the new output layer as a positive sample pair, and the temporary dropout augmented vectors of different new samples in the original output layer and the dropout augmented vectors in the new output layer as negative sample pairs, so that the overall model parameter distribution of the new output layer and the original output layer is as close as possible, while retaining a certain degree of freedom, thereby further improving the robustness of the updated credible model.
[0035] 3) Before training the new credible model, the parameters of the new output layer are randomly initialized, and the parameters of the original credible model are used for other model parameters. This can not only make full use of the training results of the original credible model, but also effectively avoid falling into the local optimal solution.
[0036] Of course, any product implementing the present application does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0038] Figure 1 An exemplary system architecture diagram to which the embodiments of the present disclosure may be applied is shown;
[0039] Figure 2 A flow chart of a method for updating a trusted model provided in an embodiment of the present disclosure;
[0040] Figure 3 A schematic diagram of the structure of the original trust model provided in the embodiment of the present disclosure;
[0041] Figure 4 A schematic diagram of the structure of a new trust model provided by an embodiment of the present disclosure;
[0042] Figure 5 A schematic diagram of the structure of the updated trust model provided in the embodiment of the present disclosure;
[0043] Figure 6 A schematic block diagram shows an apparatus for updating a trust model according to one embodiment. DETAILED DESCRIPTION
[0044] The solution provided in this specification is described below in conjunction with the accompanying drawings.
[0045] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The singular forms "a", "an", "the" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise.
[0046] It should be understood that the term "and / or" as used herein is merely a description of the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.
[0047] The word "if," as used herein, may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to the determination" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)," depending on the context.
[0048] Figure 1 An exemplary system architecture to which embodiments of the present disclosure can be applied is shown. The system primarily includes a device for updating a trusted model, a trusted model, and a risk identification system. The device for updating the trusted model can obtain new samples and labels corresponding to the new samples, and use the new samples to update the trusted model. The new samples can be derived from user network behavior data in a data warehouse, as well as annotations of the user network behavior data.
[0049] The device may periodically update the trusted model using the method provided by the embodiment of the present disclosure, or may update the trusted model using the method provided by the embodiment of the present disclosure when triggered by a specific event.
[0050] The trust model is used to identify online traffic containing user network behavior and output a result indicating whether the behavior is trustworthy. If it is trustworthy, the trust model will allow the traffic to proceed normally. If it is untrustworthy, the model can forward the traffic to the risk identification system for further refined risk identification. For example, this can identify risks such as cheating and theft.
[0051] The trusted model updating device, trusted model, and risk identification system in the above-mentioned system can be implemented on the server side. This server side can be a single server, a server group consisting of multiple servers, or a cloud server. A cloud server, also known as a cloud computing server or cloud host, is a host product within the cloud computing service system. It addresses the management difficulties and poor scalability of traditional physical hosts and virtual private servers (VPs). In addition to being implemented on the server side, it can also be implemented on a computer terminal with powerful computing capabilities.
[0052] The device for updating the trusted model may be an application located on the server side, or may be a functional unit such as a plug-in or a software development kit (SDK) in the application located on the server side.
[0053] It should be understood that Figure 1The number of the apparatus for updating the trusted model, the trusted model, the risk identification system, and the data warehouse is merely illustrative. Any number of the apparatus for updating the trusted model, the trusted model, the risk identification system, and the data warehouse may be provided according to implementation requirements.
[0054] Figure 2 This is a flow chart of a method for updating a trusted model provided by an embodiment of the present disclosure. It can be understood that this method can be performed by Figure 1 The device for updating the trust model in the system shown is executed. Figure 2 , the method comprising:
[0055] Step 202: Acquire a newly added sample and a label corresponding to the newly added sample. The newly added sample is the user's network behavior data, and the label includes whether it is a credible behavior.
[0056] Step 204: Input the newly added sample into the original trusted model, obtain and store the output result of the original trusted model for the newly added sample as the simulated original label of the newly added sample.
[0057] Step 206: Add a new output layer in parallel with the original output layer structure to the original credible model to obtain a new credible model.
[0058] Step 208: Use the newly added samples to train the new trusted model. The training objectives include minimizing the training loss. The training loss is determined based on the first difference, the second difference, and the third difference. The first difference is the difference between the output result of the original output layer for the newly added sample and the simulated original label of the newly added sample. The second difference is the difference between the output result of the new output layer for the newly added sample and the label corresponding to the newly added sample. The third difference is the difference between the output result of the new output layer for the newly added sample and the simulated original label of the newly added sample.
[0059] Step 210: Remove the original output layer from the new trusted model obtained after training to obtain an updated trusted model.
[0060] It can be seen from the technical content provided by the above embodiments that the present disclosure adopts the idea of incremental learning, and adds a new output layer with the same structure as the original output layer and parallel to the original trusted model to construct a new trusted model. The original output layer is used to simulate the learning effect of historical samples, and the new output layer is used to simulate the learning effect of new samples and historical samples. In this way, the trained new trusted model can ensure the learning effect of new samples while still having high stability for historical samples, thereby improving the robustness of the updated trusted model.
[0061] The following are Figure 2 Each step shown is explained in detail.
[0062] First, the above step 202, namely "obtaining a new sample and a label corresponding to the new sample, where the new sample is the user's network behavior data and the label includes whether it is a trustworthy behavior" is described in detail in conjunction with the embodiment.
[0063] When users use the Internet, a large amount of network behavior data is recorded by the server. These network behavior data are usually recorded in a data warehouse, reflecting the association between a large number of behavior subjects and behavior objects. Some of these behaviors are risky, while most behaviors are trustworthy. The trust model involved in the embodiment of the present application is used to identify whether user behavior is trustworthy. Therefore, the training samples used are the user's network behavior data and the labels that mark the training samples as trustworthy behaviors. Since the embodiment of the present application involves the process of updating the trust model using new samples, this step obtains the new samples and the labels corresponding to the new samples.
[0064] The aforementioned users and online behavior types vary depending on the scenario. For example, in online transactions, users can include accounts, bank cards, and red envelope IDs. Online behaviors can include payment, deposit and withdrawal, contract binding, sending and receiving red envelopes, and other financial-related activities.
[0065] Taking online friendship as an example, the aforementioned users can be social network accounts, instant messaging accounts, financial accounts, host addresses, client identifiers, etc. Online behaviors can include sending friend requests, adding friends, chatting, transferring money, sending and receiving red envelopes, sending links, etc.
[0066] The labels for newly added samples can be manually annotated or labeled using other methods. For example, some high-precision risk identification models can be used to clearly identify untrusted and trusted behaviors. The disclosed embodiments do not specifically limit the source of newly added samples or the labeling method.
[0067] The above step 204, namely, "inputting the new sample into the original trusted model, obtaining and storing the output result of the original trusted model for the new sample as the simulated original label of the new sample" is described in detail below in conjunction with an embodiment.
[0068] The original credible model refers to the credible model before the update, that is, the credible model that has been trained using historical samples. Its structure can be simply expressed as follows Figure 3 As shown in Figure 1, it includes an input layer, an intermediate layer, and an output layer. The sample is extracted from the input layer and the intermediate layer to extract the feature vector, and the output layer maps the feature vector to obtain the recognition result. The specific network structure is not described in detail here. For the convenience of description, the parameters of the input layer and the intermediate layer are represented as θ s, denote the parameters of the output layer as θ o .
[0069] Assume that the new samples and their labels are represented as (X n ,Y n ), where X n For new samples, Y n As labels. In this step, each new sample X n Input the original credible model respectively to obtain the output result Y of the original credible model for the new sample o , the Y o is considered as the simulated original label of the newly added sample. In other words, Y o It reflects the recognition ability of the original credible model and can be expressed as the following formula:
[0070] Y o =M o (X n ,θ s ,θ o ) (1)
[0071] M o () indicates the recognition processing corresponding to the original credible model.
[0072] The above step 206 , namely “adding a new output layer with the same structure as the original output layer and arranged in parallel to the original trusted model to obtain a new trusted model”, is described in detail below with reference to an embodiment.
[0073] This step involves building a new trusted model. This new trusted model is not the final updated model structure, but rather an intermediate model structure used during the training process. This new trusted model retains the original trusted model structure but adds an output layer. To distinguish them, the output layer of the original trusted model is referred to as the original output layer, and the newly added output layer is referred to as the new output layer.
[0074] like Figure 4 As shown in , in the new credible model, the original output layer and the new output layer are parallel, that is, the intermediate layer outputs to the original output layer while also outputting to the new output layer. The original output layer and the new output layer will output recognition results respectively.
[0075] The initialization parameters of the new output layer are denoted as θ n , can be randomly initialized parameters, or the parameters of the original output layer can be directly used as the initialization parameters of the new output layer. Among them, using randomly initialized parameters requires a longer model training time, but can effectively prevent the model from falling into a local optimum.
[0076] The above step 208, namely "training a new trustworthy model using newly added samples", is described in detail below with reference to an embodiment.
[0077] In each round of iteration, after the new samples are input into the new trusted model, the original output layer and the new output layer of the new trusted model will output the recognition results for the new samples. Since the parameters of the new trusted model will be updated during the training process, θ s * Represents the parameters of the input layer and intermediate layer of the new credible model during training, using θ o * and θ n * Represents the parameters of the original output layer and the new output layer of the new credible model during training.
[0078] For the newly added sample X n , the output Y of the original output layer o * Expressed as:
[0079] Y o * =M n (X n ,θ s * ,θ o * ) (2)
[0080] M n () represents the recognition processing corresponding to the new trusted model.
[0081] For the newly added sample X n , the output Y of the new output layer n * Expressed as:
[0082] Y n * =M n (X n ,θ s * ,θ o * ) (3)
[0083] As one feasible approach, when training a new trusted model, we can employ the LwF (Learning without Forgetting) approach from incremental learning. The LwF algorithm is a training method between joint training and fine-tuning training, and its characteristic is that it can update the model without using historical samples.
[0084] In the embodiment of this application, the training loss is mainly determined based on three differences:
[0085] The first difference is the difference between the output of the original output layer for the newly added samples and the simulated original labels of the newly added samples.
[0086] In step 204, the output of the original trusted model for the newly added sample is obtained and used as the simulated original label for the newly added sample. This represents the recognition ability learned by the original trusted model from historical samples. To avoid excessive adjustment of the parameters of the original trusted model for training the newly added task, which would lead to a decrease in the performance of the new trusted model on historical samples, minimizing the difference between the output of the original output layer for the newly added sample and the simulated original label of the newly added sample can be used as one of the training objectives.
[0087] For the first difference, the first loss function can be constructed, expressed as L old (Y o ,Y o * ).
[0088] Among them, L old (Y o ,Y o * ) can use the Knowledge Distillation loss function, for example, the following formula is used to calculate:
[0089]
[0090]
[0091]
[0092] Among them, l represents the number of categories of the credible model recognition results, is the confidence of the original credible model in the i-th category for the newly added sample output, is the confidence level of the original output layer of the new trust model for the newly added sample in the i-th category. The denominator in formulas (5) and (6) represents the summation over all categories. T is a hyperparameter, which is manually set to an empirical or experimental value in advance, usually greater than 1. It is used to increase the small output values in multi-category tasks, allowing the network to better characterize the correlation between different categories.
[0093] The second difference is the difference between the output results of the new output layer for the newly added samples and the labels corresponding to the newly added samples.
[0094] Naturally, when training with new samples, it is necessary to ensure that the new trustworthy model performs well on the new samples and learns a certain level of recognition capability from them. Therefore, one of the training objectives is to minimize the difference between the output of the new output layer for the new samples and the labels corresponding to the new samples.
[0095] For the second difference, a second loss function can be constructed, expressed as L new (Y n ,Y n * ).
[0096] The third difference is the difference between the output results of the new output layer for the newly added samples and the simulated original labels of the newly added samples.
[0097] In step 204, the output of the original trusted model for the newly added sample is obtained and used as the simulated original label for the newly added sample. This represents the recognition capability learned by the original trusted model from historical samples. Since the recognition capability of the new trusted model on historical samples must not be reduced during the training process, the difference between the output of the new output layer for the newly added sample and the simulated original label of the newly added sample must be minimized.
[0098] For the third difference, a third loss function can be constructed, expressed as L old_new (Y o ,Y n * ).
[0099] L new (Y n ,Y n * ) and L old_new (Y o ,Y n * ) can also use Knowledge Distillation loss, that is, use a calculation method similar to the above formulas (4), (5) and (6), which will not be repeated here. In addition, in addition to using Knowledge Distillation loss, other loss functions can also be used or designed to reflect the above three differences.
[0100] As one of the feasible ways, the loss function L1 can be designed as:
[0101] L1=α1 L old (Y o ,Y o * )+α2 L new (Y n ,Yn * )+α3 L old_new (Y o ,Y n * ) (7)
[0102] Among them, α1, α2 and α3 are weighting coefficients, which can adopt preset hyperparameters, or can be manually set empirical values or experimental values, etc.
[0103] The design of this loss function draws on the principles of knowledge distillation and references the approach of incremental learning (LwF). Within the constructed new trusted model, a distinction is made between the original output layer and the new output layer. The original output layer measures the effect of simulated historical samples on the new trusted model, while the new output layer simultaneously measures the effect of newly added samples on the new trusted model and the effect of historical samples on the new trusted model. This allows the trusted model to be trained using only newly added samples even when historical samples are missing. This ensures that the trusted model performs well for newly added samples while also taking into account the effects of historical samples.
[0104] As another feasible way, in addition to minimizing the above three differences, we can further refer to the idea of contrastive learning SimCSE (Simple Contrastive Learning of Sentence Embedding), and use the dropout subnetwork of the original output layer and the new output layer in the new trusted model to perform several forward propagations on each new sample to obtain several different vectors (embeddings). These vectors are called dropout augmented vectors. In an embodiment of the present application, the vectors obtained by the original output layer and the new output layer of the same new sample can be obtained as a positive sample pair during the training process, and the dropout augmented vectors corresponding to different new samples can be obtained as negative sample pairs. Further training goals include: minimizing the distance between positive sample pairs and maximizing the distance between negative sample pairs.
[0105] The design idea of the above training objectives is to make the overall model parameter distribution of the new output layer and the original output layer as close as possible while retaining a certain degree of freedom.
[0106] For the same newly added sample, the distance between the vectors obtained in the original output layer and the new output layer should be as close as possible, thereby reflecting that the overall model parameter distribution of the new output layer and the original output layer is as close as possible.
[0107] Dropout was originally used to solve the overfitting problem in deep learning. It refers to a model method in which a certain proportion of neurons are randomly masked in the neural network layer so that they do not play a transmission role. The effect is to randomly cause a part of the connection weights to be 0, making the network model sparse. It should be noted that dropout only works in the process of model training, and all neurons will play a role in the process of using the model for actual prediction. In the embodiment of the present application, the dropout mechanism is used to expand the negative samples. The dropout mechanism is used in the original output layer of the new credible model and the fully connected layer of the new output layer, so that the fully connected layer randomly masks some neurons according to a preset ratio (which can be understood as randomly setting a part of the connection weights in the fully connected matrix to 0) and then outputs the dropout augmented vector.
[0108] In an embodiment of the present application, the above-mentioned preset ratio can be a manually set hyperparameter, which can be set to an empirical value or a test value. The optimal ratio can also be searched by Grid Search. Grid Search is a parameter adjustment method that tries every possibility by traversing all candidate parameter selections in a loop to find the best performing parameter. In an embodiment of the present application, the search range of the dropout ratio can be pre-specified, for example, {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9}, and then the ratios within the search range and other hyperparameters are used to combine them, and training is performed on the training sample set respectively, and finally a set of hyperparameters (including the dropout ratio) that performs best in the verification sample set is selected as the final hyperparameter combination used. If other hyperparameters do not participate in the grid search, it is also possible to use only the ratios within each search range to train on the training sample set, and finally select the ratio that performs best in the verification sample set as the final dropout ratio used.
[0109] In theory, the distance between the dropout augmentation vectors corresponding to different new samples, such as different new samples in the same batch, in the original and new output layers should be as large as possible to ensure the greatest possible ability to distinguish different new samples. Therefore, the dropout augmentation vectors corresponding to different new samples in the original and new output layers are used as negative sample pairs.
[0110] For example, for a new sample X1, its corresponding dropout augmented vector in the original output layer is denoted as h1'. For another new sample X2 in the same batch, its corresponding dropout augmented vector in the new output layer is denoted as h2'. Thus, h1' and h2' constitute a negative sample pair.
[0111] The vectors in the above positive sample pairs and negative sample pairs can be obtained from the penultimate fully connected layer of the original output layer and the new output layer. For example, the embedding output from the penultimate fully connected layer constitutes the above positive sample pairs, and the dropout augmented vector from the penultimate fully connected layer constitutes the negative sample pairs.
[0112] When achieving the above further training goals, you can use infoNCE loss, for example, involving the corresponding loss function L m as follows:
[0113]
[0114] Among them, h m and h m + is a positive sample pair, h m and h n + is a negative sample pair, N is the number of samples in the same batch containing h m The number of negative sample pairs, r is a preset hyperparameter, which can be an empirical value or a test value. sim() is a function for calculating the distance between vectors. For example, the following formula can be used:
[0115]
[0116] Where || || represents the norm calculation. Replace h1 and h2 in formula (9) with h m and h m + You can calculate Replace h1 and h2 in formula (9) with h m and h n + You can calculate
[0117] As a more preferred implementation, the above loss functions L1 and L m The integration is performed to obtain a total loss function L, for example, using the following formula:
[0118]
[0119] Among them, α1, α2, α3 and α4 are hyperparameters for controlling weights, and can adopt manually set empirical values or experimental values. For the regularization term of the model parameters, for example, L2 regularization can be used. Its purpose is to prevent overfitting. Adding regularization terms to the model can limit the complexity of the model, so that the model achieves a balance between complexity and performance.
[0120] In addition to manually specifying the above hyperparameters, the weighting coefficients can also be learned as parameters during model training. For example, the following formula can be used:
[0121]
[0122] Among them, σ1, σ2, σ3 and σ4 are parameters learned during the model training process.
[0123] As one of the feasible ways, in the process of training a new trusted model, each round of iteration uses the value of the training loss (such as the above-mentioned total loss function) to update the model parameters of the new trusted model. The model parameters here refer to all model parameters. and Until the preset training end conditions are met. In other words, the parameters of the input layer, intermediate layer, original output layer and new output layer in the new credible model are updated uniformly.
[0124] The training end conditions may include the following: the training loss is less than or equal to the preset loss function threshold, the number of iterations reaches the preset threshold, the number of L in the validation set ... new (Y n ,Y n * ) and L old_new (Y o ,Y n * ) minimum etc.
[0125] Other parameter updating methods may also be used, for example, in each round of training iteration, the value of the training loss is used to update only the parameters of the new output layer of the new trusted model until the preset first training end condition is met. The value of the training loss is further used to update the parameters of the input layer, intermediate layer, original output layer and new output layer in the new trusted model until the preset second training end condition is met. The first training end condition may include, for example, the value of the training loss is less than or equal to the preset loss function threshold, and the number of iterations reaches the preset number threshold. The second training end condition may include, for example, the value of the training loss is less than or equal to the preset loss function threshold, and the number of iterations reaches the preset number threshold, and L in the validation set is less than or equal to the preset loss function threshold. new (Y n ,Y n * ) and L old_new (Y o ,Y n * ) minimum etc.
[0126] After the training, the new credible model is obtained by removing the original output layer and retaining only the new output layer to obtain the updated credible model, such as Figure 5As shown in . Then, perform an A / B test on the trusted model before and after the update. That is, use the trusted model before the update for some traffic and the trusted model after the update for some traffic. Then compare the recognition effects of the trusted model before and after the update. If the requirements are met, all traffic can be switched to the updated trusted model.
[0127] After the traffic containing the user's network behavior is input into the updated trust model, the trust model outputs a result indicating whether the user's network behavior is trustworthy. If it is trustworthy, the traffic is forwarded normally, i.e., it is forwarded to the next-hop device according to the route corresponding to the traffic's destination address. If it is untrustworthy, the traffic can be further sent to the risk identification system for more refined risk identification.
[0128] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0129] According to another embodiment, an apparatus for updating a trusted model is provided. Figure 6 FIG. 1 is a schematic block diagram showing an apparatus for updating a trusted model according to an embodiment. Figure 6 As shown, the apparatus 600 includes: a sample acquisition unit 601, a label simulation unit 602, a model construction unit 603, a model training unit 604 and a model acquisition unit 605, wherein the main functions of each component unit are as follows:
[0130] The sample acquisition unit 601 is configured to acquire a new sample and a label corresponding to the new sample. The new sample is the user's network behavior data, and the label includes whether it is a trustworthy behavior.
[0131] The label simulation unit 602 is configured to input the newly added sample into the original trusted model, obtain and store the output result of the original trusted model for the newly added sample as the simulated original label of the newly added sample.
[0132] The model building unit 603 is configured to add a new output layer in the original credible model, which has the same structure as the original output layer and is parallel to the original output layer, to obtain a new credible model.
[0133] The model training unit 604 is configured to train a new trusted model using the newly added samples. The training objective includes minimizing the training loss. The training loss is determined based on the first difference, the second difference, and the third difference. The first difference is the difference between the output result of the original output layer for the newly added sample and the simulated original label of the newly added sample. The second difference is the difference between the output result of the new output layer for the newly added sample and the label corresponding to the newly added sample. The third difference is the difference between the output result of the new output layer for the newly added sample and the simulated original label of the newly added sample.
[0134] The model acquisition unit 605 is configured to remove the original output layer from the new credible model obtained after the training is completed to obtain an updated credible model.
[0135] Furthermore, the model training unit 604 may be further configured to: during the training process, obtain a vector pair obtained from the original output layer and the new output layer for the same newly added sample as a positive sample pair, and obtain a temporarily dropped out augmented vector from the original output layer and a dropout augmented vector from the new output layer for different newly added samples as a negative sample pair. The aforementioned training objectives also include minimizing the distance between positive sample pairs and maximizing the distance between negative sample pairs.
[0136] As one of the feasible ways, the training loss is obtained by weighted processing of the first loss function, the second loss function, the third loss function and the fourth loss function; wherein, the first loss function, the second loss function and the third loss function respectively reflect the first difference, the second difference and the third difference, and the fourth loss function is determined based on the distance between the positive sample pairs and the distance between the negative sample pairs.
[0137] The weighting coefficient is a preset hyperparameter, or is learned as a parameter during the training process.
[0138] As one of the feasible ways, before using the newly added samples to train the new trusted model, the model training unit 604 may randomly initialize the parameters of the new output layer, and other model parameters may use the parameters of the original trusted model.
[0139] As one of the feasible ways, the model training unit 604 updates the model parameters of the new trusted model using the value of the training loss in each round of training iteration until the preset training end conditions are met; the model parameters include the parameters of the input layer, the intermediate layer, the original output layer and the new output layer.
[0140] As another feasible method, the model training unit 604 uses the value of the loss function to update only the parameters of the new output layer of the new trusted model in each round of training iteration until the preset first training end condition is met; and then further uses the value of the loss function to update the parameters of the input layer, intermediate layer, original output layer and new output layer in the new trusted model until the preset second training end condition is met.
[0141] Traffic containing the user's network behavior is fed into the trained trust model and the model's output determines whether the user's network behavior is trustworthy. If so, the traffic is forwarded normally, i.e., it is forwarded to the next-hop device according to the route corresponding to the traffic's destination address. If untrustworthy, the traffic is sent to the risk identification system for more refined risk identification.
[0142] The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences from other embodiments. In particular, the device embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.
[0143] According to another embodiment, there is also provided a computer readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute Figure 2 The method described.
[0144] According to another embodiment, a computing device is provided, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, Figure 2 The method described.
[0145] As time goes by and technology develops, the meaning of computer-readable storage media becomes more and more extensive, and the dissemination path of computer programs is no longer limited to tangible media, but can also be downloaded directly from the Internet, etc. Any combination of one or more computer-readable storage media can be used. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or components, or any combination of the above. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this specification, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device or device.
[0146] The processors mentioned above may include one or more single-core processors or multi-core processors. The processors may include any combination of general-purpose processors or dedicated processors (such as image processors, application processors, baseband processors, etc.).
[0147] Those skilled in the art will appreciate that, in one or more of the above examples, the functions described herein may be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions may be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.
[0148] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for updating a trusted model, characterized in that: The method includes: Obtaining a new sample and a label corresponding to the new sample, wherein the new sample is the user's network behavior data, and the label includes whether the behavior is trustworthy; Input the new sample into the original trusted model, obtain and store the output of the original trusted model for the new sample as the simulated original label of the new sample; Adding a new output layer with the same structure as the original output layer and in parallel to the original trusted model to obtain a new trusted model; wherein the input layer and the middle layer of the obtained new trusted model use the input layer and the middle layer of the original trusted model; Training the new credible model using the newly added samples, where the training objective includes minimizing training loss; During the training process, the parameters of the input layer, the parameters of the intermediate layer, the parameters of the original output layer, and the parameters of the new output layer in the new credible model are updated; The training loss is determined based on a first difference, a second difference, and a third difference, wherein the first difference is the difference between the output result of the original output layer for the newly added sample in the new credible model and the simulated original label of the newly added sample, the second difference is the difference between the output result of the new output layer for the newly added sample and the label corresponding to the newly added sample, and the third difference is the difference between the output result of the new output layer for the newly added sample and the simulated original label of the newly added sample; Removing the original output layer from the new trusted model obtained after the training to obtain an updated trusted model, wherein the output layer of the updated trusted model only includes: the new output layer in the new trusted model obtained after the training; The method further includes: Use the dropout sub-networks of the original output layer and the new output layer in the new credible model to perform forward propagation on each new sample to obtain different vectors; During the training process, a vector pair obtained from the original output layer and the new output layer of the same newly added sample in the new credible model is obtained as a positive sample pair; Use the dropout mechanism in the fully connected layers of the original output layer and the new output layer of the new credible model. Randomly set some connection weights in the fully connected matrix to 0 and then output the dropout augmented vector. Obtain the dropout augmented vectors of different newly added samples in the original output layer and the dropout augmented vectors in the new output layer as negative sample pairs. The training objective also includes minimizing the distance between positive sample pairs and maximizing the distance between negative sample pairs.
2. The method according to claim 1, characterized in that The training loss is obtained by weighting the first loss function, the second loss function, the third loss function and the fourth loss function; The first loss function, the second loss function and the third loss function respectively reflect the first difference, the second difference and the third difference, and the fourth loss function is determined based on the distance between the positive sample pairs and the distance between the negative sample pairs.
3. The method according to claim 2, characterized in that The dropout ratio used to generate the dropout augmentation vector and the weighting coefficient used in the weighting process are preset hyperparameters; or, The dropout ratio is an optimal ratio determined by grid search, and the weighting coefficient is learned as a parameter during the training process.
4. The method according to claim 1, wherein Before using the newly added samples to train the new trustworthy model, the method further includes: The parameters of the new output layer are randomly initialized, and the other model parameters use the parameters of the original credible model.
5. The method according to any one of claims 1 to 4, characterized in that In each iteration of the training, the model parameters of the new credible model are updated using the value of the training loss until a preset training end condition is met; wherein the model parameters include parameters of the input layer, the intermediate layer, the original output layer, and the new output layer; or, In each round of training, the value of the training loss is used to update only the parameters of the new output layer of the new trusted model until a preset first training end condition is met; and the value of the training loss is further used to update the parameters of the input layer, the intermediate layer, the original output layer and the new output layer in the new trusted model until a preset second training end condition is met.
6. The method according to any one of claims 1 to 4, characterized in that The method further includes: The traffic including the user's network behavior is input into the updated trust model, and a result output by the trust model regarding whether the user's network behavior is a trustworthy behavior is obtained.
7. A device for updating a trusted model, characterized in that: The device includes: a sample acquisition unit configured to acquire a newly added sample and a label corresponding to the newly added sample, wherein the newly added sample is the user's network behavior data, and the label includes whether the behavior is trustworthy; The label simulation unit is configured to input the newly added sample into the original trusted model, obtain and store the output result of the original trusted model for the newly added sample as the simulated original label of the newly added sample; The model construction unit is configured to add a new output layer with the same structure as the original output layer and in parallel to the original trusted model to obtain a new trusted model; wherein the input layer and the intermediate layer of the obtained new trusted model use the input layer and the intermediate layer of the original trusted model; a model training unit configured to train the new trusted model using the newly added samples, wherein the training objective includes minimizing the training loss. During the training process, the parameters of the input layer, the parameters of the intermediate layer, the parameters of the original output layer, and the parameters of the new output layer in the new trusted model are all updated; the training loss is determined based on a first difference, a second difference, and a third difference, wherein the first difference is the difference between the output result of the original output layer in the new trusted model for the newly added sample and the simulated original label of the newly added sample, the second difference is the difference between the output result of the new output layer for the newly added sample and the label corresponding to the newly added sample, and the third difference is the difference between the output result of the new output layer for the newly added sample and the simulated original label of the newly added sample; The model acquisition unit is configured to remove the original output layer from the new trusted model obtained after the training to obtain an updated trusted model, wherein the output layer of the updated trusted model only includes: the new output layer in the new trusted model obtained after the training; in, Use the dropout sub-networks of the original output layer and the new output layer in the new credible model to perform forward propagation on each new sample to obtain different vectors; During the training process, a vector pair obtained from the original output layer and the new output layer of the same newly added sample in the new credible model is obtained as a positive sample pair; Use the dropout mechanism in the fully connected layers of the original output layer and the new output layer of the new credible model. Randomly set some connection weights in the fully connected matrix to 0 and then output the dropout augmented vector. Obtain the dropout augmented vectors of different newly added samples in the original output layer and the dropout augmented vectors in the new output layer as negative sample pairs. The training objective also includes minimizing the distance between positive sample pairs and maximizing the distance between negative sample pairs.
8. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 6.
9. A computing device comprising a memory and a processor, characterized in that: The memory stores executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Target detection method and device based on incremental learning
CN113205142A
Text-based sentiment classification method and device, computer equipment and storage medium
CN114358201A
Method and device for training target image retrieval model
CN114565807A