Fine tuning sample construction method and device for large code model

By constructing supervised fine-tuning samples, the mapping relationship between test cases and the method being tested is established, which solves the problem that the code model is not effective in the testing field and improves the accuracy of the generation of test cases.

CN119201691APending Publication Date: 2024-12-27ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411217173.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

The existing code model is not effective in the testing field, mainly because it adopts unsupervised learning method training and lacks output labels, which affects the prediction effect.

Method used

By constructing supervised fine-tuning samples, establish a mapping relationship between the test cases and the measured method, and use the measured method and the class to be classified as prompt words, and the test cases as reference answers to fine-tune the code big model.

Benefits of technology

Improves the accuracy of generating test cases, allowing code big models to better learn and generate the logic of test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201691A_ABST
    Figure CN119201691A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a fine tuning sample construction method and device for a code large model, in the construction method, for any target test class in a test code file set, based on a first class path corresponding to the target test class in a file system, a fine tuning sample is constructed, and determining a target tested class matched with each tested class from the tested classes in the tested code file set. And for any target test case in the target test class, determining a target method matched with the target test case from the tested methods in the target tested class based on the method names of the calling methods in the target test case. A fine tuning sample is constructed, the cue word comprises the target tested class and the target method, and the reference answer comprises the target test case.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present specification relate to the field of machine learning technology, and more particularly, to a method and device for constructing fine-tuning samples for a large code model. Background Art

[0002] At present, AI technology, especially Large Language Model (LLM) technology, is becoming more and more popular. In the field of code generation, some excellent large code models have also emerged, such as Copilot, CodeLlama, etc. However, the current large code models are mainly aimed at tasks such as code generation, comment generation, code interpretation, and code error correction. The effect in the testing field is not ideal. The reason is that currently in the testing field, unsupervised learning is mainly used to train large code models. For example, when training a large code model for generating test cases, only the test cases are input as samples to the large code model, and no corresponding output labels are set for the samples, which will affect the prediction effect of the large code model. Summary of the invention

[0003] One or more embodiments of the present specification describe a method and apparatus for constructing fine-tuning samples for a large code model, which can construct supervised fine-tuning samples for the large code model, thereby enabling more accurate test cases to be generated based on the fine-tuned large code model.

[0004] In a first aspect, a method for constructing a fine-tuning sample for a large code model is provided, comprising:

[0005] For any target test class in the test code file set, based on its corresponding first-class path in the file system, determine the target tested class that matches it from each tested class in the tested code file set;

[0006] For any target test case in the target test class, based on the method names of the respective calling methods therein, a target method matching the target test case is determined from the various tested methods in the target tested class;

[0007] A fine-tuning sample is constructed, wherein the prompt words include the target tested class and the target method, and the reference answer includes the target test case.

[0008] In a second aspect, a device for constructing fine-tuning samples for a large code model is provided, comprising:

[0009] A determination unit, for determining, for any target test class in the test code file set, a target tested class that matches the target test class from each tested class in the tested code file set based on the first class path corresponding to the target test class in the file system;

[0010] The determining unit is further configured to determine, for any target test case in the target test class, a target method matching the target test case from among the various tested methods in the target tested class based on the method names of the respective calling methods therein;

[0011] The construction unit is used to construct a fine-tuning sample, wherein the prompt words include the target tested class and the target method, and the reference answer includes the target test case.

[0012] According to a third aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the method of the first aspect.

[0013] In a fourth aspect, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method of the first aspect is implemented.

[0014] One or more embodiments of the present specification provide a method and device for constructing fine-tuning samples for a large code model, first establishing a mapping relationship between a test case and a method under test, and then using the method under test and its class as prompt words, and the test case as a reference answer, to construct a supervised fine-tuning sample of the large code model. It should be understood that since there is a mapping relationship between the method under test and the test case in the fine-tuning sample, when fine-tuning the large code model based on it, the large code model can learn the generation logic of the test case, thereby improving the accuracy of the generated test case. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0016] Figure 1 A schematic diagram of an implementation scenario of an embodiment disclosed in this specification;

[0017] Figure 2 A flow chart of a method for constructing a fine-tuning sample for a large code model according to an embodiment of the present specification is shown;

