A training sample construction method, device, electronic device and medium

By obtaining code and task cards from the code hosting platform and automatically generating training tags, the problem of low manual labeling efficiency when training AI models is solved, the acquisition efficiency and accuracy of training samples are improved, and the model training efficiency is enhanced.

CN116521866BActive Publication Date: 2025-09-05BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310381165.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-11
Publication Date
2025-09-05
Estimated Expiration
2043-04-11

AI Technical Summary

Technical Problem

In the prior art, the training samples used when training AI models need to be manually marked, resulting in inefficiency and consuming a lot of manpower and time.

Method used

Obtain the code written by users and the task cards submitted by them from the code hosting platform, build training samples using the type and description information of the code, and automatically generate training tags to reduce manual annotation steps.

Benefits of technology

It improves the acquisition efficiency, accuracy and timeliness of training samples and training labels, and enhances the efficiency of model training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116521866B_ABST
    Figure CN116521866B_ABST
Patent Text Reader

Abstract

This disclosure provides a training sample construction method, apparatus, electronic device, and medium, relating to the fields of internet technology, particularly big data and code management technology. A specific implementation involves obtaining user-written code from a code hosting platform and obtaining task cards submitted by users for the code, where the task cards include the code type and description information. Training samples are then constructed based on the code type and code; and training labels are assigned to the training samples based on the code description information. This improves model training efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of Internet technology, and in particular to the field of big data and code management technology. Background Art

[0002] In code intelligence scenarios, code can be used as training samples to train artificial intelligence (AI) models, enabling the AI ​​models to support functions such as code interpretation or code repair. Summary of the Invention

[0003] The present disclosure provides a training sample construction method, device, electronic device and medium.

[0004] A first aspect of the embodiments of the present disclosure provides a method for constructing a training sample, including:

[0005] Obtain user-written code from the code hosting platform;

[0006] Obtaining a task card submitted by a user for the code, the task card including the type and description information of the code;

[0007] Constructing a training sample according to the type of the code and the code;

[0008] A training label of the training sample is set based on the description information of the code.

[0009] A second aspect of the embodiments of the present disclosure provides a training sample construction apparatus, comprising:

[0010] The acquisition module is used to obtain user-written code from the code hosting platform;

[0011] The acquisition module is further configured to acquire a task card submitted by a user for the code, wherein the task card includes the type and description information of the code;

[0012] A construction module, configured to construct a training sample according to the type of the code and the code acquired by the acquisition module;

[0013] A setting module is used to set the training label of the training sample based on the description information of the code obtained by the obtaining module.

[0014] According to a third aspect of the present disclosure, an electronic device is provided, including:

[0015] at least one processor; and

[0016] a memory communicatively connected to the at least one processor; wherein,

[0017] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any one of the methods according to the first aspect.

[0018] According to a fourth aspect of an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method according to any one of the first aspects.

[0019] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of the first aspects is implemented.

[0020] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.

[0022] Figure 1 is a flowchart of a training sample construction method provided by an embodiment of the present disclosure;

[0023] Figure 2 is an exemplary schematic diagram of a task card provided by an embodiment of the present disclosure;

[0024] Figure 3 is an exemplary schematic diagram of a display interface provided by an embodiment of the present disclosure;

[0025] Figure 4 is a flowchart of a method for setting training labels provided by an embodiment of the present disclosure;

[0026] Figure 5 is a flowchart of another method for setting training labels provided by an embodiment of the present disclosure;

[0027] Figure 6 is an exemplary schematic diagram of another task card provided by an embodiment of the present disclosure;

[0028] Figure 7 is an exemplary schematic diagram of another display interface provided by an embodiment of the present disclosure;

[0029] Figure 8 is an exemplary schematic diagram of a training sample construction process provided by an embodiment of the present disclosure;

[0030] Figure 9is a structural diagram of a training sample construction device provided by an embodiment of the present disclosure;

[0031] Figure 10 It is a block diagram of an electronic device used to implement the training sample construction method of the embodiment of the present disclosure. DETAILED DESCRIPTION

[0032] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0033] Currently, the training samples used in training AI models are all obtained from public code sets. However, the codes in public code sets generally do not have labels. Therefore, after obtaining the training samples, they need to be manually labeled, which requires a lot of manpower and time, making the model training efficiency low.

[0034] In order to improve the training efficiency of the model, the embodiment of the present disclosure provides a training sample construction method, which is applied to electronic devices, such as servers, desktop computers, virtual machines, and other devices with data processing capabilities. Figure 1 As shown, the training sample construction method of the embodiment of the present disclosure includes the following steps:

[0035] S101. Obtain the code written by the user from the code hosting platform.

[0036] The user can be a software engineer (hereinafter referred to as an engineer). The code written by the engineer can use the company's internal business code. Before the code is put online, it must be submitted to the code hosting platform.

