A sample labeling method and device

By constructing a maximum entropy model and noise contrast estimation, the correlation between label functions is learned, which solves the problem of applying unlabeled samples in risk detection models and improves the reliability of sample labeling and the detection accuracy of the model.

CN117972431BActive Publication Date: 2026-07-14ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
Filing Date
2024-02-22
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

In existing technologies, a large number of unlabeled user/transaction samples cannot be directly applied to supervised learning, resulting in insufficient quality of risk detection models.

Method used

By constructing a maximum entropy model, reliable sample labels are generated by learning the correlation between label functions using noise contrast estimation and graph sparsity constraints.

Benefits of technology

This improved the reliability of labeling unlabeled samples and enhanced the accuracy and effectiveness of the risk detection model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117972431B_ABST
    Figure CN117972431B_ABST
Patent Text Reader

Abstract

Embodiments of the present specification relate to a sample labeling method and device, the method comprising: obtaining a set of unlabeled samples and a plurality of label functions, any label function being used to add a label to a sample; adding weak labels to each sample in the set of samples using the plurality of label functions to obtain a label matrix; constructing a first graph structure based on the label matrix; nodes in the first graph structure correspond to label functions, the value of a connection edge indicates the potential association relationship between the label functions corresponding to the two nodes connected by the connection edge, and any connection edge has a corresponding weight value; determining a maximum entropy model based on the value and weight value of each connection edge in the first graph structure; solving the maximum entropy model based on noise contrast estimation and graph sparsity constraint to obtain an update result of the weight value on each connection edge; determining a second graph structure between the label functions based on the updated weight values; and the second graph structure is used to label the samples in the set of samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to one or more embodiments in the field of artificial intelligence, and more particularly to a sample annotation method and apparatus. Background Technology

[0002] With the booming development of mobile payment and e-shopping, the transaction volume on e-service platforms is increasing daily. At the same time, many risky users are using e-payment methods for fraudulent transactions, account theft, and other dangerous activities, seriously infringing upon the rights of other ordinary users. Identifying and handling potential risks is a crucial means to ensure the security of service platforms and protect user assets and transaction security.

[0003] Currently, supervised machine learning techniques are widely used in risk transaction detection. Supervised learning relies on labeled user / transaction samples to train the model. However, in real-world applications, there are often a large number of unlabeled user / transaction samples that cannot be directly applied to supervised learning. Therefore, a sample labeling method is needed to label these unlabeled samples so that they can be used in the training of risk detection models, thereby improving the quality of the risk detection models. Summary of the Invention

[0004] This specification describes one or more embodiments of a sample annotation method and apparatus, which aims to provide more reliable annotations for samples by comprehensively considering the annotation results of user-provided label functions.

[0005] Firstly, a sample annotation method is provided, including:

[0006] Obtain an unlabeled sample set and multiple labeling functions. The sample set contains transaction samples and / or user samples. Each labeling function is used to add a label to a sample, and the label indicates whether the corresponding sample has a specific risk.

[0007] Weak labels are added to each sample in the sample set using the multiple label functions to obtain a label matrix; the value at any position in the label matrix indicates the judgment result of the corresponding label function on whether the sample at that position has a specific risk;

[0008] A first graph structure is constructed based on the label matrix; in the first graph structure, nodes correspond to label functions, the value of the connecting edge indicates the potential association between the label functions of the two nodes it connects, and each connecting edge has a corresponding weight value;

[0009] Based on the values ​​and weights of each connecting edge in the first graph structure, the maximum entropy model is determined;

[0010] The maximum entropy model is solved based on noise contrast estimation and graph sparsity constraints to obtain the updated weight values ​​of each connecting edge.

[0011] Based on the updated weight values, a second graph structure is determined among the label functions; the second graph structure is used to label the samples in the sample set.

[0012] In one possible implementation, it also includes:

[0013] Based on the second graph structure and the label matrix, a generative model about the label matrix and sample labels is trained;

[0014] Based on the generative model, a strong label is determined for each sample in the sample set; the strong label indicates whether the corresponding sample has a specific risk.

[0015] In one possible implementation, it also includes:

[0016] Based on the sample set and strong labels, a risk identification model is trained; the risk identification model is a discriminative model used to determine whether a sample has a specific risk.

[0017] In one possible implementation, the labeling function includes at least one or more of the following: keyword retrieval, pattern matching, third-party models, remote supervision, and noisy manual annotation.

[0018] In one possible implementation, the first graph structure is a fully connected undirected graph.

[0019] In one possible implementation, the first graph structure includes a first connecting edge that connects a first node and a second node, the first node corresponding to a first labeling function and the second node corresponding to a second labeling function; when the first labeling function and the second labeling function add the same label to the first sample, the value of the first connecting edge is true; when the first labeling function and the second labeling function add different labels to the first sample, the value of the first connecting edge is false.

[0020] In one possible implementation, determining the maximum entropy model based on the values ​​and weights of each connection edge in the first graph structure includes:

