Code processing model training method and code task processing method
By automatically constructing large-scale and high-quality model training data, the problem of low training efficiency of large-scale models in the existing technology is solved, and efficient code processing model training is realized at the warehouse level, which is suitable for scenarios such as intelligent coding assistants.
Patent Information
- Application Number
- CN202411426871.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2024-11-12
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, the training efficiency of large models in warehouse-level code scenarios is low, mainly because the sample set construction requires high programming level and a lot of manpower, resulting in high cost and slow speed, and poor quality and stability of model training data.
By obtaining sample code documents and sample record documents, parsing and splitting them into multiple sample code snippets, generating sample description information, using this information to automatically construct model training data, reducing manual intervention, and improving the quality and efficiency of model training data.
It realizes efficient code processing model training at the warehouse level, reduces labor costs, improves the adaptability and quality of model training data, and supports applications such as intelligent coding assistants.
Smart Images

Figure CN118939245A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of computer technology, and in particular to a code processing model training method and a code task processing method. Background Art
[0002] With the development of computer technology, more and more work is trying to use large models for automatic processing to reduce labor costs. In the field of code, especially in warehouse-level code scenarios, large models do not perform well, so training large models has gradually become a research focus. In the process of large model training, the construction of sample sets becomes very important.
[0003] Currently, sample sets are usually constructed by manual annotation. However, warehouse-level sample set construction requires the annotator to be very familiar with the entire code, which places too high a requirement on the annotator. In addition, the annotation process requires a lot of manpower, resulting in high cost and slow speed of manual annotation, which further leads to extremely low model training efficiency. Therefore, an efficient code processing model training solution is urgently needed. Summary of the invention
[0004] In view of this, an embodiment of the present specification provides a code processing model training method to solve the technical defects existing in the prior art.
[0005] According to a first aspect of an embodiment of the present specification, a code processing model training method is provided, comprising: obtaining a sample code document and a sample record document, wherein the sample record document is used to record code modification information of the sample code document for a sample problem, and the sample code document comprises a plurality of sample code snippets; parsing the sample record document, and respectively determining sample modification snippets of the sample code snippets; for a first sample code snippet, generating sample description information of the first sample modification snippet according to the first sample code snippet and the first sample modification snippet, wherein the first sample code snippet is any one of a plurality of sample code snippets, and the first sample modification snippet is a sample modification snippet of the first sample code snippet; and training an initial processing model using the sample problem, the plurality of sample code snippets, the plurality of sample modification snippets, and the sample description information of the plurality of sample modification snippets to obtain a code processing model.
[0006] An embodiment of the present specification provides a code processing model training method, which constructs model training data based on sample code snippets, alleviates the situation where the model has limitations on the length of input data, making the constructed model training data more adaptable and effective during model training; and utilizes sample code documents and sample record documents in a sample code warehouse to automatically construct model training data, thereby improving the quality of model training data, while saving construction time and realizing efficient model training at the warehouse level. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] Figure 1 is an architecture diagram of a code task processing system provided by an embodiment of this specification; Figure 2 is a flowchart of a code processing model training method provided by an embodiment of this specification; Figure 3 is a flow chart of a code task processing method provided by an embodiment of this specification; Figure 4 is a flowchart of a method for generating code repair suggestions provided by an embodiment of this specification; Figure 5 is a flowchart of a code processing model training method provided by an embodiment of this specification; Figure 6 is a flowchart of an information processing method based on a code processing model provided by an embodiment of this specification; Figure 7 It is a structural diagram of a task platform provided by an embodiment of this specification; Figure 8 It is a structural diagram of a code processing model training device provided by an embodiment of this specification; Fig. 9 It is a structural diagram of a code task processing device provided by an embodiment of this specification; Fig.10 It is a structural schematic diagram of a code repair suggestion generating device provided by an embodiment of this specification; Fig.11 is a structural diagram of an information processing device based on a code processing model provided by an embodiment of this specification; Fig.12 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION
[0008] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.
[0009] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0010] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0011] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0012] In one or more embodiments of this specification, a large model refers to a deep learning model with large-scale model parameters, which usually contains hundreds of millions, tens of billions, hundreds of billions, trillions, or even more than 10 trillion model parameters. A large model can also be called a foundation model / foundation model. The large model is pre-trained with large-scale unlabeled corpus to produce a pre-trained model with more than 100 million parameters. This model can adapt to a wide range of downstream tasks, and the model has good generalization ability, such as a large-scale language model (LLM, Large Language Model), a multi-modal pre-training model, etc.
[0013] When the big model is used in practice, only a small number of samples are needed to fine-tune the pre-trained model and it can be applied to different tasks. The big model can be widely used in natural language processing (NLP), computer vision and other fields. Specifically, it can be applied to computer vision tasks such as visual question answering (VQA), image description (IC, Image Caption), image generation, as well as natural language processing tasks such as text-based sentiment classification, text summary generation, and machine translation. The main application scenarios of the big model include digital assistants, intelligent robots, search, online education, office software, e-commerce, intelligent design, etc.
[0014] First, the terms involved in one or more embodiments of this specification are explained.
[0015] Git (Git repository) warehouse: It is the place used to store all project files and their historical versions in the Git version control system.
[0016] Code repository: refers to the place where source code files written by users are stored. It can be a folder on the local computer or a repository in an online version control system.
[0017] Abstract Syntax Tree (AST): is a tree data structure that represents the structure of source code. AST consists of a series of nodes, each of which represents a syntactic component in the source code, such as function calls, variable declarations, loop structures, etc.
[0018] Static code: usually refers to the source code that has been determined and written before the program runs. In computer programming, when writing a program, every line of code written is static code.
[0019] Supervised Fine-Tuning (SFT): is a method of further training based on a pre-trained model. In this method, the model is trained on a dataset containing input and expected output pairs so that the model can learn how to generate answers closer to human level.
[0020] Intelligent Coding Assistant: Using big models and artificial intelligence technology, it provides functions such as code completion, code generation, code error detection and correction, and code optimization to help developers reduce repetitive work and improve programming efficiency and code quality.
[0021] Repository-level code modification suggestion generation: Through in-depth analysis of the code repository of the entire project, it provides suggestions on requirements implementation, error correction, code refactoring, and security improvement to help the development team improve the code and enhance the quality and maintainability of the project.
[0022] In code project development scenarios, users often need to modify and repair existing project codes based on development requirements raised by product managers or defects raised by other users. This process is a core step in software development and has very high requirements for developers' project understanding and coding skills. It is also a very time-consuming and laborious step in the project development process. In order to quickly implement code processing, the large model can be fine-tuned to obtain a large code model for code tasks.
[0023] Currently, annotators can read the entire code repository, understand it, and then build model training data. However, this solution requires annotators to have a high level of programming skills and to spend time to familiarize themselves with the code repository, which is time-consuming and labor-intensive, and has a very high construction cost, resulting in low model training efficiency. Files in the entire code repository can also be screened and provided to a large model, which then builds model training data. However, since the code repository contains many files, the accumulated code length of all files is much larger than the length limit of the large model input, which requires the code text to be screened and truncated in advance, resulting in incomplete warehouse information obtained by the large model, and the generated model training data is less stable and of lower quality, which further leads to unsatisfactory model training results.
[0024] In order to solve the above problems, the embodiment of this specification proposes a solution for automatically generating warehouse-level model training data based on the data in the open source code warehouse, and using the model training data for model training. It is worth noting that the solution proposed in the embodiment of this specification can automatically construct warehouse-level model training data, thereby supporting warehouse-level code processing model training. The warehouse-level code processing model can take the source code files in the code warehouse and the repair / development requirements proposed by the user for the code warehouse as input to generate code processing results including modification suggestion planning, code modification suggestions, modification difference forms and other contents. Thereby helping users to quickly and efficiently realize code development or repair requirements. In addition, the warehouse-level code processing model can be applied to an intelligent coding assistant, so that the intelligent coding assistant can realize functions such as automatic code completion, code unit test generation, and warehouse-level code modification suggestion generation based on advanced artificial intelligence technology, through in-depth understanding of the developer's programming requirements and code files, and significantly improve the developer's coding efficiency.
[0025] Considering that the model parameters of the code processing model are relatively large and the computing resources of the client are limited, the code task processing method proposed in the embodiment of this specification can be applied to Figure 1The code task processing system shown is not limited to this. Figure 1 , Figure 1 The following is an architecture diagram of a code task processing system provided by an embodiment of the present specification. The code task processing system may include a client 100 and a server 200; The client 100 is used to send the to-be-processed code data and code problems of the target code task to the server 200; The server 200 inputs the code data to be processed and the code problem into the code processing model to obtain the task processing result of the target code task, wherein the code processing model is trained using the code processing model training method; the task processing result is sent to the client 100; the client 100 is also used to receive the task processing result sent by the server 200.
[0026] like Figure 1 As shown, the code processing model is deployed in the server 200, and the server 200 can be connected to one or more clients 100 through a local area network connection, a wide area network connection, an Internet connection, or other types of data networks. The client 100 may include, but is not limited to: a smart phone, a tablet computer, a laptop computer, a PDA, a personal computer, a smart home device, a vehicle-mounted device, etc. The client 100 can also interact with the user through a graphical user interface to implement the call to the code processing model, and then implement the code task processing method provided in the embodiment of this specification. It is worth noting that the code task processing method provided in the embodiment of this specification is generally executed by the server, but in other embodiments of this specification, when the operating resources of the client can meet the deployment and operating conditions of the code processing model, the client can also have similar functions with the server, thereby executing the code task processing method provided in the embodiment of this specification. In other embodiments, the code task processing method provided in the embodiment of this specification can also be executed by the client and the server together.
[0027] See also Figure 2 , Figure 2 A flowchart of a code processing model training method provided by an embodiment of this specification is shown, which specifically includes the following steps: Step 202: Obtain a sample code document and a sample record document, wherein the sample record document is used to record code modification information of the sample code document for a sample problem, and the sample code document includes a plurality of sample code snippets.
[0028] It should be noted that the sample code document and sample record document can be documents stored in the sample code repository. The sample code repository refers to a place where code files are stored. The sample code repository can be a folder on a local computer, a repository in an online version control system (such as a Git repository), or a code repository in an open source code repository platform on the Internet. Taking the code repository in the code repository platform as an example, the code repository platform allows project creators to create projects on the platform, and also allows project users to create issues (issues) based on the project through the platform. The project creator then responds to the issue and modifies or repairs the project code to interact. Therefore, the code repository platform can record the creator of the project and all operations on the sample code repository and issue, forming a pull request (PR) and storing it in the repository record file (Git PR) in the sample code repository. Pull requests include but are not limited to issues and the creator's code modification information (git diff patch). The repository record file refers to a file on the code repository platform that is used to record an update by the repository creator. This update is often bound to an issue.
[0029] Sample code documents refer to documents that store code snippets that users have actually modified. For example, sample code documents can be files that the project creator has actually modified in a PR. Sample record documents are used to record code modification information for sample issues in sample code documents. Code modification information can be recorded and compared by using git diff (used to compare differences between files in the staging area and the workspace) to compare changes in the code before and after a certain modification by the project creator. Code modification information includes, but is not limited to, line number information of the modified code, the modified code content, and the upper and lower lines of code used for positioning. An example of code modification information is as follows, where -40 indicates that the line number of the modified code "chunk = os.urandom(1024)" is line 40, +43 indicates that the line number of the modified code content is line 43, 8 indicates that there are 8 lines of code before the modification, and 10 indicates that there are 10 lines of code after the modification: @@ -40,8 +43,10 @@ def create_temp_file(self, size_kb, full_random=False): chunk = os.urandom(1024) else: chunk = bytearray([0] * 1024) -for _ in range(size_kb): +for _ in range(int(size_kb)): f.write(chunk) +chunk = os.urandom(int(1024 * (size_kb % 1))) +f.write(chunk) return path In actual applications, there are multiple ways to obtain sample code documents and sample record documents. In one possible implementation, the sample code documents and sample record documents can be obtained from an open source code repository platform. In another possible implementation, the sample code documents and sample record documents sent by the user through the client can be received.
[0030] In an optional embodiment of the present specification, since there are many files in the sample code repository and some of the code files are very long, far exceeding the input length limit of the model, the sample code document can be split into multiple sample code fragments, that is, before the above-mentioned parsing of the sample record document and determining the sample modification fragments of the sample code fragments respectively, the following steps can also be included: Perform syntax analysis on the sample code document to obtain syntax analysis results; According to the grammar parsing result, the sample code document is segmented to obtain multiple sample code segments.
[0031] It should be noted that syntax parsing refers to the process of converting a sample code document into a structured representation form, which is used to understand the structure and semantics of the source code. This form is also the result of syntax parsing. The result of syntax parsing is an abstract syntax tree. The abstract syntax tree is used to represent the tree structure of the program code structure. A sample code snippet (Chunk) refers to an independent code example or function definition contained in a sample code document. For example, a function or a class can be represented as a sample code snippet. Sample code snippets can be used to demonstrate how to implement a specific function, show programming skills in different scenarios, or as part of a test case.
[0032] In practical applications, there are many ways to perform syntax parsing on sample code documents and obtain syntax parsing results. In one possible implementation, you can directly use static code analysis tools to perform syntax parsing on sample code documents to obtain syntax parsing results. In another possible implementation, you can use the standard library corresponding to the sample code document (such as Python can use the ast module) to perform syntax parsing on the sample code document to obtain syntax parsing results. After obtaining the syntax parsing results, you can traverse the syntax parsing results to find split nodes (such as function definitions, class definitions, etc.). According to the position of the split node, extract the corresponding sample code snippet from the sample code document.
[0033] By applying the solution of the embodiments of this specification, by splitting the sample code document into multiple sample code fragments, model training data can be constructed based on reasonable and effective sample code fragments, thereby alleviating the situation where the downstream model has limitations on the input length, and making the constructed model training data more adaptable and effective during model training.
[0034] In an optional embodiment of the present specification, in addition to using the syntax parsing structure to split the sample code document into segments, the sample code document may also be parsed by using the code characteristics of the sample code document to obtain multiple complete and valid code segments. That is, before the sample code document is split into segments according to the syntax parsing result to obtain multiple sample code segments in the sample code document, the following steps may be further included: Get the code language type of the sample code document; According to the grammar parsing result, the sample code document is segmented to obtain multiple sample code segments in the sample code document, which may include the following steps: The sample code document is segmented according to the syntax parsing result and the code language type to obtain multiple sample code segments in the sample code document.
[0035] It should be noted that the code language type in the sample code document refers to the type of programming language used in the sample code document. For example, the code in the document may be of Python type, JavaScript type, Java type, etc. There are many ways to obtain the code language type of the sample code document. In one possible implementation, you can check the extension of the sample code document to obtain the code language type of the sample code document. For example: ".py" means that the code language is of Python type, ".js" means that the code language is of JavaScript type, and ".java" means that the code language is of Java type. In another possible implementation, the code language type of the sample code document can be identified by analyzing the code style and syntax in the sample code document. For example, if the keyword "def" appears in the sample code document, it means that the code language type is of Python type, and if "function" appears, it means that the code language type is of JavaScript type.
[0036] In actual applications, the implementation method of "segmenting the sample code document according to the syntax parsing results and the code language type to obtain multiple sample code fragments in the sample code document" can refer to the above-mentioned implementation method of "segmenting the sample code document according to the syntax parsing results to obtain multiple sample code fragments in the sample code document", and the embodiments of this specification will not be repeated. For example, when the code language type is JavaScript type, the sample code document can be segmented into fragments in units of functions to obtain multiple sample code fragments in the sample code document.
[0037] By applying the solution of the embodiments of this specification, multiple sample code snippets are parsed according to the code characteristics of different programming languages and in combination with the grammatical parsing results, the sample code document can be deeply understood and the accuracy of the sample code snippets can be improved.
[0038] Step 204: Parse the sample record document and determine the sample modification segments of the sample code segments respectively.
[0039] In one or more embodiments of the present specification, since the sample record document records code modification information at the full-text level of the sample code document, which is inconsistent with multiple sample code snippets in the sample code document, the sample record document can be parsed to determine the sample modification snippets of the multiple sample code snippets in the sample code document respectively.
[0040] It should be noted that the sample modification snippet refers to the code snippet obtained after modifying the sample problem in the sample code document. The sample code snippet can be understood as the code snippet before the code is modified, and the sample modification snippet can be understood as the code snippet after the code is modified. In practical applications, there are many ways to parse the sample record document and determine the sample modification snippet of the sample code snippet respectively. In one possible implementation, the sample record document can be semantically analyzed, the sample record document can be split into multiple sample record snippets, the multiple sample record snippets and the multiple sample code snippets can be matched, the sample record snippets corresponding to each sample code snippet can be determined, and finally, the corresponding sample code snippet can be modified according to the sample record snippet to obtain the sample modification snippet. In another possible implementation, the sample record document includes modification location information; the above-mentioned parsing of the sample record document and determining the sample modification snippets of the sample code snippet respectively can include the following steps: Determining sample record segments of the sample code segments in the sample record document respectively according to the modification location information; The sample code snippet is modified according to the sample record snippet to obtain a sample modified snippet of the sample code snippet.
[0041] It should be noted that the modification location information is used to locate the position of the code corresponding to the code modification information in the sample code document. The sample record document may include multiple modification location information, and the modification location information corresponds to the sample record fragment one by one. The modification location information can be the line number of the code corresponding to the code modification information, or it can be the coordinates of the code corresponding to the code modification information in the sample code document. The modification location information is selected according to the actual situation, and the embodiments of this specification do not impose any restrictions on this. The sample record fragment refers to the code modification information corresponding to the sample code fragment in the sample record document.
[0042] In actual applications, when sample record fragments of sample code fragments are respectively determined in a sample record document according to the modification location information, the sample code fragment corresponding to the modification location information can be determined among multiple sample code fragments in the sample code document, and the sample record fragment corresponding to the modification location information is determined as the sample record fragment of the sample code fragment corresponding to the modification location information. For example, the sample record document is "ABC", and the sample code document includes two sample code fragments, which are sample code fragment a and sample code fragment b. The sample record document is parsed to determine that the sample record fragment of sample code fragment a is "AB", and the sample record fragment of sample code fragment b is "C".
[0043] Furthermore, after determining the sample record segment of each sample code segment, since the sample record segment records the code modification information corresponding to the corresponding sample code segment, the sample code segment can be modified using the code modification information in the sample record segment to obtain a sample modification segment. For example, if the sample code segment is "mn" and the sample record segment of the sample code segment is "modify m to n", then the sample modification segment is "nn".
[0044] By applying the solution of the embodiments of this specification, the sample record document is converted into sample record fragments corresponding to each sample code fragment through the modification location information of the sample record document and combined with multiple sample code fragments, thereby realizing the mapping of code modification information and sample code fragments and accurately determining the sample modification fragment of each sample code fragment.
[0045] In an optional embodiment of the present specification, since the sample code snippet may be long and include some content that does not need to be displayed to the user, the sample code snippet may be adjusted according to the modified positioning information to shorten the length of the sample code snippet. That is, the above-mentioned use of the sample problem, multiple sample code snippets, multiple sample modified snippets, and sample description information of multiple sample modified snippets to train the initial processing model, before obtaining the code processing model, the following steps may also be included: According to the modified positioning information, the plurality of sample code segments are adjusted to obtain a plurality of sample adjustment segments, wherein the length of the sample adjustment segment is less than the length of the sample code segment; Using the sample problem, the multiple sample code snippets, the multiple sample modification snippets, and the sample description information of the multiple sample modification snippets, training the initial processing model to obtain the code processing model may include the following steps: The initial processing model is trained using the sample problem, the plurality of sample adjustment segments, the plurality of sample modification segments, and the sample description information of the plurality of sample modification segments to obtain a code processing model.
[0046] In actual applications, there are many ways to adjust multiple sample code snippets according to the modified positioning information to obtain multiple sample adjustment snippets. In one possible implementation, the sample code snippet can be directly represented by the modified positioning information. For example, the modified positioning information is "L31-L45", which means that the sample code snippet is from line 31 to line 45 in the sample code document, and the obtained sample adjustment snippet is "L31-L45". In another possible implementation, on the basis of using the modified positioning information to represent the sample code, the upper and lower N lines of information of the modified code can be additionally retained for positioning, and multiple sample adjustment snippets can be obtained, where N is a positive integer, such as 3.
[0047] Exemplarily, referring to the above example of code modification information, through code snippet splitting and sample record document parsing, the sample location information, sample code snippet and sample modification snippet obtained are as follows, where the [`base.py`](file: / / src / azure_devtools / scenario_tests / base.py) file represents the sample location information, and [`create_temp_file`](file: / / src / azure_devtools / scenario_tests / base.py#L31-L45) represents the sample code snippet; In the [`base.py`](file: / / src / azure_devtools / scenario_tests / base.py) file, modify [`create_temp_file`](file: / / src / azure_devtools / scenario_tests / base.py#L31-L45) to the following sample modification snippet: ```Python def create_temp_file(self, size_kb, full_random=False): """ Create a temporary file for testing. The test harness will delete thefile during tearing down. :param float size_kb: specify the generated file size in kb. """ fd, path = tempfile.mkstemp() os.close(fd) self.addCleanup(lambda: os.remove(path)) By applying the solution of the embodiments of this specification, the sample code snippets are adjusted to shorten the length of the sample code snippets, and the length of the model training data is reduced, so that the constructed model training data is more adaptable and effective during model training.
[0048] Step 206: for the first sample code snippet, generate sample description information of the first sample modified snippet according to the first sample code snippet and the first sample modified snippet, wherein the first sample code snippet is any one of the multiple sample code snippets, and the first sample modified snippet is the sample modified snippet of the first sample code snippet.
[0049] In one or more embodiments of the present specification, in order to enable the trained code processing model to have code interpretation capabilities, sample description information of each sample modification segment may be generated based on multiple sample code segments and multiple sample modification segments.
[0050] It should be noted that the sample description information is a detailed description of the code modification snippet. The sample description information includes but is not limited to the reason for the modification, modification plan, modification impact, and other relevant information. The sample description information is very important for understanding the reasons, purposes, and expected effects of code changes, and can help other developers understand the intentions behind the modification more quickly. Among them, the reason for the modification is used to explain why the modification is necessary. The reasons for the modification include fixing bugs, adding new features, improving performance, improving code readability or maintainability, etc. The modification plan is used to describe the specific plan for the modification, including the code area involved in the modification, the estimated timetable, the expected results, etc. The modification impact is used to explain the impact that the modification may have on the sample code snippet or other functions. Other relevant information may include references to related work orders, issue tracking numbers, discussion links, etc.
[0051] In practical applications, there are multiple ways to generate sample description information of multiple sample modification fragments based on multiple sample code fragments and multiple sample modification fragments. In one possible implementation, a code review tool can be used to generate sample description information of multiple sample modification fragments based on multiple sample code fragments and multiple sample modification fragments. In another possible implementation, an information generation model can be used to generate sample description information of multiple sample modification fragments based on multiple sample code fragments and multiple sample modification fragments.
[0052] In an optional embodiment of the present specification, for the first sample code fragment, generating first sample description information of the first sample modified fragment according to the first sample code fragment and the first sample modified fragment may include the following steps: For the first sample code snippet, the first sample code snippet and the first sample modified snippet are input into the information generation model to obtain sample description information of the first sample modified snippet.
[0053] It should be noted that the information generation model is used to generate sample description information based on input data. The information generation model can be a pre-trained large model or a deep learning model trained based on training sample description information, training sample code snippets, and training sample modification snippets.
[0054] In actual applications, when the first sample code snippet and the first sample modification snippet are input into the information generation model, generation guide information can also be input into the information generation model to tell the information generation model the current generation target. The generation guide information is such as "You are a professional developer, please generate sample description information of the input information". The generation guide information is selected according to the actual situation, and the embodiments of this specification do not impose any restrictions on this. Optionally, in order to improve the accuracy of the sample description information, the sample location information of the first sample code snippet in the sample code document can be additionally added to the model input of the information generation model, so that the information generation model can accurately locate the sample code snippet and understand the sample code snippet, that is, the first sample code snippet, the first sample modification snippet, and the sample location information of the first sample code snippet in the sample code document can be input into the information generation model to obtain the sample description information of the first sample modification snippet.
[0055] By applying the solution of the embodiments of this specification, the information generation model is used to generate sample description information of each sample modification fragment, and the code understanding ability of the information generation model is combined to improve the generation efficiency and accuracy of the sample description information.
[0056] Step 208: train the initial processing model using the sample problem, multiple sample code snippets, multiple sample modification snippets, and sample description information of the multiple sample modification snippets to obtain a code processing model.
[0057] It should be noted that the sample problem refers to the situation in which the sample code snippet does not meet expectations, has defects or needs improvement. The sample problem can be one or more. The sample problems include but are not limited to various types such as legal errors, logical errors, performance bottlenecks, and security vulnerabilities. The initial processing model can be an untrained neural network or a pre-trained large model. The code processing model is used to generate the task processing results of the target code task. The code processing model is trained based on the model training data, and the model training data includes sample problems, multiple sample code snippets, multiple sample modification snippets, and multiple sample description information. In addition to the sample problems, multiple sample code snippets, multiple sample modification snippets, and multiple sample description information, sample reference snippets may also be included, and sample location information of each sample code snippet in the sample code document may also be included. Among them, multiple sample code snippets and multiple sample modification snippets can be understood as positive samples in the model training data, and sample reference snippets can be understood as negative samples in the model training data. The sample problems and multiple sample code snippets are the inputs of the initial processing model when training the initial processing model. At least one of the multiple sample modification snippets, the sample location information of each sample code snippet in the sample code document, and the multiple sample description information is the target output of the initial processing model.
[0058] By applying the solution of the embodiments of the present specification, large-scale, high-quality model training data can be automatically constructed by constructing model training data based on sample code fragments without manual labeling or intervention, thereby alleviating the situation where the model has limitations on the length of input data, making the constructed model training data more adaptable and effective during model training; and, by utilizing the sample code documents and sample record documents in the sample code warehouse to automatically construct model training data, the quality of the model training data is improved, while construction time is saved, thereby achieving efficient training of warehouse-level code processing models.
[0059] In an optional embodiment of the present specification, the above-mentioned use of sample questions, multiple sample code snippets, multiple sample modification snippets, and sample description information of multiple sample modification snippets to train the initial processing model to obtain the code processing model may include the following steps: Inputting a sample problem and a plurality of sample code snippets into an initial processing model to obtain prediction modification snippets and prediction description information corresponding to the plurality of sample code snippets respectively; Calculate modification loss values according to multiple sample modification segments and predicted modification segments; Calculate a description loss value according to sample description information and predicted description information of multiple sample modification fragments; According to the modified loss value and the described loss value, the model parameters of the initial processing model are adjusted to obtain the trained code processing model.
[0060] It should be noted that the training method of the code processing model is supervised training, that is, the model training data includes real processing labels (multiple sample modification fragments and multiple sample description information). Multiple sample modification fragments and multiple sample description information are the generation targets of the initial processing model, which are used to guide the training process of the initial processing model. The predicted modification fragment is the code fragment obtained by the initial processing model based on the sample problem and the sample code fragment to predict the code modification. The predicted description information is the information obtained by the initial processing model to explain and predict the predicted modification fragment.
[0061] In practical applications, when a sample question and multiple sample code snippets are input into the initial processing model, the sample question and multiple sample code snippets can be combined to obtain combined input data, which is a natural language form and a fluent expression. The combined input data is then input into the initial processing model to obtain predicted modification snippets and predicted description information corresponding to the multiple sample code snippets.
[0062] Furthermore, there are many functions for calculating the modified loss value and the described loss value, such as the cross entropy loss function, the L1 norm loss function, the maximum loss function, the mean square error loss function, the logarithmic loss function, etc., and the embodiments of this specification do not impose any restrictions on this. When adjusting the model parameters of the initial processing model according to the modified loss value and the described loss value, the modified loss value and the described loss value can be weighted to obtain the total loss value, and the model parameters of the initial processing model can be adjusted using the total loss value until the training process meets the preset stop condition, and a trained code processing model is obtained. The preset stop condition includes but is not limited to the total loss value being less than or equal to the preset threshold value and the number of iterations reaching the preset number of iterations, wherein the preset threshold value and the preset number of iterations are selected according to the actual situation, and the embodiments of this specification do not impose any restrictions on this.
[0063] In one possible implementation, after calculating the total loss value, the total loss value is compared with a preset threshold. Specifically, if the total loss value is greater than the preset threshold, it means that the difference between the sample modification segment and the predicted modification segment, the sample description information and the predicted description information is large, and the code processing capability of the initial processing model is poor. At this time, the model parameters of the initial processing model can be adjusted, and the initial processing model can continue to be trained until the total loss value is less than or equal to the preset threshold, indicating that the difference between the sample modification segment and the predicted modification segment, the sample description information and the predicted description information is small, and the preset stop condition is met to obtain a completed code processing model. In another possible implementation, in addition to comparing the size relationship between the total loss value and the preset threshold, the number of iterations can also be combined to determine whether the current initial processing model has been trained. Specifically, if the total loss value is greater than the preset threshold, the model parameters of the initial processing model are adjusted, and the initial processing model continues to be trained until the preset number of iterations is reached, and the iteration is stopped to obtain a completed code processing model.
[0064] By applying the solution of the embodiments of this specification and continuously adjusting the model parameters of the initial processing model, the resulting code processing model can be made more accurate.
[0065] In an optional embodiment of the present specification, since the initial processing model may not be able to predict the code files and code snippets that really need to be modified, some code snippets that do not need to be modified can be introduced in the training stage to improve the model's ability to select modified snippets, that is, the above-mentioned sample problems, multiple sample code snippets, multiple sample modified snippets, and sample description information of multiple sample modified snippets are used to train the initial processing model. Before obtaining the code processing model, the following steps may also be included: Get the sample repository documentation for the sample code repository; Find sample reference snippets related to sample problems from the sample repository documentation; Using the sample problem, the multiple sample code snippets, the multiple sample modification snippets, and the sample description information of the multiple sample modification snippets, training the initial processing model to obtain the code processing model may include the following steps: The initial processing model is trained using sample problems, multiple sample code snippets, multiple sample modification snippets, sample description information of multiple sample modification snippets, and sample reference snippets to obtain a code processing model.
[0066] It should be noted that the sample repository document (repo file) refers to all files contained in the sample code repository, and the sample repository document includes but is not limited to code configuration files and code auxiliary information files. The sample reference snippet is a code snippet in the sample repository document that does not require modification by the model. Therefore, the sample reference snippet can be used as a negative sample in the initial processing model training process. The number of sample reference snippets can be one or more, for example, 30. There are many ways to obtain the sample repository document of the sample code repository. In one possible implementation, the sample repository document of the sample code repository can be obtained from an open source code repository platform. In another possible implementation, the sample repository document of the sample code repository sent by the user through the client can be received.
[0067] In practical applications, there are many ways to find sample reference fragments related to sample questions from sample warehouse documents. In one possible implementation, a text matching algorithm can be used to directly find sample reference fragments related to sample questions from sample warehouse documents. In another possible implementation, the sample warehouse document can be parsed, and the sample warehouse document can be segmented according to the parsed results to obtain multiple sample warehouse fragments in the sample warehouse document; the sample reference fragments related to the sample question can be recalled from multiple sample warehouse fragments using a text matching algorithm. Among them, the text matching algorithm is used to find documents or text fragments that are very relevant to a given query in a large amount of text data. The text matching algorithm can help the system understand and quantify the similarity or correlation between the query and the document, so as to return results that are very consistent with user needs. Text matching algorithms include but are not limited to the term frequency-inverse document frequency algorithm (TF-IDF, TermFrequency-Inverse Document Frequency) and the BM25 (Best Matching 25) algorithm.
[0068] Furthermore, the implementation method of “using sample problems, multiple sample code snippets, multiple sample modification snippets, sample description information of multiple sample modification snippets, and sample reference snippets to train the initial processing model to obtain a code processing model” can refer to the implementation method of “using sample problems, multiple sample code snippets, multiple sample modification snippets, and sample description information of multiple sample modification snippets to train the initial processing model to obtain a code processing model”. During the training process, the sample reference snippets are used as negative samples in the training process of the initial processing model. The training model’s ability to modify the sample code snippets instead of the sample reference snippets enables the model to predict the code snippets that actually need to be modified.
[0069] By applying the scheme of the embodiments of this specification, the code modification capability of the initial processing model is trained through sample problems, multiple sample code snippets, and multiple sample modification snippets; the selection capability of the initial processing model for the required processing data is trained through sample problems and sample reference snippets; and the modification and interpretation capability of the initial processing model is trained through sample problems, multiple sample code snippets, and multiple sample description information, thereby improving the overall code processing capability of the code processing model.
[0070] In an optional embodiment of the present specification, the above-mentioned use of sample problems, multiple sample code snippets, multiple sample modification snippets, and sample description information of multiple sample modification snippets to train the initial processing model, before obtaining the code processing model, may also include the following steps: respectively determining sample location information of the plurality of sample code fragments in the sample code document; Using the sample problem, the multiple sample code snippets, the multiple sample modification snippets, and the sample description information of the multiple sample modification snippets, training the initial processing model to obtain the code processing model may include the following steps: The initial processing model is trained using sample problems, multiple sample code snippets, multiple sample modification snippets, sample description information of multiple sample modification snippets, and multiple sample location information to obtain a code processing model.
[0071] It should be noted that the sample location information refers to the specific location of the sample code snippet in the sample code document. The sample location information includes but is not limited to the line number, section or chapter number, class name or function name. The line number is used to indicate the specific line number where the sample code snippet starts and ends. The class name or function name refers to the name of the class or function where the sample code snippet is located in object-oriented programming or modular programming.
[0072] In actual applications, there are multiple ways to determine the sample location information of multiple sample code snippets in a sample code document. In one possible implementation, the sample location information of each sample code snippet in the sample code document can be determined through a version control system. For example, the line number is usually displayed on the code page of a Git repository, so the sample location information can be determined directly from the code page. In another possible implementation, the sample location information of each sample code snippet in the sample code document can be determined through a developer tool plugin, or a static code analysis tool can be used to determine the sample location information of each sample code snippet in the sample code document.
[0073] Furthermore, the initial processing model is trained using sample problems, multiple sample code snippets, multiple sample modification snippets, sample description information of multiple sample modification snippets, and multiple sample location information. When the code processing model is obtained, the sample problems and multiple sample code snippets can be input into the initial processing model to obtain predicted modification snippets, predicted description information, and predicted location information corresponding to the multiple sample code snippets, respectively; modification loss values are calculated based on the multiple sample modification snippets and the predicted modification snippets; description loss values are calculated based on the multiple sample description information and the predicted description information; location loss values are calculated based on the multiple sample location information and the predicted location information; model parameters of the initial processing model are adjusted based on the modification loss values, description loss values, and location loss values to obtain the trained code processing model.
[0074] By applying the solution of the embodiments of this specification, the code location capability of the initial processing model is trained through sample location information and predicted location information, so that the trained code processing model has code modification capability, code location capability and modification interpretation capability, thereby improving the overall code processing capability of the code processing model.
[0075] See also Figure 3 , Figure 3 A flowchart of a code task processing method provided by an embodiment of the present specification is shown, which specifically includes the following steps: Step 302: Obtain the code data and code problems to be processed of the target code task.
[0076] Step 304: input the code data to be processed and the code problem into the code processing model to obtain the task processing result of the target code task, wherein the code processing model is trained using the code processing model training method.
[0077] It should be noted that the target code task can be different types of code tasks, such as code completion tasks, code generation tasks, code repair tasks, etc. The code data to be processed can be a source code file in the code repository, or it can be part of the code in the source code file, that is, a code snippet. The task processing result includes at least one of a repair code file, a code repair location, and a code repair suggestion corresponding to the code data to be processed. The task processing result corresponds to the target code task. For example, if the target code task is a code repair task, the task processing result can be a repair code file.
[0078] In practical applications, there are many ways to obtain the pending code data and code problems of the target code task. In one possible implementation, the pending code data and code problems of the target code task can be read from other data acquisition devices or databases. In another possible implementation, the pending code data and code problems of the target code task sent by the user through a terminal device can be received.
[0079] By applying the solution of the embodiments of this specification, since the code processing model is a warehouse-level model obtained by training based on high-quality model training data, the code processing model has high-quality code processing capabilities. The code processing model is used to generate task processing results for the target code task, thereby improving the quality of the task processing results.
[0080] The following combination Figure 4 , taking the application of the code task processing method provided in this specification in the code repair scenario as an example, the code task processing method is further described. Figure 4 A flowchart of a method for generating code repair suggestions provided by an embodiment of this specification is shown, which specifically includes the following steps: Step 402: Receive source code files and code problems sent by a terminal device.
[0081] Step 404: input the source code file and the code problem into the code processing model to obtain the code repair location, the repair code file and the code repair suggestion, wherein the code processing model is trained using the code processing model training method.
[0082] Step 406: Feedback the code repair location, the repair code file, and the code repair suggestion to the terminal device.
[0083] It should be noted that source code files refer to text files of the codes used to write a project. Source code files include requirement documents, design documents, application programming interface documents, etc. Source code files can include instructions, logic, and metadata required to create a project, such as project descriptions, configuration files for dependency management tools, etc. Source code files are usually stored in version control systems (such as Git repositories) to track change history, support team collaboration, and manage various stages of software development. Code issues include "locating the code fix location of the problem code in the source code file, and fixing the problem code to obtain a code fix file. At the same time, code fix suggestions are given when fixing the problem code."
[0084] The code repair location refers to the code location in the source code file that needs to be modified. The code that needs to be modified can be called the problem code, and the problem code can be a function, class, method, or a line of code at a finer granularity. The code repair location can be a code line identifier, the file where the code is located, and so on. The repair code file refers to the code file obtained after the problem code in the source code file is repaired. The problem code that existed before the source code file was repaired will not appear in the repair code file. The code repair suggestion refers to the suggestion information generated during the repair of the problem code. The code repair suggestion includes information such as code modification utilization, code modification plan, and code modification time consumption.
[0085] By applying the solution of the embodiments of this specification, since the code processing model is a warehouse-level model trained based on high-quality model training data, the code processing model has high-quality code processing capabilities. By inputting source code files and code problems into the code processing model, high-quality code repair locations, repair code files, and code repair suggestions can be obtained.
[0086] See also Figure 5 , Figure 5 A flowchart of a code processing model training method provided by an embodiment of this specification is shown, which specifically includes: Get the sample code document (git diffpatch), sample record document (oracle file), and sample repository document (repo file) from the repository record file (Git PR) of the code repository platform.
[0087] For the sample code document: perform syntax parsing on the sample code document to obtain a syntax parsing result; split the sample code document into code fragments according to the syntax parsing result and the code language type of the sample code document to obtain multiple sample code fragments in the sample code document.
[0088] For the sample record document: the sample record document is parsed according to the modification location information and the multiple sample code snippets, and the sample record snippets of each sample code snippet are respectively determined in the sample record document; according to the sample record snippets, each sample code snippet is modified to obtain the sample modification snippet of each sample code snippet. According to the multiple sample code snippets, the sample modification snippet of each code snippet, and the sample location information of each sample code snippet in the sample code document, information generation data is determined.
[0089] For the sample warehouse document: perform syntax parsing on the sample warehouse document to obtain the warehouse parsing result; split the sample warehouse document into code fragments according to the warehouse parsing result to obtain multiple sample warehouse fragments in the sample warehouse document. Perform data recall on multiple sample warehouse fragments according to the sample question to obtain sample reference fragments related to the sample question.
[0090] The information generation data is input into the information generation model for model analysis to obtain sample description information of each sample modification segment. The sample problem, sample reference segment, each sample code segment, sample modification segment of each sample code segment, sample location information of each sample code segment, and sample description information of each sample modification segment are determined as model training data. The initial processing model is trained using the model training data to obtain a trained code processing model, wherein the sample problem, sample reference segment, and each sample code segment are inputs of the initial processing model, and the sample modification segment of each sample code segment, sample location information of each sample code segment, and sample description information of each sample modification segment are target outputs of the initial processing model.
[0091] The solution of the embodiment of the present specification fully utilizes the sample code documents and sample record documents in the open source code warehouse platform to automatically construct large-scale warehouse-level model training data, greatly reducing manpower investment, and the speed of constructing data is greatly improved compared to manual labeling, thereby supporting the rapid construction of large-scale training data and improving the quality of warehouse-level model training data; in the process of constructing model training data, it is constructed based on reasonable and effective sample code snippets, so that the constructed data is more adaptable and effective during model training.
[0092] See also Figure 6 , Figure 6 A flowchart of an information processing method based on a code processing model provided by an embodiment of the present specification is shown. The information processing method based on the code processing model is applied to a task platform and specifically includes the following steps: Step 602: Receive a model request sent by a terminal device, wherein the model request includes a scene identifier of a target scene, scene input data of the target scene, and at least one of a model specification parameter.
[0093] Step 604: Based on the model request, determine a target code processing model from a plurality of code processing models, wherein the plurality of code processing models are trained using a code processing model training method.
[0094] It should be noted that the target code processing model is a code processing model suitable for the target scenario. Based on the model request, there are multiple ways to determine the target code processing model from multiple code processing models. In one possible implementation, based on the model request, the corresponding target code processing model can be found from at least one code processing model included in the model library; in another possible implementation, based on the model request, the target code processing model can be trained and obtained; in another optional method of the present specification, the target code processing model can be constructed based on the model request.
[0095] For example, based on the scenario identification of the target scenario, at least one pre-trained code processing model can be searched from the model library, and then based on the model specification parameters, an initial code processing model can be obtained by screening at least one code processing model, and then based on the scenario input data of the target scenario, the initial code processing model obtained by screening can be trained to obtain a target code processing model suitable for user needs. Figure 2 The code processing model is obtained by training using the training method shown, and will not be described in detail in the embodiments of this specification.
[0096] The solution of the embodiment of this specification is applied to obtain the target code processing model according to user needs, realize personalized model service, provide users with an efficient, flexible and easy-to-use model service method, and improve user experience.
[0097] In an optional embodiment of the present specification, the model request includes a scene identifier of a target scene; and determining the target code processing model from a plurality of code processing models based on the model request may include the following steps: Based on the scenario identifier of the target scenario, a target code processing model suitable for the target scenario is searched from a model library, wherein the model library stores a plurality of code processing models suitable for different code processing scenarios.
[0098] It should be noted that scenario identification refers to a unique or specific label used to distinguish different code task scenarios. The model library is a database for storing and managing various pre-trained deep learning models. Multiple code processing models adapted to different code task scenarios cover different code application scenarios and requirements. The model library allows users to select appropriate models according to their needs, or directly call the model for code task processing through the application programming interface.
[0099] Multiple code processing models suitable for different code task scenarios are stored in the model library. Each model is optimized for a specific application environment. Figure 2 The model obtained by training the code processing model shown in the training method is as follows. For example, based on the scenario identifier "code repair" of the target scenario, a target code processing model suitable for the code repair scenario can be searched from the model library.
[0100] By applying the solution of the embodiments of this specification, based on scenario requirements, the target code processing model suitable for the scenario is accurately found through scenario identification, so that code task processing is more accurate and more in line with the scenario, thereby improving user experience and code task processing quality.
[0101] In an optional embodiment of the present specification, the model request includes scene input data of the target scene; and the above-mentioned determining the target code processing model from multiple code processing models based on the model request may include the following steps: Determine an initial code processing model suitable for a target scenario from among multiple code processing models; Based on the scenario input data of the target scenario, the initial code processing model is trained to obtain the target code processing model.
[0102] It should be noted that the initial code processing model refers to a model among multiple code processing models that is applicable to the target scenario. The initial code processing model may not only be applicable to the target scenario, but also to other scenarios. It is a general code processing model that can be applied to different scenarios. The initial code processing model can be used to process code tasks, but the effect may not be very good. At this time, the initial code processing model can be optimized based on the scenario input data of the target scenario. For example, the initial code processing model can be optimized based on the scenario input data of the code repair scenario to obtain a target code processing model suitable for the code repair scenario. The scenario input data of the target scenario can be understood as the sample data of the sample code task in the target scenario. The method of training the initial code processing model based on the scenario input data of the target scenario and obtaining the target code processing model can refer to Figure 2 The training method of the code processing model shown in the present specification will not be described in detail in the embodiments.
[0103] By applying the solution of the embodiments of this specification, based on scenario requirements, a general initial code processing model is further trained through scenario input data to obtain a target code processing model adapted to the scenario, so that the target code processing model is more in line with the scenario, thereby improving the user experience and the processing quality of code tasks.
[0104] In an optional embodiment of the present specification, the model request includes model specification parameters; and determining the target code processing model from the plurality of code processing models based on the model request may include the following steps: Based on the model specification parameters, a corresponding target code processing model is searched from a model library, wherein the model library stores a plurality of code processing models with different model specification parameters.
[0105] It should be noted that model specification parameters refer to various parameters that define the structure and behavior of the model. These parameters can be roughly divided into two categories: model parameters (learnable parameters) and hyperparameters. Model parameters refer to parameters that are automatically adjusted by the back-propagation algorithm during model training, including but not limited to weight matrices (weights) and biases (biases). For example, in a simple fully connected layer, the weight matrix is a two-dimensional tensor that connects the neurons in the input layer and the output layer; the bias term is a one-dimensional vector that provides an additional offset value for each output neuron. Hyperparameters refer to parameters set before starting model training to control the learning process and architecture of the model. Hyperparameters include but are not limited to learning rate and the number of neurons per layer (Number of Neurons per Layer), which should be selected according to actual conditions.
[0106] By applying the solution of the embodiments of this specification, the corresponding target code processing model can be accurately found based on the model specification parameters, thereby ensuring the efficient and stable operation of the target code processing model and improving the user experience.
[0107] In an optional embodiment of the present specification, after determining the target code processing model from multiple code processing models based on the model request, the following steps may also be included: Deploy the target code processing model, and build a code task processing interface based on the target code processing model to enable the terminal device to schedule the target code processing model to execute the target code task.
[0108] It should be noted that the code task processing interface is an interactive programming interface for the terminal device to schedule the target code processing model to perform target code task processing, which is usually provided in the form of an application programming interface. Through the code task processing interface, the user can input the task data of the target code task to perform code processing or code development.
[0109] In practical applications, there are many ways to deploy the target code processing model. In one possible implementation, the target code processing model can be deployed on a cloud-side device using the infrastructure provided by a cloud service provider. In another possible implementation, the target code processing model can be deployed on an edge device using a lightweight framework. For example, the target code processing model can be deployed on a distributed system, and based on the target code processing model, a code task processing interface can be constructed and provided to the terminal device, so that the terminal device can schedule the target code processing model to execute the target code task.
[0110] By applying the solution provided in the embodiments of this specification, deploying the target code processing model, and building a code task processing interface based on the target code processing model, the terminal device can efficiently call the target code processing model and improve the processing quality and response speed of the target code task.
[0111] See also Figure 7 , Figure 7 A schematic diagram of the structure of a task platform provided by an embodiment of the present specification is shown, and the task platform includes a request interface 702 and a response unit 704; The request interface 702 is used to receive a model request sent by a terminal device, wherein the model request includes a scene identifier of a target scene, scene input data of the target scene, and at least one of a model specification parameter; The response unit 704 is used to determine a target code processing model from a plurality of code processing models based on the model request, wherein the plurality of code processing models are trained using a code processing model training method.
[0112] In an optional embodiment of the present specification, the task platform further includes a code task processing interface, and the code task processing interface is constructed based on the target code processing model; The code task processing interface is used for terminal devices to schedule and execute target code tasks.
[0113] By applying the solution of the embodiments of this specification, the task platform adapts to user needs to obtain the target code processing model, realizes personalized model services, provides users with an efficient, flexible and easy-to-use model service platform, and improves user experience.
[0114] The above is a schematic scheme of a task platform of this embodiment. It should be noted that the technical scheme of the task platform and the technical scheme of the information processing method based on the code processing model belong to the same concept. For details not described in detail in the technical scheme of the task platform, please refer to the description of the technical scheme of the information processing method based on the code processing model.
[0115] Corresponding to the above-mentioned code processing model training method embodiment, this specification also provides a code processing model training device embodiment, Figure 8 FIG. 1 is a schematic diagram showing the structure of a code processing model training device provided by an embodiment of the present specification. Figure 8 As shown, the device comprises: A first acquisition module 802 is configured to acquire a sample code document and a sample record document, wherein the sample record document is used to record code modification information of the sample code document for a sample problem, and the sample code document includes a plurality of sample code snippets; A first determination module 804 is configured to parse the sample record document and determine sample modification segments of the sample code segments respectively; A generating module 806 is configured to generate, for a first sample code snippet, sample description information of a first sample modified snippet according to the first sample code snippet and a first sample modified snippet, wherein the first sample code snippet is any one of a plurality of sample code snippets, and the first sample modified snippet is a sample modified snippet of the first sample code snippet; The training module 808 is configured to train the initial processing model using the sample problems, multiple sample code snippets, multiple sample modification snippets, and sample description information of the multiple sample modification snippets to obtain a code processing model.
[0116] Optionally, the generating module 806 is further configured to input the first sample code snippet and the first sample modified snippet into an information generating model for the first sample code snippet to obtain sample description information of the first sample modified snippet.
[0117] Optionally, the sample record document includes modification location information; the first determination module 804 is further configured to determine sample record segments of the sample code segments in the sample record document according to the modification location information; modify the sample code segments according to the sample record segments to obtain sample modified segments of the sample code segments.
[0118] Optionally, the device also includes: an adjustment module, configured to adjust multiple sample code snippets according to the modification positioning information to obtain multiple sample adjustment snippets, wherein the length of the sample adjustment snippet is smaller than the length of the sample code snippet; a training module 808, further configured to train the initial processing model using sample problems, multiple sample adjustment snippets, multiple sample modification snippets, and sample description information of the multiple sample modification snippets to obtain a code processing model.
[0119] Optionally, the device further includes: a parsing module configured to perform grammatical parsing on the sample code document to obtain a grammatical parsing result; and to split the sample code document into segments according to the grammatical parsing result to obtain a plurality of sample code segments.
[0120] Optionally, the device also includes: a third acquisition module, configured to obtain the code language type of the sample code document; and a parsing module, further configured to segment the sample code document according to the grammatical parsing result and the code language type to obtain multiple sample code segments in the sample code document.
[0121] Optionally, the training module 808 is further configured to input the sample problem and multiple sample code snippets into the initial processing model to obtain predicted modification snippets and predicted description information corresponding to the multiple sample code snippets; calculate the modification loss value based on the multiple sample modification snippets and the predicted modification snippets; calculate the description loss value based on the sample description information and the predicted description information of the multiple sample modification snippets; adjust the model parameters of the initial processing model based on the modification loss value and the description loss value to obtain a trained code processing model.
[0122] Optionally, the device also includes: a fourth acquisition module, configured to acquire a sample repository document of a sample code repository; searching for sample reference fragments related to sample problems from the sample repository document; a training module 808, further configured to train an initial processing model using sample problems, multiple sample code fragments, multiple sample modification fragments, sample description information of multiple sample modification fragments, and sample reference fragments to obtain a code processing model.
[0123] Optionally, the device also includes: a fifth acquisition module, configured to respectively determine sample location information of multiple sample code snippets in the sample code document; a training module 808, further configured to train the initial processing model using sample questions, multiple sample code snippets, multiple sample modification snippets, sample description information of multiple sample modification snippets, and multiple sample location information to obtain a code processing model.
[0124] By applying the scheme of the embodiments of this specification, the code processing model training device alleviates the situation where the model has limitations on the length of input data by constructing model training data based on sample code fragments, making the constructed model training data more adaptable and effective during model training; and, by automatically constructing model training data using sample code documents and sample record documents in the sample code warehouse, the quality of model training data is improved, while saving construction time, thereby achieving efficient model training at the warehouse level.
[0125] The above is a schematic scheme of a code processing model training device of this embodiment. It should be noted that the technical scheme of the code processing model training device and the technical scheme of the above-mentioned code processing model training method belong to the same concept, and the details not described in detail in the technical scheme of the code processing model training device can be referred to the description of the technical scheme of the above-mentioned code processing model training method.
[0126] Corresponding to the above-mentioned code task processing method embodiment, this specification also provides a code task processing device embodiment, Fig. 9 FIG. 1 shows a schematic diagram of the structure of a code task processing device provided by an embodiment of the present specification. Fig. 9 As shown, the device comprises: The second acquisition module 902 is configured to acquire the to-be-processed code data and code problems of the target code task; The first input module 904 is configured to input the code data to be processed and the code problem into the code processing model to obtain the task processing result of the target code task, wherein the code processing model is trained using the code processing model training method.
[0127] By applying the solution of the embodiment of this specification, since the code processing model is a warehouse-level model obtained by training based on high-quality model training data, the code processing model has high-quality code processing capabilities. The first input module 904 inputs the code data and code problems to be processed into the code processing model, and high-quality task processing results can be obtained.
[0128] The above is a schematic scheme of a code task processing device of this embodiment. It should be noted that the technical scheme of the code task processing device and the technical scheme of the above-mentioned code task processing method belong to the same concept, and the details not described in detail in the technical scheme of the code task processing device can be referred to the description of the technical scheme of the above-mentioned code task processing method.
[0129] Corresponding to the above-mentioned code repair suggestion generating method embodiment, this specification also provides a code repair suggestion generating device embodiment, Fig.10 FIG. 1 is a schematic diagram showing a structure of a device for generating code repair suggestions provided by an embodiment of the present specification. Fig.10 As shown, the device comprises: The first receiving module 1002 is configured to receive source code files and code problems sent by a terminal device; The second input module 1004 is configured to input the source code file and the code problem into the code processing model to obtain the code repair position, the repair code file and the code repair suggestion, wherein the code processing model is trained using the code processing model training method; The feedback module 1006 is configured to feed back the code repair position, the repair code file and the code repair suggestion to the terminal device.
[0130] By applying the solution of the embodiments of this specification, since the code processing model is a warehouse-level model trained based on high-quality model training data, the code processing model has high-quality code processing capabilities. By inputting source code files and code problems into the code processing model, high-quality code repair locations, repair code files, and code repair suggestions can be obtained.
[0131] The above is a schematic scheme of a code repair suggestion generating device of this embodiment. It should be noted that the technical scheme of the code repair suggestion generating device and the technical scheme of the above-mentioned code repair suggestion generating method belong to the same concept, and the details not described in detail in the technical scheme of the code repair suggestion generating device can be referred to the description of the technical scheme of the above-mentioned code repair suggestion generating method.
[0132] Corresponding to the above-mentioned information processing method embodiment based on the code processing model, this specification also provides an information processing device embodiment based on the code processing model. Fig.11 FIG. 1 shows a schematic diagram of a structure of an information processing device based on a code processing model provided by an embodiment of the present specification. Fig.11 As shown, the device is applied to a task platform and includes: The second receiving module 1102 is configured to receive a model request sent by a terminal device, wherein the model request includes a scene identifier of a target scene, scene input data of the target scene, and at least one of a model specification parameter; The second determination module 1104 is configured to determine a target code processing model from a plurality of code processing models based on the model request, wherein the plurality of code processing models are trained using a code processing model training method.
[0133] Optionally, the model request includes a scene identifier of the target scene; the second determination module 1104 is further configured to search for a target code processing model suitable for the target scene from a model library based on the scene identifier of the target scene, wherein the model library stores multiple code processing models suitable for different code processing scenarios.
[0134] Optionally, the model request includes scene input data of the target scene; the second determination module 1104 is further configured to determine an initial code processing model suitable for the target scene from multiple code processing models; based on the scene input data of the target scene, the initial code processing model is trained to obtain the target code processing model.
[0135] Optionally, the model request includes model specification parameters; the second determination module 1104 is further configured to search for a corresponding target code processing model from a model library based on the model specification parameters, wherein the model library stores a plurality of code processing models with different model specification parameters.
[0136] Optionally, the apparatus further includes: a deployment module configured to deploy a target code processing model, and construct a code task processing interface based on the target code processing model, so that the terminal device schedules the target code processing model to execute the target code task.
[0137] By applying the solution of the embodiments of this specification, the information processing device based on the code processing model adapts to user needs to obtain the target code processing model, realizes personalized model services, provides users with an efficient, flexible and easy-to-use model service method, and improves the user experience.
[0138] The above is a schematic scheme of an information processing device based on a code processing model of this embodiment. It should be noted that the technical scheme of the information processing device based on the code processing model and the technical scheme of the information processing method based on the code processing model belong to the same concept, and the details not described in detail in the technical scheme of the information processing device based on the code processing model can be referred to the description of the technical scheme of the information processing method based on the code processing model.
[0139] Fig.12 The block diagram of a computing device provided by an embodiment of the present specification is shown. The components of the computing device 1200 include but are not limited to a memory 1210 and a processor 1220. The processor 1220 is connected to the memory 1210 via a bus 1230, and the database 1250 is used to store data.
[0140] The computing device 1200 also includes an access device 1240 that enables the computing device 1200 to communicate via one or more networks 1260. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1240 may include one or more of any type of network interface (e.g., a network interface card (NIC)) of wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world microwave interconnection access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0141] In one embodiment, the above components of computing device 1200 and Fig.12 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig.12 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0142] The computing device 1200 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 1200 may also be a mobile or stationary server. The processor 1220 is used to execute a computer program / instruction, which, when executed by the processor, implements the steps of the above-mentioned code processing model training method, code task processing method, code repair suggestion generation method, or information processing method based on a code processing model.
[0143] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical schemes of the above-mentioned code processing model training method, code task processing method, code repair suggestion generation method and code processing model-based information processing method belong to the same concept. For details not described in detail in the technical scheme of the computing device, please refer to the description of the technical scheme of the above-mentioned code processing model training method or code task processing method or code repair suggestion generation method or code processing model-based information processing method.
[0144] An embodiment of the present specification also provides a computer-readable storage medium storing a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned code processing model training method or code task processing method or code repair suggestion generation method or information processing method based on a code processing model.
[0145] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned code processing model training method, code task processing method, code repair suggestion generation method and information processing method based on the code processing model belong to the same concept. For details not described in detail in the technical scheme of the storage medium, please refer to the description of the technical scheme of the above-mentioned code processing model training method or code task processing method or code repair suggestion generation method or information processing method based on the code processing model.
[0146] An embodiment of the present specification also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned code processing model training method or code task processing method or code repair suggestion generation method or information processing method based on the code processing model.
[0147] The above is a schematic scheme of a computer program product of this embodiment. It should be noted that the technical scheme of the computer program product and the technical schemes of the above-mentioned code processing model training method, code task processing method, code repair suggestion generation method and code processing model-based information processing method belong to the same concept. For details not described in detail in the technical scheme of the computer program product, please refer to the description of the technical scheme of the above-mentioned code processing model training method or code task processing method or code repair suggestion generation method or code processing model-based information processing method.
[0148] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0149] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0150] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.
[0151] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0152] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.
Claims
1. A code processing model training method, comprising: Acquire a sample code document and a sample record document, wherein the sample record document is used to record code modification information of the sample code document for a sample problem, and the sample code document includes a plurality of sample code snippets; Parsing the sample record document to respectively determine sample modified segments of the sample code segments; For a first sample code snippet, generating sample description information of the first sample modified snippet according to the first sample code snippet and a first sample modified snippet, wherein the first sample code snippet is any one of the multiple sample code snippets, and the first sample modified snippet is a sample modified snippet of the first sample code snippet; The initial processing model is trained using the sample problem, the multiple sample code snippets, the multiple sample modification snippets, and the sample description information of the multiple sample modification snippets to obtain a code processing model.
2. The method according to claim 1, wherein for a first sample code segment, generating first sample description information of the first sample modified segment according to the first sample code segment and the first sample modified segment comprises: For the first sample code fragment, the first sample code fragment and the first sample modified fragment are input into the information generation model to obtain sample description information of the first sample modified fragment.
3. The method according to claim 1, wherein the sample record document includes modification location information; The parsing of the sample record document to respectively determine the sample modified segments of the sample code segments includes: Determining sample record segments of the sample code segment in the sample record document respectively according to the modification location information; The sample code segment is modified according to the sample record segment to obtain a sample modified segment of the sample code segment.
4. The method according to claim 3, wherein before the initial processing model is trained using the sample problem, the plurality of sample code snippets, the plurality of sample modification snippets, and the sample description information of the plurality of sample modification snippets to obtain the code processing model, the method further comprises: According to the modified positioning information, the multiple sample code segments are adjusted to obtain multiple sample adjustment segments, wherein the length of the sample adjustment segment is smaller than the length of the sample code segment; The method of training an initial processing model by using the sample problem, the multiple sample code snippets, the multiple sample modification snippets, and the sample description information of the multiple sample modification snippets to obtain a code processing model includes: The initial processing model is trained using the sample problem, the multiple sample adjustment segments, the multiple sample modification segments, and the sample description information of the multiple sample modification segments to obtain a code processing model.
5. The method according to any one of claims 1 to 4, before parsing the sample record document and respectively determining the sample modified segments of the sample code segments, further comprising: Performing syntax analysis on the sample code document to obtain a syntax analysis result; The sample code document is segmented according to the grammar parsing result to obtain the multiple sample code segments.
6. The method according to claim 5, before the sample code document is segmented according to the grammar parsing result to obtain a plurality of sample code segments in the sample code document, further comprising: Acquire the code language type of the sample code document; The step of splitting the sample code document into segments according to the grammar parsing result to obtain a plurality of sample code segments in the sample code document includes: The sample code document is segmented according to the syntax parsing result and the code language type to obtain a plurality of sample code segments in the sample code document.
7. The method according to claim 1, wherein the initial processing model is trained using the sample problem, the plurality of sample code snippets, the plurality of sample modification snippets, and the sample description information of the plurality of sample modification snippets to obtain the code processing model, comprising: Inputting the sample question and the multiple sample code snippets into the initial processing model to obtain prediction modification snippets and prediction description information respectively corresponding to the multiple sample code snippets; Calculating a modification loss value according to the plurality of sample modification segments and the predicted modification segment; Calculating a description loss value according to the sample description information of the plurality of sample modification fragments and the predicted description information; According to the modified loss value and the described loss value, the model parameters of the initial processing model are adjusted to obtain a trained code processing model.
8. The method according to claim 1, wherein before the initial processing model is trained using the sample problem, the plurality of sample code snippets, the plurality of sample modification snippets, and the sample description information of the plurality of sample modification snippets to obtain the code processing model, the method further comprises: Get the sample repository documentation for the sample code repository; Searching for a sample reference fragment related to the sample problem from the sample repository document; The method of training an initial processing model by using the sample problem, the multiple sample code snippets, the multiple sample modification snippets, and the sample description information of the multiple sample modification snippets to obtain a code processing model includes: The initial processing model is trained using the sample problem, the multiple sample code snippets, the multiple sample modification snippets, the sample description information of the multiple sample modification snippets, and the sample reference snippet to obtain a code processing model.
9. The method according to claim 1, wherein before the initial processing model is trained using the sample problem, the plurality of sample code snippets, the plurality of sample modification snippets, and the sample description information of the plurality of sample modification snippets to obtain the code processing model, the method further comprises: respectively determining sample location information of the plurality of sample code fragments in the sample code document; The method of training an initial processing model by using the sample problem, the multiple sample code snippets, the multiple sample modification snippets, and the sample description information of the multiple sample modification snippets to obtain a code processing model includes: The initial processing model is trained using the sample problem, the multiple sample code snippets, the multiple sample modification snippets, the sample description information of the multiple sample modification snippets, and multiple sample location information to obtain a code processing model.
10. A code task processing method, comprising: Get the pending code data and code issues of the target code task; The code data to be processed and the code problem are input into a code processing model to obtain a task processing result of the target code task, wherein the code processing model is trained using the code processing model training method according to any one of claims 1 to 9.
11. A method for generating a code repair suggestion, comprising: Receive source code files and code problems sent by terminal devices; Inputting the source code file and the code problem into a code processing model to obtain a code repair location, a repair code file, and a code repair suggestion, wherein the code processing model is trained using the code processing model training method according to any one of claims 1 to 9; The code repair position, the repair code file, and the code repair suggestion are fed back to the terminal device.
12. An information processing method based on a code processing model, applied to a task platform, comprising: Receiving a model request sent by a terminal device, wherein the model request includes a scene identifier of a target scene, scene input data of the target scene, and at least one of a model specification parameter; Based on the model request, a target code processing model is determined from a plurality of code processing models, wherein the plurality of code processing models are trained using the code processing model training method according to any one of claims 1 to 9.
13. The method according to claim 12, wherein the model request includes a scene identifier of a target scene; The step of determining a target code processing model from a plurality of code processing models based on the model request includes: Based on the scenario identifier of the target scenario, a target code processing model adapted to the target scenario is searched from a model library, wherein the model library stores a plurality of code processing models adapted to different code processing scenarios.
14. The method according to claim 12, wherein the model request includes scene input data of the target scene; The step of determining a target code processing model from a plurality of code processing models based on the model request includes: Determining an initial code processing model adapted to the target scenario from a plurality of code processing models; Based on the scenario input data of the target scenario, the initial code processing model is trained to obtain a target code processing model.
15. The method of claim 12, wherein the model request comprises model specification parameters; The step of determining a target code processing model from a plurality of code processing models based on the model request includes: Based on the model specification parameters, a corresponding target code processing model is searched from a model library, wherein the model library stores a plurality of code processing models with different model specification parameters.
16. The method according to any one of claims 12 to 15, after determining the target code processing model from a plurality of code processing models based on the model request, further comprising: The target code processing model is deployed, and based on the target code processing model, a code task processing interface is constructed so that the terminal device schedules the target code processing model to execute the target code task.
17. A task platform, comprising a request interface and a response unit; The request interface is used to receive a model request sent by a terminal device, wherein: The model request includes a scene identifier of a target scene, scene input data of the target scene, and at least one of a model specification parameter; The response unit is used to determine a target code processing model from a plurality of code processing models based on the model request, wherein the plurality of code processing models are trained using the code processing model training method according to any one of claims 1 to 9.
18. The task platform according to claim 17, further comprising a code task processing interface, wherein the code task processing interface is constructed based on the target code processing model; The code task processing interface is used for the terminal device to schedule and execute the target code task.
19. A computing device comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the method described in any one of claims 1 to 16 are implemented.
20. A computer-readable storage medium storing a computer program / instruction, wherein the computer program / instruction, when executed by a processor, implements the steps of the method according to any one of claims 1 to 16.
21. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 16.
Citation Information
Patent Citations
Method for automatically generating outline and label for code modification
CN104991858A
Training sample construction method and device, electronic equipment and medium
CN116521866A
Code change label generation method, device and equipment
CN117725920A
Title generation model training method and device
CN117827173A
Code processing method and code repair testing method
CN118760612A
Cited By
Any code snippet labeling method and retrieval system thereof
CN119576388A
Code data completion labeling method and device, equipment, medium and program product
CN119718286A
Code generation method and device based on large model, equipment and storage medium
CN119720199A
Model training data generation method and device, equipment, medium and program product
CN120447886A
Methods, apparatus, equipment, media, and program products for generating model training data
CN120447886B
