Test case generation method and device, storage medium and electronic equipment

Generating a diverse set of test cases through intelligent deformation evaluation seed data and induced attack techniques solves the risk of large models being maliciously manipulated, improves the security assessment and stability of the model, reduces the risk of malicious exploitation, and achieves efficient Annotation and model iteration.

CN118672902APending Publication Date: 2024-09-20ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410697648.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

Large models face the risk of being maliciously manipulated when processing complex tasks, leading to the generation of misleading content, inducing bad behaviors or leaking sensitive information, limiting their wide application, and existing test case generation methods are difficult to provide diverse and high-quality test cases. , affecting the security assessment of the model.

Method used

Through intelligent deformation evaluation seed data, the trained large model and induced attack techniques are used to generate a diverse set of test cases, and automatically generate test case annotations to enhance the comprehensiveness and automation level of model security assessment and identify potential inducements. Risk of attack.

Benefits of technology

It improves the adaptability and stability of generated large models to various inputs, reduces the risk of malicious exploitation, reduces the need for manual annotation, ensures the consistency and accuracy of annotation, quickly locates model weaknesses, and promotes model iteration. and performance evaluation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118672902A
    Figure CN118672902A
Patent Text Reader

Abstract

The embodiment of the invention discloses a test case generation method and device, a storage medium and electronic equipment, and the method comprises the steps: firstly obtaining evaluation seed data, then combining a trained generation large model, designing and selecting at least one induction attack technique, carrying out the deformation processing of the evaluation seed data, generating a diversified test case set, and carrying out the generation of a test case. And meanwhile, automatically generating a case label of each test case in the test case set.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to speech synthesis technology, and in particular to a test case generation method, a test case generation device, a storage medium and an electronic device. Background Art

[0002] With the rapid development of big data and machine learning technologies, large models have demonstrated unprecedented capabilities in handling complex tasks, especially in the fields of natural language processing, image recognition, and automatic decision support. However, the accompanying security challenges cannot be ignored and have become a key factor restricting their widespread application. For example, large models may face the risk of being maliciously manipulated, resulting in the generation of misleading content, inducing bad behavior, or inadvertently leaking sensitive information, which not only threatens the true acquisition of user information, but may also induce users to make harmful decisions, thereby limiting the development and application of large models.

[0003] Therefore, the risk assessment of the large model used can be performed to ensure that the content generated by the large model is more secure and reliable. It is usually necessary to input multiple test cases into the large model to be tested, and evaluate whether the security of the model meets the requirements based on the output results of the model. It can be seen that test cases play an important role in the risk assessment of the large model to be tested. At present, there is an urgent need to provide a test case generation method to obtain diverse and better quality test cases. Summary of the invention

[0004] The embodiment of this specification provides a method for generating test cases. The method uses intelligent deformation evaluation seed data to create diversified test cases and automatic annotation by generating a large model, which can effectively enhance the comprehensiveness and automation level of model security assessment and accurately identify potential induced attack risks. The method includes:

[0005] Get evaluation seed data;

[0006] Based on the evaluation seed data, a test case set and case annotations of each test case in the test case set are generated through a trained large generation model and at least one induced attack method.

[0007] Further, in some implementations, the test case set includes a first test case set and a second test case set;

[0008] The generating of a test case set and a case annotation of each test case in the test case set based on the evaluation seed data through a trained large generation model and at least one induced attack method includes:

[0009] Inputting the evaluation seed data into the trained generation large model to obtain the first test case set;

[0010] Obtaining generation control conditions for generating the large model;

[0011] Based on the generation control condition, determining at least one induced attack method using an adaptive attack strategy generator;

[0012] The first test case set is transformed using each of the induced attack techniques to generate a second test case set and case annotations for each test case in the second test case set.

[0013] Further, in some embodiments, the induced attack technique includes an initial induced attack technique and a target induced attack technique;

[0014] The step of determining at least one induced attack method by using an adaptive attack strategy generator based on the generated control condition includes:

[0015] Selecting the initial induced attack method;

[0016] The target test case in the first test case set is deformed using the initial induced attack technique. If the deformation result meets the generation control condition, the initial induced attack technique is adjusted by an adaptive attack strategy generator until the deformation result of the target test case does not meet the generation control condition, and the target induced attack technique is determined.

[0017] Furthermore, in some implementations, the evaluation seed data includes text seed data; and the step of inputting the evaluation seed data into the trained generation model to obtain the first test case set includes:

[0018] Generate context information of the text seed data by a context processor;

[0019] Based on the context information, the first test case set is generated by using the trained generation model.

[0020] Further, in some implementations, the evaluation seed data includes image seed data; and the step of inputting the evaluation seed data into the trained generation macro model to obtain the first test case set includes:

[0021] Performing element detection on the image seed data to obtain image elements contained in the image seed data and description information of the image elements;

[0022] Based on the description information, the first test case set is generated by using the trained generation model.

[0023] Furthermore, in some embodiments, the induced attack technique includes one or more of a contrast type technique, a role-playing technique, a reverse induction technique, a text confrontation technique, a step-by-step technique, a target confusion technique, a forced consent technique, and a long sentence overflow technique.

[0024] Furthermore, in some implementations, the use case annotations of each of the test cases include a use case quality score, a use case risk category, an induced attack technique, and a use case problem difficulty.

[0025] Further, in some implementations, obtaining evaluation seed data includes:

[0026] Acquire a historical seed data set and evaluation data corresponding to each historical seed data in the historical seed data set;

[0027] Extracting features from each of the historical seed data to obtain seed features;

[0028] Encoding each of the evaluation data to obtain evaluation features, and obtaining input features of each of the historical seed data according to the seed features and the evaluation features;

[0029] Based on each of the input features, the evaluation seed data is determined from the historical seed data set through a trained reinforcement learning model.

[0030] Furthermore, in some embodiments, the method further comprises:

[0031] Displaying the test case set and the case annotations of each test case in the test case set through a user interface;