[0037] S102: Obtain the task card submitted by the user for the code.

[0038] The task card includes the type and description information of the code.

[0039] Code types can be Task or Bug. Tasks are also called Required Task types. Required Task code is code written specifically for a specific task, such as calculating a weighted sum of data or querying a table. Bugs are also called Error Correction types. Bug code is used to replace previously submitted problematic code that contains errors.

[0040] The description is used to explain the meaning of the code. For example, the description could be: "A function for calculating the weighted sum of data" or "A function for querying a data table."

[0041] S103: Construct training samples according to the code type and code.

[0042] The embodiments of the present disclosure may directly use the codes written by the user as training samples, or may be constructed in other ways. The specific construction method may be referred to in the subsequent description.

[0043] S104: Set training labels for training samples based on the code description information.

[0044] In the embodiment of the present disclosure, the description information can be directly used as a training label, or can be set in other ways. The specific setting method can be referred to the subsequent description.

[0045] Through the above method, the embodiment of the present disclosure can use the descriptive information of the code to automatically generate training labels for the training samples while using the code written by the user and its type to construct the training samples. Since the descriptive information of the code can represent the meaning of the code, the accuracy of setting the training labels can be improved by using the descriptive information. Moreover, the code written by the engineer is the company's internal code, not the public external code, so the type and description information of the code can be obtained from within the company without the need to manually label the training samples after obtaining the training samples. Therefore, the embodiment of the present disclosure reduces the manpower and time required to obtain training samples and training labels, improves the efficiency, accuracy and timeliness of obtaining training samples and training labels, and thus can improve the efficiency of model training.

[0046] The following is a detailed description of the training sample construction method provided by the embodiment of the present disclosure:

[0047] In some embodiments of the present disclosure, before obtaining the task card submitted by the user for the code in S102, the electronic device may also obtain code submission information (commit message) submitted by the user for the written code from the code hosting platform. The code submission information includes the identifier of the task card submitted by the user for the code.

[0048] In an embodiment of the present disclosure, the electronic device may obtain the code and submission information submitted by the user to the code hosting platform during the previous period at regular intervals. For example, at 0:00 every day, the electronic device may obtain the code and submission information submitted by the user to the code hosting platform during the previous day.

[0049] Similarly, the electronic device can obtain the task cards submitted by users to the demand management platform during the previous period at regular intervals. For example, at 0:00 every day, the electronic device can obtain the task cards submitted by users to the demand management platform during the previous day.

[0050] In the embodiment of the present disclosure, the first user who submits code and code submission information to the code hosting platform can be a manager or an engineer who writes code, etc.; similarly, the second user who submits a task card to the demand management platform can be a manager or an engineer who writes code, etc.

[0051] The first user and the second user can be the same user. For example, before submitting their own code, an engineer fills out a task card for the code, then submits the code and code submission information to the code hosting platform, and submits the task card for the code to the requirements management platform.

[0052] The first user and the second user can be different users. For example, a product manager fills out a task card for the code an engineer needs to write in advance and submits it to the requirements management platform. After the engineer finishes writing the code, he or she finds the ID of the task card corresponding to the code and fills it in the code submission information. The engineer then submits the code and the code submission information to the code hosting platform.

[0053] It should be noted that the electronic device where the code hosting platform and the demand management platform are located can be the same device or different devices as the electronic device to which the above-mentioned training sample construction method is applied, and the embodiments of the present disclosure do not specifically limit this.

[0054] Because the code submission information includes the identity document (ID) of the task card, and each task card has a unique ID, the electronic device can search for the task card corresponding to the ID from the task cards on the requirements management platform when executing S102 above to obtain the task card submitted by the user for the code. The electronic device can directly search for the task card corresponding to the ID from the requirements management platform; or the electronic device can synchronize the task cards on the requirements management platform at regular intervals so that the electronic device can search for the task card corresponding to the ID from the task cards synchronized with the electronic device.

[0055] It should be noted that due to the limited amount of data that can be carried in the commit message, it is difficult to directly carry specific content such as the code type and description information. Therefore, the embodiment of the present disclosure records these specific contents in the task card and carries the identifier of the task card corresponding to the code in the commit message, thereby associating the code with these specific contents.

[0056] Optionally, the code submission information may further include the title of the task card, so that the purpose of the code can be understood more quickly based on the title in the code submission information.

[0057] Since currently all codes need to be submitted to the code hosting platform before they can be put online for use, the disclosed embodiment utilizes this mechanism and adds a task card identifier in the submission information, so that the code in the code hosting platform can be associated with the task card, thereby facilitating the subsequent acquisition of the code type and description information.

