Large model content security detection method and system based on conditional information flow maximization

By adopting the learning criterion of maximizing conditional information flow in large model content security detection, the problem of difficulty in generalization of existing technology and poor performance on categories with fewer training samples is solved, achieving better generalization performance and robustness. , improving detection performance.

CN118760896APending Publication Date: 2024-10-11INSTITUTE OF INFORMATION ENGINEERING CHINESE ACADEMY OF SCIENCES
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410943944.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-15
Publication Date
2024-10-11

AI Technical Summary

Technical Problem

Existing large model content security detection methods are difficult to generalize to rapidly changing content security scenarios, and have poor model performance for categories with fewer training samples, and cannot effectively identify user input prompts and harmful content output by generative large models.

Method used

Using a learning criterion based on conditional information flow maximization, through network parameter optimization of pre-trained language models and linear classifiers, the input-representation information flow and representation-task information flow are maximized, and noise-invariant high-order latent vector representations are extracted to enhance the model. generalization performance and robustness.

Benefits of technology

It significantly improves the generalization performance and harmful discrimination ability of the pre-trained model in large model content security detection tasks, provides robustness in noise scenarios, and the detection performance is better than the comparison method in different types of noise scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760896A_ABST
    Figure CN118760896A_ABST
Patent Text Reader

Abstract

The invention discloses a large model content security detection method and system based on conditional information flow maximization, and belongs to the technical field of large model security. The method comprises the following steps: extracting high-order implicit vector representation of a to-be-detected content text by utilizing a pre-training language model; based on the high-order implicit vector representation, utilizing a linear classifier to obtain a security detection result of the to-be-detected content text; wherein the acquisition of the network parameters of the pre-training language model and the linear classifier is to maximize the input-representation information flow and the representation-task information flow through a condition information flow maximization optimization target. According to the method, not only can the generalization performance of the pre-training model in a large model content security detection task be improved, but also the effective discrimination capability of few classes of training samples can be enhanced, and the robustness of the model in a noise scene is provided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of large model security technology, and in particular to a large model content security detection method and system based on conditional information flow maximization. Background Art

[0002] In recent years, generative language model technology represented by ChatGPT has developed rapidly and has been widely used in various fields. However, the security of the content generated by these large models has become a widespread concern. The content of large models changes rapidly and the harmful types evolve rapidly. Existing detection methods are often limited to the distribution of data related to specific users and are difficult to generalize to rapidly changing large model content security scenarios. At the same time, for categories with fewer training samples, model performance is usually poor. Therefore, how to identify harmful content in user input prompts and generative large model outputs with high generalization is one of the key challenges that urgently need to be solved in the current large model security field.

[0003] In some supervised learning scenarios, minimizing the standard cross entropy is actually equivalent to maximizing the mutual information between the representation and the target task. However, a series of existing methods represented by InfoMax tend to retain potentially redundant features that are irrelevant to the given target, resulting in biased representations. Other methods are based on the information bottleneck criterion and aim to discover compact and information-rich representations that can reduce redundant features in the input. However, these information bottleneck-based methods have the problem of over-compression of representations, and the learned representations may lose necessary information about the target task, limiting the discriminative performance of the model. Summary of the invention

[0004] In view of the above problems, the present invention proposes a large-model content security detection method and system based on conditional information flow maximization. The method uses the conditional information flow maximization learning criterion to extract noise-invariant and sufficient representations from the input and target tasks, which is used to improve the generalization performance of the pre-trained model in the large-model content security detection task. At the same time, the method can also enhance the effective discrimination ability for categories with fewer training samples, and provide the robustness of the model in noisy scenarios. Through the above innovations, the present invention can effectively solve the key challenges of current large-model content security detection.

[0005] To achieve the above purpose, the technical solution provided by the present invention is as follows:

[0006] A large model content security detection method based on conditional information flow maximization, the method comprising:

[0007] Use the pre-trained language model to extract the high-order latent vector representation of the content text to be detected;

[0008] Based on the high-order latent vector representation, a linear classifier is used to obtain a security detection result of the content text to be detected;