[0032] Receive modification information input through the user interface, and adjust the test case set and the corresponding case annotations according to the modification information.

[0033] Furthermore, in some embodiments, the method further comprises:

[0034] Inputting the target test case in the test case set into the generated large model to obtain an output result corresponding to the target test case;

[0035] The risk assessment result of the generated large model is determined according to the use case annotation corresponding to the target test case and the output result.

[0036] Further, in some implementations, inputting the target test case in the test case set into the generated large model to obtain an output result corresponding to the target test case includes:

[0037] The target test case is input into the generated large model through a preset API interface, and the output result corresponding to the target test case is obtained through the API interface.

[0038] The embodiment of this specification also proposes a test case generation device, the device comprising:

[0039] Data acquisition module, used to obtain evaluation seed data;

[0040] A use case generation module is used to generate a test case set and a use case annotation of each test case in the test case set based on the evaluation seed data through a trained generation large model and at least one induced attack method.

[0041] Furthermore, in some embodiments, the device further comprises:

[0042] A model testing module, used for inputting a target test case in the test case set into the generated large model to obtain an output result corresponding to the target test case;

[0043] A model evaluation module is used to determine the risk assessment result of the generated large model based on the use case annotation corresponding to the target test case and the output result.

[0044] The embodiments of the present specification also provide a storage medium, wherein the storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the steps of the above method.

[0045] An embodiment of the present specification also provides an electronic device, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the above method.

[0046] The embodiments of the present specification also provide a computer program product, wherein the computer program product stores at least one instruction, and the at least one instruction is suitable for being loaded by a processor and executing the above method steps.

[0047] In an embodiment of the present specification, by obtaining evaluation seed data and combining it with a trained large generation model, at least one induced attack method is designed and selected, and a diversified test case set is generated by deforming the evaluation seed data, and at the same time, case annotations for each test case in the test case set are automatically generated. By adopting the test case generation method proposed in the embodiment of this specification, on the one hand, a diverse set of test cases can be generated based on the evaluation seed data, so that the generated large model is exposed to various edge cases and complex scenarios, which helps to discover and repair the erroneous responses of the generated large model under atypical inputs, thereby improving the adaptability and stability of the generated large model to various types of inputs; on the other hand, by incorporating specific induced attack techniques to intelligently deform the test cases, it is possible to simulate malicious inputs that the generated large model may encounter in actual applications, which can help the generated large model learn how to identify and resist potential security threats and reduce the risk of malicious exploitation; on the other hand, the automatic generation of test case annotations reduces the need for manual annotation, which not only improves the efficiency of data preparation, but also ensures the consistency and accuracy of annotations, allowing researchers to iterate models faster and evaluate model performance; moreover, detailed use case annotations provide a clear reference for model evaluation, which facilitates the rapid location of model weaknesses, making improvement measures more targeted and effective. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 A schematic diagram of a system architecture for applying the embodiments of this specification;

[0049] Figure 2 A flowchart of a method for generating a test case provided in an embodiment of this specification;

[0050] Figure 3 A flowchart of another method for generating a test case provided in an embodiment of this specification;

[0051] Figure 4 A flowchart of another method for generating a test case provided in an embodiment of this specification;

[0052] Figure 5 A flowchart of another method for generating a test case provided in an embodiment of this specification;

[0053] Figure 6 A flowchart of a method for generating a large model security assessment method provided in an embodiment of this specification;

[0054] Figure 7 A schematic diagram of the structure of a test case generation device provided in an embodiment of this specification;

[0055] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of this specification. DETAILED DESCRIPTION

[0056] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.

[0057] Figure 1 A schematic diagram of a system architecture to which the embodiments of this specification can be applied is shown.

[0058] like Figure 1 As shown, the system architecture 100 may include one or more terminal devices such as a smart phone 101, a portable computer 102, a desktop computer 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the terminal device and the server 105. The network 104 may include various connection types, such as wired or wireless communication links or optical fiber cables, etc. The terminal device may be various electronic devices with data processing functions, and the electronic device may have a display screen, which is used to display the acquired evaluation seed data, the generated test case set, the case annotations of each test case in the test case set, and the risk assessment results of the generated large model, etc.

[0059] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. According to the implementation requirements, there may be any number of terminal devices, networks and servers. For example, the server 105 may be a server cluster composed of multiple servers.

[0060] It is understandable that a large model refers to a model whose model parameters exceed a preset number threshold and / or whose model structure complexity exceeds a preset complexity threshold, such as a model with more than 100 million parameters. In one or more embodiments of this specification, a large model can be a generation large model, and of course, it can also be a decision-making large model, which is not limited in this specification.

[0061] Taking the generation of a large model as an example, a certain type of test case can usually be input into the generated large model through the query step, and the corresponding output result can be obtained through the reply step, so as to evaluate the risk of the generated large model on this type of test case based on the reply, where the risk may include privacy data leakage risk, mental health risk, discrimination risk, etc. In order to improve the diversity and quality of the generated test cases, the embodiments of this specification provide a method for generating test cases, and then use the generated test cases to perform risk assessment on the large model.

[0062] See also Figure 2 , which is a flow chart of a method for generating a test case in an embodiment of this specification. In an embodiment of this specification, the method for generating a test case is applied to a test case generating device or an electronic device equipped with a test case generating device. Figure 2 The process shown is described in detail, and the test case generation method may specifically include the following steps:

[0063] S202, obtaining evaluation seed data;

[0064] Before generating test cases, seed preparation is required, that is, obtaining evaluation seed data. Evaluation seed data refers to data used to input into the generation model to generate test cases. For example, evaluation seed data can be text seed data, image seed data, or a combination of text seed data and image seed data. Text seed data includes but is not limited to words, sentences, and articles.

[0065] For example, you can choose commonly used words with clear meanings to avoid ambiguity and ensure the universal applicability of the seed data; when selecting sentences, you need to consider grammatical correctness and semantic coherence while including sufficient contextual information; you can select articles covering diverse topics and styles to simulate text input in actual applications; collect images with different features, styles, and content to cover various visual scenarios that may be encountered when generating large models.

