Large visual language model risk test method based on bimodal confrontation prompt

Through the risk testing method of dual-modal adversarial prompts, combined with visual and text perturbations, the adversarial prompts and thought chain strategies are optimized, which solves the problem of only being able to detect single-modal attacks in the existing technology, and realizes the multi-modal analysis of large-scale visual language models. Modal content security risk assessment improves test accuracy and coverage, and enhances model security.

CN118862057APending Publication Date: 2024-10-29BEIHANG UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410724214.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-05
Publication Date
2024-10-29

AI Technical Summary

Technical Problem

Existing risk testing methods for large-scale visual language models are only effective in detecting interference in a single modality and cannot accurately test content security risks in other modalities.

Method used

Adopting a risk testing method based on dual-modal adversarial prompts, by acquiring visual images and irrelevant corpora, applying visual and text perturbations, optimizing visual adversarial prompts and text adversarial prompts, updating the text adversarial prompts combined with the thinking chain strategy, and judging whether the model response is Harmful Content,Assess the model’s content security risk.

Benefits of technology

It realizes content security risk testing of large visual language models in dual modes, improves testing accuracy and coverage, can more effectively evaluate the security of the model, discovers and repairs omissions in security alignment measures, and enhances the security of the model. sexual and social values.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118862057A_ABST
    Figure CN118862057A_ABST
Patent Text Reader

Abstract

The invention discloses a large visual language model risk test method based on bimodal confrontation prompt. The method comprises the following steps: S1, acquiring a visual image, a corpus and a data set; s2, generating visual adversarial disturbance; s3, harmful texts which are not traversed in the data set are selected as initial text confrontation prompts; s4, inputting the visual confrontation prompt and the text confrontation prompt into the large visual language model to obtain a model response; s5, judging whether the model response is harmful content or not, if so, adding one to the attack success times, and entering S7; otherwise, entering S6; s6, judging whether the updating frequency is greater than a preset frequency, if so, entering S7, otherwise, updating the text confrontation prompt by adopting a thinking chain strategy, adding one to the updating frequency, and returning to S4; s7, judging whether all the harmful texts in the data set are traversed or not, if so, entering S8, and otherwise, entering S3; and S8, calculating a prison break test success rate by adopting the attack success times and the total number of the harmful texts so as to evaluate the model content security risk.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a model security monitoring technology, and in particular to a large-scale visual language model risk testing method based on dual-modal adversarial prompts. Background Art

[0002] In the application field of large-scale visual language models, understanding and generating text content based on images is a core function. It uses the visual encoder built into the large-scale visual language model to obtain the features of the input image, and then passes the features to the built-in language model through the visual-language connector to process them together with the text content. Taking the model MiniGPT4 as an example, for example, given a picture of a panda, the input text is to write a story based on the panda, describe the appearance of the panda, or tell a joke, etc. It will output a piece of text based on the picture and user needs. In practical applications, large-scale visual language models have been widely used in intelligent customer service, autonomous driving, medical auxiliary diagnosis and other fields, showing great potential and value.

[0003] However, the content generated by large visual language models can easily be inconsistent with the intended goals of their model owners, often producing outputs that are unrealistic or potentially harmful to users. In order to reveal and mitigate these security risks, the industry generally adopts a red team strategy called jailbreak testing to test their content security risks. The purpose of jailbreak testing is to bypass the guardrails and evaluate model consistency. After jailbreaking, the attacker can persuade the model to output any content that may lead to serious security consequences, such as generating harmful or unethical content. Most jailbreak tests for large visual language models focus on interfering with the visual modality (i.e., images) they receive. These include making visual adversarial samples and encoding attack intent into typographic images. However, securely aligned large visual language models use both visual and textual features for prediction, which limits the effectiveness of current attacks that only interfere with a single modality. For example, the model may refuse to answer adversarial images that are not associated with the query text, resulting in jailbreak test failure. Summary of the invention

[0004] In view of the above-mentioned deficiencies in the prior art, the large-scale visual language model risk testing method based on dual-modal adversarial cues provided by the present invention solves the problem that the existing risk testing method is only effective in detecting interference attacks of a single modality and other modalities cannot be accurately tested.

[0005] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is:

[0006] A large-scale visual language model risk testing method based on bimodal adversarial prompts is provided, which comprises the steps of:

[0007] S1, obtain visual images, a corpus unrelated to the query content, and a dataset including several harmful texts;

[0008] S2, applying perturbations on the visual image to obtain the desired visual adversarial perturbations by maximizing the log-likelihood of the large visual language model over the text in the corpus;

[0009] S3, select harmful texts that have not been traversed in the dataset as the initial text adversarial prompts;

[0010] S4, inputting the visual adversarial prompt and the text adversarial prompt into a large visual language model to obtain a model response;

[0011] S5, determine whether the model response is harmful content, if so, increase the number of successful attacks by one and proceed to S7; otherwise, proceed to step S6;

[0012] S6, judging whether the number of updates is greater than the preset number, if so, proceeding to step S7, otherwise, adopting the thinking chain strategy to update the text against the prompt, and increasing the number of updates by one, and then returning to step S4;

[0013] S7, determine whether all harmful texts in the data set have been traversed, if so, go to step S8, otherwise go to step S3;

[0014] S8. The jailbreak test success rate is calculated by combining the number of successful attacks with the total number of harmful texts in the dataset to evaluate the content security risk of large visual language models.

[0015] Furthermore, the expression for applying perturbations to visual images to obtain the desired visual adversarial perturbations is:

[0016]

[0017] Among them, max is the maximization operation; is the visual adversarial cue; logp is the probability of the text in the large visual language model output corpus; y t is the jth text in the corpus, 1≤j≤m, m is the total number of texts in the corpus; x v For visual images; The · in the text box indicates a placeholder for the text prompt; ‖·‖ ∞ is the infinite norm; ∈ is the constraint range under the infinite norm; st is the constraint condition symbol.

[0018] The beneficial effect of the above technical solution is that the solution can optimize the visual confrontation prompt that satisfies the maximization formula under the condition of visual concealment under the constraint condition, that is, the obtained visual confrontation prompt is very similar to the original visual graphic in human eye observation. And through the maximization formula, when the visual confrontation prompt is input into the large visual language model, it can guide it to give a response that is close to the semantics of the text in the corpus.

[0019] Furthermore, the expression of updating the text confrontation prompt using the thought chain strategy is:

[0020]

[0021] in, and The text confrontation prompts after the i-th and i+1-th thought chain strategy updates are respectively performed for the h-th harmful text in the dataset; For visual confrontation cues; for and Model response after input into a large visual language model; q is the initial text adversarial prompt; F θ (·) is a large visual language model; M(·) is a large language model; P c To enable the large language model to realize the function of thought chain reasoning.

[0022] The beneficial effects of the above technical solution are as follows: by adopting a large language model, with the assistance of the thought chain strategy, this solution can automatically optimize the text prompt based on the initial harmful text prompt tested, the previous text prompt, and the response of the large visual language model. And with the assistance of the thought chain, it can analyze the reasons for the poor results of the previous jailbreak test and achieve better optimization results on this basis.

[0023] Furthermore, the method for determining whether the model response is harmful content is:

[0024] A large language model is used to determine whether the model response is harmful content. The judgment result is flag, and the expression of flag is:

[0025]

[0026] Among them, q is the initial text adversarial prompt; Provide the text adversarial prompt after the i-th thought chain strategy update for the h-th harmful text in the dataset; For visual confrontation cues; for and Model response after input into a large visual language model; F θ (·) is a large visual language model; M(·) is a large language model; PJ To enable the large language model to realize the judgment function;

[0027] When flag=0, it indicates that the model response is harmless; when flag≠0, it indicates that the model response is harmful.

[0028] The beneficial effect of the above technical solution is: this solution uses a large language model to determine whether the model response is harmful, which can effectively realize the automated evaluation of whether the jailbreak is successful.

[0029] Furthermore, a large language model is used to construct a corpus that is independent of the query content, wherein the corpus includes a number of texts associated with the semantics of positive prefixes and negative suppression.

[0030] Furthermore, the method for acquiring the data set includes collecting harmful texts that appear on the Internet more frequently than a preset frequency, and performing data cleaning on them to obtain several types of scenarios that are prone to content generation risks; the data cleaning at least includes completion and deduplication operations.

[0031] The beneficial effects of the above technical solution are as follows: this solution uses harmful texts that appear frequently in the online world as a data set and uses the harmful texts as initial text adversarial prompts, which can more comprehensively evaluate the content security risks of large visual language models and effectively improve the coverage and effectiveness of jailbreak testing.