[0058] Moreover, for large Internet companies, software engineers submit tens of thousands of code submissions every working day, involving updates to millions of lines of code, which means the amount of code data involved is enormous. The disclosed embodiment uses the code written and submitted by engineers to construct training samples, which can obtain enough training samples to ensure the generalization of the model obtained through subsequent training. Moreover, the company's internal code is relevant to the company's business, making the training samples constructed through the company's internal code more accurate in identifying the company's internal business, improving the model's recall rate, and helping companies improve their R&D efficiency.

[0059] In some embodiments of the present disclosure, the above S103 constructs the training sample according to the type and code of the code, including the following two methods:

[0060] Method 1 for constructing training samples: If the code type is the required task type, split the code into multiple functions and use each function as a training sample. The required task type code is the code written for the required task.

[0061] For example, Figure 2 This is a task card of the required task type. In this task card, the code type is Task, the title is "Add a division function", and the content is "Add a division function". Figure 2 As shown, the task card may also include: the plan to which the code belongs is XXXX, the complete process of releasing the code is status 1-status 5, and the person in charge of the code is AA. Figure 2 State 1 represents the current state of the code release process, State 2 represents a reachable state, and States 3 through 5 represent unreachable states. A development requirement can be abstractly broken down into multiple plans of varying levels and types, also known as tasks. Typically, a user's code can correspond to one or multiple tasks. By recording the tasks to which code belongs on task cards, the relationship between R&D activities and code can be established, facilitating the management of development requirements.

[0062] After the user submits a task card, he can also view the code corresponding to the task card in the display interface. Figure 3 The code corresponding to the task card displayed in the display interface includes: "package main xxxxxxxxxxxxxx", and "x" represents the actual code. Among them, the code can be displayed after detecting that the "math.go:" button on the left is clicked, that is, the code content under "math.go" on the right is displayed. Figure 3 As shown, the display interface may also include: the title of the code, the time when the code was updated, an overview of the reviewer's review of the code, the code submission record, and the code file change record, etc. Among them, "xxxx-xx-xx xx:xx:xx" represents the time.

[0063] The code written by the user each time is generally a code package, which consists of one or more functions. For example, Figure 3 The "package main xxxxxxx xxxxxxx" is the main function in the code package.

[0064] Through the above method, the disclosed embodiments can split user-written code into function units and use each split function as a training sample, further increasing the number of training samples obtained and ensuring the generalization of the model obtained through subsequent training. Furthermore, splitting the user-written code can reduce the length of the code included in each training sample, thereby improving model training efficiency.

[0065] In the embodiment of the present disclosure, the description information of the code in the task card includes a title and content for describing the meaning of the code. Among them, the content is a detailed description of the meaning of the code, and the title is a brief introduction to the meaning of the code.

[0066] In the case where the code type is a required task type, the above S104 sets the training labels of the training samples based on the description information of the code, including the following two methods.

[0067] See also Figure 4 , when the code type is the required task type, method 1 of setting the training label includes the following steps:

[0068] S401: Check whether the content meets the preset specifications. If yes, execute S402; if not, execute S403.

[0069] The preset criteria may include: the word count of the content is greater than a preset word count and / or the content is not in a preset blacklist, etc.

[0070] If the word count is less than or equal to the preset word count, it means that the content is too short and the description of the code is too brief, so it is less meaningful to use this content as a training label. For example, if the preset word count is 2, the content "function", "add", and "delete" do not meet the preset specifications.

[0071] The preset blacklist includes content that cannot be used as training labels. For example, the preset blacklist includes: "Same as above," "As above," "Same title," and "Omitted." When filling out task cards, users may not fully understand the difference between the title and the content, leading them to mistakenly believe that the title and the content have exactly the same meaning. Consequently, they may enter words like "Same as above" in the content field. However, these words do not actually represent the meaning of the code, and therefore do not meet the preset specifications and cannot be used as training labels.

[0072] S402: Use the content as a training label.

[0073] When the content meets the preset specifications, it is likely to reflect the meaning of the code, so the content can be used as a training label for the training sample.

[0074] S403: Use the title as a training label.

[0075] When the content does not meet the preset specifications, it is highly likely that the content cannot reflect the meaning of the code, so the title is used as the training label of the training sample.

[0076] Through the above method, the embodiment of the present disclosure can detect whether the content meets the preset specifications, thereby setting the content or title that can reflect the meaning of the code as the training label of the training sample, which can improve the accuracy and effectiveness of the training label.

[0077] See also Figure 5 , when the code type is the required task type, method 2 of setting the training label includes the following steps:

[0078] S501: Check whether the content complies with preset specifications and identify whether the training sample includes function explanations.

[0079] The method of detecting whether the content complies with the preset specification can refer to the relevant description in the above S401 and will not be repeated here.

[0080] When writing code, engineers may record their own explanations of the code within the function, known as function explanations. For example, engineers may record the title and content of the task card associated with the code within the main function of the code. Alternatively, engineers may record other forms of function explanations, which are not specifically limited in the present embodiment.