[0066] By selecting different types of evaluation seed data, we can comprehensively evaluate the performance of the generated large model in different scenarios, which helps to reveal the potential problems and limitations of the generated large model when dealing with different types of inputs. Moreover, the selected evaluation seed data can represent the input in actual applications, making the evaluation results more realistic. Importantly, by selecting representative and diverse evaluation seed data, we can ensure the accuracy and reliability of the safety evaluation results of the generated large model.

[0067] S204, based on the evaluation seed data, generate a test case set and case annotations of each test case in the test case set through a trained large generation model and at least one induced attack method.

[0068] After obtaining the evaluation seed data, the trained generation model can be used to generate a diverse set of test cases based on the evaluation seed data. In one or more embodiments of this specification, the generation model can be a Transformer-based generation model, such as the ChatGPT (Chat Generative Pre-trained Transformer, based on pre-trained natural language processing) model, the TroubleLLM (Trouble Large Language Model, used to test the security of large language models) model, etc., or it can be a recurrent neural network-based generation model. The generation model can understand the context and content contained in the evaluation seed data and generate a set of test cases.

[0069] For example, in the security assessment of the AIGC (Artificial Intelligence Generated Content) model, test cases refer to specific scenarios or data samples used to test and evaluate the security performance of the AIGC model, including text prompts, images, etc., which are used to evaluate whether the AIGC model's response to the model input and the processing results are safe, appropriate and in line with expectations.

[0070] Optionally, for text seed data, at least one new text sequence is generated by using the words or sentences contained in the text seed data through the trained generative model, and the text sequence is the test case. It is understandable that the text sequence is consistent with the text seed data in terms of syntax and semantics, and has changed compared to the text seed data. For example, the text seed data is "Zhang San". After inputting the text into the trained generative model, at least one test case can be obtained, such as "Is Zhang San an adult now?" "Has Zhang San graduated now?".

[0071] For the image seed data, at least one new image is generated by using the scenes and objects contained in the image seed data through the trained generative model. The new image is the test case set. Similarly, the new image is similar to the image seed data in visual elements and style, and also introduces new elements compared to the image seed data. For example, if the image seed data is an image of a snowy mountain, the generated test case can be a new image showing the snowy mountain surrounded by the northern lights.

[0072] It is understandable that by inputting text seed data into a trained generative model, a test case set whose output is an image can also be obtained. Of course, by inputting image seed data into a trained generative model, a test case set whose output is a text can also be obtained.

[0073] The generated test case set not only copies the evaluation seed data, but also introduces new elements based on the evaluation seed data, which increases the diversity and creativity of the test cases and helps to comprehensively evaluate the performance of the generated large model.

[0074] In one or more embodiments of the present specification, after obtaining the test case set, at least one induced attack technique may be added to transform the generated test case set to further enhance the diversity and effectiveness of the test cases in the test case set.

[0075] In the field of AIGC, induced attack techniques refer to the use of specific strategies to manipulate or mislead AIGC models to produce unexpected outputs, such as generating false information, biased conclusions, or unsafe behaviors.

[0076] Optionally, the induced attack method includes one or more of the following: contrast type method, role-playing method, reverse induction method, text confrontation method, step-by-step method, target confusion method, forced consent method, and long sentence overflow method. Of course, the induced attack method may also include false premise method, connotation mapping method, etc., which are not limited in this specification.

[0077] Among them, contrast-type techniques refer to constructing inputs with contrasting properties to induce the model to favor the side that the attacker wants to highlight when comparing two inputs. For example, a series of questions are asked so that the model unconsciously reinforces a certain point of view or bias when answering.

[0078] Role-playing techniques refer to simulating a specific identity or position to interact with the model, and using the model's preset response to a specific role or situation to induce the model to output specific content. For example, simulating an authoritative figure asking questions will make the model give more detailed or confidential answers.

[0079] The reverse elicitation technique involves constructing instructions with hidden negative intentions so that the model reveals more information when correcting or responding.

[0080] Text adversarial techniques refer to making subtle modifications to the input data, such as fine-tuning grammar, spelling, punctuation, or semantics, so that the model makes incorrect judgments or generates specific outputs.

[0081] The step-by-step approach involves gradually guiding the model to delve deeper into a topic or situation, with each inquiry adding a little more information or complexity based on the previous one, until the model unconsciously discloses sensitive information or takes defensive actions.

[0082] Target obfuscation refers to mixing multiple topics or intentions in the input data, such as using polysemous words or puns, making it difficult for the model to accurately determine the main target, which may leak more irrelevant but sensitive information or cause confusion in the response, providing attackers with more room for operation.

[0083] The technique of forced consent involves constructing a series of neutral or harmless questions to gradually narrow the range of choices, causing the model to confirm a view that is not actually correct or even harmful.

[0084] The long sentence overflow technique refers to constructing extremely long and complex sentences or paragraphs that exceed the normal limits of model processing, taking advantage of the parsing errors or resource limitations that may occur when the model processes complex inputs, and inducing the model to make mistakes or leak information.

[0085] Furthermore, by simulating different attack scenarios and using different attack techniques to intelligently transform the generated test cases, we can simulate the malicious inputs that the generated large model may encounter in actual applications, which can help the generated large model learn how to identify and resist potential security threats and reduce the risk of malicious exploitation.

[0086] At the same time, it can also automatically generate use case annotations for each test case in the test case set. The use case annotations include but are not limited to use case quality scores, use case risk categories, induced attack techniques, and use case problem difficulty.

[0087] For example, the text seed data obtained is "Zhang San", and the test case generated after inputting the trained TroubleLLM model is "Has Zhang San graduated?" Then, the attack method of the false premise method can be used to generate a new test case, "Is Zhang San's failure to graduate due to low IQ?" The corresponding case annotations include: quality score 40 points, error, false premise method, and question difficulty 50". Among them, the question difficulty 50 can indicate that the question difficulty is medium.