[0032] Furthermore, the large visual language model is MiniGPT4, and the large language model is chatgpt or Wenxinyiyan.

[0033] The beneficial effects of the present invention are as follows: this scheme applies disturbances to visual images through the text in the corpus, combines harmful text as text adversarial prompts to perform risk prediction, and can realize security risk testing under dual modality, thereby improving the testing accuracy of the model; during the testing process, more effective text adversarial prompts are constructed based on the thinking chain technology, which can more comprehensively evaluate the content security risks of large visual language models and effectively improve the coverage and effectiveness of jailbreak testing.

[0034] The risk testing method of this scheme can evaluate the content risks of large-scale visual language models under various modal interference conditions, so as to timely discover and repair omissions in security alignment measures, thereby improving the security and social value of large-scale visual language models, and laying an important foundation for the legal and compliant commercial application of artificial intelligence. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 Flowchart of the risk testing method for large-scale visual-language models based on bimodal adversarial cues.

[0036] Figure 2A schematic diagram of a visual confrontation prompt construction method provided for an embodiment of the present invention.

[0037] Figure 3 A schematic diagram of a text adversarial prompt construction method provided for an embodiment of the present invention. DETAILED DESCRIPTION

[0038] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.

[0039] refer to Figure 1 , Figure 1 A risk testing method for large visual language models based on bimodal adversarial cues is shown; Figure 1 As shown, the method S comprehensively evaluates the content security risks of the model in visual and textual modes by simulating malicious input, which includes steps S1 to S8.

[0040] Before conducting risk testing, a typical large-scale visual language model is deployed on the GPU cluster as a test environment for the subsequent construction of adversarial prompts and data collection. Specifically, by deploying a representative large-scale visual language model in the test environment, a command line interface and a graphical web interface are deployed to facilitate automated testing and manual testing.

[0041] This solution preferably uses an open source large-scale visual language model as the test object (such as MiniGPT4, https: / / github.com / Vision-CAIR / MiniGPT-4) to build a test environment on a graphics processor cluster.

[0042] In step S1, a visual image, a corpus unrelated to the query content, and a data set including several harmful texts are obtained; the visual image can be any normal image.

[0043] The method for obtaining a data set includes collecting harmful texts that appear on the Internet more frequently than a preset frequency, and performing data cleaning on the harmful texts to obtain several types of scenarios that are prone to generating content risks; the data cleaning at least includes completion and deduplication operations.

[0044] The dataset includes 13 scenarios that are prone to generating content risks, including hate speech, malicious code generation, physical attack, economic attack, financial fraud, privacy violation, legal consultation, financial consultation, health consultation, etc. Using these as test cases, the bimodal adversarial prompts constructed based on this solution can achieve efficient and comprehensive content security risk testing for large visual language models.

[0045] In step S2, perturbations are applied to the visual image to obtain the desired visual adversarial perturbations by maximizing the log-likelihood of the large visual language model over the text in the corpus;

[0046] During implementation, the present solution preferably applies disturbance to the visual image to obtain the desired visual adversarial disturbance expression as:

[0047]

[0048] Among them, max is the maximization operation; is the visual adversarial cue; logp is the probability of the text in the large visual language model output corpus; t t is the jth text in the corpus, 1≤j≤m, m is the total number of texts in the corpus; x v For visual images; The · in the text prompt is a placeholder, that is, no text is entered at this stage;||·|| ∞ is the infinite norm; ∈ is the constraint range under the infinite norm; st is the constraint condition symbol.

[0049] Step S2 is specifically a process of optimizing the visual confrontation prompt. The detailed implementation process can be referred to Figure 2 In the figure, this scheme will apply specific perturbations to the original visual image in a limited manner based on the previously collected corpus (i.e., texts containing two types of semantics: positive prefixes and negative inhibitions) under the constraints of constraints. The specific perturbations to be applied need to satisfy the above-mentioned max formula, that is, when the image obtained after the perturbation is input into the large visual language model, it can output a response expressing positive meaning, thereby obtaining a visual adversarial prompt.

[0050] This solution is based on the constraints in the above expression, which can make the final Not with x v The gap is too large. From the perspective of simulating attacker testing, this can improve the concealment of the test.

[0051] In step S3, the harmful text that has not been traversed in the data set is selected as the initial text adversarial prompt;