[0081] For example, a function includes: "{"code":"xxxxx xxxxx","card_title":"[task]Add a division function","card_content":"Add a division function"}", which can recognize the Chinese text in the function and obtain the function explanation of the function. Among them, "x" represents the actual code.

[0082] Optionally, the Chinese text identified from the function can be deduplicated to reduce the amount of duplicate content in the training labels.

[0083] S502: If the content meets the preset specification and the training sample includes a function explanation, the content and the function explanation are used as training labels.

[0084] The content conforms to the preset specifications, indicating that the content is likely to reflect the meaning of the code. The training samples also include function explanations, which can also reflect the meaning of the code. Therefore, the content and function explanations are used as training labels.

[0085] Optionally, the function explanation and content may be deduplicated, and the deduplicated results may be used as training labels for training samples to reduce duplicate content included in the training labels.

[0086] S503: If the content meets the preset specification and the training sample does not include function explanation, the content is used as a training label.

[0087] The content meets the preset specifications, indicating that the content is likely to reflect the meaning of the code, and the training samples do not include function explanations, so the content is used as the training label.

[0088] S504: If the content does not meet the preset specifications and the training sample includes a function explanation, the title and the function explanation are used as training labels.

[0089] If the content does not meet the preset specifications, it means that the content is unlikely to reflect the meaning of the code. The training samples include function explanations, which can reflect the meaning of the code. Therefore, the title and function explanation are used as training labels.

[0090] Optionally, the function explanation and title may be deduplicated, and the deduplicated results may be used as training labels for training samples to reduce duplicate content included in the training labels.

[0091] S505. If the content does not meet the preset specifications and the training sample does not include function explanation, the title is used as the training label.

[0092] The content does not meet the preset specifications, which means that the content is unlikely to reflect the meaning of the code, and the training samples do not include function explanations. Therefore, the title is used as the training label.

[0093] Since both descriptive information and function explanation can reflect the meaning of the function, when function explanation is included in the training samples, setting training labels in combination with function explanation and descriptive information can improve the accuracy and comprehensiveness of the training labels.

[0094] As you can understand, when the code submitted by the user is of the required task type, the training samples are each function in the code, and the training labels are the meanings of the functions. Using these training samples and corresponding training labels, the trained model can identify the meanings of functions. For example, the trained model can be used for code interpretation.

[0095] Method 2 for constructing training samples: If the type of the user-written code is error elimination type, the target problem code corresponding to the user-written code is obtained, and a training sample is constructed based on the target problem code. The error elimination type code is used to replace the corresponding problem code.

[0096] In the disclosed embodiments, when the type of the user-written code obtained this time is a bug, i.e., an error-correcting code, the user-written code obtained this time can be referred to as repair code, i.e., code obtained by repairing the target problem code. The target problem code was submitted earlier than the user-written code obtained this time. The user-written code obtained this time implements the same functionality as the target problem code and does not contain the errors in the target problem code.

[0097] When the type of the code written by the user is a bug, the code submission information also includes the identifier of the target problem code corresponding to the code, that is, the ID of the target problem code, so that the electronic device can obtain the target problem code based on the ID of the target problem code.

[0098] Optionally, when obtaining the target problem code, the electronic device can directly search for the target problem code from the code hosting platform based on the target problem code ID. Alternatively, the electronic device can first search for the target problem code in local memory based on the target problem code ID. If not, the electronic device can search for the target problem code from the code hosting platform, thereby speeding up the acquisition of the target problem code.

[0099] When constructing training samples, the target problem code can be directly used as a training sample.

[0100] Alternatively, problematic functions with errors in the target problem code are identified and used as training samples.

[0101] The difference data between the target problematic code and the repaired code can be obtained from the code hosting platform, or by comparing the target problematic code and the repaired code to obtain the difference data between the target problematic code and the repaired code, i.e., the difference (DIFF) associated data. Then, the function containing the data that differs from the repaired code can be intercepted from the target problematic code. The intercepted function is the problematic function, which is used as a training sample.

[0102] Since the target problem code may contain multiple functions, and some functions may not have problems, using these non-problematic functions as training samples not only increases the workload of model training, but also makes it difficult to improve the recognition accuracy of the model. Therefore, the problem functions in the target problem code can be intercepted as training samples to improve the efficiency of model training.

[0103] Since the type of code written by the user is the error elimination type, the code is the repair code obtained after repairing the corresponding target problem code. Therefore, the target problem code is likely to contain errors, so a training sample can be constructed based on the target problem code, so that the model trained by this training sample has the ability to identify problem codes.

[0104] In the case that the type of the code written by the user is an error elimination type, the above S104 sets the training labels of the training samples based on the description information of the code, including the following two methods.