[0009] The network parameters of the pre-trained language model and the linear classifier are obtained by maximizing the input-representation information flow and the representation-task information flow through the conditional information flow maximization optimization objective.

[0010] Furthermore, the network parameters of the pre-trained language model and the linear classifier are obtained by maximizing the input-representation information flow and the representation-task information flow through the conditional information flow maximization optimization objective, including:

[0011] Construct a training data set based on the input prompt words of the large model and the output content of the large model;

[0012] Construct a Markov chain constraint Y→X→Z; where X represents the content text of the training data set, Y represents the harmful category label information Y of the content text X, and Z represents the high-order latent vector representation of the content text X;

[0013] The criterion for maximizing the conditional information flow optimization objective is set to maxI(Y; Z)+βI(X; Z)-I(X; Z δ |Y); maxI(Y; Z)+βI(X; Z) represents the information flow maximization criterion, minI(X; Z δ |Y) represents the conditional information minimization criterion, I(Y; Z) is the mutual information between the high-order latent vector representation Z and the harmful category label information Y, I(X; Z) is the mutual information between the content text X and the high-order latent vector representation Z, I(X; Z δ |Y) is the content text X and Z under the given Y condition δ The mutual information of δ It represents the high-order latent vector representation of the content text X after adding noise perturbation δ to the intermediate layer weights of the pre-trained language model;

[0014] Combined with the optimization goal under the information flow maximization criterion And the optimization goal under the conditional information minimization criterion Update network parameters of the pre-trained language model and the linear classifier.

[0015] Furthermore, the optimization objective under the information flow maximization criterion is constructed include:

[0016] The cross entropy loss is used to construct the optimization objective of mutual information I(Y; Z)

[0017] Using the InfoNCE estimator or the MINE estimator, we construct the optimization objective of the mutual information I(X; Z)

[0018] The optimization goal of the mutual information I(Y; Z) is and the optimization goal of the mutual information I(X;Z) Get the optimization goal under the information flow maximization criterion

[0019] Furthermore, the optimization goal Among them, y i Represents the i-th content text x in the training data set i Harmful category label information, z i Represents the i-th content text x in the training data set i The high-order latent vector representation of .

[0020] Furthermore, the InfoNCE estimator is used to construct the optimization objective of mutual information I(X; Z) include:

[0021] Obtain the high-order latent vector representation Z and high-order latent vector representation Z′ of the content text X under different pre-trained language model parameters;

[0022] Construct an information flow Z←X→Z′, and based on the information flow Z←X→Z′, obtain the relationship between mutual information I(X; Z)≥I(Z; Z′), where I(Z; Z′) is the mutual information between the high-order latent vector representation Z and the high-order latent vector representation Z′;

[0023] According to the relationship between the mutual information I(X; Z)≥I(Z; Z′), the optimization objective is obtained. Where K is the number of negative examples, N is the training batch size, For content text x i The high-order latent vector representation z i A positive example, For content text x i The high-order latent vector representation z i Negative example, τ is the temperature coefficient, x i is the i-th content text in the training dataset.

[0024] Furthermore, the optimization goal under the construction condition information minimization criterion is include:

[0025] An implementation method for obtaining a conditional information minimization criterion includes: based on the association between Fisher information and effective information, sampling Fisher information to control the lower bound of the conditional information, wherein the Fisher information is a high-order latent vector representation Z under a given content text X and harmful category label information Y δ The Fisher information in , the conditional information is the valid information contained in the representation under a given task;

[0026] Adopt the gradient-based adversarial training loss function to approximate the high-order latent vector representation Z δ Fisher information F in z|x,y , and use the adversarial training loss function as the optimization target under the information minimization criterion

[0027] Furthermore, the adversarial training loss function based on the gradient is used to approximate the high-order latent vector representation Z δ Fisher information Fx |x,y ,include:

[0028] Sample (x, y) from the batch input training data D, where x is a content text and y is the harmful category label information of the content text;