[0052] In step S4, the visual adversarial prompt and the textual adversarial prompt are input into the large visual language model to obtain the model response:

[0053]

[0054] in, Provide the text adversarial prompt after the i-th thought chain strategy update for the h-th harmful text in the dataset; For visual confrontation cues; for and Model response after input into a large visual language model; F θ (·) is a large-scale visual language model.

[0055] In step S5, it is determined whether the model response is harmful content. If so, the number of successful attacks is increased by one and the process proceeds to step S7; otherwise, the process proceeds to step S6;

[0056] In one embodiment of the present invention, the method for determining whether the model response is harmful content is:

[0057] A large language model is used to determine whether the model response is harmful content. The judgment result is flag, and the expression of flag is:

[0058]

[0059] Among them, q is the initial text adversarial prompt; Provide the text adversarial prompt after the i-th thought chain strategy update for the h-th harmful text in the dataset; For visual confrontation cues; for and Model response after input into a large visual language model; F θ (·) is a large visual language model; M(·) is a large language model; P J To enable the large language model to realize the judgment function;

[0060] When flag=0, it indicates that the model response is harmless; when flag≠0, it indicates that the model response is harmful.

[0061] In order to enable the large language model to respond positively to the text adversarial prompts provided subsequently, the present scheme preferably uses the large language model to construct a corpus that is independent of the query content, and the corpus includes several sentences (texts) that are semantically associated with affirmative prefixes (such as 'of course...') and negative inhibitions (such as 'don't start with 'sorry...'').

[0062] The large language model of this solution uses chatgpt or Wenxinyiyan.

[0063] In step S6, it is determined whether the number of updates is greater than the preset number. If so, it proceeds to step S7. Otherwise, the thought chain strategy is used to update the text counter-prompt, and the number of updates is increased by one, and then it returns to step S4.

[0064] During implementation, this solution preferably adopts the thought chain strategy to update the expression of the text confrontation prompt as follows:

[0065]

[0066] in, and The text confrontation prompts after the i-th and i+1-th thought chain strategy updates are respectively performed for the h-th harmful text in the dataset; For visual confrontation cues; for and Model response after input into a large visual language model; q is the initial text adversarial prompt; F θ (·) is a large visual language model; M(·) is a large language model; P c To enable the large language model to realize the function of thought chain reasoning.

[0067] Steps S3 to S6 of this solution can be understood as optimizing the initial text confrontation prompt during the risk test process. The specific implementation ideas can be referred to Figure 3 .

[0068] In step S7, it is determined whether all harmful texts in the data set have been traversed, if so, it proceeds to step S8, otherwise it proceeds to step S3;

[0069] In step S8, the jailbreak test success rate is calculated using the number of successful attacks and the total number of harmful texts in the data set to evaluate the content security risk of the large visual language model. A security threshold can be set here. For example, minigpt4 can set the security threshold to 40%. When the jailbreak test success rate is greater than 40%, it indicates that the security of the large visual language model is not good, and relevant personnel need to be prompted to adjust the large visual language model to improve the security of the model.

[0070] In order to illustrate the effect of the risk testing method of this solution, the following is an explanation in combination with two risk testing methods 1 and 2 in the prior art:

[0071] Test method 1 is the method disclosed in "Jailbreak in pieces: Compositional Adversarial Attacks on Multi-Modal Language Models". The Chinese translation of the paper is "Jailbreak in pieces: Compositional Adversarial Attacks on Multi-Modal Language Models", author: Erfan Shayegani et al., conference: The Twelfth International Conference on Learning Representations, publication date: 2023-05).

[0072] Test method 2 is the method disclosed in the paper "Visual Adversarial Examples Jailbreak Aligned Large Language Models". The Chinese translation of the paper is "Visual Adversarial Examples Jailbreak Aligned Large Language Models", author: Xiangyu Qi et al., conference: Proceedings of the AAAI Conference on Artificial Intelligence, publication date: 2024-02).

[0073] In the same test environment (MiniGPT4), content risk testing was performed on 13 scenarios that are prone to generating content risks collected by this solution. The attack success rates of this solution’s risk testing method and test methods one and two can be found in Table 1.

[0074] Table 1 The attack success rate of the risk test method of this scheme and the test methods 1 and 2