[0018] Figure 3 A schematic diagram showing a mapping relationship between a test class and a tested class is shown in an example;

[0019] Figure 4 A schematic diagram showing a mapping relationship between test cases and tested methods is shown in an example;

[0020] Figure 5 A schematic diagram of a device for constructing fine-tuning samples for a large code model according to an embodiment of the present specification is shown. DETAILED DESCRIPTION

[0021] The solution provided in this specification is described below in conjunction with the accompanying drawings.

[0022] Figure 1 A schematic diagram of an implementation scenario of an embodiment disclosed in this specification. Figure 1 In the file system, a test code file set and a tested code file set are stored. In a more specific embodiment, the test code file set and the tested code file set are both stored in the engineering directory src of the file system.

[0023] Further, the tested code file set may include multiple tested class files (referred to as tested classes), and each tested class may include multiple tested methods. The test code file set may include multiple test class files (referred to as test classes), and each test class may include multiple test cases. It should be understood that any test case in any test class here is used to test a certain tested method in a certain tested class. Thus, the test class corresponds to the tested class, and the test case corresponds to the tested method. In addition, each test case can call several methods (hereinafter referred to as calling methods).

[0024] Specifically, when constructing a fine-tuning sample for the large code model, for each test class in the test code file set, based on its corresponding class path in the text system, a matching tested class can be determined from each tested class. Afterwards, for each test case in any test class, a matching tested method can be determined from each tested method in the corresponding tested class based on the method names of the several calling methods therein, so as to establish a mapping relationship between the test case and the tested method. Finally, based on the mapping relationship, a supervised fine-tuning sample of the large code model can be constructed, in which the prompt words include the tested class and the tested method, and the reference answer includes a test case that has a mapping relationship with the tested method.

[0025] It should be noted that after the above-mentioned fine-tuning sample is constructed, the pre-trained code model can be fine-tuned based on the fine-tuning sample to obtain the code model for generating test cases. In a more specific embodiment, the test case is a unit test case.

[0026] Figure 2 The flowchart of the method for constructing fine-tuning samples for a large code model according to one embodiment of the present specification is shown. The method can be executed by any device, equipment, platform, or device cluster with computing and processing capabilities. Figure 2As shown, the method may include the following steps:

[0027] Step S202 : for any target test class in the test code file set, based on its corresponding first class path in the file system, determine a target tested class that matches it from each tested class in the tested code file set.

[0028] The first type of path mentioned above indicates the class name of the corresponding target test class.

[0029] For example, the test code file set test is stored in the project directory src of the file system, and the first class path corresponding to the test class: MyClass1 may be, for example, "src / test / MyClass1.java".

[0030] Of course, in practice, the test code file set may also be stored separately in the file system, so that the first class path corresponding to the test class: MyClass1 may be, for example: "test / MyClass1.java".

[0031] In one embodiment, a target tested class matching the target test class is first searched through class path comparison. If the search fails, a target tested class matching the target test class is then searched through class name comparison.

[0032] In another embodiment, the target tested class matching the target test class is directly searched by comparing the class names.

[0033] The implementation process of the above embodiment is described in detail below.

[0034] Specifically, based on the first class path, a second path set is queried, and the second path set is formed based on the second class path corresponding to each class under test in the file system. If the query result indicates that a target second class path matching the first class path is queried, the target class under test is determined according to the second class name extracted from the target second class path. If the query result indicates that the target second class path is not queried, the target class under test is determined according to the first class name of the target test class extracted from the first class path and the second path set.

[0035] For example, the tested code file set main is also stored in the project directory src of the file system, and the second type path corresponding to the tested class: MyClass2 can be, for example, "src / main / MyClass2.java".

[0036] It should be understood that, since under normal circumstances, the test code file set and the tested code file set are named differently, before querying the second path set based on the first path, the first path can be preprocessed to obtain the target path, and then the target path can be compared with each second path in the second path set.

[0037] The preprocessing here may include but is not limited to at least one of string replacement and case conversion, etc. String replacement may, for example, replace "src / test / " with "src / main / ", or replace "test / " with an empty string, etc. In addition, case conversion may, for example, convert "MyClass1" to "myc l ass1", so that the target path corresponding to the test class MyClass1 may, for example, be: "src / test / myc l ass1.java".

