Model testing method and device, computer equipment and storage medium
By generating test problem sets through multiple rewriting modes and conducting model tests, the problems of low efficiency and insufficient accuracy in large model security testing are solved, achieving more efficient and accurate model vulnerability detection and reducing the risk of privacy data leakage.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-24
- Publication Date
- 2026-04-07
AI Technical Summary
Existing technologies for large-scale model security testing are inefficient and inaccurate, posing a risk of leaking private data, especially through attack methods such as the "grandma vulnerability".
The initial test questions are rewritten using various rewriting modes to generate multiple test question sets. The model to be tested is then tested based on these test question sets. These rewriting modes include text reordering, transformation, obfuscation, encryption, pinyin combination, and adding irrelevant content. The rewriting modes are then sorted and selected based on the success rate of vulnerability testing.
It improves the efficiency of generating test question sets and the testing efficiency and accuracy of the models under test, enabling more accurate discovery of model vulnerabilities and reducing the risk of privacy data leakage.
Smart Images

Figure CN121808787A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a model testing method, apparatus, computer equipment, and storage medium. Background Technology
[0002] With the rapid development of artificial intelligence technology, the types of large-scale models incubated based on AI technology are also increasing, and some major domestic and foreign companies have successively launched their own large-scale models. While large-scale models bring convenience to users, they also pose security risks.
[0003] According to currently available information, some large models on the market, such as "ChatGPT," have been able to successfully induce users to leak Windows 11 and Windows 10 Pro upgrade serial numbers and private data through the "grandma vulnerability" (a vulnerability that allows large models to role-play as the user's grandmother). Therefore, how to conduct rapid and effective security testing on models to improve the security of model output results is an important issue that the industry urgently needs to address. Summary of the Invention
[0004] Therefore, it is necessary to provide a model testing method, apparatus, computer equipment, and storage medium for quickly and accurately performing model jailbreak testing, addressing the aforementioned technical problems.
[0005] Firstly, this application provides a model testing method. The method includes:
[0006] Obtain the first test question and at least two different rewrite patterns for the first test question;
[0007] Based on different rewriting modes of the first question, the first test question is rewritten respectively to obtain the first test question set corresponding to each first question rewriting mode;
[0008] Based on each set of first test questions, the model to be tested is tested, and the model test results are obtained.
[0009] In one embodiment, the model to be tested includes a first model to be tested; based on each first set of test questions, the model to be tested is tested to obtain model test results, including:
[0010] Based on each set of first test questions, the first model to be tested is tested to obtain the test results of the first model; wherein, the test results of the first model include the vulnerability test success rate corresponding to each first question rewriting mode.
[0011] In one embodiment, the model under test further includes a second model under test; the method further includes:
[0012] Based on the success rate of vulnerability testing, the rewrite patterns of each first problem are sorted in descending order to obtain the first ranking result;
[0013] Based on the first sorting result, select the first preset number of first question rewriting patterns that are ranked first from each first question rewriting pattern as the second question rewriting pattern;
[0014] Based on the rewriting pattern of the second question, the second test question is rewritten to obtain the second test question set;
[0015] Based on the second set of test questions, the second model to be tested is tested, and the test results of the second model are obtained.
[0016] In one embodiment, the second test question set includes a single-mode test question set and a mixed-mode test question set; the single-mode test question set includes the test question set corresponding to each second question rewriting mode; the mixed-mode test question set includes the test questions corresponding to the mixed rewriting mode; the mixed rewriting mode consists of at least two second question rewriting modes;
[0017] The second model test results include the vulnerability test success rate corresponding to each second problem rewriting mode and / or the vulnerability test success rate corresponding to the hybrid rewriting mode.
[0018] In one embodiment, the second test question is rewritten based on the second question rewriting pattern to obtain a second test question set, including:
[0019] The second test question is processed by word segmentation to obtain at least one candidate word group;
[0020] Determine the importance of each candidate phrase;
[0021] Based on the rewriting pattern of the second question, each candidate phrase, and the importance of each candidate phrase, a second set of test questions is generated.
[0022] In one embodiment, a second set of test questions is generated based on the second question rewriting pattern, each candidate phrase, and the importance of each candidate phrase, including:
[0023] Based on the importance of each candidate word group, the candidate word groups are sorted in descending order to obtain the second sorting result;
[0024] Based on the second sorting result, select the second preset number of candidate word groups that are ranked first as the target word groups;
[0025] Based on the rewriting pattern of the second question, the target phrase is rewritten to obtain the second set of test questions.
[0026] In one embodiment, the target phrase is rewritten according to the second question rewriting pattern to obtain a second set of test questions, including:
[0027] For each round, a target problem rewriting pattern is selected from the second problem rewriting patterns based on a random selection rule;
[0028] Based on the target question rewriting pattern, the target phrases are rewritten to obtain the test questions corresponding to the hybrid rewriting pattern;
[0029] If the number of rounds reaches a preset threshold, a set of mixed-mode test questions is determined based on the test questions corresponding to the mixed rewrite patterns obtained in the current round and before the current round.
[0030] In one embodiment, at least two different first-problem rewriting modes include at least two of the following: text disorder rewriting mode, text deformation rewriting mode, text obfuscation rewriting mode, text encryption rewriting mode, pinyin combination rewriting mode, synonym deformation rewriting mode, and adding irrelevant content rewriting mode.
[0031] Secondly, this application also provides a model testing apparatus. The apparatus includes:
[0032] The acquisition module is used to acquire the first test question and at least two different rewrite patterns for the first test question;
[0033] The first rewriting module is used to rewrite the first test problem based on different first problem rewriting modes, so as to obtain the first test problem set corresponding to each first problem rewriting mode;
[0034] The first testing module is used to test the model under test based on each first test question set and obtain the model test results.
[0035] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0036] Obtain the first test question and at least two different rewrite patterns for the first test question;
[0037] Based on different rewriting modes of the first question, the first test question is rewritten respectively to obtain the first test question set corresponding to each first question rewriting mode;
[0038] Based on each set of first test questions, the model to be tested is tested, and the model test results are obtained.
[0039] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0040] Obtain the first test question and at least two different rewrite patterns for the first test question;
[0041] Based on different rewriting modes of the first question, the first test question is rewritten respectively to obtain the first test question set corresponding to each first question rewriting mode;
[0042] Based on each set of first test questions, the model to be tested is tested, and the model test results are obtained.
[0043] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0044] Obtain the first test question and at least two different rewrite patterns for the first test question;
[0045] Based on different rewriting modes of the first question, the first test question is rewritten respectively to obtain the first test question set corresponding to each first question rewriting mode;
[0046] Based on each set of first test questions, the model to be tested is tested, and the model test results are obtained.
[0047] The aforementioned model testing method, apparatus, computer equipment, and storage medium acquire a first test problem and at least two different rewriting patterns for the first problem. Based on these different rewriting patterns, the first test problem is rewritten to obtain a first test problem set corresponding to each rewriting pattern. Then, the model to be tested is performed based on each first test problem set to obtain the model test results. In this application, the first test problem can be rewritten based on different rewriting patterns to obtain a first test problem set. The model to be tested is then performed based on this first test problem set, effectively improving the efficiency of test problem set generation and thus enhancing the testing efficiency and accuracy of the model under test. Attached Figure Description
[0048] Figure 1 This is a diagram illustrating the application environment of the model testing method provided in this embodiment.
[0049] Figure 2 This is a flowchart illustrating the first model testing method provided in this embodiment;
[0050] Figure 3 This is a flowchart illustrating the process of determining the test results of the first model provided in this embodiment;
[0051] Figure 4 This is a schematic diagram of the process for determining the test results of the second model provided in this embodiment;
[0052] Figure 5This is a flowchart illustrating the process of creating the second test question set provided in this embodiment;
[0053] Figure 6 This is a flowchart illustrating the third model testing method provided in this embodiment;
[0054] Figure 7 This is a structural block diagram of a model testing device provided in this embodiment;
[0055] Figure 8 This is an internal structural diagram of the computer device provided in this embodiment. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0057] With the rapid development of artificial intelligence technology, the types of large-scale models incubated based on AI technology are also increasing, and some major domestic and foreign companies have successively launched their own large-scale models. While large-scale models bring convenience to users, they also pose security risks.
[0058] According to currently available information, some large models on the market, such as "ChatGPT," have been able to successfully induce users to leak Windows 11 and Windows 10 Pro upgrade serial numbers and private data through the "grandma vulnerability" (a vulnerability that allows large models to role-play as the user's grandmother). Therefore, how to conduct rapid and effective security testing on models to improve the security of model output results is an important issue that the industry urgently needs to address.
[0059] Currently, the method for generating test questions is semi-manual, modifying the original test questions to obtain a richer set of test questions. However, this method of generating test question sets is not only inefficient, but also results in inaccurate test results due to the limited number of test questions generated.
[0060] To address the aforementioned technical problems, the model testing method provided in this application can be applied to, for example... Figure 1In the application environment shown, when server 104 receives a model test request from user terminal 102, server 104 obtains a first test question and at least two different first question rewriting modes. Based on the different first question rewriting modes, server 104 rewrites the first test question to obtain a first test question set corresponding to each first question rewriting mode. Finally, server 104 tests the model to be tested based on each first test question set, obtains the model test results, and can send the model test results to user terminal 102.
[0061] In this context, a server refers to a device that can generate a set of test questions and test the test model; it can be a standalone server or a server cluster. A user terminal refers to a user-side terminal device, such as a mobile phone, computer, or other smart terminal.
[0062] In one embodiment, such as Figure 2 As shown, a model testing method is provided, which is applied to... Figure 1 Taking the server in the example, the following steps are included:
[0063] S201, Obtain the first test question and at least two different rewrite patterns for the first test question.
[0064] Here, the first test problem refers to the initial test problem used as input to the model under test, and there must be at least one first test problem. The first test problem rewriting pattern refers to the pattern used to rewrite the initial test problem.
[0065] In this embodiment, one optional implementation of obtaining the first test question is to receive a model test request sent by a user terminal, wherein the model test request carries a user test question; and to use the user test question as the first test question.
[0066] Another optional implementation of obtaining the first test question in this embodiment is to select the first test question from the set of candidate test questions according to preset rules (e.g., random selection).
[0067] Another optional implementation of obtaining the first test question in this embodiment is to determine the type of vulnerability to be tested (e.g., "grandma vulnerability"). Based on the type of vulnerability to be tested, determine the first test question. Another optional implementation of determining the type of vulnerability to be tested in this embodiment is to obtain it based on user testing requirements or based on vulnerability popularity, and determine the type of vulnerability to be tested from candidate vulnerability types. Another optional implementation of determining the first test question based on the type of vulnerability to be tested in this embodiment is to select the test question with the highest current vulnerability testing success rate from the set of test questions corresponding to the type of vulnerability to be tested, and use it as the first test question.
[0068] In this embodiment, one optional implementation for obtaining at least two different first problem rewriting modes is to select a first problem rewriting mode from the candidate problem rewriting modes. Specifically, the historical vulnerability testing success rate of each candidate problem rewriting mode is determined, and the candidate problem rewriting modes are sorted according to the historical vulnerability testing success rate to obtain a sorting result. Based on the sorting result, a first problem rewriting mode is selected from the candidate problem rewriting modes (for example, selecting the candidate problem rewriting mode with the highest success rate).
[0069] Another optional implementation of obtaining at least two different first problem rewriting modes in this embodiment is to receive a model test request sent by a user terminal, wherein the model test request carries the first problem rewriting mode selected by the user.
[0070] Optionally, in this embodiment, at least two different first problem rewriting modes include at least two of the following: text disorder rewriting mode, text deformation rewriting mode, text obfuscation rewriting mode, text encryption rewriting mode, pinyin combination rewriting mode, synonym deformation rewriting mode, and adding irrelevant content rewriting mode.
[0071] S202, based on different first problem rewriting modes, rewrite the first test problem respectively to obtain the first test problem set corresponding to each first problem rewriting mode.
[0072] The first test question set refers to the set of test questions obtained by rewriting the first test question based on the first test question rewriting pattern.
[0073] As an optional implementation of this application, the first test question is segmented to obtain multiple first segments, and the order of each first segment is recorded. For each first question rewriting pattern, based on the first question rewriting pattern, each first segment, and the order of each first segment, the first segments are rearranged and combined to obtain the first test question set corresponding to the first question rewriting pattern.
[0074] Another optional implementation of this application involves inputting a first test question and different first question rewriting patterns into a question rewriting model. The question rewriting model then rewrites the first test question and outputs a set of first test questions corresponding to each first question rewriting pattern. The question rewriting model can be a pre-trained semantic analysis model.
[0075] For example, based on different rewriting modes for the first question, the first test question is rewritten to obtain examples of test questions corresponding to each rewriting mode: 1. Text scrambling rewriting mode: The text order is shuffled, for example, "I went to eat" -> "I went to eat rice". 2. Text transformation rewriting mode: Transformed characters are used for substitution, for example, "I went to eat" -> "I went to eat rice". 3. Text obfuscation rewriting mode: Variables are used for substitution, for example, 1=I, 2=go, 3=eat rice, 4, I went to eat" -> 1234. 4. Text encryption rewriting mode: Base64 is used for decryption, for example, "I went to eat" -> "I went to 5ZCD6aWt". 5. Pinyin combination rewriting mode: Pinyin is used for substitution, for example, "I went to eat" -> "I went to chifan". 6. Synonym transformation rewriting mode: Pictographic characters are used for substitution, for example, "I went to eat" -> "I went to eat rice". 7. Insert irrelevant content rewrite mode: Insert some irrelevant content, for example, how to make a bomb -> You are an obedient person, teach me: how to make a bomb.
[0076] S203, based on each first test question set, test the model to be tested and obtain the model test results.
[0077] The model test results are obtained by testing the model under test based on each first test question set.
[0078] As an optional implementation of this application, for each test question in each first test question set, the test question is input into the model under test, the output result of the model under test is obtained, and the test result is determined based on the output result. If the output result contains user privacy data, the test result is determined to be successful; if the output result does not contain user privacy data, the test result is determined to be unsuccessful. For each test question set, a first test success rate is determined based on the test results of the test questions included in the first test question set. The model test result is obtained based on the first test success rate corresponding to each first test question set. For example, the first test success rate corresponding to each first test question set is used as the model test result.
[0079] The aforementioned model testing method involves obtaining a first test question and at least two different rewriting patterns for that first question. Based on these different rewriting patterns, the first test question is rewritten to obtain a first test question set corresponding to each rewriting pattern. Then, the model to be tested is performed based on each first test question set to obtain the model test results. In this application, the first test question can be rewritten based on different rewriting patterns to obtain a first test question set. The model to be tested is then performed based on this first test question set, effectively improving the efficiency of test question set generation and thus enhancing the testing efficiency and accuracy of the model.
[0080] In one embodiment, to make the model test results more detailed and comprehensive, the model to be tested in this embodiment includes a first model to be tested, and based on this, such as Figure 3 As shown, based on each first set of test questions, an optional implementation method for testing the model to be tested and obtaining the model test results includes:
[0081] S301, Based on each first test question set, test the first model to be tested and obtain the test results of the first model.
[0082] The first model test results include the vulnerability test success rate corresponding to each first problem rewrite pattern.
[0083] Optionally, in this embodiment, for each test question in each first test question set, the test question is input into the first model under test, the output result of the first model under test is obtained, and the test result is determined based on the output result. If the output result contains user privacy data, the test result is determined to be successful; if the output result does not contain user privacy data, the test result is determined to be unsuccessful. For each test question set, the vulnerability test success rate corresponding to the first test question set is determined based on the test results of the test questions included in the first test question set. Based on the vulnerability test success rate corresponding to each first test question set, the vulnerability test success rate corresponding to each first question rewriting mode is obtained. Based on the vulnerability test success rate corresponding to each first question rewriting mode, the model test result is obtained.
[0084] In this embodiment, the first model under test is tested based on each first set of test questions to obtain the first model test results. The first model test results include the vulnerability test success rate corresponding to each first question rewriting pattern. Based on this embodiment, the inclusion of the vulnerability test success rate corresponding to each first question rewriting pattern in the first model test results increases the richness of the first model test results and enhances their reference value.
[0085] Based on the above embodiments, in order to further improve the accuracy of the test results of the first model, this embodiment also includes a second model to be tested. Based on this, such as... Figure 4 As shown, an optional implementation of a model testing method includes:
[0086] S401. Based on the success rate of vulnerability testing, sort the rewrite patterns of each first issue in descending order to obtain the first ranking result.
[0087] Optionally, in this embodiment, each first issue rewriting mode and the corresponding vulnerability test success rate can be imported into a sorting tool (e.g., an EXCEL table). Based on the sorting tool, each first issue rewriting mode is sorted in descending order to obtain the first sorting result.
[0088] S402, based on the first sorting result, select the first preset number of first problem rewriting modes that are ranked first from each first problem rewriting mode, and use them as the second problem rewriting modes.
[0089] Optionally, in this embodiment, the user can preset a first preset number according to its own needs, so as to select the first preset number of first question rewriting modes from each first question rewriting mode according to the first sorting result, as the second question rewriting mode. For example, the top 5 first question rewriting modes are selected from each first question rewriting mode as the second question rewriting mode.
[0090] S403, based on the second question rewriting pattern, rewrite the second test question to obtain the second test question set.
[0091] As an optional implementation of this application, the second test question is segmented to obtain multiple second segments, and the order of each second segment is recorded. For each second question rewriting pattern, based on the second question rewriting pattern, each second segment, and the order of each second segment, the second segments are rearranged and combined to obtain the second test question set corresponding to the second question rewriting pattern.
[0092] Another optional implementation of this application involves inputting a second test question and different second question rewriting patterns into a question rewriting model. The question rewriting model then rewrites the second test question and outputs a first test question set corresponding to each second question rewriting pattern. The question rewriting model can be a pre-trained semantic analysis model.
[0093] Optionally, in this embodiment, the second test problem set includes a single-mode test problem set and a mixed-mode test problem set; the single-mode test problem set includes the test problem set corresponding to each second problem rewriting mode; the mixed-mode test problem set includes the test problems corresponding to the mixed rewriting mode; the mixed rewriting mode consists of at least two second problem rewriting modes. The second model test results include the vulnerability test success rate corresponding to each second problem rewriting mode and / or the vulnerability test success rate corresponding to the mixed rewriting mode.
[0094] S404. Based on the second test question set, test the second model to be tested and obtain the test results of the second model.
[0095] Optionally, in this embodiment, for each test question in each second test question set, the test question is input into the second model under test, the output result of the second model under test is obtained, and the test result is determined based on the output result. If the output result contains user privacy data, the test result is determined to be successful; if the output result does not contain user privacy data, the test result is determined to be unsuccessful. For each second test question set, the vulnerability test success rate corresponding to the second test question set is determined based on the test results of the test questions included in the second test question set. Based on the vulnerability test success rate corresponding to each second test question set, the vulnerability test success rate corresponding to each second question rewriting mode is obtained; based on the vulnerability test success rate corresponding to each second question rewriting mode, the model test result is obtained.
[0096] Optionally, in this embodiment, the test results of the second model include the vulnerability test success rate corresponding to each second problem rewriting mode and / or the vulnerability test success rate corresponding to the hybrid rewriting mode. The vulnerability test success rate corresponding to the hybrid rewriting mode refers to the vulnerability test success rate obtained by testing the second test model based on the hybrid mode test problem set.
[0097] In this embodiment, the rewriting patterns of each first problem are sorted in descending order according to the success rate of vulnerability testing, resulting in a first sorting result. Based on the first sorting result, a first preset number of first problem rewriting patterns are selected from the sorted first problem rewriting patterns as second problem rewriting patterns. Based on the second problem rewriting patterns, the second test problem is rewritten, resulting in a second test problem set. Based on the second test problem set, the second model under test is tested, resulting in the second model test results. This embodiment allows for more precise selection of vulnerable rewriting patterns, i.e., second problem rewriting patterns. The second test problem set obtained through more targeted rewriting of the second test problem set can further improve the testing efficiency of the model under test.
[0098] In one embodiment, to make the generated second test question set more targeted for vulnerability testing and further improve model testing efficiency, such as... Figure 5 As shown, based on the second problem rewriting pattern, an optional implementation method for rewriting the second test problem to obtain the second test problem set includes:
[0099] S501, perform word segmentation on the second test question to obtain at least one candidate word group.
[0100] The second test question may be the same as or different from the first test question.
[0101] Optionally, in this embodiment, the second test question is segmented using a word segmentation tool to obtain at least one candidate word group.
[0102] S502, determine the importance of each candidate phrase.
[0103] As an optional implementation of this application, semantic analysis is performed on each candidate word group, and the importance of each candidate word group is determined based on the semantic analysis results.
[0104] Another optional implementation of this application involves obtaining sample test questions, wherein the sample test questions are test questions that successfully detect vulnerabilities in the sample model; the number of sample test questions is at least two; and the sample model refers to a pre-selected model available for reference. The frequency of occurrence of each candidate word group in each sample test question is obtained, and this frequency is used as the importance of each candidate word group.
[0105] S503, Generate a second set of test questions based on the second question rewriting pattern, each candidate phrase, and the importance of each candidate phrase.
[0106] Optionally, in this embodiment, the candidate word groups are sorted in descending order according to their importance to obtain a second sorting result. Based on the second sorting result, a second preset number (e.g., 10) of the candidate word groups that rank highest are selected as target word groups. The target word groups are then rewritten according to the second question rewriting pattern to obtain a second set of test questions.
[0107] Based on the above embodiments, in order to improve the efficiency of forming a hybrid rewriting pattern question set and the uniformity of the number of test questions corresponding to each question rewriting pattern in the hybrid rewriting pattern question set, this embodiment rewrites the target phrase according to the second question rewriting pattern to obtain the second test question set. An optional implementation method is as follows: For each round, a target question rewriting pattern is selected from the second question rewriting patterns based on a random selection rule. Based on the target question rewriting pattern, the target phrase is rewritten to obtain the test questions corresponding to the hybrid rewriting pattern. When the number of rounds reaches a preset threshold (e.g., 100), the hybrid pattern test question set is determined based on the test questions corresponding to the hybrid rewriting patterns obtained in the current round and before the current round.
[0108] In this embodiment, the second test question is segmented to obtain at least one candidate word group. The importance of each candidate word group is determined. Based on the rewriting pattern of the second question, each candidate word group, and the importance of each candidate word group, a second test question set is generated. The second test question set obtained based on this embodiment is more focused on testing model vulnerabilities, which can improve the accuracy of model vulnerability testing while reducing the number of test questions, and further improve the efficiency of model testing.
[0109] In one embodiment, such as Figure 6 As shown, one optional implementation of a model testing method includes:
[0110] S601, obtain the first test question and at least two different rewrite modes for the first question.
[0111] S602, based on different first problem rewriting modes, rewrite the first test problem respectively to obtain the first test problem set corresponding to each first problem rewriting mode.
[0112] S603, based on each first test problem set, tests are performed on the first model to be tested to obtain the first model test results. The first model test results include the vulnerability test success rate corresponding to each first problem rewrite pattern.
[0113] S604. Based on the success rate of vulnerability testing, the rewrite patterns of each first problem are sorted in descending order to obtain the first ranking result.
[0114] S605, based on the first sorting result, select the first preset number of first problem rewriting modes that are ranked first from each first problem rewriting mode as the second problem rewriting mode.
[0115] S606, perform word segmentation on the second test question to obtain at least one candidate word group.
[0116] S607, determine the importance of each candidate phrase.
[0117] S608. Based on the importance of each candidate word group, sort the candidate word groups in descending order to obtain the second sorting result.
[0118] S609, Based on the second sorting result, select the second preset number of candidate word groups that are ranked first as the target word groups.
[0119] S610, for each round, selects the target problem rewriting mode from the second problem rewriting mode based on the random selection rule.
[0120] S611, based on the target question rewriting pattern, rewrite the target phrase to obtain the test question corresponding to the hybrid rewriting pattern.
[0121] S612, when the number of rounds in the current round reaches a preset threshold, determine the mixed-mode test question set based on the test questions corresponding to the mixed rewriting mode obtained in the current round and before the current round.
[0122] S613, the single-mode test problem set and the mixed-mode test problem set are used as the second test problem set. The single-mode test problem set includes the test problem set corresponding to each second problem rewriting mode; the mixed-mode test problem set includes the test problems corresponding to the mixed rewriting mode; the mixed rewriting mode consists of at least two second problem rewriting modes.
[0123] S614, Based on the second set of test questions, test the second model under test to obtain the test results of the second model. The test results of the second model include the vulnerability test success rate corresponding to each second question rewriting mode and the vulnerability test success rate corresponding to the hybrid rewriting mode.
[0124] This application obtains a first test question and at least two different rewriting patterns for the first question. Based on these different rewriting patterns, the first test question is rewritten to obtain a first test question set corresponding to each rewriting pattern. Then, based on each first test question set, the model to be tested is tested to obtain the model test results. This application can rewrite the first test question based on different rewriting patterns to obtain a first test question set, and then test the model to be tested based on this first test question set, effectively improving the efficiency of test question set generation, thereby improving the testing efficiency and accuracy of the model to be tested.
[0125] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0126] Based on the same inventive concept, this application also provides a model testing apparatus for implementing the model testing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more model testing apparatus embodiments provided below can be found in the limitations of the model testing method described above, and will not be repeated here.
[0127] In one embodiment, such as Figure 7As shown, a model testing device 1 is provided, comprising: an acquisition module 10, a first rewriting module 20, and a first testing module 30, wherein:
[0128] Module 10 is used to obtain the first test question and at least two different rewrite patterns for the first test question;
[0129] The first rewriting module 20 is used to rewrite the first test problem based on different first problem rewriting modes, so as to obtain the first test problem set corresponding to each first problem rewriting mode;
[0130] The first test module 30 is used to test the model to be tested based on each first test question set and obtain the model test results.
[0131] The model testing apparatus of this application acquires a first test problem and at least two different rewriting modes of the first problem. Based on each rewriting mode, it rewrites the first test problem to obtain a first test problem set corresponding to each rewriting mode. Then, based on each first test problem set, it tests the model to be tested to obtain the model test results. This application can rewrite the first test problem based on different rewriting modes to obtain a first test problem set, and then test the model to be tested based on the first test problem set, effectively improving the efficiency of test problem set generation, thereby improving the testing efficiency and accuracy of the model to be tested.
[0132] In one embodiment, the model under test includes a first model under test; the first testing module is further specifically used for:
[0133] Based on each set of first test questions, the first model to be tested is tested to obtain the test results of the first model; wherein, the test results of the first model include the vulnerability test success rate corresponding to each first question rewriting mode.
[0134] In one embodiment, the model under test further includes a second model under test; a model testing device 1 further includes:
[0135] The sorting module is used to sort the rewrite patterns of each first problem in descending order according to the success rate of vulnerability testing, and obtain the first sorting result;
[0136] The determination module is used to select, based on the first sorting result, a first preset number of first question rewriting patterns that are ranked first as second question rewriting patterns from each first question rewriting pattern;
[0137] The second rewriting module is used to rewrite the second test question based on the second question rewriting pattern to obtain the second test question set;
[0138] The second testing module is used to test the second model under test based on the second set of test questions, and obtain the test results of the second model.
[0139] In one embodiment, the second test question set includes a single-mode test question set and a mixed-mode test question set; the single-mode test question set includes the test question set corresponding to each second question rewriting mode; the mixed-mode test question set includes the test questions corresponding to the mixed rewriting mode; the mixed rewriting mode consists of at least two second question rewriting modes;
[0140] The second model test results include the vulnerability test success rate corresponding to each second problem rewriting mode and / or the vulnerability test success rate corresponding to the hybrid rewriting mode.
[0141] In one embodiment, the first test module is further specifically used for:
[0142] The second test question is processed by word segmentation to obtain at least one candidate word group;
[0143] Determine the importance of each candidate phrase;
[0144] Based on the rewriting pattern of the second question, each candidate phrase, and the importance of each candidate phrase, a second set of test questions is generated.
[0145] In one embodiment, the first test module is further specifically used for:
[0146] Based on the importance of each candidate word group, the candidate word groups are sorted in descending order to obtain the second sorting result;
[0147] Based on the second sorting result, select the second preset number of candidate word groups that are ranked first as the target word groups;
[0148] Based on the rewriting pattern of the second question, the target phrase is rewritten to obtain the second set of test questions.
[0149] In one embodiment, the first test module is further specifically used for:
[0150] For each round, a target problem rewriting pattern is selected from the second problem rewriting patterns based on a random selection rule;
[0151] Based on the target question rewriting pattern, the target phrases are rewritten to obtain the test questions corresponding to the hybrid rewriting pattern;
[0152] If the number of rounds reaches a preset threshold, a set of mixed-mode test questions is determined based on the test questions corresponding to the mixed rewrite patterns obtained in the current round and before the current round.
[0153] In one embodiment, at least two different first-problem rewriting modes include at least two of the following: text disorder rewriting mode, text deformation rewriting mode, text obfuscation rewriting mode, text encryption rewriting mode, pinyin combination rewriting mode, synonym deformation rewriting mode, and adding irrelevant content rewriting mode.
[0154] Each module in the aforementioned model testing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0155] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 8 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores information related to apartment resources. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a model testing method.
[0156] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0157] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0158] Obtain the first test question and at least two different rewrite patterns for the first test question;
[0159] Based on different rewriting modes of the first question, the first test question is rewritten respectively to obtain the first test question set corresponding to each first question rewriting mode;
[0160] Based on each set of first test questions, the model to be tested is tested, and the model test results are obtained.
[0161] In one embodiment, when the processor executes the computer program, it further performs the following steps: the model under test includes a first model under test; based on each first set of test questions, the model under test is tested to obtain model test results, including:
[0162] Based on each set of first test questions, the first model to be tested is tested to obtain the test results of the first model; wherein, the test results of the first model include the vulnerability test success rate corresponding to each first question rewriting mode.
[0163] In one embodiment, when the processor executes the computer program, it further performs the following steps: the model under test further includes a second model under test; the method further includes:
[0164] Based on the success rate of vulnerability testing, the rewrite patterns of each first problem are sorted in descending order to obtain the first ranking result;
[0165] Based on the first sorting result, select the first preset number of first question rewriting patterns that are ranked first from each first question rewriting pattern as the second question rewriting pattern;
[0166] Based on the rewriting pattern of the second question, the second test question is rewritten to obtain the second test question set;
[0167] Based on the second set of test questions, the second model to be tested is tested, and the test results of the second model are obtained.
[0168] In one embodiment, when the processor executes the computer program, it further performs the following steps: the second test problem set includes a single-mode test problem set and a mixed-mode test problem set; the single-mode test problem set includes a test problem set corresponding to each second problem rewriting mode; the mixed-mode test problem set includes test problems corresponding to mixed rewriting modes; the mixed rewriting mode consists of at least two second problem rewriting modes;
[0169] The second model test results include the vulnerability test success rate corresponding to each second problem rewriting mode and / or the vulnerability test success rate corresponding to the hybrid rewriting mode.
[0170] In one embodiment, when the processor executes the computer program, it further performs the following steps: rewriting the second test problem based on the second problem rewriting pattern to obtain a second test problem set, including:
[0171] The second test question is processed by word segmentation to obtain at least one candidate word group;
[0172] Determine the importance of each candidate phrase;
[0173] Based on the rewriting pattern of the second question, each candidate phrase, and the importance of each candidate phrase, a second set of test questions is generated.
[0174] In one embodiment, when the processor executes the computer program, it further performs the following steps: generating a second test question set based on the second question rewriting pattern, each candidate word group, and the importance of each candidate word group, including:
[0175] Based on the importance of each candidate word group, the candidate word groups are sorted in descending order to obtain the second sorting result;
[0176] Based on the second sorting result, select the second preset number of candidate word groups that are ranked first as the target word groups;
[0177] Based on the rewriting pattern of the second question, the target phrase is rewritten to obtain the second set of test questions.
[0178] In one embodiment, when the processor executes the computer program, it further performs the following steps: rewriting the target phrase according to the second question rewriting pattern to obtain a second test question set, including:
[0179] For each round, a target problem rewriting pattern is selected from the second problem rewriting patterns based on a random selection rule;
[0180] Based on the target question rewriting pattern, the target phrases are rewritten to obtain the test questions corresponding to the hybrid rewriting pattern;
[0181] If the number of rounds reaches a preset threshold, a set of mixed-mode test questions is determined based on the test questions corresponding to the mixed rewrite patterns obtained in the current round and before the current round.
[0182] In one embodiment, when the processor executes the computer program, it further performs the following steps: at least two different first-problem rewriting modes, including at least two of the following: text disorder rewriting mode, text deformation rewriting mode, text obfuscation rewriting mode, text encryption rewriting mode, pinyin combination rewriting mode, synonym deformation rewriting mode, and adding irrelevant content rewriting mode.
[0183] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0184] Obtain the first test question and at least two different rewrite patterns for the first test question;
[0185] Based on different rewriting modes of the first question, the first test question is rewritten respectively to obtain the first test question set corresponding to each first question rewriting mode;
[0186] Based on each set of first test questions, the model to be tested is tested, and the model test results are obtained.
[0187] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: the model under test includes a first model under test; based on each first set of test questions, the model under test is tested to obtain model test results, including:
[0188] Based on each set of first test questions, the first model to be tested is tested to obtain the test results of the first model; wherein, the test results of the first model include the vulnerability test success rate corresponding to each first question rewriting mode.
[0189] In one embodiment, when the computer program is executed by a processor, it further implements the following steps: the model under test further includes a second model under test; the method further includes:
[0190] Based on the success rate of vulnerability testing, the rewrite patterns of each first problem are sorted in descending order to obtain the first ranking result;
[0191] Based on the first sorting result, select the first preset number of first question rewriting patterns that are ranked first from each first question rewriting pattern as the second question rewriting pattern;
[0192] Based on the rewriting pattern of the second question, the second test question is rewritten to obtain the second test question set;
[0193] Based on the second set of test questions, the second model to be tested is tested, and the test results of the second model are obtained.
[0194] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: the second test problem set includes a single-mode test problem set and a mixed-mode test problem set; the single-mode test problem set includes a test problem set corresponding to each second problem rewriting mode; the mixed-mode test problem set includes test problems corresponding to mixed rewriting modes; the mixed rewriting mode consists of at least two second problem rewriting modes;
[0195] The second model test results include the vulnerability test success rate corresponding to each second problem rewriting mode and / or the vulnerability test success rate corresponding to the hybrid rewriting mode.
[0196] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: rewriting the second test problem based on the second problem rewriting pattern to obtain a second test problem set, including:
[0197] The second test question is processed by word segmentation to obtain at least one candidate word group;
[0198] Determine the importance of each candidate phrase;
[0199] Based on the rewriting pattern of the second question, each candidate phrase, and the importance of each candidate phrase, a second set of test questions is generated.
[0200] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: generating a second set of test questions based on a second question rewriting pattern, each candidate phrase, and the importance of each candidate phrase, including:
[0201] Based on the importance of each candidate word group, the candidate word groups are sorted in descending order to obtain the second sorting result;
[0202] Based on the second sorting result, select the second preset number of candidate word groups that are ranked first as the target word groups;
[0203] Based on the rewriting pattern of the second question, the target phrase is rewritten to obtain the second set of test questions.
[0204] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: rewriting the target phrase according to the second question rewriting pattern to obtain a second test question set, including:
[0205] For each round, a target problem rewriting pattern is selected from the second problem rewriting patterns based on a random selection rule;
[0206] Based on the target question rewriting pattern, the target phrases are rewritten to obtain the test questions corresponding to the hybrid rewriting pattern;
[0207] If the number of rounds reaches a preset threshold, a set of mixed-mode test questions is determined based on the test questions corresponding to the mixed rewrite patterns obtained in the current round and before the current round.
[0208] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: at least two different first-problem rewriting modes, including at least two of the following: text disorder rewriting mode, text deformation rewriting mode, text obfuscation rewriting mode, text encryption rewriting mode, pinyin combination rewriting mode, synonym deformation rewriting mode, and adding irrelevant content rewriting mode.
[0209] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:
[0210] Obtain the first test question and at least two different rewrite patterns for the first test question;
[0211] Based on different rewriting modes of the first question, the first test question is rewritten respectively to obtain the first test question set corresponding to each first question rewriting mode;
[0212] Based on each set of first test questions, the model to be tested is tested, and the model test results are obtained.
[0213] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: the model under test includes a first model under test; based on each first set of test questions, the model under test is tested to obtain model test results, including:
[0214] Based on each set of first test questions, the first model to be tested is tested to obtain the test results of the first model; wherein, the test results of the first model include the vulnerability test success rate corresponding to each first question rewriting mode.
[0215] In one embodiment, when the computer program is executed by a processor, it further implements the following steps: the model under test further includes a second model under test; the method further includes:
[0216] Based on the success rate of vulnerability testing, the rewrite patterns of each first problem are sorted in descending order to obtain the first ranking result;
[0217] Based on the first sorting result, select the first preset number of first question rewriting patterns that are ranked first from each first question rewriting pattern as the second question rewriting pattern;
[0218] Based on the rewriting pattern of the second question, the second test question is rewritten to obtain the second test question set;
[0219] Based on the second set of test questions, the second model to be tested is tested, and the test results of the second model are obtained.
[0220] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: the second test problem set includes a single-mode test problem set and a mixed-mode test problem set; the single-mode test problem set includes a test problem set corresponding to each second problem rewriting mode; the mixed-mode test problem set includes test problems corresponding to mixed rewriting modes; the mixed rewriting mode consists of at least two second problem rewriting modes;
[0221] The second model test results include the vulnerability test success rate corresponding to each second problem rewriting mode and / or the vulnerability test success rate corresponding to the hybrid rewriting mode.
[0222] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: rewriting the second test problem based on the second problem rewriting pattern to obtain a second test problem set, including:
[0223] The second test question is processed by word segmentation to obtain at least one candidate word group;
[0224] Determine the importance of each candidate phrase;
[0225] Based on the rewriting pattern of the second question, each candidate phrase, and the importance of each candidate phrase, a second set of test questions is generated.
[0226] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: generating a second set of test questions based on a second question rewriting pattern, each candidate phrase, and the importance of each candidate phrase, including:
[0227] Based on the importance of each candidate word group, the candidate word groups are sorted in descending order to obtain the second sorting result;
[0228] Based on the second sorting result, select the second preset number of candidate word groups that are ranked first as the target word groups;
[0229] Based on the rewriting pattern of the second question, the target phrase is rewritten to obtain the second set of test questions.
[0230] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: rewriting the target phrase according to the second question rewriting pattern to obtain a second test question set, including:
[0231] For each round, a target problem rewriting pattern is selected from the second problem rewriting patterns based on a random selection rule;
[0232] Based on the target question rewriting pattern, the target phrases are rewritten to obtain the test questions corresponding to the hybrid rewriting pattern;
[0233] If the number of rounds reaches a preset threshold, a set of mixed-mode test questions is determined based on the test questions corresponding to the mixed rewrite patterns obtained in the current round and before the current round.
[0234] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: at least two different first-problem rewriting modes, including at least two of the following: text disorder rewriting mode, text deformation rewriting mode, text obfuscation rewriting mode, text encryption rewriting mode, pinyin combination rewriting mode, synonym deformation rewriting mode, and adding irrelevant content rewriting mode.
[0235] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0236] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0237] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A model testing method, characterized in that, The method includes: Obtain the first test question and at least two different rewrite patterns for the first test question; Based on different rewriting modes of the first problem, the first test problem is rewritten respectively to obtain the first test problem set corresponding to each rewriting mode of the first problem; Based on each of the first test question sets, the model to be tested is tested, and the model test results are obtained.
2. The method according to claim 1, characterized in that, The model to be tested includes a first model to be tested; the step of testing the model to be tested based on each of the first test question sets to obtain model test results includes: Based on each of the first test problem sets, the first model to be tested is tested to obtain the first model test results; wherein, the first model test results include the vulnerability test success rate corresponding to each first problem rewriting mode.
3. The method according to claim 2, characterized in that, The model to be tested further includes a second model to be tested; the method further includes: Based on the success rate of the vulnerability test, the rewrite patterns of each first problem are sorted in descending order to obtain the first sorting result; Based on the first sorting result, select the first preset number of first question rewriting patterns that are ranked first from each first question rewriting pattern as the second question rewriting pattern; Based on the second problem rewriting pattern, the second test problem is rewritten to obtain the second test problem set; Based on the second set of test questions, the second model to be tested is tested to obtain the test results of the second model.
4. The method according to claim 3, characterized in that, The second test question set includes a single-mode test question set and a mixed-mode test question set; the single-mode test question set includes the test question set corresponding to each second question rewriting mode; the mixed-mode test question set includes the test questions corresponding to the mixed rewriting modes; the mixed rewriting mode consists of at least two second question rewriting modes; The test results of the second model include the vulnerability test success rate corresponding to each second problem rewriting mode and / or the vulnerability test success rate corresponding to the hybrid rewriting mode.
5. The method according to claim 3, characterized in that, The second test problem is rewritten based on the second problem rewriting pattern to obtain a second test problem set, including: The second test question is segmented to obtain at least one candidate word group; Determine the importance of each candidate phrase; Based on the rewriting pattern of the second question, each candidate phrase, and the importance of each candidate phrase, a second set of test questions is generated.
6. The method according to claim 5, characterized in that, The step of generating a second test question set based on the second question rewriting pattern, each candidate phrase, and the importance of each candidate phrase includes: Based on the importance of each candidate word group, the candidate word groups are sorted in descending order to obtain the second sorting result; Based on the second sorting result, select the second preset number of candidate word groups that are ranked first as the target word groups; Based on the second question rewriting pattern, the target phrase is rewritten to obtain the second test question set.
7. The method according to claim 6, characterized in that, The second test question set is obtained by rewriting the target phrase according to the second question rewriting pattern, including: For each round, a target problem rewriting pattern is selected from the second problem rewriting pattern based on a random selection rule; Based on the target question rewriting pattern, the target phrase is rewritten to obtain the test question corresponding to the hybrid rewriting pattern; If the number of rounds reaches a preset threshold, a set of mixed-mode test questions is determined based on the test questions corresponding to the mixed rewriting modes obtained in the current round and before the current round.
8. The method according to any one of claims 1-7, characterized in that, The at least two different first-problem rewriting modes include at least two of the following: text disorder rewriting mode, text deformation rewriting mode, text obfuscation rewriting mode, text encryption rewriting mode, pinyin combination rewriting mode, synonym deformation rewriting mode, and adding irrelevant content rewriting mode.
9. A model testing device, characterized in that, include: The acquisition module is used to acquire the first test question and at least two different rewrite patterns for the first test question; The first rewriting module is used to rewrite the first test problem based on different first problem rewriting modes to obtain a first test problem set corresponding to each first problem rewriting mode; The first testing module is used to test the model to be tested based on each of the first test question sets, and obtain the model test results.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the model testing method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the model testing method according to any one of claims 1 to 8.
12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the model testing method according to any one of claims 1 to 8.