[0021] The maximum entropy model is determined by the quotient of the natural exponential result of the weighted summation of the values ​​of each connecting edge and the normalization constant.

[0022] In one possible implementation, the maximum entropy model is solved based on noise contrast estimation and graph sparsity constraints to obtain updated weight values ​​for each connected edge, including:

[0023] The noise contrast estimation is applied to the maximum entropy model to obtain the first loss;

[0024] Adding the graph sparsity constraint to the first loss yields the second loss;

[0025] Gradient descent is applied to the second loss to obtain the updated weight values ​​of each connection edge.

[0026] In one possible implementation, applying a noise contrast estimation to the maximum entropy model to obtain a first loss includes:

[0027] Based on the samples in the sample set and the maximum entropy model, determine the first expected value;

[0028] The second expected value is determined based on the noise samples obtained from the noise distribution and the maximum entropy model.

[0029] The first loss is determined based on the first expected value and the second expected value.

[0030] In one possible implementation, the noise distribution is a Bernoulli distribution.

[0031] In one possible implementation, the weight values ​​on each connecting edge constitute a weight vector; the graph sparsity constraint includes at least one of the following: the L1 norm of the weight vector, the elastic network norm of the weight vector.

[0032] In one possible implementation, the second graph structure between the label functions is determined based on the updated weight values, including:

[0033] For any target connection edge in the first graph structure, which connects the first target node and the second target node, when the updated target weight value corresponding to the target connection edge is not 0, a connection edge is established between the corresponding first target node and the second target node in the second graph structure.

[0034] Secondly, a sample labeling device is provided, comprising:

[0035] The acquisition unit is configured to acquire an unlabeled sample set and multiple labeling functions, wherein the sample set includes transaction samples and / or user samples, and any labeling function is used to add a label to the sample, wherein the label indicates whether the corresponding sample has a specific risk;

[0036] The label matrix determination unit is configured to add weak labels to each sample in the sample set using the plurality of label functions to obtain a label matrix; the value at any position in the label matrix indicates the judgment result of the corresponding label function on whether the sample at that position has a specific risk;

[0037] The first graph structure determination unit is configured to construct a first graph structure based on the label matrix; the nodes in the first graph structure correspond to label functions, the values ​​of connecting edges indicate the potential association between the label functions of the two connected nodes, and each connecting edge has a corresponding weight value.

[0038] The model determination unit is configured to determine the maximum entropy model based on the values ​​and weights of each connecting edge in the first graph structure.

[0039] The model solving unit is configured to solve the maximum entropy model based on noise contrast estimation and graph sparsity constraints, and obtain the updated weight values ​​on each connecting edge.

[0040] The second graph structure determination unit is configured to determine the second graph structure between each label function based on the updated weight values; the second graph structure is used to label the samples in the sample set.

[0041] In one possible implementation, it also includes:

[0042] The first model training unit is configured to train a generative model about the label matrix and sample labels based on the second graph structure and the label matrix.

[0043] The sample labeling unit is configured to determine strong labels for each sample in the sample set based on the generative model; the strong labels indicate whether the corresponding sample has a specific risk.

[0044] In one possible implementation, it also includes:

[0045] The second model training unit is configured to train a risk identification model based on the sample set and strong labels; the risk identification model is a discriminative model used to determine whether a sample has a specific risk.

[0046] Thirdly, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of the first aspect.

[0047] Fourthly, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, it implements the method of the first aspect.

[0048] This specification presents a sample annotation method and apparatus. By constructing a maximum entropy model, it models the correlation between user-provided label functions. The maximum entropy model is then solved using noise contrast estimation and graph sparsity constraints to obtain the correlation between the various label functions. This allows the model to learn the graph structure between the label functions and, by integrating the annotation results of the user-provided label functions, provide more reliable annotations for the samples. Attached Figure Description

[0049] To more clearly illustrate the technical solutions of the various embodiments disclosed in this specification, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only a few embodiments disclosed in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0050] Figure 1 A schematic diagram illustrating an implementation scenario of a sample annotation method according to one embodiment is shown;

[0051] Figure 2 A flowchart illustrating a sample annotation method according to one embodiment is shown;

[0052] Figure 3 A flowchart is shown illustrating a maximum entropy model based on noise contrast estimation and graph sparsity constraints according to one embodiment.

[0053] Figure 4 A schematic block diagram of a sample labeling apparatus according to one embodiment is shown. Detailed Implementation

[0054] The solution provided in this specification will now be described with reference to the accompanying drawings.

[0055] As mentioned earlier, supervised machine learning techniques are currently widely used in risky transaction detection, relying on labeled user / transaction samples to train the model. However, in real-world applications, there are often a large number of unlabeled user / transaction samples that cannot be directly applied to supervised learning.

[0056] The Snorkel weakly supervised learning framework has achieved good results in machine learning scenarios where labels are difficult to obtain. Snorkel does not require manually labeled training data; instead, it requires users to provide labeling functions (LF), which are black-box code snippets used to add labels to samples in the unlabeled dataset. Snorkel's standard workflow relies on the graph structure between labeling functions as input to leverage their correlations and obtain better supervisory signals. This requires users to input not only the sample set and labeling functions but also the graph structure between them, making end-to-end use of Snorkel somewhat challenging.