[0038] Of course, in practice, before performing the above comparison operation, each second-category path in the second path set may also be case-converted, etc. For example, after case conversion, the second-category path corresponding to the tested class MyClass2 is: "src / main / myclass2.java".

[0039] In addition, the second category name can be specifically extracted by the following steps: extract the string after the last slash from the target second category path as the second category name. Similarly, the first category name can be extracted.

[0040] For example, assuming the target second class path is: "src / main / myc l ass2.java", then the extracted second class name is: "myc l ass2.java".

[0041] It should be understood that the above determination of the target tested class based on the first class name and the second path set of the target test class extracted from the first class path is a process of searching for the target tested class by class name comparison, which is described in detail below.

[0042] Specifically, for each second-category path in the second path set, the second-category name of the corresponding tested class is extracted to obtain the target set. Based on the first-category name, the target set is queried to obtain the target second-category name. According to the target second-category name, the target tested class is determined.

[0043] The method for extracting the second category name from each second category path can be referred to above and will not be described again here.

[0044] The above-mentioned step of querying the target set may include: formatting the first class name to obtain the class name of the implementation class corresponding to the target test class. Compare the class name of the implementation class with each second class name in the target set. If there is a second class name that is consistent with the class name of the implementation class, then determine the consistent second class name as the target second class name. If there is no second class name that is consistent with the class name of the implementation class, then compare the first class name with each second class name in the target set to determine the target second class name.

[0045] The step of formatting the first class name may specifically include: removing the suffix of the first class name, and adding preset characters indicating the implementation class. For example, when the first class name is: "myc l ass1.java", the class name of the corresponding implementation class may be: "myc l ass1 imp l", wherein "imp l" is the preset characters indicating the implementation class. Of course, in practice, there may be other character strings after ".java", in which case, other character strings need to be added after the preset characters.

[0046] It should be understood that the above steps actually first search for a target tested class that matches the target test class from the implementation class (a part of the tested class) in the tested code file set, and when it cannot be found, then search for a target tested class that matches the target test class from all tested classes. Of course, in practice, it is also possible to directly search for a target tested class that matches the target test class from all tested classes, and this specification does not limit this.

[0047] It should be noted that there may be multiple target second class names found through class name comparison. When multiple target second class names are found, the first class path of the target test class can be matched with the multiple second class paths corresponding to the multiple target second class names in reverse order (reverse matching starts from the end of the string and searches and matches in order from back to front), and the number of character matches corresponding to the multiple target second class names is counted. The class under test corresponding to the target second class name with the largest number of corresponding character matches is determined as the target class under test.

[0048] It should also be noted that if there are two or more target second category names with the same number of character matches, the tested class corresponding to the target second category name that is ranked first will be determined as the target tested class.

[0049] Similarly, for each test class in the test code file set, the corresponding tested class can be determined.

[0050] Figure 3 A schematic diagram showing a mapping relationship between a test class and a tested class is shown in an example. Figure 3In , for any target test class in the test code file set, first query the second path set based on the corresponding first class path. If a target second class path that matches it is queried, the target class under test is determined based on the second class name contained therein. If a target second class path that matches it is not queried, the first class name is extracted from the first class path. After that, the first class name is first formatted to obtain the class name of the corresponding implementation class, and based on the class name of the implementation class, the target set corresponding to the second path set is queried. If a consistent target second class name is queried, the corresponding class under test is determined as the target class under test. If a consistent target second class name is not queried, the target set is queried based on the first class name before the format adjustment to determine the target class under test.

[0051] Step S204 , for any target test case in the target test class, based on the method names of the several calling methods therein, a target method matching the target test case is determined from the various tested methods in the target tested class.

[0052] In one embodiment, for any first calling method among several calling methods, based on the corresponding first method name, a first list corresponding to the target tested class is queried, and the first list is used to record the method names of each tested method. If the query result indicates that a target method name matching the first method name is found, the target method name is recorded, and the position of the first calling method in the target test case is recorded as the calling position corresponding to the target method name. The target method is determined based on the target method names and corresponding calling positions recorded for several calling methods.