[0029] Based on the regular ball constraint L q , perturbation radius ∈ and the original information flow maximization optimization objective Among them, in each training iteration, for the current network parameters The adversarial perturbation δ is obtained by calculating the back propagation of the neural network given the harmful category label information Y, and the adversarial perturbation δ is added to the network parameters of the pre-trained language model at a set ratio.

[0030] Furthermore, when the pre-trained language model is a RoBERTa model based on a Transformer architecture, the adversarial perturbation δ is added to the embedding layer and the first hidden layer of the RoBERTa model in a set ratio.

[0031] Furthermore, the adversarial training optimization objective Among them, θ is the network parameter, θ δ represents the network parameters under perturbation.

[0032] A large model content security detection system based on conditional information flow maximization, the system comprising:

[0033] A feature encoding module is used to extract high-order latent vector representations of the content text to be detected using a pre-trained language model;

[0034] A harmful discrimination module, used for obtaining a security detection result of the content text to be detected by using a linear classifier based on the high-order latent vector representation;

[0035] The training module is used to maximize the input-representation information flow and the representation-task information flow by optimizing the conditional information flow maximization objective, so as to obtain the network parameters of the pre-trained language model and the linear classifier.

[0036] Compared with the prior art, the technical solution of the present invention has the following advantages:

[0037] The present invention can make full use of existing training data and learn a better high-order latent representation. Experiments on public data sets based on harmful categories such as hatred and sarcasm show that based on the RoBERTa skeleton network, the detection performance after adopting the present invention is improved by 14.1% macro-average F1 score and 5.0% F1 score, respectively, effectively improving the harmful discrimination ability of the pre-trained model.

[0038] In addition, the present invention learns a noise-insensitive representation, which can further improve the generalization ability of out-of-distribution scenarios. Compared with the cross entropy loss (CE) method in out-of-distribution scenarios, the present invention achieves an average score improvement of 7.9%. In different types of noise scenarios, the discrimination ability of the present invention is higher than that of the comparative CE, AT, VIB and MEIB methods, and has good robustness. For categories with fewer training samples, the model can capture more valuable feature information, thereby achieving effective discrimination. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 The Venn diagram for maximizing the conditional information flow of the embodiment of the present invention is

[0040] Figure 2 This is a structural diagram of a large model content security detection system based on conditional information flow maximization according to an embodiment of the present invention. DETAILED DESCRIPTION

[0041] The present invention is described in detail below with reference to the accompanying drawings and embodiments. It should be pointed out that the described embodiments are only intended to facilitate the understanding of the present invention and do not have any limiting effect on the present invention.

[0042] An embodiment of the present invention provides a large model content security detection method based on conditional information flow maximization, which specifically includes the following steps:

[0043] Step A: Obtain input prompts or generated content data for the large model and construct a training data set; for each sample of the training data, it includes content text and corresponding harmful category label information. The harmful category label information can be harmful categories such as offensive, ironic, hate speech, and harmless categories.

[0044] Step B: Input the content text of the training data set obtained in step A. The feature encoding module uses a pre-trained language model (such as RoBERTa or BERT) and extracts a high-order latent vector representation based on the module.

[0045] Step C: Based on the high-order latent vector representation obtained in step B, the harmful discrimination module uses a parameterized linear classifier to predict the category label probability of the content text.

[0046] Step D: Design an optimization objective for maximizing conditional information flow. This optimization objective contains two criteria: maximizing information flow and minimizing conditional information. It is used to maximize the information flow between input and representation and between representation and task, while retaining some redundant features without negative impact, and training the network parameters of the feature encoding module in step B and the harmful discrimination module in step C.

[0047] The specific processing steps include:

[0048] Step D1, calculate the loss function under the information flow maximization criterion. Given the Markov chain constraint Y→X→Z, the formal calculation of the information flow maximization criterion is as follows:

[0049] max I(Y;Z)+βI(X;Z)

[0050] Where I represents mutual information, X represents input text (which can be the prompt word input to the large model or the content output by the large model), Y represents harmful category label information, Z represents high-order latent vector representation, and β is a trade-off parameter used to weigh the amount of information of X and Y. The first term of this criterion maximizes the mutual information I(Y; Z) between the representation and the task, which is used to extract the necessary information related to task Y, and the second term maximizes the mutual information I(X; Z) between the input and the representation to ensure that the representation is sufficiently learned from the input.