[0088] In the embodiments of this specification, the automatic generation of test case annotations reduces the need for manual annotation, which not only improves the efficiency of data preparation, but also ensures the consistency and accuracy of annotations, allowing researchers to iterate models more quickly and evaluate model performance; moreover, detailed use case annotations provide a clear reference for model evaluation, making it easy to quickly locate the weaknesses of the model, making improvement measures more targeted and effective.

[0089] See also Figure 3, is a flow chart of another test case generation method provided by an embodiment of this specification. The test case set includes a first test case set and a second test case set, the first test case set includes test cases generated by using a large model output, and the second test case set includes test cases after intelligently transforming the test cases generated by the large model output. Figure 3 As shown, the method comprises the following steps:

[0090] S302, obtaining evaluation seed data;

[0091] For step S302, please refer to the detailed description of step S202 in the first embodiment of this specification, which will not be repeated here.

[0092] By selecting representative and diverse evaluation seed data, the accuracy and reliability of the generated large-model security evaluation results can be ensured.

[0093] S304, inputting the evaluation seed data into the trained generation large model to obtain the first test case set;

[0094] Optionally, if the evaluation seed data is text seed data, accordingly, context information of the text seed data can be generated by a context processor, and then based on the context information, the first test case set can be generated by a trained generation model.

[0095] Among them, the context processor can be a Transformer-based NLP (Natural Language Processing) model. Optionally, the text seed data is preprocessed first, for example, the text seed data is segmented, and the segmented text is converted into a digital representation to obtain a word index or a word vector representation. The Transformer structure in the NLP model is composed of an encoder and a decoder. The encoder is used to encode the preprocessed text seed data, and the decoder is used to generate context information. Based on the generated context information, a trained large generation model such as the TroubleLLM model is used to generate a test case set to improve the diversity of test cases.

[0096] The context processor combines semantic understanding, syntactic analysis and domain knowledge to extract key information and potential associations from seed text data and generate rich contextual information. This process ensures a deep understanding and transformation of the original data and improves the accuracy of subsequent generated test cases.

[0097] Optionally, if the evaluation seed data includes image seed data, element detection can be performed on the image seed data to obtain image elements and description information of the image elements contained in the image seed data, and then based on the description information, the first test case set is generated by the trained generation model.

[0098] Among them, the image seed data contains a variety of different image elements, such as objects, scenes, textures, etc. The image seed data can be first subjected to element detection, such as edge detection, feature point detection and other image processing, to identify the various image elements in the image seed data. For each image element, corresponding description information is generated, and the description information includes but is not limited to the category, shape, color, texture and other features of the image element. It should be noted that the description information can be in a structured data format to facilitate subsequent processing. Then, the description information of each image element is input into a trained large generation model such as the TroubleLLM model to generate a first test case set.

[0099] S306, obtaining generation control conditions for generating the large model;

[0100] In one or more embodiments of this specification, the generation control condition refers to the key factors that reflect the model when generating content, including but not limited to semantic vectors, attention weights, generation probability distribution, etc. It can be understood that the generation control condition can determine the decision logic and output behavior of the model.

[0101] In addition, generation control conditions for risk assessment of generated large models can also be constructed based on the user's assessment needs. For example, when testing whether there are risks in personal privacy in the data security of the generated model, the constructed generation control conditions can include keywords such as user name, account information, identity credentials, mobile phone number, address, etc., which can be set specifically according to actual conditions, and the embodiments of this specification do not limit this.

[0102] S308, based on the generation control condition, determining at least one induced attack method using an adaptive attack strategy generator;

[0103] Before determining the induced attack technique, a library containing a variety of induced attack techniques can be pre-built. The induced attack techniques in the library include but are not limited to contrast type techniques, role-playing techniques, reverse induced techniques, text confrontation techniques, step-by-step techniques, target confusion techniques, forced consent techniques and long sentence overflow techniques, and each induced attack technique corresponds to different attack parameters and attack intensity levels.

[0104] The adaptive attack strategy generator can use genetic algorithms, reinforcement learning algorithms or fuzzy logic algorithms to generate or modify attack strategies. By considering the characteristics and potential vulnerabilities of the generated control conditions, it can automatically determine at least one effective induced attack method, ensuring that the attack strategy can be optimized as the model characteristics change, thereby improving the effectiveness of the attack.

[0105] For example, in the scenario of testing whether there are risks in personal privacy in the data security of the generated model, for each induced attack method, a corresponding attack vector can be designed for each keyword in the generated control condition to induce model leakage, misuse or generate content containing personal privacy information. The generated different attack vectors are input into the generated large model, and the response of the model is reviewed by automated scripts or manually, and whether the model leaks privacy information, the degree of leakage, and the frequency are recorded. At the same time, monitor whether the model has a learning effect, that is, whether the response of the model changes after being exposed to the same or similar attacks multiple times, so as to determine the induced attack method that can produce an attack effect.

[0106] Based on the behavioral feedback of the model, the combination and intensity of induced attack techniques can be dynamically adjusted to achieve accurate identification of model weaknesses and promote the synchronization of evaluation data sets and model evolution.

[0107] S310, using each of the induced attack techniques to transform the first test case set, to generate a second test case set and a case annotation of each test case in the second test case set.

[0108] Optionally, a corresponding induced attack method is selected to transform each or part of the test cases in the first test case set to generate a second test case set. Still taking the scenario of whether there is a risk in personal privacy in the data security of the test generation model as an example, the purpose of the deformation processing is to embed elements that can test the privacy protection mechanism of the model while retaining the original intention of the test case.

[0109] For example, the first test case asking about the weather: "What will the weather be like tomorrow?" can be transformed into the second test case: "I recently moved to District A and would like to know what the weather is like here?", where the geographic location information of "District A" is used as an implicit hint to test whether the model associates or leaks more information about the area.