[0053] The first list is obtained by the following steps: using a syntax parsing tool (e.g., Tree-Sitter) to parse the target class under test, and obtaining a first abstract syntax tree (abstract syntax code, AST), wherein each node represents a structure, and the structure here includes but is not limited to method (function) declarations, variable declarations, operators, control flow statements, etc., and the child nodes of the node represent the components of the structure. For example, a method declaration node may have the following types of child nodes: a child node representing the method name, a child node representing the parameter list, and a child node representing the function body, etc. Afterwards, the first list can be determined based on the child node representing the method name of the node representing the method declaration in the first abstract syntax tree.

[0054] Of course, in practice, when the number of tested methods in the target tested class is relatively small, each tested method can be directly read from the target tested class to form the first list without first parsing into an abstract syntax tree.

[0055] In addition, for the above target test class, the syntax parsing tool can be used to parse it into a second abstract syntax tree, and then further based on the second abstract syntax tree, the test case list and the call method list corresponding to each test case are determined. Afterwards, for each test case in the test case list, the corresponding method to be tested is determined based on each call method name in the corresponding call method list.

[0056] That is to say, the target test case may be any test case in the test case list corresponding to the target test class, and the method names of the several calling methods therein are the method names recorded in the corresponding calling method list.

[0057] Generally speaking, the methods under test in the class under test are divided into two types: private methods and public methods. For private methods, the test class needs to call them through reflection, and the corresponding method names need to be defined according to the naming rules of the reflection mechanism. Therefore, for methods called through reflection (referred to as reflection call), the corresponding method names need to be restored to regular names first, and then compared with the method names of each method under test.

[0058] For example, when the calling method of the first calling method is a reflection call, the regular name of the first calling method is obtained based on the first method name, and the regular name is compared with the method name of each method under test. When the calling method of the first calling method is a normal call, the first method name is directly compared with the method name of each method under test.

[0059] In a specific example, for each test case, the correspondence between the method name of the reflectively called method and the conventional name may be associated and stored, and then the conventional name of the first calling method may be obtained by querying the correspondence.

[0060] As mentioned above, for any target test case, several target method names and corresponding call locations will be recorded. Afterwards, the method under test corresponding to the target method name with the last corresponding call location among the target method names can be determined as the target method corresponding to the target test case.

[0061] Similarly, for each test case in each test class, the corresponding tested method can be determined from the corresponding tested class.

[0062] It should be understood that the above-mentioned embodiment actually determines the tested method corresponding to the target test case by traversing each calling method in the target test case in sequence. In practice, the calling methods in the target test case can also be sorted according to the calling order from front to back. Then, for each sorted calling method, starting from the last calling method, it is determined from back to front whether the corresponding target method name can be found. If the corresponding target method name can be found for any calling method, the tested method corresponding to the target method name is determined as the above-mentioned target method, and the judgment is ended, thereby improving the efficiency of determining the tested method.

[0063] Figure 4 A schematic diagram showing a mapping relationship between test cases and tested methods in an example is shown. Figure 4 In the example, it is assumed that test class 1 corresponds to class 1 under test, and test class 1 includes two test cases: user 1 and case 2, and case 1 includes two calling methods: calling method 11 and calling method 12, and calling method 11 is called by reflection, and calling method 12 is called by normal method. In addition, class 1 under test includes 6 methods under test: method A to method F under test.

[0064] The process of determining the method under test corresponding to use case 1 is as follows:

[0065] For calling method 11, first obtain the corresponding regular name, and then match the regular name with the method name of each tested method in the tested class. If it matches the tested method C, the line number of calling method 11 and the tested method C are added to the backup list; for calling method 12, directly match its method name with the method name of each tested method in the tested class. If it matches the tested method E, the line number of calling method 12 and the tested method E are added to the backup list; because the line number of calling method 12 is after the line number of calling method 11, a mapping relationship between use case 1 and tested method E is established.

[0066] Step S206, constructing a fine-tuning sample, wherein the prompt words include the target tested class and the target method, and the reference answer includes the target test case.

[0067] Similarly, multiple fine-tuning samples can be constructed based on the mapping relationship between other test cases and the method under test. Then, the pre-trained code model can be fine-tuned based on the multiple fine-tuning samples to obtain a fine-tuned code model. Finally, test cases can be generated based on the fine-tuned code model.