[0051] Based on the above analysis, the implementation method of the information flow maximization criterion is defined as For the implementation of the first item maxI(Y; Z), the large model content security detection is regarded as a classification task, and the cross entropy loss is used to estimate the lower bound of I(Y; Z). The calculation method is as follows:

[0052] -logSoftmax(z i ,y i )

[0053] For the implementation of the second term maxI(X; Z), InfoNCE or MINE estimator can be used. Taking InfoNCE estimator as an example, given the information flow Z←X→Z′ and the input X, different high-order latent vector representations Z and Z′ can be obtained. According to the Markov chain properties, I(X; Z)≥I(Z; Z′). Based on this, given the i-th sample x i and its corresponding high-order implicit representation z i , maxI(X;Z) is implemented as follows:

[0054]

[0055] in, To represent z i Positive example of To represent z i negative examples; K is the number of negative examples, K = 2N-2, N is the training batch size; τ>0 is the temperature coefficient.

[0056] Step D2: Calculate the loss function under the conditional information minimization criterion. The conditional information minimization criterion is formally expressed as follows, which aims to eliminate negative redundant features and retain noise-invariant features.

[0057] minI(X;Z δ |Y)

[0058] Among them, Z δ It represents the latent vector representation under the noise δ disturbance, which is calculated as Z δ =φ w+δ (X); φ w+δ represents the neural network after being perturbed by noise, that is, adding noise δ to the network weight w. Under the supervision of task Y, the higher the order of noise perturbation δ, the more likely Z δ The effective information about X in will gradually decrease until the optimal value is learned under the maximum noise level ∈ and the simplest effective information is obtained.

[0059] Based on the above analysis, the implementation of the conditional information minimization criterion is as follows: Based on the association between Fisher information and effective information, Fisher information is sampled to control the lower bound of the conditional information:

[0060]

[0061] Among them, F z|x,y Refers to Z given input X and target Y δ The Fisher information in represents the Jacobian matrix, p(z|x,y) represents the probability distribution of calculating z given x and y; H(X|Y) is the conditional information entropy of X given the target Y; k is a constant; the conditional information is the effective information contained in the representation under a given task.

[0062] To reduce the input X and Z for a given target Y δ The conditional information between z|x,y |, that is, increasing the noise ∈ while the target Y remains unchanged under the noise. Specifically, the present invention adopts the adversarial training loss function based on the gradient to approximate the estimation of Z δ Fisher information F z|x,y . Sample (x,y) from the batch input training data D, based on L qRegular ball constraints, perturbation radius ∈ and the original information flow maximization optimization objective In each training iteration, the current network parameters are By giving Y, we calculate the back propagation of the neural network to obtain the adversarial perturbation δ, and add the perturbation to the model network parameters at a certain ratio. Taking the RoBERTa model of the Transformer architecture as an example, the perturbation can be added to the embedding layer and the first hidden layer. In summary, the goal of conditional information minimization is:

[0063]

[0064] Where θ is a trainable model parameter; θ δ is the network parameter under disturbance; the disturbance is calculated as δ = -∈g / ||g|| q ,||·|| q Indicates L q norm, g represents the gradient, which is calculated as

[0065] Step D3: The overall optimization criterion for maximizing the conditional information flow is defined as:

[0066] maxI(Y;Z)+βI(X;Z)-I(X;Z δ |Y)

[0067] Among them, the first two terms maxI(Y; Z)+βI(X; Z) represent the maximization of information flow, while maximizing the mutual information between input-representation and representation-task, aiming to learn more adequate representations from input and harmful discrimination tasks; the last term max-I(X; Z δ |Y), that is, minI(X; Z δ |Y), which represents the minimization of conditional information and aims to eliminate redundant features that have negative effects in the representation. Figure 1 As shown in the figure, under the constraints of these criteria, the present invention learns a more adequate representation Z from the input X and the target Y, namely, region ① and region ②, and adversarially eliminates redundant features with negative effects, namely, region ③, prompting the model to extract a noise-invariant representation. This representation has good class uniformity and sufficient predictive power, and can enhance the generalization ability of the existing pre-trained language model in large-model content security detection tasks.