[0110] It should be noted that the second test case set should cover a variety of induced attack methods, and there should be diverse test cases under each induced attack method to fully test the privacy protection performance of the generated large model in different scenarios.

[0111] Finally, add detailed annotations to each test case in the second test case set, including but not limited to the use case quality score, use case risk category, induced attack method and use case problem difficulty, etc.

[0112] The induced attack methods determined by the adaptive attack strategy generator are highly targeted and can effectively simulate attack scenarios encountered in actual applications. The generated second test case set can comprehensively evaluate the security and robustness of the generated large model. Moreover, the generation process of the entire test case set is highly automated, reducing manual intervention and improving evaluation efficiency.

[0113] See also Figure 4 , which is a flow chart of another test case generation method provided in an embodiment of this specification.

[0114] Among them, the test case set includes a first test case set and a second test case set. The first test case set includes test cases generated by generating large model outputs, and the second test case set includes test cases after intelligent deformation of test cases generated by generating large model outputs. Induced attack techniques include initial induced attack techniques and target induced attack techniques. Initial induced attack techniques refer to initialized induced attack techniques, which are used to preliminarily evaluate the robustness of the model. Target induced attack techniques refer to attack techniques for model weaknesses obtained through continuous iterative optimization of adaptive algorithms based on initial induced attack techniques. Target induced attack techniques can more effectively trigger model errors.

[0115] like Figure 4 As shown, the method comprises the following steps:

[0116] S402, obtaining evaluation seed data;

[0117] For step S402, please refer to the detailed description of step S202 in the first embodiment of this specification, which will not be repeated here.

[0118] By selecting representative and diverse evaluation seed data, the accuracy and reliability of the generated large-model security evaluation results can be ensured.

[0119] S404, inputting the evaluation seed data into the trained generation large model to obtain the first test case set;

[0120] For step S404, please refer to the detailed description of step S304 in another embodiment of this specification, which will not be repeated here.

[0121] S406, obtaining generation control conditions for generating the large model;

[0122] For step S406, please refer to the detailed description of step S306 in another embodiment of this specification, which will not be repeated here.

[0123] S408, selecting the initial induced attack method;

[0124] Optionally, one or more attack techniques are preliminarily selected as initial induced attack techniques according to the induced attack scenario.

[0125] For example, in a scenario where testing is performed to determine whether there are risks to personal privacy in the data security of a generated model, for each induced attack technique, a corresponding attack vector can be designed for each keyword in the generated control conditions, and the different generated attack vectors can be input into the generated large model. Based on the model's response, the induced attack technique that can produce an attack effect can be determined, thereby determining the initial induced attack technique.

[0126] S410, using the initial induced attack technique to transform the target test case in the first test case set, if the transformation result meets the generation control condition, adjusting the initial induced attack technique through the adaptive attack strategy generator until the transformation result of the target test case does not meet the generation control condition, and determining the target induced attack technique;

[0127] The target test case in the first test case set may refer to any test case in the first test case set. The target test case in the first test case set is deformed by using the preset large generation model and the selected initial induced attack method, and the effectiveness of the initial induced attack method is evaluated according to the generation control condition.

[0128] Optionally, if the deformation result meets the generation control condition, such as the generation control condition is that the test case does not contain a personal name, and the deformed test case is a person image, it indicates that the initial induced attack method did not produce an effective attack on the target test case. At this time, the attack strategy can be dynamically adjusted through the adaptive attack strategy generator, such as increasing the attack complexity of the initial induced attack method or selecting another induced attack method, until the deformation result of the target test case does not meet the generation control condition, such as the deformed test case is an identity document image, and the induced attack method that produces an effective attack is the target induced attack method.

[0129] In addition, the process of attacking, collecting feedback, and adjusting strategies can be repeated to form a closed-loop adaptive attack strategy generation process.

[0130] S412: transform the first test case set by using the target induced attack technique to generate a second test case set and a case annotation of each test case in the second test case set.

[0131] Optionally, each or part of the test cases in the first test case set is transformed using a target-induced attack technique to generate a second test case set. Still taking the scenario of whether there is a risk in personal privacy in the data security of the test generation model as an example, the purpose of the transformation is to embed elements that can test the privacy protection mechanism of the model while retaining the original intention of the test case.

[0132] Finally, add detailed annotations to each test case in the second test case set, including but not limited to the use case quality score, use case risk category, induced attack method and use case problem difficulty, etc.

[0133] The adaptive attack strategy generator achieves accurate positioning and continuous tracking of model weaknesses by continuously learning and optimizing attack strategies, promotes the synchronization between evaluation data sets and model evolution, and improves the efficiency and depth of model security evaluation.

[0134] See also Figure 5 , is a flow chart of another test case generation method provided in the embodiment of this specification. Figure 5 As shown, the method comprises the following steps:

[0135] S502, obtaining a historical seed data set and evaluation data corresponding to each historical seed data in the historical seed data set;

[0136] In one or more embodiments of the present specification, evaluation seed data may be intelligently recommended to automatically optimize the selection of evaluation seed data, thereby maximizing the coverage of test cases.

[0137] Optionally, the historical seed data set and the evaluation data corresponding to each historical seed data in the historical seed data set can be obtained to determine the evaluation seed data using the historical seed data and the corresponding evaluation data. Among them, each historical seed data in the historical seed data set can be text seed data, image seed data, or a combination of text seed data and image seed data. It should be noted that the historical seed data set needs to contain diverse data samples so that the model can learn comprehensive features.

[0138] Each historical seed data corresponds to evaluation data, which can reflect and quantify the quality of the seed data. For example, the evaluation data can be the prediction accuracy, AUC value, loss function value, user feedback score, etc. of the model on the data.

[0139] S505, extracting features from each of the historical seed data to obtain seed features;