[0068] In summary, the method for constructing fine-tuning samples for the code big model provided in the embodiment of this specification first establishes a mapping relationship between the test case and the method under test, and then uses the method under test and its class as prompt words, and the test case as a reference answer, to construct a supervised fine-tuning sample of the code big model. It should be understood that since there is a mapping relationship between the method under test and the test case in the fine-tuning sample, when fine-tuning the code big model based on it, the code big model can learn the generation logic of the test case, thereby improving the accuracy of the generated test case.

[0069] Corresponding to the above-mentioned method for constructing fine-tuning samples for a large code model, an embodiment of the present specification also provides a device for constructing fine-tuning samples for a large code model, such as Figure 5 As shown, the device may include:

[0070] The determination unit 502 is used to determine, for any target test class in the test code file set, a target tested class that matches the target test class from each tested class in the tested code file set based on the first class path corresponding to the target test class in the file system.

[0071] The determining unit 502 is further configured to determine, for any target test case in the target test class, a target method that matches the target test case from among the methods under test in the target tested class based on the method names of the several calling methods therein.

[0072] The construction unit 504 is used to construct a fine-tuning sample, wherein the prompt words include the target tested class and the target method, and the reference answer includes the target test case.

[0073] In one embodiment, the determining unit 502 includes:

[0074] A query submodule 5022, configured to query a second path set based on the first path, wherein the second path set is formed based on the second path corresponding to each of the tested classes in the file system;

[0075] The determination submodule 5024 is used to determine the target tested class according to the second class name extracted from the target second class path if the query result indicates that the target second class path matching the first class path is queried;

[0076] The determination submodule 5024 is further configured to determine the target tested class according to the first class name of the target test class extracted from the first class path and the second path set if the query result indicates that the target second class path is not found.

[0077] In one embodiment, the query submodule 5022 is specifically used for:

[0078] Preprocess the first type of path to obtain the target path;

[0079] Comparing the target path with each second-category path in the second path set;

[0080] The preprocessing includes at least one of string replacement and case conversion.

[0081] The determination submodule 5024 is specifically used for:

[0082] For each second-category path in the second path set, extract the second-category name corresponding to the tested class to obtain a target set;

[0083] Based on the first category name, query the target set to obtain the second category name of the target;

[0084] Determine the target class to be tested based on the target second class name.

[0085] In one embodiment, the determination submodule 5024 is further specifically configured to:

[0086] Adjust the format of the first class name to obtain the class name of the implementation class corresponding to the target test class;

[0087] Compare the class name of the implementation class with each second class name in the target set;

[0088] If there is a second class name that is consistent with the class name of the implementation class, the consistent second class name is determined as the target second class name;

[0089] If there is no second class name that is consistent with the class name of the implementation class, the first class name is compared with each second class name in the target set to determine the target second class name.

[0090] In one embodiment, the target second category name is a plurality of target second category names;

[0091] The determination submodule 5024 is further specifically configured to:

[0092] Perform reverse matching on the first-category path and the plurality of second-category paths corresponding to the plurality of target second-category names, and count the number of character matches corresponding to the plurality of target second-category names;

[0093] The tested class corresponding to the target second class name with the largest number of corresponding character matches is determined as the target tested class.

[0094] In another embodiment, the determining unit 502 includes:

[0095] A query submodule 5022 is used to query a first list corresponding to a target tested class based on a corresponding first method name for any first calling method among the plurality of calling methods, where the first list is used to record the method names of the respective tested methods;

[0096] The recording submodule 5026 is used to record the target method name if the query result indicates that the target method name matching the first method name is found, and record the position of the first calling method in the target test case as the calling position corresponding to the target method name;

[0097] The determination submodule 5024 is used to determine the target method according to the target method names and corresponding calling positions recorded for the plurality of calling methods.

[0098] In one embodiment, the apparatus further comprises:

[0099] A parsing unit 506 is used to parse the target class under test using a syntax parsing tool to obtain a first abstract syntax tree AST;

[0100] The determining unit 502 is further configured to determine a first list according to the child nodes representing the method names of the nodes representing the method declarations.

[0101] In one embodiment, the query submodule 5022 is specifically used for:

[0102] In the case where the calling mode of the first calling method is a reflection call, based on the first method name, a conventional name of the first calling method is obtained, and the conventional name is compared with the method name of each method under test;