[0068] like Figure 2 As shown, the embodiment of the present invention also provides a large model content security detection system based on conditional information flow maximization, which specifically includes:

[0069] The large-model harmful content data collection and labeling module is used to collect a small amount of large-model harmful content data by collecting public harmful prompt data and using existing jailbreak attack strategies to induce large models to generate harmful content, and complete the labeling of harmful labels through manual analysis;

[0070] The feature encoding module is used to extract high-order latent vector representations from natural text through a pre-trained language model;

[0071] The harmful discrimination module is used to predict the probability of harmful category labels for a given text using a 1-layer parameterized linear classifier based on high-order latent vector representations;

[0072] The conditional information flow maximization training module is used to maximize the information flow of input-representation and representation-task based on a small amount of annotated large-model harmful content data through the designed conditional information flow maximization optimization goal, while retaining some redundant features without negative effects, to obtain the network parameters in the above-mentioned feature encoding module and harmful discrimination module.

[0073] Experimental test:

[0074] Experimental tests were conducted on the public datasets of HateEval, IronyEval, and OffensEval for harmful discrimination tasks such as hatred, irony, and offensive speech. Experiments show that compared with existing optimization methods such as CE, CE+AT, VIB, MINE-IB, and MEIB, the present invention has achieved the best discrimination effect, especially based on the RoBERTa skeleton network. After adopting the present invention, the detection performance of the hatred and irony categories has been improved by 14.1% and 5.0% respectively in terms of macro-average F1 score, which effectively improves the harmful discrimination ability of the pre-trained model. On the content security datasets collected from 10 large domestic and foreign models such as Wenxin Yiyan and Zhipu, the present invention has a better recall rate than the existing harmful detection interfaces such as Moderation API and Perspective API.

[0075] In addition, the present invention sets up out-of-distribution scenarios to test the generalization ability of the model. Experiments show that in three out-of-distribution scenarios, compared with the cross entropy loss method, the present invention achieves an average score improvement of 7.9%. Furthermore, by applying different types of noise (such as random noise, adversarial noise) to the input samples, the experimental results show that compared with existing methods such as CE, CE+AT, VIB and MEIB, the present invention still has better discrimination ability in the target task, indicating the good robustness of the present invention.

[0076] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be considered as the scope of protection of the present invention.

Claims

1. A large model content security detection method based on conditional information flow maximization, characterized in that: The method comprises: Use the pre-trained language model to extract the high-order latent vector representation of the content text to be detected; Based on the high-order latent vector representation, a linear classifier is used to obtain a security detection result of the content text to be detected; The network parameters of the pre-trained language model and the linear classifier are obtained by maximizing the input-representation information flow and the representation-task information flow through the conditional information flow maximization optimization objective.

2. The method according to claim 1, characterized in that The network parameters of the pre-trained language model and the linear classifier are obtained by maximizing the input-representation information flow and the representation-task information flow through the conditional information flow maximization optimization objective, including: Construct a training data set based on the input prompt words of the large model and the output content of the large model; Construct a Markov chain constraint Y→X→Z; where X represents the content text of the training data set, Y represents the harmful category label information Y of the content text X, and Z represents the high-order latent vector representation of the content text X; The criterion for maximizing the conditional information flow optimization objective is set to maxI(Y; Z)+βI(X; Z)-I(X; Z δ |Y); maxI(Y; Z)+βI(X; Z) represents the information flow maximization criterion, minI(X; Z δ |Y) represents the conditional information minimization criterion, I(Y; Z) is the mutual information between the high-order latent vector representation Z and the harmful category label information Y, I(X; Z) is the mutual information between the content text X and the high-order latent vector representation Z, I(Z; Z δ |Y) is the content text X and Z δ |Y mutual information, β represents the trade-off parameter, Z δ It represents the high-order latent vector representation of the content text X after adding noise perturbation δ to the intermediate layer weights of the pre-trained language model; Combined with the optimization goal under the information flow maximization criterion And the optimization goal under the conditional information minimization criterion Update network parameters of the pre-trained language model and the linear classifier.

