A method for automatically evaluating large model code generation capabilities and related products
By constructing Chinese evaluation benchmarks and preset test units, and combining them with the execution evaluation criteria and pass@k+ unit test pass rates, the problems of insufficient evaluation capabilities and poor flexibility in large model code generation capabilities are solved, and efficient and accurate evaluation of large model code generation capabilities is achieved.
Patent Information
- Application Number
- CN202311212732.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-19
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-09-19
AI Technical Summary
Existing methods for evaluating the code generation capabilities of large models suffer from insufficient evaluation capabilities and poor flexibility, especially in the Chinese environment where there is a lack of effective evaluation benchmarks and fine-grained evaluation standards.
By constructing Chinese evaluation benchmarks and preset test units, and using pre-set Chinese test samples and preset test units, the code generated by large language models is evaluated. Combined with the evaluation method of execution evaluation criteria and pass@k+ unit test pass rate, the automatic evaluation of the code generation capability of large models is realized.
It improves the evaluation capabilities and flexibility of large model code generation, enabling more accurate assessment of code correctness and executability, and adapting to complex evaluation needs in a Chinese environment.
Smart Images

Figure CN117215944B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to an automatic evaluation method and related products for large model code generation capabilities. Background Technology
[0002] With technological advancements, large language models (LLMs) have revolutionized the field of natural language processing (NLP), and these models also support code writing capabilities. However, when generating code, LLMs primarily focus on the correctness of the code. Therefore, accurately and reasonably evaluating the code generation capabilities of large models is an important task.
[0003] Compared to Natural Language Processing (NLP), two syntactically different code snippets may be semantically equivalent, rendering some classic NLP metrics unreliable. Existing evaluation methods typically rely on unit tests, but these are limited in number, leading to insufficient testing and inaccurate problem descriptions. Furthermore, existing benchmarks for code evaluation in these methods are often based on English datasets, resulting in a lack of flexibility in the evaluation process.
[0004] Therefore, improving the evaluation capabilities and flexibility of large model code generation is an urgent problem to be solved by those skilled in the art. Summary of the Invention
[0005] To address the aforementioned issues, this application provides an automatic evaluation method and related products for large model code generation capabilities. It takes into account Chinese test samples and evaluates the code generation capabilities of large models through pre-built execution evaluation criteria and preset test units, thus solving the problems of insufficient evaluation capabilities and poor evaluation flexibility in existing evaluation methods.
[0006] Firstly, this application provides an automatic evaluation method for the code generation capability of large models, including:
[0007] The pre-set Chinese test samples are input into the large language model to be evaluated, so that the large language model to be evaluated generates the corresponding test code based on the Chinese test samples;
[0008] Obtain the code to be evaluated;
[0009] Based on pre-built execution evaluation criteria, the code to be evaluated is evaluated using preset test units to obtain evaluation results.
[0010] Optionally, before inputting pre-set Chinese test samples into the large language model to be evaluated, and before the large language model to be evaluated generates corresponding test code based on the Chinese test samples, the method further includes:
[0011] Establish Chinese evaluation benchmarks;
[0012] Obtain pre-set Chinese test samples from the Chinese evaluation benchmark.
[0013] Optionally, the construction of the Chinese evaluation benchmark includes:
[0014] A translation model is used to translate the English evaluation questions in the basic English evaluation benchmark into Chinese, resulting in the first evaluation question, which is then output for manual calibration.
[0015] Obtain the calibration results, and based on the calibration results, filter the first evaluation question to obtain the second evaluation question; the second evaluation question is the evaluation question in the first evaluation question whose calibration result is accurate;
[0016] Construct Chinese test cases based on the second evaluation question and basic Chinese programming questions;
[0017] A Chinese evaluation benchmark is constructed based on the aforementioned Chinese test samples.
[0018] Optionally, before evaluating the code to be evaluated using preset test units based on pre-built execution evaluation criteria and obtaining the evaluation results, the method further includes:
[0019] A first test unit group is constructed based on a neural network; the first test unit group includes at least two test units to be screened;
[0020] The test units to be screened are tested using standard evaluation codes to obtain test results;
[0021] Based on the test results, the test units to be screened are screened, and the test units that pass the test are recorded as preset test units.
[0022] A unit test sample library is constructed using the preset test units.
[0023] Optionally, before evaluating the code to be evaluated using preset test units based on pre-built execution evaluation criteria and obtaining the evaluation results, the method further includes:
[0024] Based on the code to be evaluated, determine the preset test unit corresponding to the code to be evaluated;
[0025] Obtain the preset test unit from the unit test sample library.
[0026] Optionally, before evaluating the code to be evaluated using preset test units based on pre-built execution evaluation criteria and obtaining the evaluation results, the method further includes:
[0027] An execution evaluation standard is constructed based on the code generation model evaluation metric pass@k and the unit test pass rate.
[0028] Based on the aforementioned performance evaluation criteria, an evaluation dimension is constructed that includes editing errors, runtime errors, memory outages, time outages, result errors, partial pass, and pass.
[0029] Optionally, the evaluation of the code to be evaluated based on pre-built execution evaluation criteria and using preset test units to obtain evaluation results includes:
[0030] The execution evaluation criteria are constructed based on the pass@k and the unit test pass rate. The code to be evaluated is evaluated using preset test units, and at least one of the evaluation dimensions is obtained as the evaluation result.
[0031] The unit test pass rate is the proportion of the preset test units that the code under test passed to the total number of preset test units used to evaluate the code under test when the evaluation result of the code under test is partially passed.
[0032] Secondly, this application provides an automatic evaluation device for large model code generation capabilities, comprising:
[0033] The input module is used to input pre-set Chinese test samples into the large language model to be evaluated, so that the large language model to be evaluated generates corresponding test code based on the Chinese test samples;
[0034] The acquisition module is used to acquire the code to be evaluated;
[0035] The evaluation module is used to evaluate the code to be evaluated based on preset execution evaluation criteria and using preset test units to obtain evaluation results.
[0036] Thirdly, this application provides an automatic evaluation device for large model code generation capabilities, including:
[0037] Memory, used to store computer programs;
[0038] A processor, used to execute the computer program, implement the steps of an automatic evaluation method for large model code generation capability as described in any of the preceding claims.
[0039] Fourthly, this application provides a readable storage medium, characterized in that a computer program is stored on the readable storage medium, and when the computer program is executed by a processor, it implements the steps of the automatic evaluation method for large model code generation capability as described in any of the preceding claims.
[0040] As can be seen from the above technical solutions, compared with the prior art, this application has the following advantages:
[0041] This application first inputs pre-set Chinese test cases into the large language model to be evaluated, causing the large language model to generate corresponding code to be evaluated based on the Chinese test cases. Then, the code to be evaluated is obtained. Finally, based on a pre-built execution evaluation criterion, the code to be evaluated is evaluated using preset test units to obtain the evaluation results. In this way, the evaluation method provided by this application takes into account Chinese test cases, evaluates the code generation capability of large models based on pre-built execution evaluation criteria and preset test units, and improves the evaluation capability and flexibility. Attached Figure Description
[0042] Figure 1 A flowchart illustrating an automatic evaluation method for large model code generation capability provided in this application;
[0043] Figure 2 A flowchart of a method for generating unit tests provided in this application;
[0044] Figure 3 A schematic diagram of the structure of an automatic evaluation device for large model code generation capability provided in this application. Detailed Implementation
[0045] As mentioned earlier, existing evaluation methods suffer from insufficient evaluation capabilities and poor flexibility. Specifically, with technological advancements, Large Language Models (LLMs) have revolutionized Natural Language Processing (NLP), and these large models also support code writing. However, LLMs primarily focus on code correctness when generating code. Compared to NLP, two syntactically different code snippets may be semantically equivalent, rendering classic NLP metrics like BLEU unreliable. Current technologies typically evaluate the correctness of code generated by large models through unit testing, such as the HumanEval benchmark. However, the number of unit tests is insufficient, as manually building high-quality tests is a challenging task, especially for complex programs, leading to inadequate testing and unclear or inaccurate problem descriptions. Furthermore, existing evaluation methods primarily use English datasets for code benchmarks, lacking Chinese code benchmarks, thus limiting the flexibility of the evaluation process.
[0046] To address the aforementioned issues, this application provides an automated evaluation method for the code generation capability of a large language model, comprising: first, inputting pre-set Chinese test examples into the large language model to be evaluated, causing the large language model to generate corresponding code to be evaluated based on the Chinese test examples; then, obtaining the code to be evaluated; and finally, evaluating the code to be evaluated using pre-built execution evaluation criteria and preset test units to obtain the evaluation results.
[0047] Thus, the evaluation method provided in this application takes into account Chinese test examples, evaluates the code generation capability of large models based on pre-built execution evaluation criteria and preset test units, and improves the evaluation capability and the flexibility of the evaluation.
[0048] It should be noted that the automatic evaluation method and related products for large model code generation capability provided in this application can be applied to the field of data processing technology. The above is merely an example and does not limit the application areas of the automatic evaluation method and related products for large model code generation capability provided in this application.
[0049] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0050] Figure 1 A flowchart illustrating an automatic evaluation method for large model code generation capability provided in this application. Combined with... Figure 1 As shown, the automatic evaluation method for large model code generation capability provided in this application may include:
[0051] S101: Input the pre-set Chinese test samples into the large language model to be evaluated, so that the large language model to be evaluated generates the corresponding test code based on the Chinese test samples.
[0052] In practical applications, with the development of technology, LLM has made revolutionary breakthroughs in the field of NLP. Large models also support code writing capabilities. When generating code, LLM primarily focuses on the correctness of the code. Large language models can generate code based on natural language instructions and then execute the code. Therefore, when evaluating the code generation capabilities of large language models, test cases must first be input into the model to generate corresponding code. Specifically, existing code evaluation benchmarks are mostly based on English datasets, lacking Chinese code evaluation benchmarks. Therefore, this application pre-sets Chinese test cases. During evaluation, the pre-set Chinese test cases are first input into the large language model to be evaluated, and the model generates the code to be evaluated. The Chinese test cases include API calls, Chinese understanding, content understanding, algorithmic ability, mathematical reasoning, and simple programming interview questions.
[0053] Furthermore, since the methods for obtaining Chinese test samples are not entirely the same, this application can describe one possible method of obtaining them.
[0054] In one scenario, regarding how to obtain Chinese test samples, before inputting the pre-set Chinese test samples into the large language model to be evaluated, and before the large language model to be evaluated generates the corresponding code to be evaluated based on the Chinese test samples, the method further includes:
[0055] Establish Chinese evaluation benchmarks;
[0056] Obtain pre-set Chinese test samples from the Chinese evaluation benchmark.
[0057] In practical applications, existing code evaluation benchmarks are mostly based on English datasets, lacking Chinese code evaluation benchmarks. Therefore, this application first constructs a Chinese evaluation benchmark. Specifically, the Chinese evaluation benchmark mainly covers API calls (including Python third-party library calls), Chinese comprehension, content comprehension, algorithmic ability, mathematical reasoning, and Chinese test examples related to simple programming interview questions. When evaluating the code generation capability of large models, the automatic evaluation device for large model code generation capability can obtain pre-set Chinese test examples from the Chinese evaluation benchmark.
[0058] Furthermore, since there are different ways to construct Chinese test cases, this application can describe one possible construction method.
[0059] In one scenario, regarding how to construct Chinese test cases, the corresponding construction of the Chinese evaluation benchmark includes:
[0060] A translation model is used to translate the English evaluation questions in the basic English evaluation benchmark into Chinese, resulting in the first evaluation question, which is then output for manual calibration.
[0061] Obtain the calibration results, and based on the calibration results, filter the first evaluation question to obtain the second evaluation question; the second evaluation question is the evaluation question in the first evaluation question whose calibration result is accurate;
[0062] Construct Chinese test cases based on the second evaluation question and basic Chinese programming questions;
[0063] A Chinese evaluation benchmark is constructed based on the aforementioned Chinese test samples.
[0064] In practical applications, the constructed Chinese benchmark contains 370 Chinese test cases, derived from Chinese programming problems, programming application problems, and some questions selected from the English benchmarks HumanEval and MBPP. These were translated into Chinese and their accuracy was manually verified. Specifically, a translation model is used to translate the English assessment questions in the basic English benchmark into Chinese, resulting in the first assessment question, which is then manually calibrated. This produces a series of questions with either accurate or inaccurate translations. An automated evaluation device with large-scale code generation capabilities uses the calibration results to select the accurately translated assessment questions, which are then designated as the second assessment questions for constructing the Chinese benchmark. It's important to note that the original English benchmark questions were formatted as code completion questions. Each test case includes a natural language description of the question, input and output descriptions, and some input / output examples, as shown below:
[0065]
[0066] To make it more convenient for developers, this application uses a text-to-code format for generating instructions. Each test case contains only a natural language description, such as "Given a positive floating-point number, it can be decomposed into an integer part and a fractional part. Return the fractional part of the number. Please implement this using Python code."
[0067] S102: Obtain the code to be evaluated.
[0068] In practical applications, an automated evaluation device capable of generating large-scale language model code inputs pre-set Chinese test samples into the large-scale language model to be evaluated, which then generates corresponding code for evaluation. The automated evaluation device then acquires this code and performs evaluation to obtain the evaluation result.
[0069] S103: Based on the pre-built execution evaluation criteria, the code to be evaluated is evaluated using preset test units to obtain the evaluation results.
[0070] In practical applications, the automatic evaluation device for large model code generation capabilities, after acquiring the code to be evaluated corresponding to the large language model to be evaluated, evaluates the code based on pre-built execution evaluation criteria and uses preset test units to obtain evaluation results. It should be noted that the pre-built execution evaluation criteria of this application have a more granular evaluation capability for large model code compared to existing technologies, while the preset test units provided by this application have a more comprehensive evaluation effect compared to existing technologies.
[0071] Furthermore, since there are different ways to construct unit test sample libraries, this application can describe one possible construction method.
[0072] In one scenario, the focus is on how to construct a unit test sample library. Accordingly, before evaluating the code to be evaluated using preset test units based on pre-built execution evaluation criteria and obtaining the evaluation results, the process further includes:
[0073] A first test unit group is constructed based on a neural network; the first test unit group includes at least two test units to be screened;
[0074] The test units to be screened are tested using standard evaluation codes to obtain test results;
[0075] Based on the test results, the test units to be screened are screened, and the test units that pass the test are recorded as preset test units.
[0076] A unit test sample library is constructed using the preset test units.
[0077] In practical applications, the unit test sample library contains test units for testing the code to be evaluated. Figure 2 A flowchart illustrating a method for generating unit tests provided in this application. (Combined with...) Figure 2 As shown, a design prompt is constructed to generate sample unit tests. Specifically, the neural network `chatgpt` is used to generate multiple new unit tests, generating at least two test units to be selected, forming the first test unit group. Then, based on the automatic evaluation framework, the standard evaluation code `ground_truth` is used to test the test units to be selected, thereby selecting high-quality unit tests, that is, selecting test units whose test results are passed, and recording them as preset test units. Thus, the library composed of preset test units that have passed the test is the unit test sample library. It should be noted that the automatic evaluation framework is composed of the automatic evaluation method with large model code generation capabilities provided in this application. In addition, the design prompt consists of two parts: a task description: please generate the corresponding unit tests based on the provided problem description and code; and a problem description: ground_truth code and sample input / output of the unit tests.
[0078] Furthermore, since there are different ways to obtain the preset test units, this application can describe one possible method of obtaining them.
[0079] In one scenario, regarding how to obtain preset test units, the process of evaluating the code to be evaluated using preset test units based on pre-built execution evaluation criteria and obtaining the evaluation results further includes:
[0080] Based on the code to be evaluated, determine the preset test unit corresponding to the code to be evaluated;
[0081] Obtain the preset test unit from the unit test sample library.
[0082] In practical applications, the constructed unit test sample library stores various preset test units. Different test samples have corresponding test units. Therefore, before obtaining preset test units, the automatic evaluation device for large model code generation capabilities needs to first identify the code to be evaluated generated by the large language model to be evaluated, then identify the corresponding preset test units based on the code to be evaluated, and then obtain these preset test units from the unit test sample library for testing.
[0083] Furthermore, since there are different ways to construct performance evaluation criteria, this application can describe one possible construction method.
[0084] In one scenario, the focus is on how to construct the execution evaluation criteria. Accordingly, before evaluating the code to be evaluated using preset test units based on the pre-constructed execution evaluation criteria and obtaining the evaluation results, the process further includes:
[0085] An execution evaluation standard is constructed based on the code generation model evaluation metric pass@k and the unit test pass rate.
[0086] Based on the aforementioned performance evaluation criteria, an evaluation dimension is constructed that includes editing errors, runtime errors, memory outages, time outages, result errors, partial pass, and pass.
[0087] In practical applications, in order to rigorously and accurately evaluate the ability of large model code generation, this application provides a fine-grained execution evaluation standard: code generation model evaluation index pass@k + unit test pass rate. Then, based on the execution evaluation standard, in order to evaluate the usability of the code from the perspective of unit test "executability", seven evaluation dimensions are designed, specifically including (1) compilation error: the program fails to compile due to syntax errors; (2) runtime error: the program compiles successfully, but fails to run due to environmental issues; (3) memory exceedance: the program consumes too much memory during execution, exceeding the memory limit; (4) time exceedance: the program runs beyond the originally predetermined time limit; (5) result error: the program compiles successfully and runs successfully, but the result is inconsistent with the correct result of the unit test; (6) partial pass: the percentage of the program that passes the unit tests; (7) pass: the program passes all unit tests. Among them, the pass@k evaluation index is: the sample must pass all the unit tests set for the sample, that is, all the preset test units are considered to be passed, and the statistical result is the sample pass rate that passes all preset test units.
[0088] Furthermore, since the evaluation methods are not entirely the same, this application may describe one possible evaluation method.
[0089] In one scenario, regarding how to conduct the evaluation, the code to be evaluated is evaluated using preset test units based on pre-built execution evaluation criteria to obtain evaluation results, including:
[0090] The execution evaluation criteria are constructed based on the pass@k and the unit test pass rate. The code to be evaluated is evaluated using preset test units, and at least one of the evaluation dimensions is obtained as the evaluation result.
[0091] The unit test pass rate is the proportion of the preset test units that the code under test passed to the total number of preset test units used to evaluate the code under test when the evaluation result of the code under test is partially passed.
[0092] In practical applications, the automatic evaluation device for large model code generation capabilities is based on the execution evaluation standard constructed from the above-mentioned pass@k+ unit test pass rate. It uses preset test units generated based on chatgpt and filtered to evaluate the code to be evaluated, obtaining at least one of the above evaluation dimensions as the evaluation result. The unit test pass rate is the percentage of preset test units that pass among the partially passed examples, representing a more granular evaluation method. The formula for calculating the unit test pass rate is as follows:
[0093] pass_ratio = n / N * 100%
[0094] Where N refers to the total number of preset test units for the sample, and n is the number of preset test units that the code can pass. The evaluation metric "pass@k+ unit test pass rate" proposed in this application can evaluate the code capability of large models in a more granular way.
[0095] In addition, to ensure security and executability, this application also provides an automatic evaluation framework for implementing the automatic evaluation method of the large model code generation capability provided in this application. Specifically, the input to the automatic code evaluation framework includes importing relevant Python libraries, complete code implementation, `def check(function name)`, and unit test assertions, in the following format:
[0096]
[0097] The output of the automated code evaluation framework includes: whether the test passed, the reasons for incomplete failure, and the percentage of unit tests that passed, in the following format:
[0098] {"result":"passed","whole_passed":true,"pass_ratio":100%}
[0099] {"result":"failed:unsupported operand type(s)for-:'list'and'list'","whole_passed":false,"pass_ratio":50%}.
[0100] In summary, this application first inputs pre-set Chinese test cases into the large language model to be evaluated, enabling the model to generate corresponding code for evaluation based on these test cases. Then, the code is obtained. Finally, based on pre-built execution evaluation criteria, the code is evaluated using preset test units to obtain the evaluation results. Thus, the evaluation method provided in this application takes into account Chinese test cases, evaluates the code generation capability of large models based on pre-built execution evaluation criteria and preset test units, and improves both the evaluation capability and the flexibility of the evaluation.
[0101] Based on the automatic evaluation method for large model code generation capability provided in the above embodiments, this application also provides an automatic evaluation device for large model code generation capability. The automatic evaluation device for large model code generation capability will be described below with reference to embodiments and accompanying drawings.
[0102] Figure 3 This is a schematic diagram of the structure of an automatic evaluation device for large model code generation capability provided in this application. (Combined with...) Figure 3 As shown in the embodiment of this application, the automatic evaluation device 200 for large model code generation capability includes:
[0103] The input module 201 is used to input pre-set Chinese test samples into the large language model to be evaluated, so that the large language model to be evaluated generates corresponding test code based on the Chinese test samples;
[0104] Module 202 is used to acquire the code to be evaluated;
[0105] The evaluation module 203 is used to evaluate the code to be evaluated based on a preset execution evaluation standard and a preset test unit to obtain the evaluation result.
[0106] As one implementation method, the automatic evaluation device 200 for large model code generation capability mentioned above, which is designed to obtain Chinese test samples, further includes: a first construction submodule and a first acquisition submodule;
[0107] The first submodule is used to build Chinese benchmarks;
[0108] The first acquisition submodule is used to acquire pre-set Chinese test samples from the Chinese evaluation benchmark.
[0109] As one implementation method, regarding how to construct a Chinese evaluation benchmark, the first construction submodule mentioned above is specifically used for:
[0110] A translation model is used to translate the English evaluation questions in the basic English evaluation benchmark into Chinese, resulting in the first evaluation question, which is then output for manual calibration.
[0111] Obtain the calibration results, and based on the calibration results, filter the first evaluation question to obtain the second evaluation question; the second evaluation question is the evaluation question in the first evaluation question whose calibration result is accurate;
[0112] Construct Chinese test cases based on the second evaluation question and basic Chinese programming questions;
[0113] A Chinese evaluation benchmark is constructed based on the aforementioned Chinese test samples.
[0114] As one implementation method, the above-mentioned automatic evaluation device 200 for large model code generation capability further includes: a second construction submodule, which addresses how to construct unit test samples;
[0115] The second construction submodule is used to construct a first test unit group based on a neural network; the first test unit group includes at least two test units to be screened.
[0116] The test units to be screened are tested using standard evaluation codes to obtain test results;
[0117] Based on the test results, the test units to be screened are screened, and the test units that pass the test are recorded as preset test units.
[0118] A unit test sample library is constructed using the preset test units.
[0119] As one implementation method, the above-mentioned automatic evaluation device 200 for large model code generation capability further includes a second acquisition submodule for obtaining preset test units;
[0120] The second acquisition submodule is used to determine the preset test unit corresponding to the code to be evaluated based on the code to be evaluated;
[0121] Obtain the preset test unit from the unit test sample library.
[0122] As one implementation method, the above-mentioned automatic evaluation device 200 for large model code generation capability, which is designed to construct performance evaluation criteria, also includes: a third construction submodule;
[0123] The third submodule is used to build an execution evaluation standard based on the code generation model evaluation metric pass@k and the unit test pass rate.
[0124] Based on the aforementioned performance evaluation criteria, an evaluation dimension is constructed that includes editing errors, runtime errors, memory outages, time outages, result errors, partial pass, and pass.
[0125] As one implementation method, regarding how to conduct the evaluation and obtain the evaluation results, the aforementioned evaluation module 203 is specifically used for:
[0126] The execution evaluation criteria are constructed based on the pass@k and the unit test pass rate. The code to be evaluated is evaluated using preset test units, and at least one of the evaluation dimensions is obtained as the evaluation result.
[0127] The unit test pass rate is the proportion of the preset test units that the code under test passed to the total number of preset test units used to evaluate the code under test when the evaluation result of the code under test is partially passed.
[0128] In summary, this application first inputs pre-set Chinese test cases into the large language model to be evaluated, enabling the model to generate corresponding code for evaluation based on these test cases. Then, the code is obtained. Finally, based on pre-built execution evaluation criteria, the code is evaluated using preset test units to obtain the evaluation results. Thus, the evaluation method provided in this application takes into account Chinese test cases, evaluates the code generation capability of large models based on pre-built execution evaluation criteria and preset test units, and improves both the evaluation capability and the flexibility of the evaluation.
[0129] In addition, this application also provides an automatic evaluation device for large model code generation capability, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of the automatic evaluation method for large model code generation capability as described in any of the above claims.
[0130] In addition, this application also provides a readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the automatic evaluation method for large model code generation capability as described in any of the preceding claims.
[0131] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An automatic evaluation method for the code generation capability of large models, characterized in that, The method includes: The pre-set Chinese test samples are input into the large language model to be evaluated, so that the large language model to be evaluated generates the corresponding test code based on the Chinese test samples; Obtain the code to be evaluated; Based on pre-built execution evaluation criteria, the code to be evaluated is evaluated using preset test units to obtain evaluation results; Before the step of inputting pre-set Chinese test samples into the large language model to be evaluated, and causing the large language model to generate corresponding test code based on the Chinese test samples, the method further includes: Establish Chinese evaluation benchmarks; Obtain pre-set Chinese test samples from the aforementioned Chinese evaluation benchmark; The construction of the Chinese evaluation benchmark includes: A translation model is used to translate the English evaluation questions in the basic English evaluation benchmark into Chinese, resulting in the first evaluation question, which is then output for manual calibration. Obtain the calibration results, and based on the calibration results, filter the first evaluation question to obtain the second evaluation question; the second evaluation question is the evaluation question in the first evaluation question whose calibration result is accurate; Construct Chinese test cases based on the second evaluation question and basic Chinese programming questions; A Chinese evaluation benchmark is constructed based on the aforementioned Chinese test samples.
2. The method according to claim 1, characterized in that, Before obtaining the evaluation result by evaluating the code to be evaluated using a preset test unit based on a pre-built execution evaluation standard, the process further includes: A first test unit group is constructed based on a neural network; the first test unit group includes at least two test units to be screened; The test units to be screened are tested using standard evaluation codes to obtain test results; Based on the test results, the test units to be screened are screened, and the test units that pass the test are recorded as preset test units. A unit test sample library is constructed using the preset test units.
3. The method according to claim 2, characterized in that, Before obtaining the evaluation result by evaluating the code to be evaluated using a preset test unit based on a pre-built execution evaluation standard, the process further includes: Based on the code to be evaluated, determine the preset test unit corresponding to the code to be evaluated; Obtain the preset test unit from the unit test sample library.
4. The method according to claim 1, characterized in that, Before obtaining the evaluation result by evaluating the code to be evaluated using a preset test unit based on a pre-built execution evaluation standard, the process further includes: An execution evaluation standard is constructed based on the code generation model evaluation metric pass@k and the unit test pass rate. Based on the aforementioned performance evaluation criteria, an evaluation dimension is constructed that includes editing errors, runtime errors, memory outages, time outages, result errors, partial pass, and pass.
5. The method according to claim 4, characterized in that, The evaluation, based on pre-built execution evaluation criteria, utilizes preset test units to evaluate the code to be evaluated, obtaining evaluation results, including: The execution evaluation criteria are constructed based on the pass@k and the unit test pass rate. The code to be evaluated is evaluated using preset test units, and at least one of the evaluation dimensions is obtained as the evaluation result. The unit test pass rate is the proportion of the preset test units that the code under test passed to the total number of preset test units used to evaluate the code under test when the evaluation result of the code under test is partially passed.
6. An automatic evaluation device for large model code generation capability, characterized in that, include: The first submodule is used to build Chinese benchmarks; The first acquisition submodule is used to acquire pre-set Chinese test samples from the Chinese evaluation benchmark; The input module is used to input pre-set Chinese test samples into the large language model to be evaluated, so that the large language model to be evaluated generates corresponding test code based on the Chinese test samples; The acquisition module is used to acquire the code to be evaluated; The evaluation module is used to evaluate the code to be evaluated based on pre-built execution evaluation criteria and using preset test units to obtain evaluation results; The first construction submodule is specifically used for: A translation model is used to translate the English evaluation questions in the basic English evaluation benchmark into Chinese, resulting in the first evaluation question, which is then output for manual calibration. Obtain the calibration results, and based on the calibration results, filter the first evaluation question to obtain the second evaluation question; The second evaluation question is the evaluation question in the first evaluation question where the calibration result is accurate; Construct Chinese test cases based on the second evaluation question and basic Chinese programming questions; A Chinese evaluation benchmark is constructed based on the aforementioned Chinese test samples.
7. An automatic evaluation device for large model code generation capability, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the automatic evaluation method for large model code generation capability as described in any one of claims 1 to 5 when executing the computer program.
8. A readable storage medium, characterized in that, The readable storage medium stores a computer program that, when executed by a processor, implements the steps of the automatic evaluation method for large model code generation capability as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Pre-training language model evaluation method and device and storage medium
CN113673702A
Model evaluation method and device, electronic equipment and storage medium
CN116737881A