[0057] Some existing methods assume the graph structure between the label functions is a fully connected graph. Then, during Snorkel's subsequent learning of the generative model, a penalty term that makes the graph structure sparse is added to its original loss function. The generative model in this approach is generally a maximum entropy model, which contains an unknown and difficult-to-estimate normalization constant. This requires explicit calculation of the gradient of the loss function using Gibbs sampling, which is computationally difficult. Furthermore, the method's computational complexity is high when the number of label functions is large.

[0058] To address the difficulty in determining the graph structure between the labeling functions, the inventors discovered that the label variables produced by each labeling function are actually fully observable during the graph structure learning stage prior to the Snorkel process. Therefore, this fully observable characteristic can be utilized to employ noisy contrastive learning to learn the graph structure, thereby improving the numerical convergence properties of the estimation.

[0059] Figure 1 This diagram illustrates an implementation scenario of a sample annotation method according to one embodiment. Figure 1 As shown, the unlabeled sample set contains N samples, which can be denoted as follows: Where x i Let represent the i-th sample, which can be a transaction or user sample during the transaction process. The set of label functions contains M label functions, which can be denoted as follows: Where f j This represents the j-th label function, used to assign a label to sample x. i Add weak tag f j (x iWeak labels, as opposed to strong labels, have lower reliability in annotating training samples. In strong labels, each training sample has a clear and accurate label, while in weak labels, the label may be incomplete, imprecise, or only annotate some aspects of the sample. Multiple labeling functions may produce conflicting weak labels for the same sample. The subsequent solutions in this specification's embodiments involve learning the potential relationships between the M labeling functions (N rows, M columns) based on the N x M label matrix Λ formed by the weak labels added to N samples by the M labeling functions. This allows for the synthesis of the M less reliable weak labels for any given sample into a single, more reliable strong label. In this specification's embodiments, the label indicates whether the corresponding sample carries a specific risk.

[0060] After labeling N samples using M label functions to form a label matrix Λ, each label function is used as a vertex in a graph structure G, and the potential relationship between any two label functions is used as an edge, thus constructing the graph structure. in, Let G be the set of nodes and E be the set of edges. Initially, the graph structure G is a fully connected undirected graph, meaning that there is an edge connecting any two nodes in G. Furthermore, each edge in graph structure G has a value representing a potential association and a weight coefficient. It should be noted that... Figure 1 The label matrix shown is 3 rows and 4 columns. It is just an example and does not impose any restrictions on the values ​​of N and M. Figure 1 The graph structure of the label function shown is merely an example and does not impose any restrictions on the nodes and connecting edges in the graph structure G.

[0061] Then, a maximum entropy model is constructed based on the graph structure G, which contains an unknown and difficult-to-estimate normalization constant. To better solve the maximum entropy model, this embodiment uses a method based on noise contrast estimation and graph sparsity constraints to solve the maximum entropy model, obtaining updated weight values ​​on each connecting edge in the graph structure G. The specific process of constructing and solving the maximum entropy model will be described in detail in subsequent embodiments of this specification.

[0062] Then, based on the updated weight values, the edge set E in the graph structure G is updated to obtain the graph structure. The graph structure G′ can better describe the relationships between the various label functions. Next, based on the label matrix Λ and the graph structure G′, a generative model of the label matrix Λ and sample labels is trained. This generative model determines the strong labels for each sample in the unlabeled sample set; the strong labels indicate whether the corresponding sample has a specific risk. After obtaining the strong labels for each sample, the process of combining the weak labels from the various label functions into a single strong label is completed, thus enabling the labeling of the unlabeled sample set.

[0063] Additionally, a risk identification model can be trained based on the sample set and strong labels. This risk identification model is a discriminative model used to determine whether a sample to be predicted carries a specific risk.

[0064] The following describes the specific implementation steps of the above sample annotation method with reference to specific embodiments. Figure 2 A flowchart illustrating a sample annotation method according to one embodiment is provided. The entity executing the method can be any platform, server, or device cluster with computing and processing capabilities. Figure 2 As shown, the method includes at least the following steps: Step 202, obtaining an unlabeled sample set and multiple labeling functions, wherein the sample set contains transaction samples and / or user samples, and any labeling function is used to add a label to the sample, the label indicating whether the corresponding sample has a specific risk; Step 204, using the multiple labeling functions to add weak labels to each sample in the sample set, obtaining a label matrix; the value at any position in the label matrix indicates the judgment result of the corresponding labeling function on whether the sample at that position has a specific risk; Step 206, constructing a first graph structure based on the label matrix; the nodes in the first graph structure correspond to labeling functions, the values ​​of connecting edges indicate the potential correlation between the labeling functions corresponding to the two connected nodes, and each connecting edge has a corresponding weight value; Step 208, determining a maximum entropy model based on the values ​​and weight values ​​of each connecting edge in the first graph structure; Step 210, solving the maximum entropy model based on noise contrast estimation and graph sparsity constraints to obtain the updated weight values ​​of each connecting edge; Step 212, determining a second graph structure between the labeling functions based on the updated weight values; the second graph structure is used to label the samples in the sample set. The specific execution process of each of the above steps is described below.

[0065] First, in step 202, an unlabeled sample set and multiple labeling functions are obtained. The sample set contains transaction samples and / or user samples. Any labeling function is used to add a label to the sample, and the label indicates whether the corresponding sample has a specific risk.

[0066] Using the aforementioned notation, the number of samples in the unlabeled sample set can be N, denoted as N0. Where xi This represents the i-th sample. When x... i When providing a transaction sample, the fields may include, for example, transaction time, initiator, transaction object, transaction amount, and the IP address that initiated the transaction; when x i When creating user samples, fields may include, for example, user ID, user transaction frequency, last login IP address, login device information, etc. The set of tag functions can contain M tag functions, denoted as M. Where f j This represents the j-th label function, used to assign a label to sample x. i Add weak tag f j (x i ).

[0067] The labeling function can take many forms and come from various sources. In one embodiment, the labeling function includes at least one or more of the following: keyword retrieval, pattern matching, third-party models, remote supervision, and noisy human annotation.

[0068] Specifically, keyword search finds specific words in a sample, typically using regular expressions, and then determines whether the sample carries a specific risk based on the matching results. Pattern matching finds specific syntactic patterns, for example, using dependency trees, and then determines whether the sample carries a specific risk based on whether the sample contains these specific syntactic patterns. Third-party models use pre-trained models to make specific judgments on samples and then determine whether the sample carries a specific risk based on the judgment results (usually models used for tasks different from the current task). For example, a pre-trained language model can be used to determine the semantic tendency of the text contained in a sample, and thus determine whether the sample carries a specific risk. Remote supervision uses external knowledge bases to assist in determining whether a sample carries a specific risk. Noisy manual annotation directly obtains noisy annotation results for samples through crowdsourcing platforms.

[0069] In other embodiments, other types of labeling functions can be designed based on actual needs and industry experience accumulated in risk identification practices. For example, heuristic rule-based labeling functions can be used, as long as they can label samples. No limitation is made here.

[0070] The sample label can be a binary label, meaning that for a sample and a specific risk, the sample label indicates whether or not it carries that specific risk. Meanwhile, because the labeling function may have limitations—that is, it may not be able to provide a yes or no label for every sample—this embodiment of the specification also provides an additional "abstain" label. When the labeling function cannot provide a yes or no label for a sample, an abstain label is given.

[0071] In one embodiment, the label function f j Given sample x i Add weak tag f j (x i The value of ) can be in the range {-1, 0, 1}. Here, -1 represents "no" or "false", that is, if sample x is false... i No specific risk; 1 represents "yes" or "true", that is, sample x i There are specific risks; 0 represents "abstention", i.e., the label function f j Unable to process sample x i Provide a label.

[0072] In other embodiments, other value ranges can be set for weak labels, as long as they can distinguish between "true", "false", and "abstain".

[0073] Then, in step 204, weak labels are added to each sample in the sample set using the multiple label functions to obtain a label matrix; the value at any position in the label matrix indicates the judgment result of the corresponding label function on whether the sample at that position has a specific risk.

[0074] The label matrix Λ can be an N x M matrix, where the value in the i-th row and j-th column corresponds to the j-th label function f. j For sample x i Add weak tag f j (x i ), indicating the label function f j For sample x i The result of determining whether there is a specific risk.

[0075] Next, in step 206, a first graph structure is constructed based on the label matrix; the nodes in the first graph structure correspond to label functions, the value of the connecting edge indicates the potential association between the label functions corresponding to the two connected nodes, and each connecting edge has a corresponding weight value.

[0076] Specifically, each label function is used as a vertex in the graph structure, and the potential relationships between any two label functions are used as edges to construct the first graph structure. in, Let G be the set of nodes, and E be the set of edges. Furthermore, each edge in the first graph structure G has a value representing a potential association, as well as a weight coefficient. Node f u and node f v The connecting edge (f) between u f v The value on ) can be denoted as φ(f) u f v ), connecting edge (f u fv The weighting coefficient can be denoted as θ. uv φ(f) on the connecting edge u f v The value of ) is determined through subsequent steps, while the weighting coefficient θ uv These are trainable parameters, obtained through subsequent training steps. The weight coefficients on each connecting edge can form a weight vector θ.