[0103] When the calling mode of the first calling method is a normal calling, the first method name is directly compared with the method names of each tested method.

[0104] In one embodiment, the determination submodule 5024 is specifically used to:

[0105] The method under test corresponding to the target method name with the last corresponding call position in each target method name is determined as the target method.

[0106] The functions of the functional units of the device in the above-mentioned embodiment of this specification can be implemented through the steps of the above-mentioned method embodiment. Therefore, the specific working process of the device provided by one embodiment of this specification will not be repeated here.

[0107] An embodiment of the present specification provides a device for constructing fine-tuning samples for a large code model, which can construct supervised fine-tuning samples for the large code model, thereby enabling more accurate test cases to be generated based on the fine-tuned large code model.

[0108] According to another embodiment, there is also provided a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute a combination of Figure 2 The method described.

[0109] According to another embodiment of the present invention, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the Figure 2 The method described.

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

[0111] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0112] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of this specification. It should be understood that the above description is only the specific implementation method of this specification and is not intended to limit the protection scope of this specification. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of this specification should be included in the protection scope of this specification.

Claims

1. A method for constructing fine-tuning samples for a large code model, comprising: For any target test class in the test code file set, based on its corresponding first-class path in the file system, determine the target tested class that matches it from each tested class in the tested code file set; For any target test case in the target test class, based on the method names of the respective calling methods therein, a target method matching the target test case is determined from the various tested methods in the target tested class; A fine-tuning sample is constructed, wherein the prompt words include the target tested class and the target method, and the reference answer includes the target test case.

2. The method according to claim 1, wherein: The step of determining a target tested class that matches each tested class in the tested code file set includes: Based on the first class path, query a second path set; the second path set is formed based on the second class path corresponding to each of the tested classes in the file system; If the query result indicates that a target second-category path matching the first-category path is found, determining the target tested class according to the second-category name extracted from the target second-category path; If the query result indicates that the target second class path is not found, the target tested class is determined according to the first class name of the target test class extracted from the first class path and the second path set.

3. The method according to claim 2, wherein: The querying of the second path set includes: Preprocessing the first type of path to obtain a target path; Comparing the target path with each second-category path in the second path set; The preprocessing includes at least one of string replacement and case conversion.

4. The method according to claim 2, wherein: The determining of the target tested class includes: For each second-category path in the second path set, extract the second-category name corresponding to the tested class to obtain a target set; Based on the first category name, query the target set to obtain the target second category name; According to the second class name of the target, the class of the target to be tested is determined.

5. The method according to claim 4, wherein: The querying the target set includes: Adjusting the format of the first class name to obtain the class name of the implementation class corresponding to the target test class; Comparing the class name of the implementation class with each second class name in the target set; If there is a second class name that is consistent with the class name of the implementation class, then the consistent second class name is determined as the target second class name; If there is no second class name that is consistent with the class name of the implementation class, the first class name is compared with each second class name in the target set to determine the target second class name.

6. The method according to claim 4, wherein: The target second category name is a plurality of target second category names; The determining of the target tested class includes: Perform reverse matching of the first-category path with the plurality of second-category paths corresponding to the plurality of target second-category names, and count the number of character matches corresponding to the plurality of target second-category names; The tested class corresponding to the target second class name with the largest number of corresponding character matches is determined as the target tested class.

7. The method according to claim 1, wherein: The step of determining a target method that matches each of the tested methods in the target tested class includes: For any first calling method among the plurality of calling methods, based on the corresponding first method name, query a first list corresponding to the target tested class; the first list is used to record the method name of each of the tested methods; If the query result indicates that a target method name matching the first method name is found, the target method name is recorded, and the position of the first calling method in the target test case is recorded as the calling position corresponding to the target method name; The target method is determined according to each target method name and the corresponding calling position recorded for the plurality of calling methods.

8. The method according to claim 7, wherein: The first list is obtained by the following steps: Parsing the target class under test using a syntax parsing tool to obtain a first abstract syntax tree AST; The first list is determined based on the child nodes representing the method names of the nodes representing the method declarations.

9. The method according to claim 7, wherein: The query corresponds to the first list of target tested classes, including: In the case where the calling mode of the first calling method is a reflection call, based on the first method name, obtaining a conventional name of the first calling method, and comparing the conventional name with the method names of each of the tested methods; When the calling mode of the first calling method is a normal calling mode, the first method name is directly compared with the method names of the various tested methods.