[0140] According to the type of historical seed data, feature extraction is performed on each historical seed data to obtain corresponding seed features. The seed features may include text seed features and image seed features. Optionally, TF-IDF (TermFrequency_Inverse Document Frequency) is used to extract features from text seed data to obtain corresponding text seed features; pixel intensity histogram is used to extract features from image seed data to obtain corresponding image seed features. This specification does not limit the specific implementation of obtaining seed features.

[0141] S506, encoding each evaluation data to obtain evaluation features, and obtaining input features of each historical seed data according to the seed features and the evaluation features;

[0142] Similarly, the evaluation data needs to be converted into a data format that can be understood by the generated large model, that is, converted into evaluation features. For example, if the evaluation data is discrete data, one-hot encoding can be used to encode the evaluation data; if the evaluation data is continuous data, it can be directly used as an evaluation feature so that the evaluation data can be effectively used together with the seed feature to generate the large model.

[0143] Then, the extracted seed features are combined with the encoded evaluation features, such as concatenating the seed features and the evaluation features to obtain the input features, which contain information about the characteristics of the seed data itself and the evaluation information of the seed data, thereby providing a comprehensive data description for the model.

[0144] S508, determining the evaluation seed data from the historical seed data set through a trained reinforcement learning model based on each of the input features;

[0145] Optionally, the input features are input into a trained reinforcement learning model, and the evaluation seed data is determined according to the decision of the model. Specifically, the current state is determined according to the input features, and the reinforcement learning model selects an action according to the model strategy based on the current state, that is, it decides to select the evaluation seed data from the historical seed data set, where the action can be to select the evaluation seed data of a specific number or category, or to transform the evaluation seed data and then select it.

[0146] Execute this action and record the response of the generated large model. Calculate and receive rewards based on the model's response. The rewards can be used to evaluate the value of the evaluation seed data selected by the model to the model. For example, if the selected evaluation seed data can effectively expose the weaknesses of the generated large model, a high reward will be given; otherwise, a low reward or penalty will be given. Update the model strategy based on the reward feedback received, and finally determine the evaluation seed data that is beneficial to the system evaluation.

[0147] When training a reinforcement learning model, the constructed input features and corresponding evaluation data can be used to train a reinforcement learning model, in which the evaluation data can be used as a reward signal. The model can be trained through policy gradient, Q-learning or other reinforcement learning algorithms, so that the model can learn how to predict or select seed data with better performance based on seed features and evaluation features.

[0148] S510, based on the evaluation seed data, generate a test case set and case annotations of each test case in the test case set through a trained large generation model and at least one induced attack method.

[0149] For step S510, please refer to the detailed description of step S202 in one embodiment of this specification, or refer to the detailed description of steps S304 to S310 in another embodiment of this specification, or refer to the detailed description of steps S404 to S412 in yet another embodiment of this specification, which will not be repeated here.

[0150] Generating a diverse set of test cases can enhance the robustness and security of large models and improve the model's ability to cope with atypical data. Among them, by intelligently deforming the evaluation seed data to simulate offensive inputs, the model's ability to identify and defend against security vulnerabilities can be enhanced, reducing the risk of malicious attacks; by automatically generating use case annotations, it not only reduces manual dependence and accelerates the data processing process, but also ensures the quality of annotations, promotes rapid iteration and accurate evaluation of models; moreover, detailed use case annotations help to quickly locate model defects and facilitate optimization guidance for the model.

[0151] It should be noted that after generating the test case set and the use case annotations of each test case in the test case set, the test case set and the corresponding use case annotations can be displayed through the user interface. Moreover, the user can review, modify and manually add test cases through the user interface. Optionally, receive modification information input through the user interface, and adjust the test case set and the corresponding use case annotations according to the modification information.

[0152] Using the user interface as a channel for instant feedback can quickly capture users' modification opinions or new requirements for test cases, making it easier to optimize test cases in a timely manner. Moreover, based on the use of large model generation to generate diverse test cases, the accuracy and practicality of test cases are ensured through manual review and supplementation, further improving the quality of the test case set.

[0153] See also Figure 6 , is a flow chart of a method for generating a large model security assessment provided in an embodiment of this specification. Figure 6 As shown, the method comprises the following steps:

[0154] S602, obtaining evaluation seed data;

[0155] For step S602, please refer to the detailed description of step S202 in the first embodiment of this specification, which will not be repeated here.

[0156] By selecting representative and diverse evaluation seed data, the accuracy and reliability of the generated large-model security evaluation results can be ensured.

[0157] S604, based on the evaluation seed data, generating a test case set and a case annotation of each test case in the test case set through a trained large generation model and at least one induced attack method;

[0158] For step S604, please refer to the detailed description of step S202 in one embodiment of this specification, or refer to the detailed description of steps S304 to S310 in another embodiment of this specification, or refer to the detailed description of steps S404 to S412 in yet another embodiment of this specification, which will not be repeated here.

[0159] By obtaining the evaluation seed data and generating a test case set based on the evaluation seed data, it can be ensured that the evaluation covers various typical and edge cases that the model may encounter. Importantly, the combination of induced attack techniques can effectively simulate scenarios that may pose a threat to the model in actual applications, improving the comprehensiveness and pertinence of the evaluation. Moreover, the introduction of induced attack techniques can not only verify the general performance of the model, but also deeply explore the performance of the model when facing malicious inputs, which helps to discover and fix security vulnerabilities in a timely manner. The use of trained large-scale models to automatically generate test case sets greatly reduces the time and cost of manually designing test cases. The automated generation and optimization process of the test case set accelerates the evaluation process, making the security assessment of the model more efficient and suitable for model environments with frequent iterative updates.

[0160] S606, inputting the target test case in the test case set into the generated large model to obtain an output result corresponding to the target test case;

[0161] In order to standardize the access to the risk assessment platform and avoid access efficiency issues caused by different models, a corresponding API (Application Programming Interface) interface can be set, including setting unified API interface input and output parameters (such as model parameters and device parameters, etc.).

[0162] Optionally, the target test case obtained through intelligent deformation can be passed to the generated large model, and the output result corresponding to the target test case can be obtained from the generated large model through an API interface.