[0077] Connecting edges (f) u f v The value φ(f) on ) u f v (This depends on the label function f) u with f v The result of labeling the samples. In one embodiment, the first graph structure G includes connections to the first node f. u Second node f v The first connecting edge (f) u f v The first node corresponds to the first label function f. u The second node corresponds to the second label function f. v When the first label function and the second label function assign a label to the first sample x i When the added labels are the same, the first connecting edge (f) u f v The value of φ(f) v f v The first connection edge (f) is true; when the labels added to the first sample by the first labeling function and the second labeling function are different, the first connection edge (f) is true. u f v The value of φ(f) u f v () is false.

[0078] Formalized, φ(f u f v The value of ) can be represented as shown in formula (1):

[0079] φ(f u f v )=1(Λ i,u =Λ i,v (1)

[0080] Among them, Λ i,u The value in the i-th row and u-th column of the label matrix Λ is the first label function f. u Given sample x i Added weak tag f u (x i );Λ i,vThe value in the i-th row and v-th column of the label matrix Λ is the first label function f. v Given sample x i Added weak tag f v (x i ). 1(·) represents an indicator function. The value of the indicator function is 1 when the result of the discriminant in the parentheses is true, and -1 when the result of the discriminant in the parentheses is false.

[0081] For any sample x i Each sample can be assigned a set of values ​​φ() on the connecting edges of the graph structure using the method shown in formula (1). The values ​​of φ() for each sample will be used in subsequent steps 210 and sub-steps 302 and 306 of this specification when calculating the mathematical expectation and loss function related to the model.

[0082] In other embodiments, other methods can be used to determine the potential associations between label functions, i.e., the values ​​of the connecting edges between the nodes corresponding to the label functions. For example, when the first label function and the second label function assign values ​​to the first sample x... i When the added labels are the same and not abstentions, the first connection edge (f) v f v The value of φ(f) u f v The first connection edge (f) is true; when the first labeling function and the second labeling function add different labels to the first sample, or both are abstentions, the first connection edge (f) is true. u f v The value of φ(f) u f v () is false.

[0083] In one embodiment, the first graph structure G is a fully connected undirected graph. That is, there is an undirected edge connecting any two nodes in G. Initially, it can be assumed that the first graph structure G is a fully connected graph. After subsequent training, the connectivity of the graph structure between the label functions is re-determined based on the training results.

[0084] Then, in step 208, the maximum entropy model is determined based on the values ​​and weights of each connecting edge in the first graph structure.

[0085] The maximum entropy model can be the conditional probability distribution of the label matrix Λ with respect to the graph structure G and the weight vector θ on the connecting edges. Specifically, determining the maximum entropy model can include determining the maximum entropy model based on the quotient of the natural exponential result of the weighted summation of the values ​​of the respective connecting edges and the normalization constant, as shown in Equation (2):

[0086]

[0087] Where Z(θ) is the normalization constant used to ensure that the sum of the probability distributions is 1, exp(·) is the natural exponential function, and E is the edge set of G.

[0088] By solving the maximum entropy model p(Λ|G, θ), the updated weight vector θ can be obtained, allowing for the updating of the graph structure and thus enabling better learning of the graph structure between label functions. Solving the maximum entropy model p(Λ|G, θ) typically uses maximum likelihood estimation, which requires first determining the value of the normalization constant Z(θ). However, the sample size in the dataset is usually enormous, making the value of the normalization constant Z(θ) very difficult to calculate, thus significantly hindering the solution of the maximum entropy model p(Λ|G, θ).

[0089] Therefore, the embodiments of this specification use noise contrast estimation and graph sparsity constraints to solve the maximum entropy model, as shown in subsequent steps 210 to 212.

[0090] In step 210, the maximum entropy model is solved based on noise contrast estimation and graph sparsity constraints to obtain the updated weight values ​​on each connection edge.

[0091] Noise contrastive estimation trains a model by learning the differences between real and noisy data, enabling it to accurately distinguish between real and noisy data and thus learn the probability distribution of the data.

[0092] Specifically, for the maximum entropy model p(Λ|G, θ), to avoid explicitly calculating the normalization constant Z(θ), noise contrastive learning introduces an additional parameter z to replace the unknown constant log(Z(θ)), such as... Figure 3 Steps 302 to 306 are shown. Figure 3 A flowchart is shown for solving a maximum entropy model based on noise contrast estimation and graph sparsity constraints according to one embodiment.

[0093] In step 302, the noise contrast estimation is applied to the maximum entropy model to obtain the first loss L1. The first loss L1 can be calculated as shown in formula (3):

[0094]

[0095] Where log(·) is the natural logarithm, Λ i Let represent the i-th row of the label matrix Λ, and q(·) be the noise distribution in the same probability space as p(·). For noise samples sampled from noise distribution q, Let h(·) be the mathematical expectation. The function h(·) can be expressed as shown in formula (4):

[0096]

[0097] Where σ(·) represents the sigmoid function, The normalization constant is removed from the maximum entropy model p(·), as shown in formula (5):

[0098]

[0099] For any sample x i All can determine a set of values ​​φ() on the connecting edges of the graph structure according to the method shown in formula (1), and then summate i according to the first term of L1. The above formula (3) is to determine the first expected value ∑ of the sample distribution based on the samples in the sample set and the maximum entropy model. i log(h(Λ i |θ,z)); Based on the noise samples obtained from the noise distribution and the maximum entropy model, determine the second expected value regarding the noise distribution. Then, based on the first expected value and the second expected value, the first loss L1 is determined.

[0100] The noise distribution q(·) is a noise distribution in the same probability space as p(·). The specific distribution type can be arbitrarily chosen, as long as it satisfies the following conditions: q is relatively continuous with p, its probability density can be evaluated, and it is easy to sample.

[0101] Based on the above requirements, in one embodiment, the noise distribution q can be a Bernoulli distribution. In this case, q(Λ) in formula (4) can be as shown in formula (6):

[0102]

[0103] Among them, c m Let be the parameters of the Bernoulli distribution, and be the hyperparameters.

[0104] After applying the noise contrast estimation to the maximum entropy model to obtain the first loss L1, in step 304, the graph sparsity constraint is added to the first loss L1 to obtain the second loss L2. As shown in formula (7):

[0105]

[0106] Wherein, λ is a hyperparameter, and the graph sparsity constraint ||θ|| can take many forms, such as the L1 norm of the weight vector θ, or the elastic network norm of the weight vector θ, that is, the weighted sum of the L1 norm and L2 norm of the weight vector θ.

[0107] By employing noise contrast estimation and graph sparsity constraints, the optimization objective is transformed from a maximum entropy model to finding the weight vector θ that minimizes the second loss L2.

[0108] In step 306, gradient descent is performed on the second loss L2 to obtain the updated weight values ​​on each connection edge.

[0109] Perform gradient descent on L2, and in each round let Update the value of θ, where ← represents the assignment operator, used to assign the value on the right side of the operator to the variable on the left side. η is the learning rate, a hyperparameter. When the algorithm converges or reaches the preset stopping condition, the updated weight vector θ is obtained.

[0110] The updated result of the weight vector θ obtained based on steps 302 to 306 Then, the value of the normalization constant Z(θ) can be further determined. The value of the normalization constant Z(θ) is determined based on the maximum entropy model p(Λ|G, θ) and the update result θ of the weight values ​​on each connecting edge.

[0111] The updated result of the weight vector θ obtained based on steps 302 to 306 Afterwards, return Figure 2 In step 212, based on the updated weight values Determine the second graph structure G′ between the various labeling functions; the second graph structure G′ is used to label the samples in the sample set.

[0112] Specifically, for any target connection edge in the first graph structure G, which connects the first target node and the second target node, when the updated target weight value corresponding to the target connection edge is not 0, a connection edge is established between the corresponding first target node and the second target node in the second graph structure G′.

[0113] The structure of the second diagram can be represented as follows: The method for determining E′ is shown in formula (8):

[0114]

[0115] Based on the second graph structure G′ learned in steps 202 to 212, a correlation graph between label functions can be obtained for subsequent parts of Snorkel, thereby improving the numerical convergence properties of the estimation.

[0116] After obtaining the second graph structure G′ according to steps 202 to 212, in some possible implementations, the method further includes steps 214 and 216.

[0117] In step 214, a generative model about the label matrix and sample labels is trained based on the second graph structure G′ and the label matrix Λ.

[0118] Specifically, the generative model can be represented as shown in equation (9):

[0119]

[0120] Where Y represents the vector composed of the true labels of each sample, ω is the weight coefficient to be learned, and Z... -1 (ω) is the normalization constant. φ i (Λ,y i ) is about sample x i A factor vector composed of multiple predefined factors; the setting of these factors will be described later. i For sample x i The true label.

[0121] The factors can be set as shown in formulas (10) to (12):

[0122]

[0123]

[0124]

[0125] Among them, in formula (10) The labeling propensity is indicated in formula (11). The labeling accuracy is indicated in formula (12). Indicates the pairwise correlations of labeling functions.

[0126] For any sample x i Formulas (10) and (11) will determine M factors respectively (i.e., let j take values ​​from 1 to M to obtain M factors), while the number of factors determined by formula (12) is the number of elements in set C, i.e., |C|. Therefore, for any sample x i The factor vector φ, which consists of multiple corresponding factors. i (Λ,y i The dimension of ) is 2M+|C|, and the dimension of the corresponding weight coefficient ω is also 2M+|C|.

[0127] The set C in formula (12) is the graph structure between label functions described at the beginning of the specific implementation of this specification as "the standard Snorkel process relies on the graph structure between label functions as input". In the embodiment of this specification, the set E′ of the edges in the second graph structure G′ obtained according to steps 202 to 212 (as shown in formula (8)), that is, the set of edges composed of connecting edges with non-zero weight values ​​after the update in step 210, is used as the set C in formula (12) to eliminate the correlation between label functions and obtain a better supervision signal. At this time, The expression can also be written as shown in formula (13):

[0128]

[0129] The updated weight vector obtained in step 210 After that, you can also As the weight ω in formula (9) and The initial values ​​of the weights of the dimensions corresponding to the factors make the subsequent generative model p in formula (9) more suitable for the generative model. ω The learning of (Λ, Y) converges faster. For example, suppose The |C| factors correspond to φ i (Λ,y i The last |C| dimension in ) will be This serves as the initial value for the final |C| dimension during ω initialization.

[0130] Then, in step 216, based on the generative model, a strong label for each sample in the sample set is determined; the strong label indicates whether the corresponding sample has a specific risk.

[0131] Specifically, in order to learn a generative model p as shown in Equation (9) without obtaining the real label Y. ω (Λ,Y), in this embodiment of the specification, the weight coefficients ω to be learned are determined by minimizing its negative log-marginal likelihood function, as shown in formula (14):

[0132]

[0133] The optimization of equation (14) can be achieved using stochastic gradient descent based on Gibbs sampling, which will not be elaborated upon here. The optimization results of the weight coefficients ω to be learned are then obtained. Then, the strong labels of each sample in the sample set can be determined according to formula (15).

[0134]

[0135] That is, the strong labels of each sample Let Y be the conditional probability of the label variable Y given the occurrence of the label matrix Λ in the optimized generative model.

[0136] strong tags Let x be a vector, and the value of the i-th dimension corresponds to the sample x. i The strong label is in probabilistic label form, with a value range of [0, 1]. It represents the strong label for sample x after the model integrates the labeling results of M label functions on N samples. i The given label indicates the sample x i The probability of having a specific risk.

[0137] After obtaining the strong labels of each sample according to steps 214 to 216, in some possible implementations, the method further includes step 218: training a risk identification model based on the sample set and the strong labels; the risk identification model is a discriminative model used to determine whether a sample has a specific risk.

[0138] After obtaining the strong labels for each sample, a labeled training set can be constructed based on the unlabeled sample set and the strong labels. A risk identification model is then trained on this labeled sample set to determine whether a sample carries a specific risk. The risk identification model can be a discriminative model, such as a logistic regression model, a random forest model, a neural network model, etc., and is not limited here.

[0139] In summary, the sample annotation method described in the embodiments of this specification, for an unlabeled sample set, learns the latent relationships between the M label functions based on the label matrix composed of the annotation results of M label functions for N samples, so as to obtain the graph structure relationship between the label functions.

[0140] According to another embodiment, a sample labeling device is also provided. Figure 4 A schematic block diagram of a sample annotation apparatus according to one embodiment is shown. This apparatus can be deployed in any device, platform, or cluster of devices with computing and processing capabilities. Figure 4 As shown, the device 400 includes:

[0141] The acquisition unit 401 is configured to acquire an unlabeled sample set and multiple labeling functions, wherein the sample set includes transaction samples and / or user samples, and any labeling function is used to add a label to the sample, wherein the label indicates whether the corresponding sample has a specific risk;

[0142] The label matrix determination unit 402 is configured to add weak labels to each sample in the sample set using the plurality of label functions to obtain a label matrix; the value at any position in the label matrix indicates the judgment result of the corresponding label function on whether the sample at that position has a specific risk;

[0143] The first graph structure determination unit 403 is configured to construct a first graph structure based on the label matrix; the nodes in the first graph structure correspond to label functions, the value of the connecting edge indicates the potential association between the label functions corresponding to the two connected nodes, and each connecting edge has a corresponding weight value.

[0144] The model determination unit 404 is configured to determine the maximum entropy model based on the values ​​and weights of each connecting edge in the first graph structure.

[0145] The model solving unit 405 is configured to solve the maximum entropy model based on noise contrast estimation and graph sparsity constraints, and obtain the updated weight values ​​on each connecting edge.

[0146] The second graph structure determination unit 406 is configured to determine the second graph structure between each label function based on the updated weight values; the second graph structure is used to label the samples in the sample set.

[0147] In some possible implementations, the device 400 further includes:

[0148] The first model training unit 407 is configured to train a generative model about the label matrix and sample labels based on the second graph structure and the label matrix.

[0149] The sample labeling unit 408 is configured to determine the strong label of each sample in the sample set according to the generative model; the strong label indicates whether the corresponding sample has a specific risk.

[0150] In some possible implementations, the device 400 further includes:

[0151] The second model training unit 409 is configured to train a risk identification model based on the sample set and strong labels; the risk identification model is a discriminative model used to determine whether a sample has a specific risk.

[0152] According to another embodiment, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed in a computer, causes the computer to perform the methods described in any of the above embodiments.

[0153] According to another embodiment, a computing device is also provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, it implements the method described in any of the above embodiments.

[0154] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0155] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0156] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, 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. Without further limitations, 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 the element.