3. The method according to claim 2, characterized in that Construct the optimization goal under the information flow maximization criterion include: The cross entropy loss is used to construct the optimization objective of mutual information I(Y; Z) Using the InfoNCE estimator or the MINE estimator, we construct the optimization objective of the mutual information I(X; Z) The optimization goal of the mutual information I(Y; Z) is and the optimization goal of the mutual information I(X;Z) Get the optimization goal under the information flow maximization criterion 4. The method according to claim 3, characterized in that The optimization goal Among them, y i Represents the i-th content text x in the training data set i Harmful category label information, z i Represents the i-th content text x in the training data set i The high-order latent vector representation of .

5. The method according to claim 3, characterized in that: The InfoNCE estimator is used to construct the optimization objective of mutual information I(X; Z) include: Get the high-order latent vector representation Z and high-order latent vector representation Z of the content text X under different pre-trained language model parameters ′ ; Construct an information flow Z←X→Z′, and based on the information flow Z←X→Z′, obtain the relationship between mutual information I(X; Z)≥I(Z; Z ′ ), I(Z; Z ′ ) is the high-order latent vector representation Z and the high-order latent vector representation Z ′ The mutual information of According to the relationship between the mutual information I(X; Z)≥I(Z; Z ′ ), and get the optimization target Where K is the number of negative examples, N is the training batch size, For content text x i The high-order latent vector representation z i A positive example, For content text x i The high-order latent vector representation z i Negative example, τ is the temperature coefficient, x i is the i-th content text in the training dataset.

6. The method according to claim 2, characterized in that The optimization goal under the construction condition information minimization criterion include: An implementation method for obtaining a conditional information minimization criterion includes: based on the association between Fisher information and effective information, sampling Fisher information to control the lower bound of the conditional information, wherein the Fisher information is a high-order latent vector representation Z under a given content text X and harmful category label information Y δ The Fisher information in , the conditional information is the valid information contained in the representation under a given task; Adopt the gradient-based adversarial training loss function to approximate the high-order latent vector representation Z δ Fisher information F in z|x,y , and use the adversarial training loss function as the optimization target under the information minimization criterion 7. The method according to claim 6, characterized in that The gradient-based adversarial training loss function is used to approximate the high-order latent vector representation Z δ Fisher information F in z|x,y ,include: Sample (x, y) from the batch input training data D, where x is a content text and y is the harmful category label information of the content text; Based on the regular ball constraint L q , perturbation radius ∈ and the original information flow maximization optimization objective Among them, in each training iteration, for the current network parameters The adversarial perturbation δ is obtained by calculating the back propagation of the neural network given the harmful category label information Y, and the adversarial perturbation δ is added to the network parameters of the pre-trained language model at a set ratio.

8. The method according to claim 7, characterized in that When the pre-trained language model is a RoBERTa model based on a Transformer architecture, the adversarial perturbation δ is added to the embedding layer and the first hidden layer of the RoBERTa model in a set proportion.

9. The method according to claim 7, characterized in that: The adversarial training optimization goal Among them, θ is the network parameter, θ δ represents the network parameters under perturbation.

10. A large model content security detection system based on conditional information flow maximization, characterized in that: The system comprises: A feature encoding module is used to extract high-order latent vector representations of the content text to be detected using a pre-trained language model; A harmful discrimination module, used for obtaining a security detection result of the content text to be detected by using a linear classifier based on the high-order latent vector representation; The training module is used to maximize the input-representation information flow and the representation-task information flow by optimizing the conditional information flow maximization objective, so as to obtain the network parameters of the pre-trained language model and the linear classifier.

Citation Information

Patent Citations

  • Noise constraint-based sentence vector representation method and device and electronic equipment

    CN116303908A

  • Large model risk assessment method and device, storage medium and electronic equipment

    CN117113339A

  • Large language model security test method and device based on tabu search algorithm

    CN118132748A