[0105] If the user-written code is error-correcting, Method 1 for setting training labels can be implemented as follows: Check whether the content meets the preset specifications. If so, the content is used as the meaning label of the training sample, and the user-written code is used as the repair label of the training sample. If not, the title is used as the meaning label of the training sample, and the user-written code is used as the repair label of the training sample.

[0106] The method of detecting whether the content complies with the preset specification can refer to the relevant description in the above S401 and will not be repeated here.

[0107] Since the content description in the task card can include a title and content for describing the meaning of the code, when the type of code written by the user is the error elimination type, the title can be a brief introduction to the error fixed by the code, and the content can be a detailed description of the error fixed by the code.

[0108] For example, Figure 6 This is a task card for eliminating error-type code. In this task card, the code type is bug, the title is "Fix division by 0 error", and the content description is "Division by 0 causes program crash". The task card can also include other information. For details, please refer to the Figure 2 The description is not repeated here.

[0109] Using titles or content as meaning labels for training samples allows the model trained with these training samples and meaning labels to identify the meaning of errors in problematic code, that is, to identify the type of error in the problematic code. Using repair code as the repair label for training samples allows the model trained with these training samples and repair labels to repair the problematic code and output the repaired code.

[0110] Optionally, a positioning label can be set for the training sample, where the positioning label is the DIFF association data between the repair code and the problem code, so that the model trained based on the training sample and the positioning label has the ability to locate the error position in the code.

[0111] After the user submits a task card, he can also view the corresponding repair code and problem code of the task card in the display interface. Figure 7 The display interface shows two code segments. The code on the left is the problem code, and the code on the right is the repair code. The "x" under "math.go" indicates the actual code. The display interface can also include other information. For details, please refer to the Figure 3 The description is not repeated here.

[0112] Since the user-written repair code is the result of fixing the problem code, it can be used as a repair label, allowing the model trained based on the repair label to have the ability to repair the problem code. Furthermore, the title and content are descriptions of the errors fixed in the code. Using the title or content as a meaning label allows the model trained based on the meaning label to have the ability to identify the meaning of errors in the problem code. Therefore, the disclosed embodiments can improve the accuracy and comprehensiveness of the training labels.

[0113] When the type of code written by the user is error elimination type, method 2 of setting training labels can be implemented as follows:

[0114] Step 1: Check whether the content complies with the preset specifications and identify whether the user-written code includes function interpretation.

[0115] The method of detecting whether the content complies with the preset specification can refer to the relevant description in the above S401 and will not be repeated here.

[0116] Step 2: If the content meets the preset specifications and the user-written code includes function explanations, the content and function explanations are used as the meaning labels of the training sample, and the user-written code is used as the repair label of the training sample.

[0117] Step 3: If the content meets the preset specifications and the user-written code does not include function explanations, the content is used as the meaning label of the training sample, and the user-written code is used as the repair label of the training sample.

[0118] Step 4: If the content does not meet the preset specifications and the user-written code includes function explanations, the title and function explanations are used as the meaning labels of the training samples, and the user-written code is used as the repair label of the training samples.

[0119] Step 5: If the content does not meet the preset specifications and the user-written code does not include function explanations, the title is used as the meaning label of the training sample, and the user-written code is used as the repair label of the training sample.

[0120] The specific implementation of method 2 for setting training labels is the same as Figure 5 Similar, you can refer to Figure 5 The relevant description in will not be repeated here.

[0121] For example, the repair code written by the user includes: ""problem_code":"xxxxxx xxxxxx","fixed_code":"xxxxxxx","card_title":"[bug]Fix division by 0 error","card_content":"Division by 0 causes program crash"". Chinese text can be recognized from the code to obtain the function interpretation of the code, where "x" represents the actual code.

[0122] Optionally, the Chinese text identified from the code may be deduplicated, thereby reducing the situation where the meaning tags contain duplicate content.

[0123] Since the repair code written by the user is the result of repairing the problem code, the repair code written by the user can be used as a repair label, so that the model trained based on the repair label has the ability to repair the problem code. Moreover, the title and content are descriptions of the errors repaired in the code, and the function explanation in the code can also reflect the repaired errors. Therefore, the title or content, combined with the function explanation, is used as a meaning label, so that the model trained based on the meaning label has the ability to recognize the meaning of errors in the problem code. Therefore, the embodiment of the present disclosure can improve the accuracy and comprehensiveness of the training labels.

[0124] It is understandable that when the type of code written by the user is error-eliminating, it indicates that the code written by the user is repair code. In this case, the training sample is obtained based on the problem code, and the training label is obtained based on the repair code, description information, and function interpretation. Therefore, the model trained with the training sample and the corresponding training label can repair the problem code, obtain repair code, and / or identify the type of error in the problem code or the cause of the error. For example, the trained model can be used for code repair.

[0125] In some embodiments of the present disclosure, after constructing the training samples and the corresponding training labels, the electronic device may further store the training samples and the training labels in a database in correspondence with each other.