[0157] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0158] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A sample annotation method, comprising: Obtain an unlabeled sample set and multiple labeling functions. The sample set includes transaction samples and / or user samples. Each labeling function is used to add a label to a sample. The label indicates whether the corresponding sample has a preset risk. Weak labels are added to each sample in the sample set using the multiple label functions to obtain a label matrix; the value at any position in the label matrix indicates the judgment result of the corresponding label function on whether the sample at that position has a preset risk; A first graph structure is constructed based on the label matrix; in the first graph structure, nodes correspond to label functions, the value of the connecting edge indicates the potential association between the label functions of the two nodes it connects, and each connecting edge has a corresponding weight value; Based on the values ​​and weights of each connecting edge in the first graph structure, the maximum entropy model is determined; The maximum entropy model is solved based on noise contrast estimation and graph sparsity constraints to obtain the updated weight values ​​of each connecting edge. Based on the updated weight values, a second graph structure is determined among the label functions; the second graph structure is used to label the samples in the sample set.

2. The method according to claim 1, further comprising: Based on the second graph structure and the label matrix, a generative model about the label matrix and sample labels is trained; Based on the generative model, determine the strong labels of each sample in the sample set; The strong label indicates whether the corresponding sample has a preset risk.

3. The method according to claim 2, further comprising: Based on the aforementioned sample set and strong labels, a risk identification model is trained. The risk identification model is a discriminant model used to determine whether a sample has a preset risk.