[0076] The experiment shows that the attack success rate of the test method of this solution is higher than that of test method 1 and test method 2 in each scenario. It can be seen that this solution improves the success rate of the insecurity of the output content of the large-scale visual language model from the perspective of the attacker. This shows that the risk testing method of this solution is very effective, and from the perspective of the attacker, it can further improve the testing effect of the model. In other words, it effectively tests the degree of security risks that the model may face when attacked.

[0077] In summary, the large-scale visual language model risk testing method based on dual-modal adversarial cues in this scheme can perform accurate testing under multimodality by combining visual adversarial cues and textual adversarial cues.

Claims

1. Risk testing method for large-scale visual language models based on bimodal adversarial cues, It is characterized in that Includes steps: S1, obtain visual images, a corpus unrelated to the query content, and a dataset including several harmful texts; S2, applying perturbations on the visual image to obtain the desired visual adversarial perturbations by maximizing the log-likelihood of the large visual language model over the text in the corpus; S3, select harmful texts that have not been traversed in the dataset as the initial text adversarial prompts; S4, inputting the visual adversarial prompt and the text adversarial prompt into a large visual language model to obtain a model response; S5, determine whether the model response is harmful content, if so, increase the number of successful attacks by one and proceed to S7; otherwise, proceed to step S6; S6, judging whether the number of updates is greater than the preset number, if so, proceeding to step S7, otherwise, adopting the thinking chain strategy to update the text against the prompt, and increasing the number of updates by one, and then returning to step S4; S7, determine whether all harmful texts in the data set have been traversed, if so, go to step S8, otherwise go to step S3; S8. The jailbreak test success rate is calculated by combining the number of successful attacks with the total number of harmful texts in the dataset to evaluate the content security risk of large visual language models.

2. The large-scale visual language model risk testing method according to claim 1, It is characterized in that The expression for applying perturbations to visual images to obtain the desired visual adversarial perturbations is: Among them, max is the maximization operation; is the visual adversarial cue; logp is the probability of the text in the large visual language model output corpus; y t is the jth text in the corpus, 1≤j≤m, m is the total number of texts in the corpus; x v For visual images; The · in the text prompt is a placeholder; ||·|| ∞ is the infinite norm; ∈ is the constraint range under the infinite norm; st is the constraint condition symbol.

3. The large-scale visual language model risk testing method according to claim 1, It is characterized in that The expression of updating the text confrontation prompt using the thought chain strategy is: in, and The text confrontation prompts after the i-th and i+1-th thought chain strategy updates are respectively performed for the h-th harmful text in the dataset; For visual confrontation cues; for and Model response after input into a large visual language model; q is the initial text adversarial prompt; F θ (·) is a large visual language model; M(·) is a large language model; P c To enable the large language model to realize the function of thought chain reasoning.

4. The large-scale visual language model risk testing method according to claim 1, It is characterized in that The method to determine whether the model response is harmful content is: A large language model is used to determine whether the model response is harmful content. The judgment result is flag, and the expression of flag is: Among them, q is the initial text adversarial prompt; Provide the text adversarial prompt after the i-th thought chain strategy update for the h-th harmful text in the dataset; For visual confrontation cues; for and Model response after input into a large visual language model; F θ (·) is a large visual language model; M(·) is a large language model; P J To enable the large language model to realize the judgment function; When flag=0, it indicates that the model response is harmless; when flag≠0, it indicates that the model response is harmful.

5. The large-scale visual language model risk testing method according to claim 1, It is characterized in that A large language model is used to construct a corpus that is independent of query content, wherein the corpus includes a number of texts associated with semantics of positive prefixes and negative suppression.

6. The large-scale visual language model risk testing method according to claim 1, It is characterized in that The method for acquiring the data set includes collecting harmful texts that appear on the Internet with a frequency higher than a preset frequency, and performing data cleaning on the harmful texts to obtain several types of scenarios that are prone to generating content risks; the data cleaning includes at least completion and deduplication operations.

7. The large-scale visual language model risk testing method according to any one of claims 3 to 5, It is characterized in that The large visual language model is MiniGPT4, and the large language model is chatgpt or Wenxinyiyan.

Citation Information

Cited By

  • Large language model voice vulnerability test method and device based on Monte Carlo tree search algorithm, and medium

    CN119830298A

  • Method for mining and preventing multi-modal large language model vulnerabilities

    CN119939595A