A code change label generation method, device and equipment
Patent Information
- Application Number
- CN202311642908.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-01
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2043-12-01
AI Technical Summary
[0003]实际应用中,需要人工判别并手动为代码变更添加对应的标签,但是,由于代码变更会频繁发生而且涉及的代码量规模较大,则人工判别并手动添加标签的方式费时费力,效率低下,尤其是在代码变更并非当前的标签维护人员产出的情况,更是连标签的可靠性也难以保证
[0010] The above-mentioned at least one technical solution adopted in one or more embodiments of this specification can achieve the following beneficial effects: through semantic comparison and code difference comparison feature analysis, the semantics of the substantive expression or implied meaning of code change information can be understood more accurately and efficiently, thereby automatically, on a small scale, and efficiently generating appropriate and reliable labels for it. These small-scale data are then used to fine-tune and train a large language model that already has a good understanding of both natural language and programming language, enabling the large language model to quickly and reliably generate code change labels, which can then be used to efficiently generate labels for other large-scale code change information. Moreover, this solution also supports users to customize label information according to actual needs, and similarly efficient small-scale fine-tuning training data can be obtained for the customized label information.
Smart Images

Figure CN117725920B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of machine learning, and in particular to a method, apparatus, and device for generating code change tags. Background Technology
[0002] In software development, code change tags are key information used to identify the type of code change. Common tags include "fix" (e.g., to fix a bug), "feat" (e.g., to add a new feature), and "test" (e.g., to test-related changes).
[0003] In practical applications, code changes require manual identification and tagging. However, due to frequent code changes and the large volume of code involved, this manual tagging method is time-consuming, labor-intensive, and inefficient, especially when the code changes are not the work of the current tag maintenance personnel, making it difficult to guarantee the reliability of the tags. Furthermore, the types of tags currently used are relatively fixed and cannot adapt to personalized needs.
[0004] Therefore, there is a need for a solution that can help add code change tags more efficiently, reliably, and in a way that better meets individual needs. Summary of the Invention
[0005] This specification provides one or more embodiments of a code change tag generation method, apparatus, device, and storage medium to solve the following technical problem: the need for a solution that helps to add code change tags more efficiently, reliably, and to better meet personalized needs.
[0006] To solve the above-mentioned technical problems, one or more embodiments of this specification are implemented as follows: This specification provides a method for generating code change tags through one or more embodiments, including: Retrieve a set of code change information and a set of predefined tag information; Based on the tag information contained in the tag information set, semantic comparison and code difference comparison feature analysis are performed on the code change information contained in the code change information set to generate corresponding tags for the code change information; Obtain large language models trained using massive amounts of natural language and programming language data; Based on the code change information and its corresponding tags, the large language model is fine-tuned and trained to obtain a tag-generated large language model; The tags are used to generate a large language model, and corresponding tags are generated for target code change information.
[0007] This specification provides one or more embodiments of a code change tag generation device, comprising: The information set acquisition module acquires a set of code change information and a set of predefined tag information. The first tag generation module performs semantic comparison and code difference comparison feature analysis on the code change information contained in the code change information set based on the tag information contained in the tag information set, and generates corresponding tags for the code change information. The large language model acquisition module acquires large language models trained using large-scale natural language data and programming language data. The model fine-tuning training module fine-tunes and trains the large language model based on the code change information and its corresponding tags to obtain a tag-generated large language model. The second tag generation module uses the tags to generate a large language model and generates corresponding tags for target code change information.
[0008] This specification provides one or more embodiments of a code change tag generation device, comprising: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to: Retrieve a set of code change information and a set of predefined tag information; Based on the tag information contained in the tag information set, semantic comparison and code difference comparison feature analysis are performed on the code change information contained in the code change information set to generate corresponding tags for the code change information; Obtain large language models trained using massive amounts of natural language and programming language data; Based on the code change information and its corresponding tags, the large language model is fine-tuned and trained to obtain a tag-generated large language model; The tags are used to generate a large language model, and corresponding tags are generated for target code change information.
[0009] This specification provides one or more embodiments of a non-volatile computer storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured as follows: Retrieve a set of code change information and a set of predefined tag information; Based on the tag information contained in the tag information set, semantic comparison and code difference comparison feature analysis are performed on the code change information contained in the code change information set to generate corresponding tags for the code change information; Obtain large language models trained using massive amounts of natural language and programming language data; Based on the code change information and its corresponding tags, the large language model is fine-tuned and trained to obtain a tag-generated large language model; The tags are used to generate a large language model, and corresponding tags are generated for target code change information.
[0010] The above-mentioned at least one technical solution adopted in one or more embodiments of this specification can achieve the following beneficial effects: through semantic comparison and code difference comparison feature analysis, the semantics of the substantive expression or implied meaning of code change information can be understood more accurately and efficiently, thereby automatically, on a small scale, and efficiently generating appropriate and reliable labels for it. These small-scale data are then used to fine-tune and train a large language model that already has a good understanding of both natural language and programming language, enabling the large language model to quickly and reliably generate code change labels, which can then be used to efficiently generate labels for other large-scale code change information. Moreover, this solution also supports users to customize label information according to actual needs, and similarly efficient small-scale fine-tuning training data can be obtained for the customized label information. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 A schematic diagram illustrating the composition of document changes involved in one or more embodiments of this specification; Figure 2 A flowchart illustrating a proposed scheme for generating submission information in the event of a single file change, provided for one or more embodiments of this specification. Figure 3 A flowchart illustrating a proposed scheme for generating submission information in the event of multiple file changes, provided for one or more embodiments of this specification. Figure 4 A schematic diagram illustrating a structured commit message provided for one or more embodiments of this specification; Figure 5 A flowchart illustrating a code change tag generation method provided in one or more embodiments of this specification; Figure 6 A flowchart illustrating a code change information set generation scheme provided in one or more embodiments of this specification; Figure 7 A schematic diagram illustrating a tag information set provided in one or more embodiments of this specification; Figure 8 A flowchart illustrating a scheme for generating tags for a set of code change information, provided for one or more embodiments of this specification; Figure 9 A schematic diagram of a fine-tuning training dataset provided for one or more embodiments of this specification; Figure 10 A schematic diagram illustrating a scheme for fine-tuning training and deployment of a large language model provided for one or more embodiments of this specification; Figure 11 A schematic diagram of a code change tag generation device provided in one or more embodiments of this specification; Figure 12 This is a schematic diagram of a code change tag generation device provided for one or more embodiments of this specification. Detailed Implementation
[0013] This specification provides a method, apparatus, device, and storage medium for generating code change tags.
[0014] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this application.
[0015] To address the issues in the background technology, the applicant initially proposed and attempted a solution based on automatically generated commit messages (such as Commit Messages, which may contain tags) to implement code change tags (referred to as the trial solution). However, significant flaws were discovered during actual testing, leading to the further proposal of a superior solution. The trial solution will be explained first to more fully demonstrate the advantages of the proposed solution.
[0016] In the trial approach, the input is a list of file changes. Figure 1This is a schematic diagram illustrating the composition of file changes involved in one or more embodiments of this specification. Figure 1 In this process, each file change consists of two parts: the file change operation type and the corresponding file path. For example, different uppercase letters can be used to represent different change operation types: A for adding a file, D for deleting a file, M for modifying a file, R for renaming a file, etc. The corresponding file path can be represented by the full filename or other encoding formats. The commit message is generated by parsing these two parts. The main implementation principle and process are as follows: For single file changes: Figure 2 This document illustrates a flowchart of an attempt to generate a commit message in the event of a single file change, provided for one or more embodiments of this specification. It can be summarized as follows:
[0017] The first step involves processing only the file path and change type for a single change. The change type reveals the specific file change operation, such as modify, output, or rename. A new file path is generated by transforming the file path into a more readable form. This new file path is then combined with the generated change type to create the description section of the commit message.
[0018] The second step involves generating a Conventional Commit object based on the file path. Then, it performs string matching between the file name, file path, and file extension and predefined constants to generate corresponding labels. Since there may be cases where the matching fails, the final label may be essentially invalid (e.g., Unknown).
[0019] Finally, the description generated in the first part of the steps and the tags generated in the second part of the steps are assembled to generate the final submission information.
[0020] For multiple file changes: Figure 3 The flowchart illustrating a proposed solution for generating submission information in the event of multiple file changes, provided in one or more embodiments of this specification, is briefly described below.
[0021] For cases with multiple changes, two types of commit messages can be generated. One type is tagged, which lists the changed files and the types of changes. This type of commit message is only generated when the number of changes is less than a set threshold and all changes have the same operation type. Otherwise, a commit message is generated that only counts the number of file changes and the type of operation, such as "2 files were deleted, 3 files were added, and 1 file was modified".
[0022] Therefore, the above-mentioned approach has the following problems: its tag generation process is entirely based on the file paths of file repository changes, and the generation method is to perform string matching by enumerating the file path features of various tag types. If no match is found, tags cannot be generated effectively. Moreover, since it is based solely on file paths and does not consider file code changes at all, it lacks a semantic understanding of the specific code changes in the repository, which may lead to unreliable generated tags.
[0023] To address the problems of the background technology and the aforementioned attempts, the applicant provides a superior solution (referred to as this solution) in this application. This solution is an automated label generation scheme based on a large language model. It uses a cleaned and processed dataset with label information to fine-tune and train a specified large language model, enabling the model to generate specified labels. This large language model is trained on a large amount of natural language data and programming language data, and therefore it already possesses the ability to understand natural language and programming language, thus better understanding the semantics of code changes and generating more accurate and appropriate labels.
[0024] Furthermore, this solution supports generating multi-tag sets, meaning that multiple tags can be generated for a single piece of data. This is because the same code change may have multiple tag attributes; for example, it might belong to both "fix" and "build." These generated multi-tag sets can be applied to various scenarios, such as structured commit messages, change logs, and release notes. Users can also select the appropriate tag from the multiple tags for their specific needs.
[0025] A commit message is a descriptive text provided by developers when submitting code changes to the platform. It typically contains information about the purpose, content, and context of the change. Figure 4 This diagram illustrates a structured commit message provided for one or more embodiments of this specification. The commit message may include one or more tags automatically generated by this solution, as well as a message portion.
[0026] A change log is a document that records the history of software versions and updates. It records information such as changes made, bug fixes, and added features in each version, so that users or developers can understand the evolution and updates of the software.
[0027] A release note is a document or record used to describe changes, new features, bug fixes, and other important information in a specific version of software, application, or product. It is typically prepared by the development or product management team and provided to users, customers, or other stakeholders when the software is released or updated. The purpose of a release note is to provide clear guidance so that users understand the improvements, new features, and fixed issues in the new version, enabling them to better use, understand, and evaluate the software updates.
[0028] Similarly, the tags automatically generated by this solution can be used in Change Logs and Release Notes.
[0029] This solution automatically generates appropriate tags for code changes. Leveraging the language understanding and generation capabilities of a large language model, it analyzes the content of code changes and generates tags that reflect their characteristics. In commit messages, these tags provide concise and clear change types, allowing developers and team members to quickly understand the nature of the code changes. In release notes and change logs, these tags provide more detailed change descriptions, helping users understand the changes in each version. This solution improves development efficiency and documentation accuracy. The automatically generated tags accurately reflect the characteristics of code changes, reducing the workload of manually writing tags and contributing to consistent and standardized change descriptions, as well as better change tracking and understanding.
[0030] Based on the general overview above, the following section will provide a detailed explanation of this solution.
[0031] Figure 5 This is a flowchart illustrating a code change label generation method provided in one or more embodiments of this specification. In this process, a large language model is fine-tuned and trained using a small dataset containing cleaned and processed label information, and then the large language model is used to generate labels for more data.
[0032] Figure 5 The process includes the following steps: S502: Obtain a set of code change information and a set of predefined tag information.
[0033] Steps S502 and S504 are the preparation process for the small-scale dataset used for fine-tuning training described above.
[0034] In one or more embodiments of this specification, the code change information set can be collected from the developers themselves or from relevant platforms. For example, by calling the interface provided by the code data management platform (such as GitHub, SVN and other code version control platforms), the commit information associated with different code changes submitted by the developers to the code data management platform can be obtained. As can be seen from the foregoing description, the commit information itself can describe the code change situation. Therefore, the code change information set can be constructed based on these commit information. This is less costly and makes it easier to select specific fine-tuning training samples according to actual needs.
[0035] It should be noted that the obtained submission information itself may not contain tags, or may not contain reliable tags, but these situations do not affect the implementation of this solution, because this solution will automatically generate tags for each code change information in the code change information set.
[0036] In the example above, code change information can be commit messages such as Commit Messages, or other forms of change information for similar purposes, such as Release Notes and Change Logs mentioned above, as well as comments describing changes within the code, and so on.
[0037] Furthermore, the acquired commit or code change information can be filtered according to certain set strategies, retaining relatively high-quality data to form a set of code change information to be tagged. These strategies may include at least one of the following: retaining commits with sufficiently high approval ratings and / or secondary development activity for the corresponding code changes; filtering out commits with too little effective information; filtering out commits with too many tokens for large language models; and so on.
[0038] In one or more embodiments of this specification, in addition to using existing tags, custom tags can also be used as needed for the tag information set.
[0039] To make the semantics of tags clearer, tags and their associated descriptive information can be defined to form a set of tag information. Multiple such sets of tag information constitute a tag information collection. This also facilitates the expansion of tags and effectively improves the scalability of the solution.
[0040] S504: Based on the tag information contained in the tag information set, perform semantic comparison and code difference comparison feature analysis on the code change information contained in the code change information set, and generate corresponding tags for the code change information.
[0041] In one or more embodiments of this specification, the semantic similarity calculation between code change information and tag information can lead to a deeper understanding of the direct and implicit semantics of the code change information, thereby attempting to match it with semantically corresponding tags. A pre-trained machine learning model can be used to perform text semantic similarity calculation, which helps to comprehensively and accurately mine various semantics.
[0042] In one or more embodiments of this specification, code difference comparison is performed using codeDiff, which is easy to parse and has low implementation costs. Of course, other forms and their corresponding syntax can also be used to describe the differences between the compared codes. By employing feature analysis logic defined separately for different tag information, feature analysis is performed on codeDiff. Specifically, it can analyze the relevant statement keywords or other specific changed areas to infer and determine which tags' semantics are more consistent with the current code change operation. This approach helps to efficiently and accurately mine certain specific semantics.
[0043] S506: Obtain large language models trained using large-scale natural language data and programming language data.
[0044] Large language models typically consist of artificial neural networks with massive numbers of parameters, trained using large-scale training data. They support both supervised training with labeled data and self-supervised or semi-supervised training with unlabeled data. The large language model used in this solution demonstrates good understanding capabilities for both natural and programming languages.
[0045] S508: Based on the code change information and its corresponding tags, fine-tune the large language model to obtain a tag-generated large language model.
[0046] Fine-tuning training refers to the process of further adjusting and optimizing a pre-trained model in machine learning. By training on task-specific data, fine-tuning can make the pre-trained model more suitable for a specific application scenario or task. This process typically involves smaller datasets and fewer training iterations, making it more efficient and less costly.
[0047] Based on code change information and its corresponding tags, a supervised training method is used to fine-tune the large language model.
[0048] S510: Use the tags to generate a large language model and generate corresponding tags for target code change information.
[0049] In one or more embodiments of this specification, the finely tuned large language model can be used to automatically generate code change labels for target code change information, such as newly generated code change information. In use, the target code change information, or information obtained through adaptive processing, is input as a prompt into the large language model, and the corresponding answer is output, which is the generated label.
[0050] pass Figure 5 This method, through semantic comparison and code difference comparison feature analysis, can more accurately and efficiently understand the semantics expressed or implied by code change information. This allows for the automatic, small-scale, and efficient generation of appropriate and reliable labels. These small-scale data are then used to fine-tune and train a large language model that already has a good understanding of both natural and programming languages. This enables the large language model to quickly gain the ability to reliably generate code change labels, which can then be used to efficiently generate labels for other large-scale code change information. Furthermore, this solution also supports users in customizing label information according to their actual needs, and similarly, small-scale fine-tuning training data can be efficiently obtained for the customized label information.
[0051] based on Figure 5 In addition to the method described herein, this specification also provides some specific implementation schemes and extension schemes of this method, which will be further explained below.
[0052] More intuitively, taking a code version control platform like GitHub as an example, this specification provides a flowchart illustrating a code change information set generation scheme through one or more embodiments. See [link / reference]. Figure 6 .
[0053] GitHub provides interfaces for retrieving Commit Messages, Release Notes, and Change Logs. Figure 6 The example uses Commit Messages. On GitHub, stars represent positive reviews and forks represent using the current code for further development. Therefore, data with high star and fork counts can be retained; data with insufficient effective information, such as empty messages, messages containing garbled characters, or messages lacking information (e.g., modifying the XXX.java file), can be filtered out; data with excessively high token counts can be filtered out based on the input token length limit of the large language model to be used later; and so on.
[0054] The filtered Commit Message dataset serves as a collection of code change information. Below is an example of a structured representation of this Commit Message dataset: “{ "commitId": <id>, "message": <message>, "difference": [ { "oldPath": <oldpath>, "newPath": <newpath>, "codeDiff": <codediff> }, { "oldPath": <oldpath>, "newPath": <newpath>, "codeDiff": <codediff> }, ... ] }” In this structure, the commitId field represents the commit number, the message field provides a basic description of the change, and the key focus is on the difference field, which contains multiple sets of change information. Each set includes an oldPath field representing the path before the code change, a newPath field representing the path after the code change, and a codeDiff field representing the code differences. This scenario will be used again in later examples.
[0055] Furthermore, regarding the tag information set, a tag can be defined, along with one or more synonyms and related descriptions in one language generated for that tag, constituting a set of tag information. This process can be repeated to construct multiple sets of tag information, forming a tag information set. For ease of use, a relatively representative word from the synonym group can be used as the tag. Intuitively, one or more embodiments of this specification also provide a schematic diagram of a tag information set, see [link to relevant documentation]. Figure 7 .
[0056] exist Figure 7 In this example, both Chinese and English are used to describe the tag information. To reduce the amount of data, short descriptions are used. Therefore, each set of tag information contains four parts: a Chinese synonym phrase, an English synonym phrase, a short Chinese description, and a short English description.
[0057] In one or more embodiments of this specification, code change information such as submission information may typically include a message portion, a code path portion, and a code difference comparison portion. In such cases, the semantic comparison or code difference comparison feature analysis described above can be selected in a differentiated manner to improve the efficiency and reliability of understanding the semantics of different parts of the information.
[0058] For semantic comparison, it can specifically include: determining the message part and code path part of the code change information contained in the code change information set; extracting keywords from the message part and code path part to obtain the keywords to be compared; calculating the text semantic similarity between the keywords to be compared and the tag information contained in the tag information set to obtain the corresponding semantic comparison results, so as to generate corresponding tags for the code change information based on the semantic comparison results.
[0059] For code difference comparison feature analysis, it can specifically include: determining the code difference comparison part of the code change information contained in the code change information set; determining the feature analysis logic defined for one or more sets of tag information contained in the tag information set; in the code difference comparison part, identifying whether the specified code region involved in the feature analysis logic has undergone code change, so as to generate corresponding tags for the code change information based on the identification results.
[0060] Based on this implementation approach, intuitively, one or more embodiments of this specification provide a flowchart illustrating a scheme for generating tags for a code change information set. See [link to flowchart]. Figure 8 .
[0061] exist Figure 8 In this example, the Commit Message dataset is used as a collection of code change information. In this case, the message part is specifically the content of the message field, the code path part is specifically the content of the oldPath and / or newPath (which can be collectively referred to as codePath) fields, and the code difference comparison part is specifically the content of the codeDiff field.
[0062] After collecting and filtering the Commit Message dataset, we begin generating labels for the dataset, mainly including: Based on message and code path, machine learning models such as HarvestText or KeyBERT are used to extract keywords. Then, machine learning models such as hiiamsid or sentence_similarity_hindi are used to calculate the semantic similarity between the keywords and the various sets of tag information in the tag information database. If the similarity exceeds a set threshold, the corresponding tag information is labeled.
[0063] Pre-write the corresponding feature analysis logic based on the currently defined tag information. For example, assume that three tags are defined: "fix", "docs", and "style".
[0064] For the "fix" tag, the corresponding feature analysis logic includes, for example, generating the tag information if code changes are detected in the specified code region corresponding to the tag information in codeDiff. In this case, the specified code region includes the specified program control flow region. The specified program control flow region may include the conditional region in a specified keyword statement. The specified keyword statement may include at least one of the following: return statement, continue statement, break statement, if statement; and / or, the catch block region in a try-catch statement, etc.
[0065] In other words, if a code change is identified as causing a change in program control flow, it falls under the "fix" category. Modifications to return statements, continue statements, break statements, or the conditions of if statements, or modifications to the catch block of try-catch statements, can all be marked with the "fix" label.
[0066] As for the "docs" and "style" tags, these fall under the category of non-repair cases. In these cases, if codeDiff identifies that only the specified code region corresponding to the tag information has undergone code changes, then the tag information is generated for the code change information. In this case, the specified code region includes at least one of the following: comment content region, blank line editing region.
[0067] Specifically, the "docs" tag specifies that the code area includes the comment content area; that is, if the code change only modifies the comment content, the "docs" tag can be used. The "style" tag specifies that the code area includes the blank line editing area; that is, if the code change only modifies blank lines (e.g., adding or deleting blank lines), the "style" tag can be used.
[0068] Similarly, depending on the specific area being changed, corresponding feature analysis logic can be written for other different label information.
[0069] The tags generated from the two separate processing steps above can be merged to form a tag set corresponding to the current code change information. The tagged Commit Message dataset can be represented in a structured manner as follows: { "commitId": <id>, "message": <message>, "difference": [ { "oldPath": <oldpath>, "newPath": <newpath>, "codeDiff": <codediff> }, { "oldPath": <oldpath>, "newPath": <newpath>, "codeDiff": <codediff> }, ... ] , "labels": [ <label>, <label>, <label>...] }” As you can see, a labels field has been added, which contains one or more generated labels.
[0070] In practical applications, structured data such as Commit Message datasets are not suitable for direct use in fine-tuning training of large language models. They require transformation and processing before training. Specifically, this may include: extracting the corresponding field content of the message portion, code path portion, and code difference comparison portion from the code change information, fusing them, and converting them into a string as the prompt information; using one or more tags generated for the code change information as answer information, forming prompt-answer pairs with the prompt information; and using these prompt-answer pairs as supervised training data to fine-tune the large language model. Intuitively, one or more embodiments of this specification provide a schematic diagram of a fine-tuning training dataset, see [link to documentation]. Figure 9 .
[0071] exist Figure 9 In this context, the prompt information is specifically called "Prompt," and the answer information is specifically called "Answer." Therefore, we can use the message, oldPath, newPath, codeDiff, etc., from the CommitMessage dataset as "Prompt," concatenating them into a string format using newline characters. Similarly, we can use the content from the corresponding labels as "Answer," concatenating them into a string format using commas or other separators. By processing each set of data in this way, we can generate various...<Prompt,Answer> Yes, that is, each training data point.
[0072] Based on the prepared fine-tuning training dataset, this specification further provides a schematic diagram of a scheme for fine-tuning training and deployment of a large language model, based on one or more embodiments. (See attached diagram.) Figure 10 .
[0073] exist Figure 10 In this approach, the labeled data serves as the fine-tuning training dataset, and the large language model is pre-trained on a large scale of natural language and programming language data. The labeled data is then used to further fine-tune and train this large language model to generate a new model capable of generating code change labels. The new model is then evaluated through inference. If it meets the requirements, it can be directly deployed. If the performance is not as expected, the training dataset can be adjusted and optimized for the next iteration until a satisfactory result is achieved. Furthermore, since this approach may generate multiple labels, only one or a few labels may be needed in actual use. Therefore, a post-processing module can be added for label correction and selection during deployment.
[0074] Based on the same idea, one or more embodiments of this specification also provide apparatus and devices corresponding to the above methods, such as... Figure 11 , Figure 12 As shown. The apparatus and equipment are capable of performing the above methods and related alternatives accordingly.
[0075] Figure 11 This is a schematic diagram of a code change tag generation device provided in one or more embodiments of this specification. The device includes: The information set acquisition module 1102 acquires a set of code change information and a set of predefined tag information. The first tag generation module 1104 performs semantic comparison and code difference comparison feature analysis on the code change information contained in the tag information set based on the tag information contained in the tag information set, and generates corresponding tags for the code change information. Large language model acquisition module 1106 acquires a large language model trained using large-scale natural language data and programming language data; The model fine-tuning training module 1108 fine-tunes and trains the large language model based on the code change information and its corresponding tags to obtain a tag-generated large language model. The second tag generation module 1110 uses the tags to generate a large language model and generates corresponding tags for target code change information.
[0076] Optionally, before acquiring the code change information set, the information set acquisition module 1102 acquires the submission information associated with different changed codes submitted by the R&D personnel to the code data management platform by calling the interface provided by the code data management platform; The code change information set is generated by filtering the submission information according to the set strategy.
[0077] Optionally, the code data management platform includes a code version control platform; The setting strategy includes at least one of the following: Retain submissions that reflect a high level of positive feedback and / or a high level of interest in secondary development of the corresponding modified code; Filter out submissions with insufficient valid information; Filter out submissions with an excessive number of tokens for the large language model.
[0078] Optionally, before acquiring the predefined tag information set, the information set acquisition module 1102 defines a tag and generates one or more synonyms and related descriptions in one language for the tag, thus forming a set of tag information; Determine the set of tag information consisting of multiple different sets of the aforementioned tag information.
[0079] Optionally, the first tag generation module 1104 determines the message portion and code path portion of the code change information included in the code change information set; Keyword extraction is performed on the message portion and the code path portion to obtain the keywords to be compared; For the keyword to be compared, the text semantic similarity is calculated with the tag information contained in the tag information set to obtain the corresponding semantic comparison result, so as to generate a corresponding tag for the code change information based on the semantic comparison result.
[0080] Optionally, the first tag generation module 1104 determines the code difference comparison portion of the code change information included in the code change information set; Define feature analysis logic for one or more sets of tag information contained in the tag information set; In the code difference comparison section, it is identified whether a specified code region involved in the feature analysis logic has undergone code changes, so as to generate corresponding tags for the code change information based on the identification results.
[0081] Optionally, the first tag generation module 1104, for tag information indicating code change type as repair, if in the code difference comparison part it is identified that a code change has occurred in the specified code region involved in the feature analysis logic corresponding to the tag information, then generates the tag information for the code change information; The specified code region corresponding to the tag information indicating that the code change type is repair includes the specified program control flow region.
[0082] Optionally, the specified program control flow region includes the conditional region in the specified keyword statement; The specified keyword statement includes at least one of the return statement, continue statement, break statement, and if statement; and / or, the catch block area in a try-catch statement.
[0083] Optionally, the first tag generation module 1104, for tag information indicating that the code change type is non-repair, if in the code difference comparison part it is identified that only the specified code area involved in the feature analysis logic corresponding to the tag information has changed, then the tag information is generated for the code change information. The non-repair type includes document type modification and / or style type modification. The specified code region corresponding to the tag information indicating that the code change type is "repair" includes at least one of the following: Annotation area; Empty line editing area.
[0084] Optionally, the code change information is structured data; The model fine-tuning training module 1108 extracts the field contents corresponding to the message part, code path part and code difference comparison part from the code change information, and fuses them into a string as a prompt message; One or more tags generated for the code change information will be used as answer information, forming a hint-answer pair with the hint information; The large language model is fine-tuned using the aforementioned prompt-answer pairs as supervised training data.
[0085] Figure 12 This specification provides a schematic diagram of the structure of a code change tag generation device according to one or more embodiments, the device comprising: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to: Retrieve a set of code change information and a set of predefined tag information; Based on the tag information contained in the tag information set, semantic comparison and code difference comparison feature analysis are performed on the code change information contained in the code change information set to generate corresponding tags for the code change information; Obtain large language models trained using massive amounts of natural language and programming language data; Based on the code change information and its corresponding tags, the large language model is fine-tuned and trained to obtain a tag-generated large language model; The tags are used to generate a large language model, and corresponding tags are generated for target code change information.
[0086] Based on the same idea, one or more embodiments of this specification also provide a non-volatile computer storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured as follows: Retrieve a set of code change information and a set of predefined tag information; Based on the tag information contained in the tag information set, semantic comparison and code difference comparison feature analysis are performed on the code change information contained in the code change information set to generate corresponding tags for the code change information; Obtain large language models trained using massive amounts of natural language and programming language data; Based on the code change information and its corresponding tags, the large language model is fine-tuned and trained to obtain a tag-generated large language model; The tags are used to generate a large language model, and corresponding tags are generated for target code change information.
[0087] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also understand that by simply performing some logic programming on the method flow using one of these hardware description languages and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.
[0088] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0089] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0090] For ease of description, the above devices are described in terms of function, divided into various units. Of course, in implementing this specification, the functions of each unit can be implemented in one or more software and / or hardware components.
[0091] Those skilled in the art will understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, the embodiments of this specification can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the embodiments of this specification can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0092] This specification is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this specification. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0093] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0094] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0095] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0096] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0097] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0098] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0099] This specification can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This specification can also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0100] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, devices, and non-volatile computer storage media are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0101] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0102] The above description is merely one or more embodiments of this specification and is not intended to limit this specification. Various modifications and variations can be made to the one or more embodiments of this specification by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of one or more embodiments of this specification should be included within the scope of the claims of this specification.< / label> < / label> < / label> < / codediff> < / newpath> < / oldpath> < / codediff> < / newpath> < / oldpath> < / message> < / id> < / codediff> < / newpath> < / oldpath> < / codediff> < / newpath> < / oldpath> < / message> < / id>
Claims
1. A method for generating code change tags, comprising: Retrieve a set of code change information and a set of predefined tag information; Based on the tag information contained in the tag information set, semantic comparison and code difference comparison feature analysis are performed on the code change information contained in the code change information set to generate corresponding tags for the code change information; Obtain large language models trained using massive amounts of natural language and programming language data; Based on the code change information and its corresponding tags, the large language model is fine-tuned and trained to obtain a tag-generated large language model; The tags are used to generate a large language model, and corresponding tags are generated for target code change information. The step of performing semantic comparison on the code change information in the code change information set based on the tag information in the tag information set specifically includes: determining the message part and the code path part in the code change information in the code change information set; extracting keywords from the message part and the code path part to obtain keywords to be compared; calculating the text semantic similarity between the keywords to be compared and the tag information in the tag information set to obtain corresponding semantic comparison results, so as to generate corresponding tags for the code change information based on the semantic comparison results.
2. The method as described in claim 1, wherein before obtaining the code change information set, the method further includes: By calling the interface provided by the code data management platform, the submission information associated with different change codes submitted by the R&D personnel to the code data management platform can be obtained; The code change information set is generated by filtering the submission information according to the set strategy.
3. The method as described in claim 2, wherein the code data management platform includes a code version control platform; The setting strategy includes at least one of the following: Retain submissions that reflect a high level of positive feedback and / or a high level of interest in secondary development of the corresponding modified code; Filter out submissions with insufficient valid information; Filter out submissions with an excessive number of tokens for the large language model.
4. The method as described in claim 1, wherein before obtaining the predefined set of tag information, the method further comprises: Define a tag, and generate synonyms and related descriptions in one or more languages for the tag, which constitute a set of tag information; Determine the set of tag information consisting of multiple different sets of the aforementioned tag information.
5. The method as described in claim 1, wherein performing code difference comparison feature analysis on the code change information contained in the code change information set based on the tag information contained in the tag information set specifically includes: Identify the code difference comparison portion of the code change information contained in the code change information set; Define feature analysis logic for one or more sets of tag information contained in the tag information set; In the code difference comparison section, it is identified whether a specified code region involved in the feature analysis logic has undergone code changes, so as to generate corresponding tags for the code change information based on the identification results.
6. The method as described in claim 5, wherein generating a corresponding tag for the code change information based on the recognition result specifically includes: For tag information indicating code change type as repair, if in the code difference comparison section, it is identified that a code change has occurred in the specified code region involved in the feature analysis logic corresponding to the tag information, then the tag information is generated for the code change information; The specified code region corresponding to the tag information indicating that the code change type is repair includes the specified program control flow region.
7. The method of claim 6, wherein the specified program control flow region includes the conditional region in the specified keyword statement; The specified keyword statement includes at least one of the return statement, continue statement, break statement, and if statement; and / or, the catch block area in a try-catch statement.
8. The method as described in claim 5, wherein generating a corresponding tag for the code change information based on the identification result specifically includes: For tag information indicating code change type as non-repair, if in the code difference comparison section it is identified that only the specified code region involved in the feature analysis logic corresponding to the tag information has undergone code change, then the tag information is generated for the code change information. The non-repair includes document-type modification and / or style-type modification. The specified code region corresponding to the tag information indicating that the code change type is "repair" includes at least one of the following: Annotation area; Empty line editing area.
9. The method as described in claim 1, wherein the code change information is structured data; The step of fine-tuning the large language model based on the code change information and its corresponding tags specifically includes: Extract the field contents corresponding to the message part, code path part, and code difference comparison part from the code change information, and merge them into a string to serve as a prompt message; One or more tags generated for the code change information will be used as answer information, forming a hint-answer pair with the hint information; The large language model is fine-tuned using the aforementioned prompt-answer pairs as supervised training data.
10. A code change tag generation device, comprising: The information set acquisition module acquires a set of code change information and a set of predefined tag information. The first tag generation module performs semantic comparison and code difference comparison feature analysis on the code change information contained in the code change information set based on the tag information contained in the tag information set, and generates corresponding tags for the code change information. The large language model acquisition module acquires large language models trained using large-scale natural language data and programming language data. The model fine-tuning training module fine-tunes and trains the large language model based on the code change information and its corresponding tags to obtain a tag-generated large language model. The second tag generation module uses the tags to generate a large language model and generates corresponding tags for target code change information. The step of performing semantic comparison on the code change information in the code change information set based on the tag information in the tag information set specifically includes: determining the message part and the code path part in the code change information in the code change information set; extracting keywords from the message part and the code path part to obtain keywords to be compared; calculating the text semantic similarity between the keywords to be compared and the tag information in the tag information set to obtain corresponding semantic comparison results, so as to generate corresponding tags for the code change information based on the semantic comparison results.
11. The apparatus of claim 10, wherein the information set acquisition module, before acquiring the code change information set, acquires the submission information associated with different change codes submitted by the R&D personnel to the code data management platform by calling the interface provided by the code data management platform; The code change information set is generated by filtering the submission information according to the set strategy.
12. The apparatus of claim 11, wherein the code data management platform includes a code version control platform; The setting strategy includes at least one of the following: Retain submissions that reflect a high level of positive feedback and / or a high level of interest in secondary development of the corresponding modified code; Filter out submissions with insufficient valid information; Filter out submissions with an excessive number of tokens for the large language model.
13. The apparatus of claim 10, wherein the information set acquisition module, before acquiring the predefined tag information set, defines a tag and generates one or more synonyms and related descriptions in one or more languages for the tag, constituting a set of tag information; Determine the set of tag information consisting of multiple different sets of the aforementioned tag information.
14. The apparatus of claim 10, wherein the first tag generation module determines the code difference comparison portion of the code change information included in the code change information set; Define feature analysis logic for one or more sets of tag information contained in the tag information set; In the code difference comparison section, it is identified whether a specified code region involved in the feature analysis logic has undergone code changes, so as to generate corresponding tags for the code change information based on the identification results.
15. The apparatus of claim 14, wherein the first tag generation module, for tag information indicating code change type as repair, if in the code difference comparison section, it is identified that a code change has occurred in a specified code region involved in the feature analysis logic corresponding to the tag information, then the tag information is generated for the code change information; in, The specified code region corresponding to the tag information indicating that the code change type is repair includes the specified program control flow region.
16. The apparatus of claim 15, wherein the designated program control flow region includes a conditional region in a designated keyword statement; The specified keyword statement includes at least one of the return statement, continue statement, break statement, and if statement; and / or, the catch block area in a try-catch statement.
17. The apparatus of claim 14, wherein the first tag generation module, for tag information indicating that the code change type is non-repair, if in the code difference comparison section it is identified that only the specified code region involved in the feature analysis logic corresponding to the tag information has undergone code change, then the tag information is generated for the code change information, wherein the non-repair includes document-type modification and / or style-type modification; The specified code region corresponding to the tag information indicating that the code change type is "repair" includes at least one of the following: Annotation area; Empty line editing area.
18. The apparatus of claim 10, wherein the code change information is structured data; The model fine-tuning training module extracts the field contents corresponding to the message part, code path part and code difference comparison part from the code change information, and fuses them into a string as a prompt message; One or more tags generated for the code change information will be used as answer information, forming a hint-answer pair with the hint information; The large language model is fine-tuned using the aforementioned prompt-answer pairs as supervised training data.
19. A code change tag generation 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: Retrieve a set of code change information and a set of predefined tag information; Based on the tag information contained in the tag information set, semantic comparison and code difference comparison feature analysis are performed on the code change information contained in the code change information set to generate corresponding tags for the code change information; Obtain large language models trained using massive amounts of natural language and programming language data; Based on the code change information and its corresponding tags, the large language model is fine-tuned and trained to obtain a tag-generated large language model; The tags are used to generate a large language model, and corresponding tags are generated for target code change information. The step of performing semantic comparison on the code change information in the code change information set based on the tag information in the tag information set specifically includes: determining the message part and the code path part in the code change information in the code change information set; extracting keywords from the message part and the code path part to obtain keywords to be compared; calculating the text semantic similarity between the keywords to be compared and the tag information in the tag information set to obtain corresponding semantic comparison results, so as to generate corresponding tags for the code change information based on the semantic comparison results.
Citation Information
Patent Citations
Java code review comment generation method and device based on code structured information and review knowledge
CN116841869A