Large model reasoning ability test method and framework based on metamorphic test
Through the method and framework based on transformation testing, the seven-element transformation relationship template and transformation function are used to solve the Oracle problem in the evaluation of large model reasoning capabilities, achieve efficient test case construction and evaluation, and reduce costs and human resource requirements.
Patent Information
- Application Number
- CN202410738682.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-03
AI Technical Summary
It is difficult to accurately construct test cases to evaluate the reasoning ability of large models with existing technology, which makes Oracle problems difficult to solve in software testing, and traditional testing methods are inefficient and costly.
Using the method and framework based on transformation testing, by dynamically acquiring and updating the test case set, a seven-element transformation relationship template is designed, combined with the transformation function method, to achieve efficient transformation relationship design and application, and use the error detection rate to optimize the test logic.
It significantly improves the operability and interpretability of transformation relationship design, alleviates the problem of expected construction in large-scale testing, and enhances the efficiency and accuracy of large model reasoning ability evaluation.
Smart Images

Figure CN118585447A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software testing technology, and in particular to a technology for testing and evaluating large model reasoning capabilities, and in particular to a large model reasoning capability testing method and framework based on metamorphosis testing. Background Art
[0002] As a new AI technology that has emerged in recent years, the large language model has developed rapidly and has great potential. It is true that the development and creation of intelligent models and algorithms are important, and they are the direct driving force for the continuous development of new technologies. However, we must also face the fact that our ability to explain AI technology is getting weaker and weaker, and our ability to fully control the technology is threatened. To evaluate and test the model, in simple terms, is to use human wisdom to challenge the design problems of AI. Every successful challenge means that human wisdom still outperforms machine wisdom.
[0003] Relevant literature shows that articles and technologies related to large model evaluation methods have been published and published in 2023, such as the HaluEval evaluation standard proposed by Junyi Li et al (2023) for large-scale hallucination problems, the new ANALOGICAL benchmark proposed by Thilini Wijesiriwardene et al (2023) for long text analogy evaluation problems, and the LLM-EVAL unified multi-dimensional automatic evaluation method built based on open domain dialogue by Yen-Ting Lin et al (2023). The mainstream orientation of large model evaluation and testing in the industry is mainly in two aspects: one is high performance, which can effectively conduct evaluation and testing of multiple different models; the other is low cost, including costs at multiple levels such as funding, time, and manpower.
[0004] Software testing is a crucial part of the entire life cycle of software development and plays an indispensable role in software quality assurance. The traditional software testing technology route evaluates the software under test by comparing whether the actual output of the set test case is equal to the expected output. However, in many cases, it is difficult for testers to accurately construct the expected output of the test case to achieve a comparison between the actual output and the expected output. This is the Oracle problem of software testing.
[0005] In order to solve the Oracle problem, Chen TY and others from Swinburne University in Australia proposed the concept of metamorphic testing. By setting a certain scale of correct test cases, according to the metamorphic relationships that have been mined and constructed, iterative changes are made on the basis of existing test cases to generate new test cases. While continuously improving and expanding the scale and scope of the test case set, there is no need to carry out boring and inefficient test case data set annotation work. Sometimes, even this original manual annotation work is limited by the background knowledge of the annotators, and it is difficult to ensure high reliability and accuracy. Summary of the invention
[0006] In order to solve the above problems and technical defects, the present invention provides a large model reasoning ability testing method and framework based on metamorphic testing. The framework includes three modules: use case method preparation, template combination construction, and test execution process, which correspond to different links in the metamorphic relationship design. Among them, the use case method preparation module is responsible for dynamically acquiring and updating the initial test case set and continuously enriching and improving the metamorphic function method library; in the template combination construction module, according to the metamorphic testing technology principle, a six-element metamorphic relationship template concept is proposed for the practical problems faced in the field of large model testing, and combined with the characteristics of reasoning tasks, a seven-element metamorphic relationship template suitable for reasoning tasks is further proposed; the test execution process module comprehensively uses the technical and theoretical achievements formed by the first two modules, and under the guidance of the metamorphic relationship template, efficiently uses different metamorphic function methods to realize the design and practical application of metamorphic relationships. It provides a possible analytical solution and idea for the research on metamorphic testing in the field of large model reasoning ability evaluation, and effectively improves the development process of applying metamorphic testing technology to the field of large model reasoning ability evaluation.
[0007] In order to achieve the above object, the present invention adopts the following technical solutions:
[0008] On the one hand, the present invention provides a large model reasoning ability testing method based on metamorphosis testing, comprising:
[0009] Step 1: Collect and obtain the latest large model test benchmark data, and extract the test case data as the initial test case set. At the same time, update and improve the transformation function method library by designing and implementing different transformation functions;
[0010] Step 2: In the context of the actual task of evaluating the reasoning ability of large models, different transformation relationship templates are constructed through different combinations of seven elements; the seven elements include the target large model, prompt words, antecedents, consequents, output text, functions between input data, and functions between output data; antecedents refer to the conditional part of the reasoning task; consequents refer to the judgment content of the situation of things that depend on certain conditions in the reasoning task;
[0011] Step 3: Based on the different metamorphosis relationship templates that have been constructed, by selecting metamorphosis function methods with different effects, specifying the corresponding input data function and output data function relationship, the metamorphosis relationship is designed, and the actual metamorphosis test process is performed in combination with the collected initial test case set; and based on the actual test execution results of the metamorphosis relationship, the error detection rate is used on the same initial test case data set to represent the error detection ability of different metamorphosis relationships, and the transformation relationship execution logic of the metamorphosis test is optimized and updated through the dynamic update of the error detection rate.
[0012] Furthermore, the initial test cases in the initial test case set are designed in the following manner:
[0013] X A =Prompt A +Consequence+(Antecedent1+Antecedent2)
[0014] X C =Prompt C +Antecedent+(Consequence1+Consequence2)
[0015] Where X A represents the inductive antecedent test case, X C Indicates the deduction of the aftermath class test case, Prompt A Prompt word design for inductive antecedent test cases, C It indicates the prompt word design of the deduced consequent test case; Antecedent1 and Antecedent2 indicate two different antecedents in the inductive antecedent test case; Consequence1 and Consequence2 indicate two different consequents in the deduced consequent test case.
[0016] Furthermore, the transformation function includes: a predefined semantic-level language translation transformation function MR_FY, a sentence-level context replacement function MR_AC and a system-level target big model transformation function MR_LA; the MR_FY obtains a translation text that has undergone mapping transformation to varying degrees through a pre-constructed single-round translation iteration based on a small language or multiple-round translation iterations based on the official language of the United Nations; the MR_AC constructs a derivative test case with the opposite direction according to the direction of the big model reasoning task to which the initial test case belongs, and correspondingly swaps the structure of the input text and the output text, transforming the positive context relationship in the initial test case into the reverse context relationship in the derived test case set; the MR_LA uses the transformation function to directly transform the big model being tested, and transforms the target big model into an intelligent agent developed based on the big model.
[0017] Furthermore, the output data function includes a get_predict function, which extracts the final reasoning option answer from the generative answer text of the large model for subsequent result verification.
[0018] Furthermore, the transformation relationship template includes a transformation template MRT1 based on the reasoning result of the use case, which remains unchanged; a transformation template MRT2 based on the reasoning link of the use case, which remains unchanged; and a transformation template MRT3 based on the reasoning result of the large model, which remains unchanged.
[0019] Furthermore, in the MRT1, the input data function uses MR_FY, and the output data function uses the get_predict function, and the options of the generative text are extracted to design the corresponding metamorphosis relationship MR1; MR1 satisfies: the use case content expressed in different languages finally obtains a consistent reasoning result.
[0020] Furthermore, in the MRT2, the function between input data adopts MR_AC, and the function between output data adopts get_predict function, and the corresponding metamorphosis relationship MR2 is designed; MR2 satisfies: there are antecedents and antecedents of the deductive reasoning relationship, and in inductive reasoning, it has a belonging relationship of the set, and there are antecedents and antecedents of the inductive reasoning relationship, and in deductive reasoning, it has a belonging relationship of the set.
[0021] Furthermore, in the MRT3, the function between input data adopts MR_LA, and the function between output data adopts get_predict function, and the corresponding metamorphosis relationship MR3 is designed. MR3 satisfies: when the input test case remains unchanged, different target large models with the same function or intelligent agents built based on the target large model are changed to finally obtain consistent reasoning results.
[0022] Furthermore, the step 3 comprises:
[0023] According to the obtained design requirements of the metamorphic relationship template, the pre-designed input data function with the specified effect is applied to the initial test case to obtain the corresponding derived test case, and then the initial test case and the derived test case are respectively combined with the designed prompt words, and the target large model is input to obtain the initial test output and the derived test output, so as to check whether the two output results conform to the output data function selected by the metamorphic relationship template to determine whether the designed metamorphic relationship is satisfied; at the same time, for the same initial test case set, based on different metamorphic relationship templates combined with different input data functions and output data functions to form different metamorphic relationships, their error detection capabilities are quantitatively evaluated through the error detection rate, and the evaluation results of the error detection capabilities of each metamorphic relationship in this round of testing are fed back to the metamorphic test framework to optimize the deployment and use of metamorphic relationships in the test framework.
[0024] On the other hand, the present invention proposes a large model reasoning capability testing framework based on metamorphic testing, including:
[0025] The use case method preparation module is used to collect the latest large model test benchmark data and extract the test case data as the initial test case set. At the same time, the transformation function method library is updated and improved by designing and implementing different transformation functions.
[0026] The template combination building module is used to build different transformation relationship templates through different combinations of seven elements in the actual task background of large model reasoning ability evaluation; the seven elements include the target large model, prompt words, antecedents, consequents, output texts, functions between input data and functions between output data; antecedents refer to the conditional part of the reasoning task; consequents refer to the judgment content of the situation of things that depend on certain conditions in the reasoning task;
[0027] The test execution process module is used to design the transformation relationship based on the different transformation relationship templates that have been constructed, by selecting the transformation function methods with different effects, specifying the corresponding input data function and output data function relationship, and combining the collected initial test case set to execute the actual transformation test process; and based on the actual test execution results of the transformation relationship, the error detection rate is used to represent the error detection ability of different transformation relationships on the same initial test case data set, and the transformation relationship execution logic of the transformation test is optimized and updated through the dynamic update of the error detection rate.
[0028] Compared with the prior art, the present invention has the following beneficial effects:
[0029] The present invention first dynamically acquires and updates the initial test case set and continuously enriches and improves the metamorphic function method library; in view of the practical problems faced in the field of large model testing, according to the principle of metamorphic testing technology, a metamorphic relationship template concept of six elements is proposed: target large model, prompt word, input text, output text, input data function and output data function, and combined with the characteristics of the reasoning task, the input text is further disassembled into antecedent and consequent, and a seven-element metamorphic relationship template suitable for the reasoning task is obtained to guide the design process of the metamorphic relationship; then the technical and theoretical achievements formed by the first two steps are comprehensively used, and different metamorphic function methods are efficiently used under the guidance of the metamorphic relationship template to realize the design and practical application of the metamorphic relationship, and based on the metamorphic relationship judgment result, the metamorphic relationship error rate is introduced, and the quantitative feedback framework of the error rate for the metamorphic relationship error-revealing ability is used to optimize the execution order of the metamorphic relationship. The present invention provides a possible analytical solution and idea for the research on metamorphic testing in the field of large model reasoning ability evaluation, and effectively improves the development process of applying metamorphic testing technology to the field of large model reasoning ability evaluation.
[0030] The present invention can effectively assist the application of metamorphosis testing technology in the field of large models, efficiently sort out the logic and links of framework construction, and significantly enhance the operability and explainability of the metamorphosis relationship design process; the present invention can effectively alleviate the expected construction problems of large-scale testing, that is, the Oracle problem in the field of software testing; it can also provide methods and ideas for metamorphosis testing application research in the field of large models, and adjust and adapt the invention according to specific problems and tasks to assist in supporting the test evaluation research of large model capabilities. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A large model reasoning capability testing method and framework schematic diagram based on metamorphosis testing according to an embodiment of the present invention;
[0032] Figure 2 A schematic diagram of a test case design provided for an embodiment of the present invention;
[0033] Figure 3 A schematic diagram of the specific relationship between the transformation relationship, the transformation relationship template and the transformation function provided in an embodiment of the present invention;
[0034] Figure 4 A schematic diagram of the principle of the preceding and following substitution function provided by an embodiment of the present invention;
[0035] Figure 5 This is a flow chart of a large model reasoning capability testing method based on metamorphosis testing according to an embodiment of the present invention;
[0036] Figure 6 This is a module diagram of a large model reasoning capability testing framework based on metamorphosis testing in an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments:
[0038] Example 1
[0039] like Figure 1 As shown, a large model reasoning ability testing method based on metamorphosis testing includes:
[0040] S101. To ensure the timeliness and richness of the test cases used to build the framework, regularly collect and obtain newly released benchmark test data related to the evaluation of large model reasoning capabilities, and extract the test cases used for testing and evaluation, so as to accumulate more diverse initial test case data for the construction of the test framework; simultaneously, implement the metamorphosis function through design, and update the metamorphosis function method library. The specific deployment of the metamorphosis function method library can be flexibly designed according to specific task requirements;
[0041] S102. Starting from the three-layer abstract logic of large model testing, metamorphosis testing and reasoning ability evaluation tasks, the research work of metamorphosis testing in the field of large model reasoning ability evaluation is analyzed and deconstructed to form a metamorphosis relationship template for guiding the design of metamorphosis relationship. Research background Aiming at the test field of large models, the development foundation of large model testing is summarized into four elements: target large model LLMs, prompt word Prompt, input text Input and output text Output; according to the principle of metamorphosis testing technology, the "two elements and one process" architecture of metamorphosis testing including metamorphosis relationship, test case and metamorphosis test execution process is further refined, focusing on the metamorphosis relationship, and summarizing it into two core elements: input data function In_Func and output data function Out_Func. Combined with the characteristics of reasoning ability evaluation tasks, considering the format of the initial test cases collected in S101, the input text element Input is further decomposed into antecedent Antecedent and consequent Consequence, and a metamorphosis relationship template containing seven elements is obtained, which further assists the application of metamorphosis testing technology in the field of large model reasoning ability testing.
[0042] S103. Using the metamorphosis relationship template constructed in S102, different specific templates are formed from the perspective of logical design through different combinations of seven elements. Based on the combination requirements of the specific template and combined with the resources and methods prepared in advance for each element, the metamorphosis relationship template at the abstract framework level is transformed into a metamorphosis relationship including specific input data functions and output data functions. Among them, based on the operation of S101, the collected initial test case set will serve as the data source for the antecedent and the consequent, and the continuously updated and improved metamorphosis function method library will provide candidate metamorphosis function methods for the input data function In_Func and the output data function Out_Func. Relying on the guiding role of the metamorphosis relationship template and utilizing the accumulation of specific initial test cases and the metamorphosis function method library, the interpretability of the metamorphosis relationship design process is significantly improved, the design efficiency is greatly stimulated, and it can be quickly put into the work of evaluating the reasoning ability of the target large model.
[0043] Furthermore, the initial test case is designed based on the seven-element metamorphosis relation template, which includes three elements: prompt, antecedent, and consequence (input text). By referring to the design structure of the e-CARE interpretable causal reasoning dataset, the large model reasoning task is divided into two directions: deducing the consequent and inducing the antecedent, and a multiple-choice question containing two options is used as the test case template. The specific expression is as follows:
[0044] X A =Prompt A+Consequence+(Antecedent1+Antecedent2)
[0045] X C =Prompt C +Antecedent+(Consequence1+Consequence2)
[0046] The symbols in the formula have the following meanings:
[0047] 1.X A : Inductive antecedent class test cases;
[0048] 2.X C : Deducing post-processing test cases;
[0049] 3. Prompt A : Design of prompt words for inductive antecedent class;
[0050] 4. Prompt C : Design of prompt words for deducing the aftermath;
[0051] 5.Antecedent n : Antecedent, has two choices in the inductive antecedent class;
[0052] 6.Consequence n : Consequence, there are two choices in the deduction of the consequent class;
[0053] Specific design such as Figure 2 shown.
[0054] Furthermore, the transformation relationship, transformation relationship template and transformation function (function between input data and function between output data) are different levels of concepts for actual transformation test tasks. Among them, the transformation relationship is defined at the level of the software system under test. Exploring and developing diversified transformation relationships from more angles is the core task of efficiently applying the transformation testing technology. The design of the transformation relationship is the basis and reference to ensure the smooth implementation of the transformation test; the transformation relationship template is an auxiliary construction and analysis method at the level of the transformation relationship, and the design and development of the transformation relationship is guided by the template form of the logical abstraction level. The function between input data and the function between output data are actual transformation operations and methods carried out at the level of test cases and test outputs. They are the technical basis for generating derived test cases based on initial test cases, and are the means and methods for checking whether the test outputs satisfy the transformation relationship; the specific relationship between the three is as follows: Figure 3 shown.
[0055] Furthermore, the seven-element parsing architecture of the metamorphosis relationship template for large model reasoning tasks summarizes and sorts out the typical characteristics of the large model testing field and the metamorphosis test, and obtains the target large model LLMs, prompt word Prompt, input text Input, output text Output, input data function In_Func and output data function Out_Func; at the same time, the present invention is designed for large model reasoning tasks, and further decomposes the Input into the antecedent Antecedent and the consequent Consequence based on logical reasoning knowledge.
[0056] Specifically, the target big model LLMs refers to the specific big model selected to be tested. The big models used in the present invention include but are not limited to Baidu Qianfan ERNIE-Bot, Tsinghua University ChatGLM, and iFLYTEK Spark.
[0057] The prompt word refers to the prompt text designed to ensure that the large model accurately and effectively understands the test task. According to the different test case types, it is divided into inductive antecedent prompt words and deductive consequent prompt words; according to the different test question paths, it is divided into direct questions, CoT thinking chain questions, and Agent intelligent body questions.
[0058] Antecedent refers to the conditional part of the reasoning task.
[0059] Consequence refers to the judgment content of the situation of things that depends on certain conditions in the reasoning task.
[0060] The output text Output refers to the feedback information of the big model obtained when the big model is used to perform reasoning tasks. According to different test question paths, it is divided into direct question output, CoT thinking chain question output, and Agent intelligent body question output. By sorting and parsing different types of output texts in corresponding formats, the answer part is extracted to determine the statistical big model's answer situation.
[0061] The input data function In_Func refers to a specific function method that can be used to generate derivative test cases. By continuously updating the rich metamorphosis function method library, the types and effects of the input data functions are continuously supplemented and improved. The present invention provides predefined semantic-level language translation transformation functions, sentence-level context replacement functions, and system-level target large model transformation functions.
[0062] The language translation transformation function MR_FY is used to obtain translation texts that have undergone mapping transformations to different degrees through pre-constructed single-round translation iterations based on minority languages or multiple-round translation iterations based on the six official languages of the United Nations.
[0063] The function of the context replacement function MR_AC is to construct a derivative test case with the opposite direction according to the direction of the large model reasoning task to which the initial test case belongs, and to perform a structural exchange of the input text and the output text accordingly, so as to transform the positive context relationship in the initial test case into the reverse context relationship in the derived test case set. The specific process is as follows: Figure 4 shown.
[0064] The target large model transformation function MR_LA has the following functions: on the one hand, it uses the transformation function to directly transform the test large model; on the other hand, it transforms the target large model into an intelligent entity developed based on the large model.
[0065] The output data function Out_Func refers to a specific functional relationship between the initial test output and the derived test output corresponding to the specific input data function. The present invention designs the get_predict function: the function can extract the final reasoning option answer from the generative answer text of the large model for subsequent result verification. The corresponding combination relationship between the input data function and the output data function is the metamorphosis relationship obtained through the framework process design.
[0066] Furthermore, the three typical metamorphosis relationship templates for large model reasoning tasks: MRT1, MRT2 and MRT3 are classic templates with guiding significance that are constructed through different combinations of seven elements.
[0067] Specifically, MRT1 is a transformation template based on the reasoning result of the use case. According to the seven elements of the transformation relationship template, the function between the input data acts on the input predecessor and successor, and the difference between the derived test case and the initial test case is only reflected in the input use case content, without affecting other elements. At the same time, the transformation relationship template that keeps the test output after reasoning is consistent. Substitute the function MR_FY into the function In_Func between the input data and the function Out_Func between the output data as the get_predict function, extract the options of the generated text, and a MR1 is designed. This transformation relationship meets the following conditions: the use case content expressed in different languages should eventually get a consistent reasoning result.
[0068] MRT2 is a use case-based reasoning link unchanged metamorphosis template. This template, like MRT1, applies the input data function to the test case input. Since the change target of MRT1 points to the test case content level, the specific input data function used is the semantic-level language translation transformation function; MRT2 changes the test case structure level, so the predefined structure-level antecedent and posterior replacement function MR_AC is used as the input data function, and the output data function Out_Func uses the get_predict function. At the same time, the additional result must be a correct judgment condition. The metamorphosis relationship MR2 is designed in this way. This metamorphosis relationship meets the following conditions: there are antecedents and antecedents of the deductive reasoning relationship, and in inductive reasoning, they have a set belonging relationship; similarly, there are antecedents and antecedents of the inductive reasoning relationship, and in deductive reasoning, they have a set belonging relationship.
[0069] MRT3 is a metamorphosis template based on the reasoning result of the large model. This template applies the input data function to the target large model LLMs element, uses the system-level target large model transformation function MR_LA as the input data function, and the get_predict function as the output data function. MR3 can be designed from different perspectives of the template. This metamorphosis relationship meets the following conditions: when the input test case remains unchanged, changing different target large models with the same function or the intelligent agent built based on the target large model should eventually obtain consistent reasoning results.
[0070] Example 2
[0071] Based on the above embodiments, Figure 1 As shown, the present invention also proposes a large model reasoning capability testing framework based on metamorphosis testing, and the testing framework consists of three modules: use case method preparation, template combination construction, and test execution process.
[0072] The use case method preparation module is used to collect and extract the test cases used in the latest large model reasoning task test benchmark as initial test cases and update the enriched transformation function method library as a candidate transformation function method set for the input data function In_Func and the output data function Out_Func.
[0073] The template combination building module, in order to form different metamorphosis relationship templates, uses the metamorphosis test seven-element parsing architecture for large model reasoning tasks to disassemble the task structure, and quickly builds it through different combinations of the seven elements. The present invention designs three typical metamorphosis relationship templates, including MRT1: a metamorphosis template with unchanged reasoning results based on use cases; MRT2: a metamorphosis template with unchanged reasoning links based on use cases; and MRT3: a metamorphosis template with unchanged reasoning results based on large models.
[0074] The test execution process module is used to generate the designed metamorphosis relationship according to the three typical metamorphosis relationship template design requirements for large model reasoning tasks, using the use case method to prepare the functions between input data and the functions between output data that are pre-accumulated by the module, and combine the initial test case to obtain the corresponding derived test case, and jointly input the target large model for testing, and judge the initial test output and the derived test output results to determine whether the metamorphosis relationship is satisfied between the two, complete the complete metamorphosis test execution process, and quantitatively evaluate the execution results using the error detection rate, and evaluate the error detection ability of the metamorphosis relationship based on the error detection rate, and feedback optimize the use order of the metamorphosis relationship in the execution process to improve the metamorphosis test execution efficiency of the framework.
[0075] Example 3
[0076] Based on the above embodiments, Figure 5 As shown, another large model reasoning capability testing method based on metamorphic testing of the present invention, the specific implementation takes the method flow of the use case-based reasoning link unchanged metamorphic template MRT2 as an example, and includes the following specific steps:
[0077] Step 1: Collect and obtain the latest large model test benchmark data, and extract the test case data as the initial test case set. At the same time, update and improve the transformation function method library by designing different transformation functions; including:
[0078] Step 1.1: Collect and obtain the latest large model test benchmark data, extract the test case data therein, and reorganize it according to the initial test case data structure predefined by the invention.
[0079] Specifically, take the interpretable causal reasoning dataset e-CARE as an example. The complete e-CARE dataset obtained from the open source channel contains multiple directories. By analyzing and extracting the directory "e-CARE / dataset / Causal_Reasoning / " containing test cases, we can get the test case sets "dev.jsonl" and "train.jsonl" of the dataset.
[0080] For reasoning problems, the present invention determines the test case template structure as a multiple-choice question with two options, and divides it into two directions: deducing the consequent and summarizing the antecedent. The collected e-CARE dataset is organized in jsonl format, and the json structure of a single test case in each row is fixed. The example of the first test case is as follows:
[0081]
[0082]
[0083] The "index" field is the index of the test case, which is used to uniquely identify the serial number of each test case; the "premise" field is the assumption, which indicates the assumption given in the reasoning problem. According to the reasoning tasks of different categories, in the reasoning consequent task, the assumption given by the "premise" field is the logical antecedent, which is the basis for further reasoning the logical consequent; in the induction antecedent task, the assumption given by the "premise" field is the logical consequent, which is used to summarize the assumed status of the logical antecedent; the "ask-for" field identifies different task types, "cause" is the induction antecedent task, and "effect" is the deduction consequent task; the "hypothesis1" and "hypothesis2" fields are the optional assumptions given, and the test cases used in the present invention are limited to two options; the "label" field is the label field provided by the e-CARE dataset, which gives the correct reasoning situation and can be used to assist the design process of the metamorphosis relationship in the framework of the present invention.
[0084] According to the predetermined test case questioning method and with reference to the e-CARE data set organization form, the initial test case data structure of the present invention is determined to be json data containing the fields "index", "premise", "ask-for", "hypothesis1", and "hypothesis2" (the "label" field is optional). Based on the determined initial test case data structure, other collected and extracted test cases are formatted to form a usable initial test case data set.
[0085] Step 1.2: Form a new transformation function method by writing design means, and enrich and improve the designed transformation function method library.
[0086] Specifically, the transformation function method library is used to organize and uniformly manage and store the available transformation functions, and to select and use them more efficiently and orderly when designing transformation relationships based on the different classifications and effects of the function methods. This specific implementation example provides a design idea based on the level of function objects, and divides the functions between input data into three major categories: word semantic level functions, structure level functions, and system level functions:
[0087] 1. Semantic-level function: The function acts on a single word or phrase in the input test case text and does not affect the syntactic structure of the input test case.
[0088] 2. Structural-level function: The function operates on the sentence level in the input test case text, including the semantic content and syntactic structure of the test case segment.
[0089] 3. System-level function: The function acts on the target large model being tested and affects the system used.
[0090] The design idea of the transformation function method library proposed here is an example in this specific implementation. It must be clear that the specific design of the transformation function method library can be adapted and adjusted according to the different actual test tasks.
[0091] In the method flow of MRT2, the function required is the antecedent-conjunction replacement function MR_AC, which can construct a derivative test case with the opposite direction according to the direction of the large model reasoning task to which the initial test case belongs, and correspondingly perform a structural swap between the input text and the output text, transforming the positive antecedent-conjunction relationship in the initial test case into a reverse antecedent-conjunction relationship in the derived test case set. It can be seen that the function change not only involves the adjustment and modification of the sentence structure of the test case, but also forms a new test case structure in combination with the prompt words. Therefore, the antecedent-conjunction replacement function MR_AC will be stored in the structural-level function category of the metamorphosis function method library, and will be selected and called when needed. In addition, the metamorphosis function MR_FY is stored in the semantic-level function category, and MR_LA is stored in the system-level function.
[0092] Step 2: Introduce the concept of metamorphosis relationship template, decompose the reasoning ability evaluation task for the large model testing field into a seven-element testing framework, and form different metamorphosis relationship templates through different combinations of the seven elements.
[0093] Specifically: three-layer abstract logic based on the research field of the invention: large model testing field, metamorphosis testing technical principles, and reasoning tasks. This specific implementation example defines the metamorphosis relationship template under this specific task as a combination of seven elements: target large model LLMs, prompt word Prompt, antecedent Antecedent, consequent Consequence (input text Input is divided into antecedent and consequent), output text Output, input data function In_Func and output data function Out_Func. Among them, the input text adopts different initial test case formats according to different actual application tasks, and corresponding adjustments and modifications can be made.
[0094] The different combination changes here refer to: according to the functional principle of the large model of the software under test, the operating logic of the large model can be obtained as shown below.
[0095] LLMS(Prompt|(Antecedent,Consequence))=Output
[0096] This formula shows the operation logic when the initial test case is used to input the large model, and the output result can be obtained normally. According to the principle of metamorphic test technology, the input data function In_Func and the output data function Out_Func elements are introduced to perform derivative transformation on the input test case and check the functional relationship between the initial test output and the derived test output. Based on the different objects of the metamorphic relationship function used, different combination templates can be obtained. The schematic form of the MRT2 constructed by this specific implementation example is as follows.
[0097]
[0098] In MRT2, the target large model elements do not change, the transformation function acts on the antecedent, the consequent, and the output text Output, and the Prompt is adjusted accordingly based on the changes in the test case input text. At the same time, the test case that has been changed by the transformation function, its output result after large model reasoning should be a subset of the original input.
[0099] Step 3: Based on the different transformation relationship templates that have been constructed, by selecting transformation function methods with different effects, specify the corresponding input data function and output data function relationship, design the transformation relationship, and combine the collected initial test case set to perform the actual transformation test process.
[0100] Specifically: according to the design requirements of the MRT2 template, its metamorphosis effect should be adjusted and changed accordingly to the structure of the input text. Based on the storage accumulation of the sentence-level function category of the metamorphosis function method library in step 1.2, a selection is made. In this specific implementation example, the input data function In_Func is selected as the antecedent and posterior replacement function MR_AC, and the output data function Out_Func is selected as the get_predict function for obtaining specific options, and the output data function result "A" is added as the correct judgment condition. Therefore, through the guidance and assistance of the metamorphosis relationship template and the use of the combing and reorganization of the metamorphosis function method library, the framework quickly completes the design process of the metamorphosis relationship MR2, and by replacing the metamorphosis function method, the change metamorphosis relationship of the metamorphosis relationship MR2 can be effectively formed.
[0101] Using the metamorphosis relationship MR2, combined with the stored initial test cases, the metamorphosis test process for the target large model is carried out. Based on the initial test case data structure, the reasoning task direction to which it belongs is extracted, and the predefined prompt word templates of different categories of tasks are integrated to obtain the final text content of the initial test case input into the target large model. Taking the first test case as an example, its input content is as follows:
[0102]
[0103] In this specific implementation example, based on the big model API interface of Zhipu Qingyan, it is input into the GLM-4 big model for answering, and the results can be obtained as follows:
[0104]
[0105]
[0106] Using the get_predict function, the answer text of the large model is analyzed and extracted, and the final selection result can be obtained as "B", that is, after the GLM-4 large model reasoning, it is obtained that among the two options provided, the content of option "B" is the cause of the result. Based on the metamorphosis relationship MR2 design, the antecedent and causal permutation function MR_AC is used as the input data function, acting on the antecedent, consequent, and output, and the derived test case can be obtained, and it is input into the large model again to obtain the output result of the derived test.
[0107]
[0108] For the derived test output, the get_predict function is used again, and the result is "A. Yes", which meets the requirements designed by the metamorphosis relationship MR2. It can be determined that for the target large model, under the test case example, the metamorphosis relationship used in the design is satisfied.
[0109] Step 4: Based on the actual test execution results of the metamorphic relationship, the error detection capability of different metamorphic relationships on the same initial test case data set is represented by the error detection rate. By dynamically updating the error detection rate, the execution logic of the metamorphic relationship of the metamorphic test is optimized and updated.
[0110] Specifically, for the multiple transformation relationships contained in the framework, in order to reasonably optimize the test execution process, the concept of error detection rate is introduced to quantitatively evaluate each transformation relationship. A transformation relationship with a high error detection rate indicates that it has a strong error detection ability on the initial test case set, and vice versa. By sorting by error detection rate, the order of transformation relationships in the transformation test execution process is further optimized to optimize the test process.
[0111] Take the three metamorphosis relationships MR1, MR2, and MR3 designed by the framework as an example. In the initial test process, the test is first executed in the order of MR1-MR2-MR3. After one round of execution, the three metamorphosis relationships are reordered based on their error detection rates. If the error detection rate after one round is MR1-MR3-MR2 from low to high, then in the next round of test execution process, the new execution order is MR2-MR3-MR1. Based on this dynamic order update, the test execution process is kept optimized.
[0112] Example 4
[0113] The present invention takes the reasoning ability evaluation in the field of large model testing as the research object, proposes a metamorphosis relationship template for guiding the auxiliary metamorphosis relationship design process, designs a typical template example, and forms a development framework that can efficiently apply the metamorphosis testing technology. The formed development framework includes three working modules, namely the use case method preparation module, the template combination building module and the test execution process module. The metamorphosis test application development framework composed of three modules takes the generation of metamorphosis relationships as the core goal, and connects the framework from top to bottom through the metamorphosis relationship template construction process.
[0114] like Figure 6 As shown, it is a module diagram of a large model reasoning ability test framework based on metamorphic testing of the present invention. The framework uses the seven-element architecture theory of the metamorphic relationship template to disassemble the practical application task problems of the metamorphic test in the field of large model reasoning ability testing, and then uses the pre-built metamorphic relationship template, combined with the metamorphic function method that has been designed and stored by level classification, to guide the design process of auxiliary metamorphic relationships. Among them:
[0115] The module 100 shown is a use case method preparation module, which is used to collect and obtain the latest large model test benchmark data, and extract the test case data therein as the initial test case set of the framework. At the same time, according to the actual needs of the functions between input data and the functions between output data, the transformation function method library is updated and improved by designing different transformation functions;
[0116] The 200 modules shown are template combination building modules, which are used to introduce the concept of metamorphic relationship templates before the metamorphic relationship design. In the actual task context of large model reasoning ability evaluation, the seven-element architecture is adjusted and combined to build different metamorphic relationship templates;
[0117] The module 300 shown is a test execution process module, which is used to apply the input data function with the specified effect collected in advance to the initial test case according to the design requirements of the metamorphic relationship template obtained by the module 200, and obtain the corresponding derivative test case, and then respectively combine the initial test case and the derivative test case with the designed prompt words, and input the target large model to obtain the initial test output and the derivative test output, so as to check whether the two output results meet the output data function selected by the metamorphic relationship template, so as to determine whether the designed metamorphic relationship is satisfied. At the same time, for the same initial test case set, based on different metamorphic relationship templates combined with different input data functions and output data functions The function formed, the concept of error detection rate is introduced to quantitatively evaluate its error detection ability, and the evaluation results of the error detection ability of each metamorphic relationship in this round of testing are fed back to the metamorphic test framework to optimize the deployment and use of the metamorphic relationship in the test framework.
[0118] The above is only a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.
Claims
1. A large model reasoning ability testing method based on metamorphosis testing, characterized in that: include: Step 1: Collect and obtain the latest large model test benchmark data, and extract the test case data as the initial test case set. At the same time, update and improve the transformation function method library by designing and implementing different transformation functions; Step 2: In the context of the actual task of evaluating the reasoning ability of large models, different transformation relationship templates are constructed through different combinations of seven elements; the seven elements include the target large model, prompt words, antecedents, consequents, output text, functions between input data, and functions between output data; antecedents refer to the conditional part of the reasoning task; consequents refer to the judgment content of the situation of things that depend on certain conditions in the reasoning task; Step 3: Based on the different transformation relationship templates that have been constructed, by selecting transformation function methods with different effects, specifying the corresponding input data function and output data function relationship, designing the transformation relationship, and combining the collected initial test case set to perform the actual transformation test process; Based on the actual test execution results of the metamorphosis relationship, the error detection rate is used to represent the error detection capabilities of different metamorphosis relationships on the same initial test case data set. By dynamically updating the error detection rate, the metamorphosis relationship execution logic of the metamorphosis test is optimized and updated.
2. According to the large model reasoning ability testing method based on metamorphic testing according to claim 1, it is characterized in that: The initial test cases in the initial test case set are designed in the following manner: X A =Prompt A +Consequence+(Antecedent1+Antecedent2) X C =Prompt C Antecedent+(Consequence1+Consequence2) Where X A represents the inductive antecedent test case, X C Indicates the deduction of the aftermath class test case, Prompt A Prompt word design for inductive antecedent test cases, C It indicates the prompt word design of the deduced consequent test case; Antecedent1 and Antecedent2 indicate two different antecedents in the inductive antecedent test case; Consequence1 and Consequence2 indicate two different consequents in the deduced consequent test case.
3. According to claim 1, a large model reasoning ability testing method based on metamorphic testing is characterized in that: The transformation function includes: a predefined semantic-level language translation transformation function MR_FY, a sentence-level context replacement function MR_AC and a system-level target big model transformation function MR_LA; the MR_FY obtains a translation text that has undergone mapping transformation to different degrees through a pre-built single-round translation iteration based on a small language or multiple-round translation iterations based on the official language of the United Nations; the MR_AC constructs a derivative test case with the opposite direction according to the direction of the big model reasoning task to which the initial test case belongs, and correspondingly exchanges the structure of the input text and the output text, transforming the positive context relationship in the initial test case into the reverse context relationship in the derived test case set; the MR_LA uses the transformation function to directly transform the big model being tested, and transforms the target big model into an intelligent agent based on the big model as the development basis.
4. A large model reasoning ability testing method based on metamorphosis test according to claim 3, characterized in that: The output data function includes a get_predict function, which extracts the final reasoning option answer from the generative answer text of the large model for subsequent result verification.
5. A large model reasoning ability testing method based on metamorphic testing according to claim 4, characterized in that: The transformation relationship templates include a transformation template MRT1 based on a use case in which the inference result remains unchanged; a transformation template MRT2 based on a use case in which the inference link remains unchanged; and a transformation template MRT3 based on a large model in which the inference result remains unchanged.
6. A large model reasoning ability testing method based on metamorphosis test according to claim 5, characterized in that: In the MRT1, the input data function uses MR_FY, and the output data function uses the get_predict function. The options of the generative text are extracted and the corresponding transformation relationship MR1 is designed. MR1 satisfies: the use case content expressed in different languages finally obtains a consistent reasoning result.
7. A large model reasoning ability testing method based on metamorphosis test according to claim 5, characterized in that: In the MRT2, the function between input data adopts MR_AC, and the function between output data adopts get_predict function, and the corresponding metamorphosis relationship MR2 is designed; MR2 satisfies: there are antecedents and antecedents of the deductive reasoning relationship, and in the inductive reasoning, it has a belonging relationship of the set, and there are antecedents and antecedents of the inductive reasoning relationship, and in the deductive reasoning, it has a belonging relationship of the set.
8. A large model reasoning capability testing method based on metamorphic testing according to claim 5, characterized in that: In the MRT3, the function between input data adopts MR_LA, and the function between output data adopts get_predict function, and the corresponding metamorphosis relationship MR3 is designed. MR3 satisfies: when the input test case remains unchanged, different target large models with the same function or intelligent agents built based on the target large model are changed to finally obtain consistent reasoning results.
9. A large model reasoning ability testing method based on metamorphic testing according to claim 1, characterized in that: The step 3 comprises: According to the obtained design requirements of the metamorphic relationship template, the pre-designed input data function with the specified effect is applied to the initial test case to obtain the corresponding derived test case, and then the initial test case and the derived test case are respectively combined with the designed prompt words, and the target large model is input to obtain the initial test output and the derived test output, so as to check whether the two output results conform to the output data function selected by the metamorphic relationship template to determine whether the designed metamorphic relationship is satisfied; at the same time, for the same initial test case set, based on different metamorphic relationship templates combined with different input data functions and output data functions to form different metamorphic relationships, their error detection capabilities are quantitatively evaluated through the error detection rate, and the evaluation results of the error detection capabilities of each metamorphic relationship in this round of testing are fed back to the metamorphic test framework to optimize the deployment and use of metamorphic relationships in the test framework.
10. A large model reasoning capability testing framework based on metamorphic testing, characterized in that: include: The use case method preparation module is used to collect the latest large model test benchmark data and extract the test case data as the initial test case set. At the same time, the transformation function method library is updated and improved by designing and implementing different transformation functions. The template combination building module is used to build different transformation relationship templates through different combinations of seven elements in the actual task background of large model reasoning ability evaluation; the seven elements include the target large model, prompt words, antecedents, consequents, output texts, functions between input data and functions between output data; antecedents refer to the conditional part of the reasoning task; consequents refer to the judgment content of the situation of things that depend on certain conditions in the reasoning task; The test execution process module is used to design the transformation relationship based on the different transformation relationship templates that have been constructed, by selecting transformation function methods with different effects, specifying the corresponding input data function relationship and output data function relationship, and combining the collected initial test case set to execute the actual transformation test process; Based on the actual test execution results of the metamorphosis relationship, the error detection rate is used to represent the error detection capabilities of different metamorphosis relationships on the same initial test case data set. By dynamically updating the error detection rate, the metamorphosis relationship execution logic of the metamorphosis test is optimized and updated.
Citation Information
Cited By
Method and device for evaluating logic conflict detection capability of large language model
CN119621516A
Large model reasoning verification method and device, medium and equipment
CN122242769A