[0126] Afterwards, the electronic device may periodically obtain training samples and training labels from the database, and perform data cleaning on the obtained training samples and corresponding training labels, that is, delete the training samples and corresponding training labels that meet the filtering conditions.

[0127] Optionally, the filtering conditions may include any one or more combinations of the following conditions: the file size of the training sample exceeds a preset number of bytes, the number of code lines included in the training sample exceeds a preset number of lines, the number of characters in the training label does not exceed a preset number of characters, and the training label is meaningless content.

[0128] For example, a training label is “This is a test”, which is meaningless content.

[0129] A natural language processing (NLP) word segmentation algorithm may be used to identify whether a training tag is meaningless content. Alternatively, other algorithms may be used to identify whether a training tag is meaningless content, which is not specifically limited in the present embodiment.

[0130] See also Figure 8 The following describes the overall process of the training sample construction method provided by the embodiment of the present disclosure in combination with actual application scenarios:

[0131] In this scenario, the training sample construction method provided by the embodiment of the present disclosure is implemented by a construction system, which includes: a construction platform, a database, and a data collector. The construction platform, database, and data collector can be in the same electronic device or different electronic devices.

[0132] Engineers submit code and commit messages to the code hosting platform through user terminals, and submit task cards to the requirements management platform. The commit message includes the ID of the task card associated with the code.

[0133] The build platform regularly retrieves the code and commit messages written and submitted by users in the previous cycle from the code hosting platform, and also regularly retrieves the task cards submitted by users in the previous cycle from the requirements management platform. It associates each code with the task card based on the task card ID in the commit message.

[0134] The construction platform constructs training samples based on the code type and code, and sets training labels for the training samples based on the code description information. The training samples and training labels are stored in the database.

[0135] The data collector regularly collects training samples and corresponding training labels from the database to obtain the original data set. The data collector also performs data cleaning on the collected training samples and training labels, and constructs the cleaning results into the training data set for the model.

[0136] In the technical solution disclosed herein, the collection, storage, use, processing, transmission, provision and disclosure of the code information involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0137] Based on the same inventive concept, corresponding to the above method embodiment, the embodiment of the present disclosure provides a training sample construction device, such as Figure 9 As shown, the device includes: an acquisition module 901, a construction module 902 and a setting module 903;

[0138] The acquisition module 901 is used to obtain the user-written code from the code hosting platform;

[0139] The acquisition module 901 is further used to obtain a task card submitted by a user for a code, wherein the task card includes the type and description information of the code;

[0140] A construction module 902 is used to construct a training sample according to the type and code of the code obtained by the acquisition module 901;

[0141] The setting module 903 is used to set the training label of the training sample based on the description information of the code obtained by the obtaining module 901.

[0142] In some embodiments of the present disclosure, the building block 902 is specifically configured to:

[0143] If the code type is a required task type, the code is split into multiple functions. The required task type code is the code written for the required task;

[0144] Take each function as a training sample.

[0145] In some embodiments of the present disclosure, the description information includes a title and content for describing the meaning of the code; the setting module 903 is specifically used to:

[0146] Check whether the content meets the preset specifications;

[0147] If it meets the requirements, the content is used as the training label;

[0148] If not, the title is used as the training label.

[0149] In some embodiments of the present disclosure, the description information includes a title and content for describing the meaning of the code; the setting module 903 is specifically used to:

[0150] Check whether the content meets the preset specifications and identify whether the training samples include function explanations;

[0151] If the content meets the preset specifications and the training sample includes function explanations, the content and function explanations are used as training labels;

[0152] If the content meets the preset specifications and the training sample does not include function explanations, the content is used as the training label;

[0153] If the content does not meet the preset specifications and the training sample includes function explanations, the title and function explanations are used as training labels;

[0154] If the content does not meet the preset specifications and the training sample does not include function explanations, the title is used as the training label.

[0155] In some embodiments of the present disclosure, the building block 902 is specifically configured to:

[0156] If the type of the code written by the user is an error elimination type, the target problem code corresponding to the code written by the user is obtained; the error elimination type code is used to replace the corresponding problem code;

[0157] Construct training samples based on the target problem code.

[0158] In some embodiments of the present disclosure, the building block 902 is specifically configured to:

[0159] Use the target problem code as a training sample; or,

[0160] Identify the problem functions with errors in the target problem code and use the problem functions as training samples.

[0161] In some embodiments of the present disclosure, the description information includes a title and content for describing the meaning of the code; the setting module 903 is specifically used to:

[0162] Check whether the content meets the preset specifications;

[0163] If they match, the content is used as the meaning label of the training sample, and the code written by the user is used as the repair label of the training sample;

[0164] If not, the title is used as the meaning label of the training sample, and the code written by the user is used as the repair label of the training sample.