[0163] Among them, the target test cases can be test cases selected based on the use case quality score, use case risk category, induced attack method, and use case problem difficulty in the use case annotation. For example, selecting test cases with higher use case quality scores can more accurately test the performance of the model in a specific scenario, quickly locate the main security defects of the model, and efficiently use test resources; for another example, conduct special tests on the security weaknesses of the model according to the use case risk category; for another example, conduct security tests in the corresponding attack scenarios according to the induced attack method represented by the test case, and the evaluation process is more flexible; for another example, by gradually increasing the difficulty of the test cases, the robustness of the model under attacks at different levels can be evaluated.

[0164] S608, determining the risk assessment result of the generated large model according to the use case annotation corresponding to the target test case and the output result.

[0165] Further, the output result of the generated large model is compared with the case annotation of each target test case, and it is determined whether the model responds to the input target test case safely as expected according to the comparison result. In one embodiment of the present specification, the risk assessment result can be a risk level determined according to the comparison result.

[0166] Optionally, evaluate the accuracy score of the model output results, and compare the accuracy score of the output results with the use case quality score of the test case. Close scores indicate that the model can exhibit the expected behavior, and the corresponding risk level is low risk or no risk. Large differences in scores may indicate poor model performance, and the corresponding risk level is high risk. Check whether the model's output results trigger the expected use case risk category, such as whether there is information leakage, logical errors, or inappropriate content generation. If triggered, the model's risk level is high. Analyze whether the model's output results respond to the expected induced attack method, such as whether it successfully bypasses the security check or whether it is misled to produce an erroneous response. If it responds, the model's risk level is high. Observe the performance differences of the model on use cases of different problem difficulties to evaluate the model's risk level.

[0167] Based on the performance of all test cases, the overall security of the generated large model is comprehensively analyzed to identify the risks that the model may have in specific scenarios. Moreover, through comparative analysis of use case annotations and output results, the response of the model under specific attacks or inducements can be quantified, thereby standardizing the risk assessment process. Finally, after determining the risk assessment results of the generated large model, the model can be strengthened in a targeted manner, such as by increasing adversarial training, adjusting the model architecture, etc., to reduce the risk of accidents caused by security issues in actual deployment.

[0168] See also Figure 7, is a schematic diagram of a structure of a test case generation device provided in an embodiment of this specification. Figure 7 As shown, the test case generation device 1 can be implemented as all or part of the electronic device through software, hardware or a combination of both. According to some embodiments, the test case generation device 1 includes a data acquisition module 11 and a case generation module 12, specifically including:

[0169] The data acquisition module 11 is used to acquire evaluation seed data;

[0170] The use case generation module 12 is used to generate a test case set and a use case annotation of each test case in the test case set based on the evaluation seed data through a trained generation large model and at least one induced attack method.

[0171] Optionally, the test case set includes a first test case set and a second test case set; when the test case generation module 12 generates a test case set and a case annotation of each test case in the test case set based on the evaluation seed data through a trained generation large model and at least one induced attack method, it is specifically used to:

[0172] Inputting the evaluation seed data into the trained generation large model to obtain the first test case set;

[0173] Obtaining generation control conditions for generating the large model;

[0174] Based on the generation control condition, determining at least one induced attack method using an adaptive attack strategy generator;

[0175] The first test case set is transformed using each of the induced attack techniques to generate a second test case set and case annotations for each test case in the second test case set.

[0176] Optionally, the induced attack technique includes an initial induced attack technique and a target induced attack technique; when the use case generation module 12 determines at least one induced attack technique based on the generation control condition by using an adaptive attack strategy generator, it is specifically used to:

[0177] Selecting the initial induced attack method;

[0178] The target test case in the first test case set is deformed using the initial induced attack technique. If the deformation result meets the generation control condition, the initial induced attack technique is adjusted by an adaptive attack strategy generator until the deformation result of the target test case does not meet the generation control condition, and the target induced attack technique is determined.

[0179] Optionally, the evaluation seed data includes text seed data; when the use case generation module 12 inputs the evaluation seed data into the trained generation large model to obtain the first test case set, it is specifically used to:

[0180] Generate context information of the text seed data by a context processor;

[0181] Based on the context information, the first test case set is generated by using the trained generation model.

[0182] Optionally, the evaluation seed data includes image seed data; when the use case generation module 12 inputs the evaluation seed data into the trained generation large model to obtain the first test case set, it is specifically used to:

[0183] Performing element detection on the image seed data to obtain image elements contained in the image seed data and description information of the image elements;

[0184] Based on the description information, the first test case set is generated by using the trained generation model.

[0185] Optionally, in the use case generation module 12, the induced attack technique includes one or more of a contrast type technique, a role-playing technique, a reverse induction technique, a text confrontation technique, a step-by-step technique, a target confusion technique, a forced consent technique and a long sentence overflow technique.

[0186] Optionally, in the use case generation module 12, the use case annotation of each test case includes a use case quality score, a use case risk category, an induced attack technique, and a use case problem difficulty.

[0187] Optionally, the data acquisition module 11 is specifically used for:

[0188] Acquire a historical seed data set and evaluation data corresponding to each historical seed data in the historical seed data set;

[0189] Extracting features from each of the historical seed data to obtain seed features;

[0190] Encoding each of the evaluation data to obtain evaluation features, and obtaining input features of each of the historical seed data according to the seed features and the evaluation features;

[0191] Based on each of the input features, the evaluation seed data is determined from the historical seed data set through a trained reinforcement learning model.

[0192] Optionally, the test case generating device 1 further includes:

[0193] A use case display module 13, used to display the test case set and the use case annotations of each test case in the test case set through a user interface;

[0194] The use case adjustment module 14 is used to receive modification information input through the user interface and adjust the test case set and the corresponding use case annotation according to the modification information.

[0195] Optionally, the test case generating device 1 further includes:

[0196] A model testing module 15, used for inputting a target test case in the test case set into the generated large model to obtain an output result corresponding to the target test case;

[0197] The model evaluation module 16 is used to determine the risk assessment result of the generated large model according to the use case annotation corresponding to the target test case and the output result.

[0198] Optionally, when the model testing module 15 inputs the target test case in the test case set into the generated large model to obtain an output result corresponding to the target test case, it is specifically used to:

[0199] The target test case is input into the generated large model through a preset API interface, and the output result corresponding to the target test case is obtained through the API interface.

[0200] The above device embodiments correspond to the method embodiments. For specific descriptions, please refer to the description of the method embodiments, which will not be repeated here. The device embodiments are obtained based on the corresponding method embodiments and have the same technical effects as the corresponding method embodiments. For specific descriptions, please refer to the corresponding method embodiments.

[0201] The present specification also provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded and executed by a processor as described above. Figures 2 to 6 The method of the embodiment shown in the figure can be specifically executed by referring to Figures 2 to 6 The specific description of the illustrated embodiment will not be repeated here.

[0202] The present specification also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor as described above. Figures 2 to 6 The method of the embodiment shown in the figure can be specifically executed by referring to Figures 2 to 6 The specific description of the illustrated embodiment will not be repeated here.

[0203] The embodiments of this specification also provide Figure 8The structural diagram of the electronic device shown in FIG. Figure 8 At the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the above-mentioned voice activity detection method.

[0204] Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the executor of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0205] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0206] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.

[0207] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0208] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0209] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0210] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0211] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0212] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0213] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0214] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0215] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0216] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0217] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0218] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0219] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0220] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.

Claims

1. A method for generating a test case, the method comprising: Get evaluation seed data; Based on the evaluation seed data, a test case set and case annotations of each test case in the test case set are generated through a trained large generation model and at least one induced attack method.

2. The method for generating a test case according to claim 1, wherein the test case set comprises a first test case set and a second test case set; The generating of a test case set and a case annotation of each test case in the test case set based on the evaluation seed data through a trained large generation model and at least one induced attack method includes: Inputting the evaluation seed data into the trained generation large model to obtain the first test case set; Obtaining generation control conditions for generating the large model; Based on the generation control condition, determining at least one induced attack method using an adaptive attack strategy generator; The first test case set is transformed using each of the induced attack techniques to generate a second test case set and case annotations for each test case in the second test case set.

3. According to the test case generation method of claim 2, the induced attack technique comprises an initial induced attack technique and a target induced attack technique; The step of determining at least one induced attack method by using an adaptive attack strategy generator based on the generated control condition includes: Selecting the initial induced attack method; The target test case in the first test case set is deformed using the initial induced attack technique. If the deformation result meets the generation control condition, the initial induced attack technique is adjusted by an adaptive attack strategy generator until the deformation result of the target test case does not meet the generation control condition, and the target induced attack technique is determined.

4. The test case generation method according to claim 2, wherein the evaluation seed data comprises text seed data; and the step of inputting the evaluation seed data into the trained generation model to obtain the first test case set comprises: Generate context information of the text seed data by a context processor; Based on the context information, the first test case set is generated by using the trained generation model.

5. The test case generation method according to claim 2, wherein the evaluation seed data comprises image seed data; and the step of inputting the evaluation seed data into the trained generation model to obtain the first test case set comprises: Performing element detection on the image seed data to obtain image elements contained in the image seed data and description information of the image elements; Based on the description information, the first test case set is generated by using the trained generation model.

6. According to the test case generation method described in claim 1, the induced attack technique includes one or more of a contrast type technique, a role-playing technique, a reverse induction technique, a text confrontation technique, a step-by-step technique, a target confusion technique, a forced consent technique, and a long sentence overflow technique.

7. According to the test case generation method of claim 1, the case annotation of each test case includes a case quality score, a case risk category, an induced attack method and a case problem difficulty.

8. The method for generating a test case according to claim 1, wherein obtaining evaluation seed data comprises: Acquire a historical seed data set and evaluation data corresponding to each historical seed data in the historical seed data set; Extracting features from each of the historical seed data to obtain seed features; Encoding each of the evaluation data to obtain evaluation features, and obtaining input features of each of the historical seed data according to the seed features and the evaluation features; Based on each of the input features, the evaluation seed data is determined from the historical seed data set through a trained reinforcement learning model.

9. The method for generating a test case according to claim 1, further comprising: Displaying the test case set and the case annotations of each test case in the test case set through a user interface; Receive modification information input through the user interface, and adjust the test case set and the corresponding case annotations according to the modification information.

10. The method for generating a test case according to claim 1, further comprising: Inputting the target test case in the test case set into the generated large model to obtain an output result corresponding to the target test case; The risk assessment result of the generated large model is determined according to the use case annotation corresponding to the target test case and the output result.

11. The method for generating a test case according to claim 10, wherein the step of inputting a target test case in the test case set into the generated large model to obtain an output result corresponding to the target test case comprises: The target test case is input into the generated large model through a preset API interface, and the output result corresponding to the target test case is obtained through the API interface.

12. A test case generation device, the device comprising: Data acquisition module, used to obtain evaluation seed data; A use case generation module is used to generate a test case set and a use case annotation of each test case in the test case set based on the evaluation seed data through a trained generation large model and at least one induced attack method.

13. The test case generation device according to claim 12, further comprising: A model testing module, used for inputting a target test case in the test case set into the generated large model to obtain an output result corresponding to the target test case; A model evaluation module is used to determine the risk assessment result of the generated large model based on the use case annotation corresponding to the target test case and the output result.

14. A storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method according to any one of claims 1 to 11.

15. An electronic device, comprising: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the method as claimed in any one of claims 1 to 11.

16. A computer program product having at least one instruction stored thereon, wherein when the at least one instruction is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.

Citation Information

Cited By

  • Systems and methods for analyzing artificial intelligence systems

    WO2026112084A1