4. The method according to claim 1, wherein, The labeling function includes at least one or more of the following: keyword retrieval, pattern matching, third-party models, remote supervision, and noisy manual annotation.

5. The method according to claim 1, wherein, The first graph structure is a fully connected undirected graph.

6. The method according to claim 1, wherein the first graph structure includes a first connecting edge connecting a first node and a second node, the first node corresponds to a first label function, and the second node corresponds to a second label function; when the first label function and the second label function add the same label to the first sample, the value of the first connecting edge is true; when the first label function and the second label function add different labels to the first sample, the value of the first connecting edge is false.

7. The method according to claim 1, wherein determining the maximum entropy model based on the values ​​and weights of each connecting edge in the first graph structure, includes: The maximum entropy model is determined by the quotient of the natural exponential result of the weighted summation of the values ​​of each connecting edge and the normalization constant.

8. The method according to claim 1, wherein the maximum entropy model is solved based on noise contrast estimation and graph sparsity constraints to obtain the updated weight values ​​on each connection edge, comprising: The noise contrast estimation is applied to the maximum entropy model to obtain the first loss; Adding the graph sparsity constraint to the first loss yields the second loss; Gradient descent is applied to the second loss to obtain the updated weight values ​​of each connection edge.

9. The method according to claim 8, wherein, Applying the noise contrast estimation to the maximum entropy model yields the first loss, which includes: Based on the samples in the sample set and the maximum entropy model, determine the first expected value; The second expected value is determined based on the noise samples obtained from the noise distribution and the maximum entropy model. The first loss is determined based on the first expected value and the second expected value.