[0165] In some embodiments of the present disclosure, the description information includes a title and content for describing the meaning of the code; the setting module 903 is specifically used to:

[0166] Check whether the content complies with the preset specifications and identify whether the user-written code includes function interpretations;

[0167] If the content meets the preset specifications and the user-written code includes function explanations, the content and function explanations are used as the meaning labels of the training sample, and the user-written code is used as the repair label of the training sample;

[0168] If the content meets the preset specifications and the user-written code does not include function explanations, the content is used as the meaning label of the training sample, and the user-written code is used as the repair label of the training sample;

[0169] If the content does not meet the preset specifications and the user-written code includes function explanations, the title and function explanations are used as the meaning labels of the training sample, and the user-written code is used as the repair training label of the training sample;

[0170] If the content does not meet the preset specifications and the user-written code does not include function explanations, the title is used as the meaning label of the training sample, and the user-written code is used as the repair label of the training sample.

[0171] In some embodiments of the present disclosure, the acquisition module 901 is further configured to acquire, from the code hosting platform, code submission information submitted by the user for the written code before acquiring the task card submitted by the user for the code, the code submission information including the identifier of the task card;

[0172] The acquisition module 901 is specifically used to:

[0173] From the task cards on the demand management platform, find the task card corresponding to the identifier.

[0174] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0175] Figure 10A schematic block diagram of an example electronic device 1000 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0176] like Figure 10 As shown, the electronic device 1000 includes a computing unit 1001, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1002 or a computer program loaded from a storage unit 1008 into a random access memory (RAM) 1003. Various programs and data required for the operation of the electronic device 1000 can also be stored in the RAM 1003. The computing unit 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0177] Multiple components in the electronic device 1000 are connected to the I / O interface 1005, including an input unit 1006, such as a keyboard, a mouse, etc.; an output unit 1007, such as various types of displays, speakers, etc.; a storage unit 1008, such as a magnetic disk, an optical disk, etc.; and a communication unit 1009, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1009 allows the electronic device 1000 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0178] The computing unit 1001 can be a variety of general-purpose and / or specialized processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1001 performs the various methods and processes described above, such as the training sample construction method. For example, in some embodiments, the training sample construction method can be implemented as a computer software program that is tangibly contained in a machine-readable medium, such as the storage unit 1008. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 1000 via the ROM 1002 and / or the communication unit 1009. When the computer program is loaded into the RAM 1003 and executed by the computing unit 1001, one or more steps of the training sample construction method described above can be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to execute the training sample construction method in any other appropriate manner (for example, by means of firmware).

[0179] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0180] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0181] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0182] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0183] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0184] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact through a communication network. The client-server relationship arises through computer programs running on the respective computers and having a client-server relationship with each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.

[0185] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not limited herein.

[0186] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.

Claims

1. A training sample construction method, comprising: Obtain user-written code from the code hosting platform; Obtaining a task card submitted by a user for the code, the task card including the type and description information of the code; Constructing a training sample according to the type of the code and the code; Setting a training label for the training sample based on the description information of the code; The step of constructing a training sample according to the code type and the code includes: If the type of the code written by the user is an error elimination type, then the target problem code corresponding to the code written by the user is obtained; the error elimination type code is used to replace the problem code corresponding to the code itself; A training sample is constructed based on the target problem code.

2. The method according to claim 1, wherein The step of constructing a training sample according to the code type and the code includes: If the type of the code is a required task type, the code is split into multiple functions, and the code of the required task type is the code written for the required task; Take each function as a training sample.

3. The method according to claim 2, wherein: The description information includes a title and content for describing the meaning of the code; The step of setting the training label of the training sample based on the description information of the code includes: Checking whether the content complies with preset specifications; If it meets the requirements, the content is used as the training label; If not, the title is used as the training label.

4. The method according to claim 2, wherein: The description information includes a title and content for describing the meaning of the code; and setting the training label of the training sample based on the description information of the code includes: Detecting whether the content complies with preset specifications and identifying whether the training sample includes function explanations; If the content meets the preset specification and the training sample includes a function explanation, the content and the function explanation are used as the training label; If the content meets the preset specification and the training sample does not include a function explanation, the content is used as the training label; If the content does not conform to the preset specification and the training sample includes a function explanation, the title and the function explanation are used as the training label; If the content does not conform to the preset specification and the training sample does not include a function explanation, the title is used as the training label.

5. The method according to claim 1, wherein The constructing of a training sample based on the target problem code includes: Using the target question code as the training sample; or, Determine a problem function having errors in the target problem code, and use the problem function as the training sample.

6. The method according to claim 1, wherein The description information includes a title and content for describing the meaning of the code; The step of setting the training label of the training sample based on the description information of the code includes: Checking whether the content complies with preset specifications; If it matches, the content is used as the meaning label of the training sample, and the code written by the user is used as the repair label of the training sample; If not, the title is used as the meaning label of the training sample, and the code written by the user is used as the repair label of the training sample.

