Method for detecting target model, electronic device and storage medium
By detecting the optional tag prejudice or option position preferences of the selection question answer, the problem of lack of detection methods in the existing technology has been solved, and the fairness and accuracy of the model in the education and testing environment are realized.
Patent Information
- Application Number
- CN202411092157.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-08-09
AI Technical Summary
The lack of methods in the prior art to detect whether the model has option label bias or option position preferences when generating multiple-choice answers has affected the impartiality and accuracy of the model in educational and testing environments.
By obtaining the general set of the preset option label list and the specified selection question data list collection, the cumulative number of selected and related key vectors of the options of the target model is used to calculate the key vector correlation coefficient, and determine whether there is an option tag prejudice or option position preference Essence
It realizes the detection of option label bias or option position preference when the target model generates answers to multiple-choice questions, enhances the reliability and fairness of the model, and improves the accuracy of evaluation in education and testing environments.
Smart Images

Figure CN118627492B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of model detection, and in particular to a method for detecting a target model, an electronic device and a storage medium. Background Art
[0002] Against the backdrop of the rapid development of natural language processing (NLP), large language models (LLMs), as cutting-edge technologies, have been widely used in technical fields such as text summarization and dialogue generation. However, with the widespread application of LLMs, their inherent bias problems have gradually emerged. These biases include not only biases in code generation and sample bias, but also biases in specific task processing, such as option label bias or option position preference in generating answers to multiple-choice questions. Option label bias refers to the systematic preference of the model to select the option corresponding to a certain option label when LLMs generate answers to multiple-choice questions. This bias may be caused by an unbalanced distribution in the training data or by a bias formed during the model learning process. For example, if the correct answer appears more frequently in the training data, For option A, the model may learn this rule and unconsciously tend to choose A as the answer when predicting. This bias may persist even in new, unseen questions. Option position preference means that LLMs tend to choose options in a certain position when generating answers to multiple-choice questions. This preference may be caused by a variety of factors, including but not limited to the statistical characteristics of the training data, the limitations of the model architecture, and the user's potential preferences when designing multiple-choice questions. For example, when writing test questions, users may inadvertently place more difficult options at the back, or prefer to put the "best" answer at the end among multiple correct options. This writing habit may be captured and internalized by the model, thereby showing a preference for a certain position when generating answers.
[0003] Research on bias in the prior art shows that LLMs may exhibit bias in the preprocessing, training, and post-processing stages. By examining these biases, evaluation and mitigation strategies are proposed. In order to solve the bias problem, an innovative text generation mechanism that does not rely on predefined phrases is developed. For bias in code generation, strategies such as few-shot learning are used to mitigate these biases and improve the fairness and accuracy of code generation. For sample bias, identification and quantification of samples are used to mitigate bias.
[0004] However, in terms of bias detection in the generation of answers to multiple-choice questions, the existing technology does not have a method that can detect whether the model has option label bias or option position preference when generating answers to multiple-choice questions. In environments such as education and testing, the fairness of multiple-choice questions is crucial to the accuracy and reliability of evaluation results, and most of the existing data sets used for model evaluation are multiple-choice questions. If the model has option label bias or option position preference when generating answers to multiple-choice questions, it will affect the evaluation of the model's true level of effectiveness. Summary of the invention
[0005] In view of the above technical problems, the technical solution adopted by the present invention is:
[0006] According to a first aspect of the present invention, a method for detecting a target model is provided. The method is used to detect whether the target model has an option label bias or an option position preference when generating answers to multiple-choice questions. The method comprises the following steps:
[0007] S1. Obtain a preset option tag list A and a preset option tag value exchange rule list JH, where A={A1, A2, ..., A x , …, A p}, A x is the xth preset option tag, the value of x ranges from 1 to p, p is the number of preset option tags, and JH includes several preset option tag value exchange rules.
[0008] S2. Based on the preset option label value exchange rules in JH, the preset multiple-choice question data list set B is processed to obtain the total set C of the specified multiple-choice question data list set, where B={B1, B2, …, B j , …, B n}, B j ={B j1 , B j2}, B j2 ={B 1 j2 , B 2 j2 , …, B x j2 , …, B p j2}, B j is the preset multiple-choice question data list corresponding to the jth preset multiple-choice question, the value of j ranges from 1 to n, n is the number of preset multiple-choice questions, B j1 is the text of the j-th preset multiple-choice question, B j2 is the preset option combination list of the jth preset multiple-choice question, B x j2 For B j2 Middle A x The corresponding preset option combination, A x The corresponding preset option combinations include A x and A x The corresponding preset option label value, C={C1, C2, …, C e , …, C f}, C e ={C e1 , C e2 , …, C ej , …, Cen}, C ej ={C ej1 , C ej2}, C ej2 ={C 1 ej2 , C 2 ej2 , …, C x ej2 , …, C p ej2}, C e is the e-th specified multiple-choice question data list set, the value of e ranges from 1 to f, f is the number of specified multiple-choice question data lists, C ej C e The jth specified multiple choice question data list, C ej1 C ej The specified text in the question and C ej1 =B j1 , C ej2 C ej A list of specified option combinations in C x ej2 C ej2 Middle A x The corresponding specified option combination, A x The corresponding specified option combinations include A x and A x The corresponding value of the specified option tag.
[0009] S3. According to C e Get the first cumulative number of selected times list D corresponding to A and the target model e And construct the first cumulative selection times list set D corresponding to A = {D1, D2, ..., D e , …, D f}, D e ={D e1 , D e2 , …, D ex , …, D ep}, D ex D e Middle A x The corresponding first cumulative number of selections.
[0010] S4. For each D e D e1 , D e2 , …, D ex , …, D ep Perform vectorization processing to obtain the key vector list set E={E1, E2, …, E e , …, E f}, Ee ={E e1 , E e2 , …, E ex , …, E ep}, E e D e The corresponding key vector list, E ex D ex The corresponding key vector.
[0011] S5. Obtain the key vector correlation coefficient list F={F1, F2, ..., F i , …, F m}, F i is the i-th key vector correlation coefficient, i ranges from 1 to m, m is the number of key vector correlation coefficients and m=f×(f-1) / 2, and the key vector correlation coefficient is the Spearman correlation coefficient between two different key vector lists in E.
[0012] S6, when F 0 / m≤F 1 When the target model generates answers to multiple-choice questions, it is determined that there is no option label bias or option position preference, F 0 is F1, F2, …, F i , …, F m The number of key vector correlation coefficients greater than △F in the , △F is the preset vector correlation coefficient, F 1 is the preset ratio.
[0013] According to a second aspect of the present invention, a non-transitory computer-readable storage medium is provided, in which a computer program is stored. The computer program is loaded and executed by a processor to implement the aforementioned method.
[0014] According to a third aspect of the present invention, there is provided an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the aforementioned method when executing the computer program.
[0015] The present invention has at least the following beneficial effects:
[0016] The present invention provides a method, electronic device and storage medium for detecting a target model. The method can obtain a total set of preset option label lists and specified multiple-choice question data list sets, obtain a first cumulative selection count list set corresponding to the preset option label list according to the total set of specified multiple-choice question data list sets and the target model, obtain a key vector list set corresponding to the first cumulative selection count list set, and obtain a key vector correlation coefficient list corresponding to the key vector list set. When the ratio of the number of key vector correlation coefficients greater than the preset vector correlation coefficient to all key vector correlation coefficients is not greater than the preset ratio, it is determined that the target model does not have option label bias or option position preference when generating answers to multiple-choice questions. It can be seen that the present invention can detect whether the target model has option label bias or option position preference when generating answers to multiple-choice questions, which is beneficial to enhancing the reliability of the target model and improving the fairness of the target model in environments such as education and testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 A flowchart of a method for detecting a target model provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0019] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0020] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar tasks, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0021] An embodiment of the present invention provides a method for detecting a target model, the method being used to detect whether the target model has an option label bias or an option position preference when generating answers to multiple-choice questions, the option label bias being that the target model systematically tends to select an option corresponding to a certain option label when generating answers to multiple-choice questions, the option position preference being that the target model tends to select an option in a certain position when generating answers to multiple-choice questions, the target model being a large language model (LLMs), the method comprising the following steps, Figure 1 As shown:
[0022] S1. Obtain a preset option tag list A and a preset option tag value exchange rule list JH, where A={A1, A2, ..., A x , …, A p}, A x is the xth preset option tag, the value of x ranges from 1 to p, p is the number of preset option tags, and JH includes several preset option tag value exchange rules. Those skilled in the art know that the preset option tags are option tags pre-set by those skilled in the art according to actual needs, for example: option A, option B, option C, option D, which will not be repeated here.
[0023] S2. Based on the preset option label value exchange rules in JH, the preset multiple-choice question data list set B is processed to obtain the total set C of the specified multiple-choice question data list set, where B={B1, B2, ..., B j , …, B n}, B j ={B j1 , B j2}, B j2 ={B 1 j2 , B 2 j2 , …, B x j2 , …, B p j2}, B j is the preset multiple-choice question data list corresponding to the jth preset multiple-choice question, the value of j ranges from 1 to n, n is the number of preset multiple-choice questions, B j1 is the text of the j-th preset multiple-choice question, B j2 is the preset option combination list of the jth preset multiple-choice question, B x j2 For B j2 Middle A x The corresponding preset option combination, A x The corresponding preset option combinations include A x and A xThe corresponding preset option label value, C={C1, C2, …, C e , …, C f}, C e ={C e1 , C e2 , …, C ej , …, C en}, C ej ={C ej1 , C ej2}, C ej2 ={C 1 ej2 , C 2 ej2 , …, C x ej2 , …, C p ej2}, C e is the e-th specified multiple-choice question data list set, the value of e ranges from 1 to f, f is the number of specified multiple-choice question data lists, C ej C e The jth specified multiple choice question data list, C ej1 C ej The specified text in the question and C ej1 =B j1 , C ej2 C ej A list of specified option combinations in C x ej2 C ej2 Middle A x The corresponding specified option combination, A x The corresponding specified option combinations include A x and A x The corresponding specified option tag value; for example: if B j1 What is the product of 5 and 3? p=5. The default option label value corresponding to A1 is 5, the default option label value corresponding to A2 is 10, the default option label value corresponding to A3 is 15, the default option label value corresponding to A4 is 20, and the default option label value corresponding to A5 is 25. Then B j2 ={B 1 j2 , B 2 j2 , B 3 j2 , B 4 j2 , B 5 j2}, B 1 j2 Including A1 and 5, B 2 j2 Including A2 and 10, B3 j2 Including A3 and 15, B 4 j2 Including A4 and 20, B 5j 2Including A 5 and 25;C ej1 What is the product of 5 and 3? ej2 ={C 1 ej2 , C 2 j2 , C 3 ej2 , C 4 j2 , C 5 ej2}, C 1 ej2 , C 2 j2 , C 3 ej2 , C 4 j2 , C 5 ej2 Can be: C 1 ej2 Including A1 and 5, C 2 j2 Including A2 and 10, C 3 ej2 Including A3 and 15, C 4 j2 Including A4 and 20, C 5 ej2 Including A 5 and 25; can also be: C 1 ej2 Including A1 and 10, C 2 j2 Including A2 and 20, C 3 ej2 Including A3 and 5, C 4 j2 Including A4 and 15, C 5 ej2 Including A 5 and 25; can also be: C 1 ej2 Including A1 and 15, C 2 j2 Including A2 and 5, C 3 ej2 Including A3 and 10, C 4 j2 Including A4 and 20, C 5 ej2 Including A 5 and 25.
[0024] Specifically, the stem text of the preset multiple-choice question can be understood as the title of the preset multiple-choice question.
[0025] Specifically, the preset option label value corresponding to the preset option label is the numerical value corresponding to the preset option label. Those skilled in the art know that the numerical value corresponding to the preset option label is a numerical value pre-set by those skilled in the art according to actual needs, and will not be repeated here. For example: if the preset option label is option A, and the numerical value corresponding to option A is 2, then the preset option label value corresponding to the preset option label is 2.
[0026] Specifically, step S2 includes the following sub-steps S21-S22:
[0027] S21. Extract f-1 preset option label value exchange rules from JH as specified option label value exchange rules to construct a specified option label value exchange rule list, wherein the specified option label value exchange rule list includes f-1 specified option label value exchange rules.
[0028] Specifically, the preset option tag value exchange rule is a rule that represents the simultaneous replacement of the preset option tag value corresponding to the first type of preset option tag with the preset option tag value corresponding to the second type of preset option tag corresponding to the first type of preset option tag, wherein the first type of preset option tag and the second type of preset option tag corresponding to the first type of preset option tag are two different preset option tags in A, wherein those skilled in the art know that the first type of preset option tag and the second type of preset option tag corresponding to the first type of preset option tag are determined by those skilled in the art from A according to actual needs, and will not be repeated here; for example: the first preset option tag value exchange rule is: replace A 2. A5 and A7 are used as the first category of preset option tags, A7 is used as the second category of preset option tags corresponding to A2, A2 is used as the second category of preset option tags corresponding to A5, and A5 is used as the second category of preset option tags corresponding to A7. At the same time, the preset option tag values corresponding to the first category of preset option tags are replaced with the preset option tag values corresponding to the second category of preset option tags corresponding to the first category of preset option tags, that is, the preset option tag value corresponding to A2 is replaced with the preset option tag value corresponding to A7, the preset option tag value corresponding to A5 is replaced with the preset option tag value corresponding to A2, and the preset option tag value corresponding to A7 is replaced with the preset option tag value corresponding to A5.
[0029] S22, when e=1, B x j2 Middle A x The corresponding default option tag value is C ej2 Middle A xThe corresponding specified option tag value, when e>1, is exchanged according to the e-1th specified option tag value exchange rule. j2 A1, A2, ..., A x , …, A p The corresponding preset option tag value is exchanged to obtain C ej2 A1, A2, ..., A x , …, A p For example, if the exchange rule for the e-1th specified option tag value is: A2, A5 and A7 are used as the first type of preset option tags, A7 is used as the second type of preset option tag corresponding to A2, A2 is used as the second type of preset option tag corresponding to A5, A5 is used as the second type of preset option tag corresponding to A7, and the preset option tag value corresponding to the first type of preset option tag is replaced with the preset option tag value corresponding to the second type of preset option tag corresponding to the first type of preset option tag, then B is replaced at the same time. j2 The default option label value corresponding to A2 is replaced by B j2 The default option label value corresponding to A7 in B j2 The default option label value corresponding to A5 is replaced by B j2 The default option label value corresponding to A2 in B j2 The default option label value corresponding to A7 is replaced by B j2 The default option label value corresponding to A5 in C is obtained ej2 A1, A2, ..., A x , …, A p The corresponding specified option tag value; it can be understood as B j2 The default option label value corresponding to A2 is replaced by B j2 The default option label value corresponding to A7 in B j2 The default option label value corresponding to A5 is replaced by B j2 The default option label value corresponding to A2 in B j2 The default option label value corresponding to A7 is replaced by B j2 The preset option label value corresponding to A5 in B j2 Update and update B j2 As C ej2 .
[0030] Through the above steps, the specified option label value exchange rule list is obtained according to the preset option label value exchange rule list, and the preset option label value corresponding to the preset option label is replaced by the specified option label value exchange rule in the specified option label value exchange rule list to obtain the total set of the specified multiple-choice question data list set, so that the specified option label values corresponding to the preset option labels in different specified multiple-choice question data lists are not exactly the same, which increases the diversity and breadth of the data input into the target model, which is conducive to helping the model to learn better.
[0031] S3. According to C e Get the first cumulative number of selected times list D corresponding to A and the target model e And construct the first cumulative selection times list set D corresponding to A = {D1, D2, ..., D e , …, D f}, D e ={D e1 , D e2 , …, D ex , …, D ep}, D ex D e Middle A x The corresponding first cumulative number of selections.
[0032] Specifically, step S3 includes the following sub-steps S31-S34:
[0033] S31, C ej1 and C ej2 Input into the target model to obtain C x ej2 The corresponding selection score K x ej2 And build C e The corresponding selection score list set K e ={K e1 , K e2 , …, K ej , …, K en}, K ej ={K 1 ej2 , K 2 ej2 , …, K x ej2 , …, K p ej2}, where K ej C ejThe corresponding selection score list, the selection score corresponding to the specified option combination is the original prediction value corresponding to the specified option combination in the target model after the specified question stem text and the specified option combination list in the specified multiple-choice question data list including the specified option combination are input into the target model, and the original prediction value is the original unprocessed score or score of the output layer of the target model; it can be understood as: the linear part of the output of the target model before passing through the activation function.
[0034] S32, according to K x ej2 Get C x ej2 The corresponding probability of being selected is L x ej2 And build C e The corresponding selected probability value list set L e ={L e1 , L e2 , …, L ej , …, L en}, L ej ={L 1 ej2 , L 2 ej2 , …, L x ej2 , …, L p ej2}, L ej C ej The corresponding selected probability value list, L x ej2 Meet the following conditions:
[0035] .
[0036] S33, max(L 1 ej2 , L 2 ej2 , …, L x ej2 , …, L p ej2 ) corresponding to C x ej2 As C ej Corresponding answer option combination M ej To obtain C e Corresponding answer option combination list M e ={M e1 , M e2 , …, M ej , …, M en}, max() is the maximum value acquisition function.
[0037] S34, M e1 , M e2 , …, M ej , …, M en Included in A x The number of answer option combinations is D ex .
[0038] Through the above steps, the specified question stem text and the specified option combination list in the specified multiple-choice question data list are input into the target model to obtain the selection score corresponding to the specified option combination in the specified multiple-choice question data list, and the selection probability value corresponding to the specified option combination is obtained according to the selection score, that is, the probability value of the option combination being the answer, and the answer option combination corresponding to the specified multiple-choice question data list is obtained according to the selection probability value corresponding to the specified option combination, and the first cumulative number of selections corresponding to the preset option label is obtained according to the preset option label included in the answer option combination corresponding to the specified multiple-choice question list, which is conducive to improving the accuracy of obtaining the first cumulative number of selections, and obtaining the key vector list set corresponding to the first cumulative number of selections list set. , And obtain the key vector correlation coefficient list corresponding to the key vector list set, when the ratio of the number of key vector correlation coefficients greater than the preset vector correlation coefficient to all key vector correlation coefficients is not greater than the preset ratio, it is determined that the target model does not have option label bias or option position preference when generating answers to multiple-choice questions. It can be seen that the present invention can detect whether the target model has option label bias or option position preference when generating answers to multiple-choice questions, which is conducive to enhancing the reliability of the target model and improving the fairness of the target model in environments such as education and testing.
[0039] S4. For each D e D e1 , D e2 , …, D ex , …, D ep Perform vectorization processing to obtain the key vector list set E={E1, E2, …, E e , …, E f}, E e ={E e1 , E e2 , …, E ex , …, E ep}, E e D e The corresponding key vector list, E ex D ex The corresponding key vectors, wherein those skilled in the art know that any vectorization processing method in the prior art belongs to the protection scope of the present invention and will not be described in detail here.
[0040] S5. Obtain the key vector correlation coefficient list F={F1, F2, ..., Fi , …, F m}, F i is the i-th key vector correlation coefficient, i ranges from 1 to m, m is the number of key vector correlation coefficients and m=f×(f-1) / 2, and the key vector correlation coefficient is the Spearman correlation coefficient between two different key vector lists in E.
[0041] Specifically, step S5 also includes the following sub-steps S51-S52 for obtaining the Spearman correlation coefficient between two different key vector lists:
[0042] S51, obtain two different key vector lists from E and use one of the key vector lists as the first key vector list XL1, and use the other key vector list as the second key vector list XL2, XL1={XL11, XL12, ..., XL1 x , …, XL1 p}, XL2={XL21, XL22,…,XL2 x , ..., XL2 p}, XL1 x is the xth first key vector in XL1, XL2 x is the xth second key vector in XL2.
[0043] S52. Obtain the Spearman correlation coefficient ρ between XL1 and XL2, where ρ meets the following conditions:
[0044] ρ=1-6×∑ p x=1 ((XL 0 x ) 2 ) / (p×(p 2 -1)), XL 0 x For XL1 x and XL2 x The vector distance between two vectors, wherein those skilled in the art know that any method for obtaining the vector distance between two vectors in the prior art belongs to the protection scope of the present invention and will not be described in detail here.
[0045] Specifically, when ρ=1, it indicates that the first key vector list and the second key vector list are completely positively correlated.
[0046] Specifically, when ρ=0, it indicates that there is no positive correlation between the first key vector list and the second key vector list.
[0047] Specifically, when ρ=-1, it indicates that the first key vector list and the second key vector list are completely negatively correlated.
[0048] S6, when F0 / m≤F 1 When the target model generates answers to multiple-choice questions, it is determined that there is no option label bias or option position preference, F 0 is F1, F2, …, F i , …, F m The number of key vector correlation coefficients greater than △F in the , △F is the preset vector correlation coefficient, F 1 is the preset ratio; when F 0 / m>F 1 When generating answers to multiple-choice questions, it is determined whether the target model has option label bias or option position preference based on A, B and a preset option label position exchange rule list, where the preset option label position exchange rule list includes several preset option label position exchange rules.
[0049] Through the above steps, a key vector correlation coefficient list corresponding to the key vector list set is obtained, where the key vector correlation coefficient is the Spearman correlation coefficient between two different key vector lists in the key vector list set. When the ratio of the number of key vector correlation coefficients greater than the preset vector correlation coefficient to all key vector correlation coefficients is less than or equal to the preset ratio, it is determined that the target model does not have option label bias or option position preference when generating answers to multiple-choice questions. Otherwise, it is further determined whether the target model has option label bias or option position preference when generating answers to multiple-choice questions based on the preset option label list, the preset multiple-choice question data list set, and the preset option label position exchange rule list. By detecting whether the target model has option label bias or option position preference when generating answers to multiple-choice questions from different angles, the option label bias or option position preference of the target model can be more comprehensively evaluated, thereby ensuring the comprehensiveness of the evaluation results.
[0050] Specifically, the value range of ΔF is (0, 1]. Those skilled in the art know that they can determine the specific value of ΔF from (0, 1) according to actual needs, which will not be repeated here.
[0051] Specifically, F 1 The value range of F is (0.5, 1), where those skilled in the art know that they can determine F from (0.5, 1) according to actual needs. 1 The specific value of is not described here.
[0052] Specifically, in step S6, determining whether the target model has option label bias or option position preference when generating answers to multiple-choice questions based on A, B and the preset option label position exchange rule list includes the following sub-steps S61-S66:
[0053] S61. Extract a preset option label position exchange rule from the preset option label position exchange rule list as the middle option label position exchange rule.
[0054] Specifically, the preset option label position exchange rule is a rule for simultaneously replacing the arrangement position of the third type of preset option label in A with the arrangement position of the fourth type of preset option label corresponding to the third type of preset option label in A, wherein the third type of preset option label and the fourth type of preset option label corresponding to the third type of preset option label are two different preset option labels in A, wherein those skilled in the art know that the third type of preset option label and the fourth type of preset option label corresponding to the third type of preset option label are determined by those skilled in the art from A according to actual needs, and will not be repeated here; for example: the first preset option label position exchange rule is: A2, A5 and A7 are used as the third type of preset option labels, A7 is used as the fourth type of preset option label corresponding to A2, A2 is used as the fourth type of preset option label corresponding to A5, and A5 is used as the fourth type of preset option label corresponding to A7, and at the same time, the arrangement position of the third type of preset option label in A is replaced with the arrangement position of the fourth type of preset option label corresponding to the third type of preset option label in A, that is, {A1, A2, A3, A4, A5, A6, A7, A8, A9, ..., A n} is updated to {A1, A7, A3, A4, A2, A6, A5, A8, A9, …, A n}.
[0055] S62, according to the middle option label position exchange rule, A1, A2, ..., A x , …, A p Exchange the arrangement positions in A to obtain the intermediate option label list G = {G1, G2, ..., G y , …, G q}, G y is the yth middle option label, y ranges from 1 to q, q is the number of middle option labels and q=p, for example: if the middle option label position exchange rule is: A2, A5 and A7 are used as the third type of preset option labels, A7 is used as the fourth type of preset option label corresponding to A2, A2 is used as the fourth type of preset option label corresponding to A5, and A5 is used as the fourth type of preset option label corresponding to A7, and at the same time, the arrangement position of the third type of preset option label in A is replaced with the arrangement position of the fourth type of preset option label corresponding to the third type of preset option label in A, that is, {A1, A2, A3, A4, A5, A6, A7, A8, A9, …, A n} is updated to {A1, A7, A3, A4, A2, A6, A5, A8, A9, …, A n} and {A1, A7, A3, A4, A2, A6, A5, A8, A9, …, A n}as G.
[0056] S63, according to G and B, obtain the intermediate multiple-choice question data list set H = {H1, H2, ..., H j , …, H n}, H j ={H j1 , H j2}, H j2 ={H 1 j2 , H 2 j2 , …, H y j2 , …, H q j2}, where H j is the data list of the jth intermediate multiple-choice question, H j1 H j The middle text in the question, H j2 H j The list of intermediate option combinations in H y j2 H j2 Medium G y The corresponding middle option combination, G y The corresponding middle option combination includes G y and G y The corresponding middle option label value, where H j1 =B j1 , when G y =A x When H y j2 G in y The corresponding middle option label value is the same as B x j2 A x The corresponding preset option tag values are the same.
[0057] S64, according to B and the target model, obtain a second cumulative selection times list R corresponding to A = {R1, R2, ..., R x , …, R p}, where R x A in R x The corresponding second cumulative number of selections, wherein those skilled in the art know that in step S64, R in R is obtained according to B and the target model x The method is the same as step S3 according to C e And the target model obtains D e D exThe method is basically the same, and those skilled in the art can refer to steps S31-S34 in step S3 according to B j1 , B j2 and the target model gets the R x , that is, C in steps S31-S34 ej1 Replace with B j1 , C ej2 Replace with B j2 , C x ej2 Replace with B x j2 , C e Replace with B and execute steps S31-S34 to obtain R x , I will not go into details here.
[0058] S65, according to H and the target model, obtain a third cumulative selection times list J corresponding to G = {J1, J2, ..., J y , …, J p}, where J y For J in G y The corresponding third cumulative number of selections, wherein those skilled in the art know that in step S65, J in J is obtained according to H and the target model y The method is the same as step S3 according to C e And the target model obtains D e D ex The method is basically the same, and those skilled in the art can refer to steps S31-S34 in step S3 according to H j1 , H j2 and the target model obtains J in J y , that is, C in steps S31-S34 ej1 Replace with H j1 , C ej2 Replace with H j2 , C x ej2 Replace with H y j2 , C e Replace with H, A x Replace with G y And execute steps S31-S34 to obtain J y , I will not go into details here.
[0059] S66. Determine whether the target model has option label bias or option position preference when generating answers to multiple-choice questions based on R and J.
[0060] Through the above steps, when the ratio of the number of key vector correlation coefficients greater than the preset vector correlation coefficient to the correlation coefficients of all key vectors is greater than the preset ratio, the intermediate option label position exchange rule is obtained according to the preset option label position exchange rule list, the preset option labels in the preset option label list are processed according to the intermediate option label position exchange rule to obtain the intermediate option label list, the second cumulative selection count list corresponding to the preset multiple-choice question label list is obtained according to the preset multiple-choice question data list set and the target model, the third cumulative selection count list corresponding to the intermediate option label list is obtained according to the intermediate multiple-choice question data list set and the target model, and the target model is determined according to the second cumulative selection count list and the third cumulative selection count list to determine whether the target model has option label bias or option position preference when generating answers to multiple-choice questions. Detecting whether the target model has option label bias or option position preference when generating answers to multiple-choice questions from different angles can more comprehensively evaluate the option label bias or option position preference of the target model, and ensure the comprehensiveness of the evaluation results.
[0061] Specifically, step S66 also includes the following steps S661-S664:
[0062] S661, for R1, R2, ..., R x , …, R p and J1, J2, …, J in J y , …, J p Perform vectorization processing to obtain the first intermediate vector list R corresponding to R 0 ={R 0 1. R 0 2, ..., R 0 x , …, R 0 p} and the second intermediate vector list J corresponding to J 0 ={J 0 1. J 0 2, …, J 0 y , …, J 0 q}, where R 0 x For R x The corresponding first intermediate vector, J 0 y For J y The corresponding second intermediate vector.
[0063] S662, when G y =A x When G y The corresponding J 0 y As Ax The corresponding third intermediate vector N x To obtain the third intermediate vector list N={N1, N2, ..., N x ,…,N p}.
[0064] S663, Get R 0 The Spearman correlation coefficient XG between and N, where XG meets the following conditions:
[0065] XG=1-6×∑ p x=1 ((R_N x ) 2 ) / (p×(p 2 -1)), R_N x For R 0 x With N x The vector distance between .
[0066] S664. When XG≤△F, it is determined that the target model has an option position preference when generating answers to multiple-choice questions. When XG>△F, it is determined that the target model has an option label bias when generating answers to multiple-choice questions.
[0067] Specifically, when XG>△F, a bias score FS corresponding to the option label bias of the target model when generating answers to multiple-choice questions is generated. FS meets the following conditions:
[0068] FS=(∑ p x=1 (R 0 x -N x ) 2 ) 1 / 2 / ((∑ p x=1 R x -(∑ p x=1 R x ) / p) 2 +∑ p x=2 (∑ p x=1 R x / p) 2 ) 1 / 2 .
[0069] Specifically, the larger the FS, the greater the option label bias of the target model when generating answers to multiple-choice questions.
[0070] Through the above steps, the first intermediate vector list corresponding to the second cumulative selection number list and the second intermediate vector list corresponding to the third cumulative selection number list are obtained, and the Spearman correlation coefficient between the first intermediate vector list and the second intermediate vector list is obtained. When the Spearman correlation coefficient between the first intermediate vector list and the second intermediate vector list is not greater than the preset vector correlation coefficient, it is determined that the target model has option position preference when generating answers to multiple-choice questions. Otherwise, it is determined that the target model has option label bias when generating answers to multiple-choice questions, and a bias score corresponding to the option label bias of the target model when generating answers to multiple-choice questions is generated. A variety of evaluation indicators are used in combination to analyze whether the target model has option label bias or option position preference when generating answers to multiple-choice questions based on the Spearman correlation coefficient, and a bias score corresponding to the option label bias of the target model when generating answers to multiple-choice questions is generated based on the Euclidean distance. The degree of bias of the option label bias of the target model when generating answers to multiple-choice questions is quantified, thereby enhancing the accuracy and reliability of the detection results.
[0071] An embodiment of the present invention also provides a non-transitory computer-readable storage medium, which can be set in an electronic device to store a computer program related to a method in a method embodiment, and the computer program is loaded and executed by the processor to implement the method provided in the above embodiment.
[0072] An embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method provided in the above embodiment when executing the computer program.
[0073] An embodiment of the present invention further provides a computer program product, which includes program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the method according to various exemplary embodiments of the present invention described above in this specification.
[0074] The present invention provides a method, electronic device and storage medium for detecting a target model. The method can obtain a total set of preset option label lists and specified multiple-choice question data list sets, obtain a first cumulative selection count list set corresponding to the preset option label list according to the total set of specified multiple-choice question data list sets and the target model, obtain a key vector list set corresponding to the first cumulative selection count list set, and obtain a key vector correlation coefficient list corresponding to the key vector list set. When the ratio of the number of key vector correlation coefficients greater than the preset vector correlation coefficient to all key vector correlation coefficients is not greater than the preset ratio, it is determined that the target model does not have option label bias or option position preference when generating answers to multiple-choice questions. It can be seen that the present invention can detect whether the target model has option label bias or option position preference when generating answers to multiple-choice questions, which is beneficial to enhancing the reliability of the target model and improving the fairness of the target model in environments such as education and testing.
[0075] Although some specific embodiments of the present invention have been described in detail by way of example, it should be understood by those skilled in the art that the above examples are only for illustration, not for limiting the scope of the present invention. It should also be understood by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention.
Claims
1. A method for detecting a target model, the method being used to detect whether the target model has an option label bias or an option position preference when generating answers to multiple-choice questions, characterized in that: The method comprises the following steps: S1. Obtain a preset option tag list A and a preset option tag value exchange rule list JH, where A={A1, A2, ..., A x , …, A p }, A x is the xth preset option tag, x ranges from 1 to p, p is the number of preset option tags, and JH includes several preset option tag value exchange rules; S2. Based on the preset option label value exchange rules in JH, the preset multiple-choice question data list set B is processed to obtain the total set C of the specified multiple-choice question data list set, where B={B1, B2, …, B j , …, B n }, B j ={B j1 , B j2 }, B j2 ={B 1 j2 , B 2 j2 , …, B x j2 , …, B p j2 }, B j is the preset multiple-choice question data list corresponding to the jth preset multiple-choice question, the value of j ranges from 1 to n, n is the number of preset multiple-choice questions, B j1 is the text of the j-th preset multiple-choice question, B j2 is the preset option combination list of the jth preset multiple-choice question, B x j2 For B j2 Middle A x The corresponding preset option combination, A x The corresponding preset option combinations include A x and A x The corresponding preset option label value, C={C1, C2, …, C e , …, C f }, C e ={C e1 , C e2 , …, C ej , …, C en }, C ej ={C ej1 , C ej2 }, C ej2 ={C 1 ej2 , C 2 ej2 , …, C x ej2 , …, C p ej2 }, C e is the e-th specified multiple-choice question data list set, the value of e ranges from 1 to f, f is the number of specified multiple-choice question data lists, C ej C e The jth specified multiple choice question data list, C ej1 C ej The specified text in the question and C ej1 =B j1 , C ej2 C ej A list of specified option combinations in C x ej2 C ej2 Middle A x The corresponding specified option combination, A x The corresponding specified option combinations include A x and A x The corresponding specified option tag value; Step S2 includes the following sub-steps S21-S22: S21, extracting f-1 preset option label value exchange rules from JH as designated option label value exchange rules to construct a designated option label value exchange rule list, wherein the designated option label value exchange rule list includes f-1 designated option label value exchange rules, and the preset option label value exchange rule is a rule that represents simultaneously replacing a preset option label value corresponding to a first type of preset option label with a preset option label value corresponding to a second type of preset option label corresponding to the first type of preset option label, wherein the first type of preset option label and the second type of preset option label corresponding to the first type of preset option label are two different preset option labels in A; S22, when e=1, B x j2 Middle A x The corresponding default option tag value is C ej2 Middle A x The corresponding specified option tag value, when e>1, is exchanged according to the e-1th specified option tag value exchange rule. j2 A1, A2, ..., A x , …, A p The corresponding preset option tag value is exchanged to obtain C ej2 A1, A2, ..., A x , …, A p The corresponding specified option tag value; S3. According to C e Get the first cumulative number of selected times list D corresponding to A and the target model e And construct the first cumulative selection times list set D corresponding to A = {D1, D2, ..., D e , …, D f }, D e ={D e1 , D e2 , …, D ex , …, D ep }, D ex D e Middle A x The corresponding first cumulative number of selections; Step S3 includes the following sub-steps S31-S34: S31, C ej1 and C ej2 Input into the target model to obtain C x ej2 The corresponding selection score K x ej2 And build C e The corresponding selection score list set K e ={K e1 , K e2 , …, K ej , …, K en }, K ej ={K 1 ej2 , K 2 ej2 , …, K x ej2 , …, K p ej2 }, where K ej C ej a corresponding selection score list, wherein the selection score corresponding to the specified option combination is the original prediction value corresponding to the specified option combination in the target model after the specified question stem text and the specified option combination list in the specified multiple-choice question data list including the specified option combination are input into the target model, and the original prediction value is the original unprocessed score or score of the output layer of the target model; S32, according to K x ej2 Get C x ej2 The corresponding probability of being selected is L x ej2 And build C e The corresponding selected probability value list set L e ={L e1 , L e2 , …, L ej , …, L en }, L ej ={L 1 ej2 , L 2 ej2 , …, L x ej2 , …, L p ej2 }, L ej C ej The corresponding selected probability value list, L x ej2 Meet the following conditions: ; S33, max(L 1 ej2 , L 2 ej2 , …, L x ej2 , …, L p ej2 ) corresponds to C x ej2 As C ej Corresponding answer option combination M ej To obtain C e Corresponding answer option combination list M e ={M e1 , M e2 , …, M ej , …, M en }, max() is the maximum value acquisition function; S34, M e1 , M e2 , …, M ej , …, M en Includes A x The number of answer option combinations is D ex ; S4. For each D e D e1 , D e2 , …, D ex , …, D ep Perform vectorization processing to obtain the key vector list set E={E1, E2, …, E e ,…,E f }, E e ={E e1 , E e2 ,…,E ex ,…,E ep }, E e D e The corresponding key vector list, E ex D ex The corresponding key vector; S5. Obtain the key vector correlation coefficient list F={F1, F2, ..., F i , …, F m }, F i is the i-th key vector correlation coefficient, i ranges from 1 to m, m is the number of key vector correlation coefficients and m=f×(f-1) / 2, the key vector correlation coefficient is the Spearman correlation coefficient between two different key vector lists in E; S6, when F 0 / m≤F 1 When the target model generates answers to multiple-choice questions, it is determined that there is no option label bias or option position preference, F 0 is F1, F2, …, F i , …, F m The number of key vector correlation coefficients greater than △F in the , △F is the preset vector correlation coefficient, F 1 is the preset ratio.
2. The method for detecting a target model according to claim 1, characterized in that: The option label bias refers to the target model's systematic preference for selecting an option corresponding to a certain option label when generating answers to multiple-choice questions, and the option position preference refers to the target model's preference for selecting an option in a certain position when generating answers to multiple-choice questions.
3. The method for detecting a target model according to claim 1, characterized in that: Step S5 also includes the following sub-steps S51-S52 to obtain the Spearman correlation coefficient between two different key vector lists: S51, obtain two different key vector lists from E and use one of the key vector lists as the first key vector list XL1, and use the other key vector list as the second key vector list XL2, XL1={XL11, XL12, ..., XL1 x , …, XL1 p }, XL2={XL21, XL22,…,XL2 x , ..., XL2 p }, XL1 x is the xth first key vector in XL1, XL2 x is the xth second key vector in XL2; S52. Obtain the Spearman correlation coefficient ρ between XL1 and XL2, where ρ meets the following conditions: ρ=1-6×∑ p x=1 ((XL 0 x ) 2 ) / (p×(p 2 -1)), XL 0 x For XL1 x and XL2 x The vector distance between .
4. The method for detecting a target model according to claim 1, characterized in that: In step S6, it also includes: when F 0 / m>F 1 When generating answers to multiple-choice questions, it is determined whether the target model has option label bias or option position preference based on A, B and a preset option label position exchange rule list, where the preset option label position exchange rule list includes several preset option label position exchange rules.
5. The method for detecting a target model according to claim 4, characterized in that: In step S6, determining whether the target model has option label bias or option position preference when generating answers to multiple-choice questions based on A, B and the preset option label position exchange rule list includes the following sub-steps S61-S66: S61, extracting a preset option label position exchange rule from the preset option label position exchange rule list as the middle option label position exchange rule; S62, according to the middle option label position exchange rule, A1, A2, ..., A x , …, A p Exchange the arrangement positions in A to obtain the intermediate option label list G = {G1, G2, ..., G y , …, G q }, G y is the yth middle option label, the value of y ranges from 1 to q, q is the number of middle option labels and q=p; S63, according to G and B, obtain the intermediate multiple-choice question data list set H = {H1, H2, ..., H j , …, H n }, H j ={H j1 , H j2 }, H j2 ={H 1 j2 , H 2 j2 , …, H y j2 , …, H q j2 }, where H j is the data list of the jth intermediate multiple-choice question, H j1 H j The middle text in the question, H j2 H j The list of intermediate option combinations in H y j2 H j2 Medium G y The corresponding middle option combination, G y The corresponding middle option combination includes G y and G y The corresponding middle option label value, where H j1 =B j1 , when G y =A x When H y j2 G in y The corresponding middle option label value is the same as B x j2 A x The corresponding preset option tag values are the same; S64, according to B and the target model, obtain a second cumulative selection times list R corresponding to A = {R1, R2, ..., R x , …, R p }, where R x A in R x The corresponding second cumulative number of selections; S65, according to H and the target model, obtain a third cumulative selection times list J corresponding to G = {J1, J2, ..., J y , …, J p }, where J y For J in G y The corresponding third cumulative number of selections; S66. Determine whether the target model has option label bias or option position preference when generating answers to multiple-choice questions based on R and J.
6. The method for detecting a target model according to claim 5, characterized in that: Step S66 also includes the following steps S661-S664: S661, for R1, R2, ..., R x , …, R p and J1, J2, …, J in J y , …, J p Perform vectorization processing to obtain the first intermediate vector list R corresponding to R 0 ={R 0 1. R 0 2, ..., R 0 x , …, R 0 p } and the second intermediate vector list J corresponding to J 0 ={J 0 1. J 0 2, …, J 0 y , …, J 0 q }, where R 0 x For R x The corresponding first intermediate vector, J 0 y For J y The corresponding second intermediate vector; S662, when G y =A x When G y The corresponding J 0 y As A x The corresponding third intermediate vector N x To obtain the third intermediate vector list N={N1, N2, ..., N x ,…,N p }; S663, Get R 0 The Spearman correlation coefficient XG between and N, where XG meets the following conditions: XG=1-6×∑ p x=1 ((R_N x ) 2 ) / (p×(p 2 -1)), R_N x For R 0 x With N x The vector distance between S664. When XG≤△F, it is determined that the target model has an option position preference when generating answers to multiple-choice questions. When XG>△F, it is determined that the target model has an option label bias when generating answers to multiple-choice questions.
7. A non-transitory computer-readable storage medium, characterized in that: The storage medium stores a computer program, which is loaded and executed by a processor to implement the method for detecting a target model as described in any one of claims 1 to 6.
8. An electronic device comprising: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method for detecting a target model as described in any one of claims 1 to 6 when executing the computer program.
Citation Information
Patent Citations
Answer acquisition method and device
CN115828899A
Assessment method and device of large language model, storage medium and computer equipment
CN117291184A