10. The method according to claim 9, wherein, The noise distribution is a Bernoulli distribution.

11. The method according to claim 8, wherein, The weight values ​​on each connecting edge constitute a weight vector; the graph sparsity constraint includes at least one of the following: the L1 norm of the weight vector, the elastic network norm of the weight vector.

12. The method according to claim 1, wherein determining the second graph structure between the label functions based on the updated weight values, includes: For any target connection edge in the first graph structure, which connects the first target node and the second target node, when the updated target weight value corresponding to the target connection edge is not 0, a connection edge is established between the corresponding first target node and the second target node in the second graph structure.

13. A sample labeling device, comprising: The acquisition unit is configured to acquire an unlabeled sample set and multiple labeling functions. The sample set includes transaction samples and / or user samples. Each labeling function is used to add a label to a sample. The label indicates whether the corresponding sample has a preset risk. The label matrix determination unit is configured to add weak labels to each sample in the sample set using the plurality of label functions to obtain a label matrix; the value at any position in the label matrix indicates the judgment result of the corresponding label function on whether the sample at that position has a preset risk; The first graph structure determination unit is configured to construct a first graph structure based on the label matrix; the nodes in the first graph structure correspond to label functions, the values ​​of connecting edges indicate the potential association between the label functions of the two connected nodes, and each connecting edge has a corresponding weight value. The model determination unit is configured to determine the maximum entropy model based on the values ​​and weights of each connecting edge in the first graph structure. The model solving unit is configured to solve the maximum entropy model based on noise contrast estimation and graph sparsity constraints, and obtain the updated weight values ​​on each connecting edge. The second graph structure determination unit is configured to determine the second graph structure between each label function based on the updated weight values; the second graph structure is used to label the samples in the sample set.

14. The apparatus of claim 13, further comprising: The first model training unit is configured to train a generative model about the label matrix and sample labels based on the second graph structure and the label matrix. The sample labeling unit is configured to determine the strong labels of each sample in the sample set based on the generative model. The strong label indicates whether the corresponding sample has a preset risk.

15. The apparatus of claim 14, further comprising: The second model training unit is configured to train a risk identification model based on the sample set and strong labels. The risk identification model is a discriminant model used to determine whether a sample has a preset risk.

16. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of any one of claims 1-12.

17. A computing device comprising a memory and a processor, wherein, The memory stores executable code, and when the processor executes the executable code, it implements the method of any one of claims 1-12.