7. The method according to claim 6, wherein the description information includes a title and content for describing the meaning of the code; and setting the training label of the training sample based on the description information of the code comprises: Detect whether the content complies with preset specifications and identify whether the user-written code includes function interpretations; If the content meets the preset specification and the user-written code includes a function explanation, the content and the function explanation are used as the meaning label of the training sample, and the user-written code is used as the repair label of the training sample; If the content meets the preset specification and the user-written code does not include a function explanation, the content is used as the meaning label of the training sample, and the user-written code is used as the repair label of the training sample; If the content does not conform to the preset specification, and the code written by the user includes a function explanation, the title and the function explanation are used as the meaning label of the training sample, and the code written by the user is used as the repair label of the training sample; If the content does not conform to the preset specification and the code written by the user does not include a function explanation, the title is used as the meaning label of the training sample, and the code written by the user is used as the repair label of the training sample.

8. The method according to any one of claims 1 to 7, before obtaining the task card submitted by the user for the code, the method further comprises: Obtaining code submission information submitted by a user for the written code from the code hosting platform, the code submission information including an identifier of the task card; The obtaining of a task card submitted by a user for the code includes: From each task card on the demand management platform, search for the task card corresponding to the identifier.

9. A training sample construction device, comprising: The acquisition module is used to obtain user-written code from the code hosting platform; The acquisition module is further configured to acquire a task card submitted by a user for the code, wherein the task card includes the type and description information of the code; A construction module, configured to construct a training sample according to the type of the code and the code acquired by the acquisition module; A setting module, configured to set a training label for the training sample based on the description information of the code acquired by the acquisition module; The building blocks are specifically used for: If the type of the code written by the user is an error elimination type, then the target problem code corresponding to the code written by the user is obtained; the error elimination type code is used to replace the problem code corresponding to the code itself; A training sample is constructed based on the target problem code.

10. The device according to claim 9, wherein The building blocks are specifically used for: If the type of the code is a required task type, the code is split into multiple functions, and the code of the required task type is the code written for the required task; Take each function as a training sample.

11. The device according to claim 10, wherein The description information includes a title and content for describing the meaning of the code; the setting module is specifically used to: Checking whether the content complies with preset specifications; If it meets the requirements, the content is used as the training label; If not, the title is used as the training label.

12. The device according to claim 10, wherein The description information includes a title and content for describing the meaning of the code; the setting module is specifically used to: Detecting whether the content complies with preset specifications and identifying whether the training sample includes function explanations; If the content meets the preset specification and the training sample includes a function explanation, the content and the function explanation are used as the training label; If the content meets the preset specification and the training sample does not include a function explanation, the content is used as the training label; If the content does not conform to the preset specification and the training sample includes a function explanation, the title and the function explanation are used as the training label; If the content does not conform to the preset specification and the training sample does not include a function explanation, the title is used as the training label.

13. The device according to claim 9, wherein The building blocks are specifically used for: Using the target question code as the training sample; or, Determine a problem function having errors in the target problem code, and use the problem function as the training sample.

14. The device according to claim 9, wherein The description information includes a title and content for describing the meaning of the code; the setting module is specifically used to: Checking whether the content complies with preset specifications; If it matches, the content is used as the meaning label of the training sample, and the code written by the user is used as the repair label of the training sample; If not, the title is used as the meaning label of the training sample, and the code written by the user is used as the repair label of the training sample.

15. The device according to claim 9, wherein The description information includes a title and content for describing the meaning of the code; the setting module is specifically used to: Detect whether the content complies with preset specifications and identify whether the user-written code includes function interpretations; If the content meets the preset specification and the user-written code includes a function explanation, the content and the function explanation are used as the meaning label of the training sample, and the user-written code is used as the repair label of the training sample; If the content meets the preset specification and the user-written code does not include a function explanation, the content is used as the meaning label of the training sample, and the user-written code is used as the repair label of the training sample; If the content does not conform to the preset specification, and the code written by the user includes a function explanation, the title and the function explanation are used as the meaning label of the training sample, and the code written by the user is used as the repair label of the training sample; If the content does not conform to the preset specification and the code written by the user does not include a function explanation, the title is used as the meaning label of the training sample, and the code written by the user is used as the repair label of the training sample.

16. The device according to any one of claims 9 to 15, The acquisition module is further configured to acquire, from the code hosting platform, code submission information submitted by the user for the written code before acquiring the task card submitted by the user for the code, the code submission information including an identifier of the task card; The acquisition module is specifically used to: From each task card on the demand management platform, search for the task card corresponding to the identifier.

17. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.

18. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-8.

19. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Application program development method and device, electronic equipment and storage medium

    CN112748914A