10. The method according to claim 7, wherein: Determining the target method according to the target method names and corresponding call locations recorded for the plurality of call methods includes: The method under test corresponding to the target method name with the last corresponding calling position among the target method names is determined as the target method.

11. A fine-tuning sample construction device for a large code model, comprising: A determination unit, for determining, for any target test class in the test code file set, a target tested class that matches the target test class from each tested class in the tested code file set based on the first class path corresponding to the target test class in the file system; The determining unit is further configured to determine, for any target test case in the target test class, a target method matching the target test case from among the various tested methods in the target tested class based on the method names of the respective calling methods therein; The construction unit is used to construct a fine-tuning sample, wherein the prompt words include the target tested class and the target method, and the reference answer includes the target test case.

12. The device according to claim 11, wherein The determining unit comprises: A query submodule, configured to query a second path set based on the first class path; the second path set is formed based on the second class path corresponding to each of the tested classes in the file system; a determination submodule, configured to determine the target tested class according to the second class name extracted from the target second class path if the query result indicates that a target second class path matching the first class path is queried; The determination submodule is further configured to determine the target tested class according to the first class name of the target test class extracted from the first class path and the second path set if the query result indicates that the target second class path is not found.

13. The device according to claim 12, wherein: The query submodule is specifically used for: Preprocessing the first type of path to obtain a target path; Comparing the target path with each second-category path in the second path set; The preprocessing includes at least one of string replacement and case conversion.

14. The device according to claim 12, wherein: The determination submodule is specifically used for: For each second-category path in the second path set, extract the second-category name corresponding to the tested class to obtain a target set; Based on the first category name, query the target set to obtain the target second category name; According to the second class name of the target, the class of the target to be tested is determined.

15. The device according to claim 14, wherein: The determining submodule is also specifically used for: Adjusting the format of the first class name to obtain the class name of the implementation class corresponding to the target test class; Comparing the class name of the implementation class with each second class name in the target set; If there is a second class name that is consistent with the class name of the implementation class, then the consistent second class name is determined as the target second class name; If there is no second class name that is consistent with the class name of the implementation class, the first class name is compared with each second class name in the target set to determine the target second class name.

16. The device according to claim 14, wherein: The target second category name is a plurality of target second category names; The determining submodule is also specifically used for: Perform reverse matching of the first-category path with the plurality of second-category paths corresponding to the plurality of target second-category names, and count the number of character matches corresponding to the plurality of target second-category names; The tested class corresponding to the target second class name with the largest number of corresponding character matches is determined as the target tested class.

17. The device according to claim 11, wherein: The determining unit comprises: A query submodule, for querying a first list corresponding to the target tested class based on the corresponding first method name for any first calling method among the plurality of calling methods; the first list is used to record the method names of the respective tested methods; A recording submodule, for recording the target method name if the query result indicates that a target method name matching the first method name is found, and recording the position of the first calling method in the target test case as a calling position corresponding to the target method name; The determination submodule is used to determine the target method according to the target method names and corresponding calling positions recorded for the plurality of calling methods.

18. The apparatus according to claim 17, further comprising: A parsing unit, used for parsing the target class under test by using a syntax parsing tool to obtain a first abstract syntax tree AST; The determining unit is further configured to determine the first list according to the child nodes representing the method names of the nodes representing the method declarations.

19. The device according to claim 17, wherein: The query submodule is specifically used for: In the case where the calling mode of the first calling method is a reflection call, based on the first method name, obtaining a conventional name of the first calling method, and comparing the conventional name with the method names of each of the tested methods; When the calling mode of the first calling method is a normal calling mode, the first method name is directly compared with the method names of the various tested methods.

20. The device according to claim 17, wherein: The determination submodule is specifically used for: The method under test corresponding to the target method name with the last corresponding calling position among the target method names is determined as the target method.

21. A computer-readable storage medium having a computer program stored thereon, wherein: When the computer program is executed in a computer, the computer is caused to execute the method according to any one of claims 1 to 10.

22. A computing device comprising a memory and a processor, wherein: The memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 10 is implemented.