Model training method, code processing method, and code processing platform

By performing syntax parsing and negative sampling optimization on the source code, and constructing cross-file call dependency metadata, we solved the problem of call hallucinations in large code model training and achieved more efficient software development.

WO2025200715A1PCT designated stage Publication Date: 2025-10-02ALIBABA (CHINA) CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/071616
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-03-29
Filing Date
2025-01-09
Publication Date
2025-10-02

AI Technical Summary

Technical Problem

During the model training process, existing technologies ignore the information of classes, functions, and member variables defined across files, resulting in call hallucination problems in the trained large code models. This makes it impossible to effectively handle complex code data in actual development scenarios, leading to low software development efficiency.

Method used

By parsing the source code syntax, we can find the cross-file dependencies, construct call dependency metadata, and use it as training samples. We then use negative sampling technology to optimize the call dependency metadata, eliminate call illusions during model training, and improve the model's ability to understand cross-file call relationships.

Benefits of technology

The performance of the code processing model has been improved, enabling it to better handle complex code data in actual development scenarios, improving software development efficiency and avoiding service delays caused by inefficient development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025071616_02102025_PF_FP_ABST
    Figure CN2025071616_02102025_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the embodiments of the present disclosure are a model training method, a code processing method, and a code processing platform. The model training method comprises: determining a first sample code file and a second sample code file that correspond to a code processing model to be trained, wherein there is a calling relationship between the first sample code file and the second sample code file; on the basis of the first sample code file, determining first sample code data and sample code labels; on the basis of the second sample code file, determining second sample code data, and on the basis of the first sample code data and the second sample code data, determining sample code data; and on the basis of the sample code data and the sample code labels, performing model training on the code processing model to be trained, in order to obtain a trained code processing model. Thus, the trained code processing model can process code data having a relatively complex calling relationship in actual development scenarios, and therefore the performance of the code processing model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Model training methods, code processing methods, and code processing platforms

[0001] This disclosure claims priority to the Chinese patent application filed with the China Patent Office on March 29, 2024, with application number 202410384068.8 and application name “Model training method, code processing method and code processing platform”, the entire contents of which are incorporated by reference into this disclosure. Technical Field

[0002] The embodiments of the present disclosure relate to the field of computer technology, and in particular to a model training method, a code processing method, and a code processing platform. Background Art

[0003] With the continuous advancement of computer technology, many institutions, businesses, and other organizations are developing software based on actual needs to provide services for themselves or their users. During this software development process, developers can use neural network models to assist in writing software code. By inputting the written code data into the neural network model, the corresponding processing results are obtained.

[0004] Before using a neural network model to process code data, the model must be trained using code sample data. However, existing techniques often use independent code samples for model training. This results in poor performance of the trained neural network model, making it ineffective in processing the complex code data found in actual development scenarios. This leads to low software development efficiency and the inability to provide services using the developed software in a timely manner. Therefore, there is an urgent need for a high-performance model capable of processing complex code data. Summary of the Invention

[0005] In view of this, embodiments of the present disclosure provide a model training method. One or more embodiments of the present disclosure also involve a code processing method, a model training apparatus, a code processing apparatus, a code processing platform, a computing device, a computer-readable storage medium, and a computer program product to address the technical shortcomings of existing neural network models, such as their poor performance and inability to effectively process complex code data in actual development scenarios.

[0006] According to a first aspect of an embodiment of the present disclosure, a model training method is provided, comprising:

[0007] Determining a first sample code file and a second sample code file corresponding to the code processing model to be trained, wherein a calling relationship exists between the first sample code file and the second sample code file;

[0008] Determining first sample code data and a sample code label based on the first sample code file;

[0009] determining second sample code data based on the second sample code file, and determining sample code data based on the first sample code data and the second sample code data;

[0010] Based on the sample code data and the sample code label, model training is performed on the code processing model to be trained to obtain a trained code processing model.

[0011] According to a second aspect of an embodiment of the present disclosure, a model training device is provided, comprising:

[0012] a code file determination module, configured to determine a first sample code file and a second sample code file corresponding to the code processing model to be trained, wherein the first sample code file and the second sample code file have a calling relationship;

[0013] A first sample determination module is configured to determine first sample code data and a sample code label based on the first sample code file;

[0014] a second sample determination module configured to determine second sample code data based on the second sample code file, and to determine sample code data based on the first sample code data and the second sample code data;

[0015] The model training module is configured to perform model training on the code processing model to be trained based on the sample code data and the sample code label to obtain a trained code processing model.

[0016] According to a third aspect of an embodiment of the present disclosure, a code processing method is provided, including:

[0017] Receiving code data to be processed sent by the user through the code processing interface in the client;

[0018] Inputting the code data to be processed into a code processing model, and performing a data adjustment operation on the code data to be processed using the code processing model to obtain target code data corresponding to the code data to be processed, wherein the code processing model is trained according to the above-mentioned model training method, and the data adjustment operation includes a code completion operation, a code generation operation, or a code repair operation;

[0019] The target code data is sent to the client, so that the client displays the target code data to the user through the code processing interface.

[0020] According to a fourth aspect of an embodiment of the present disclosure, there is provided a code processing apparatus, including:

[0021] A code data receiving module is configured to receive code data to be processed sent by a user through a code processing interface in the client;

[0022] a code data processing module configured to input the code data to be processed into a code processing model, and perform a data adjustment operation on the code data to be processed using the code processing model to obtain target code data corresponding to the code data to be processed, wherein the code processing model is trained according to the above-mentioned model training method, and the data adjustment operation includes a code completion operation, a code generation operation, or a code repair operation;

[0023] The code data sending module is configured to send the target code data to the client, so that the client displays the target code data to the user through the code processing interface.

[0024] According to a fifth aspect of an embodiment of the present disclosure, there is provided a code processing platform, comprising a request receiving unit, a code processing unit, and a response unit;

[0025] The request receiving unit is configured to receive a code processing request and determine, based on the code processing request, code data to be processed and a code processing model identifier corresponding to the code data to be processed;

[0026] The code processing unit is configured to determine a code processing model based on the code processing model identifier, input the code data to be processed into the code processing model, and perform a data adjustment operation on the code data to be processed using the code processing model to obtain target code data corresponding to the code data to be processed, wherein the code processing model is trained according to the above-mentioned model training method, and the data adjustment operation includes a code completion operation, a code generation operation, or a code repair operation;

[0027] The response unit is used to output the target code data.

[0028] According to a sixth aspect of an embodiment of the present disclosure, there is provided a computing device, including:

[0029] memory and processor;

[0030] 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 above-mentioned model training method and code processing method are implemented.

[0031] According to the seventh aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, which stores a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the above-mentioned model training method and code processing method are implemented.

[0032] According to an eighth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the above-mentioned model training method and code processing method when executed by a processor.

[0033] The model training method in one or more embodiments of the present disclosure can determine a first sample code file and a second sample code file that has a calling relationship with the first sample code file, and perform model training by determining first sample code data and a sample code label based on the first sample code file and second sample code data based on the second sample code file. In this way, during the model training process, the code processing model is trained using sample code files that have a calling relationship with each other, so that the trained code processing model can process code data with relatively complex calling relationships in actual development scenarios, thereby improving the performance of the code processing model in actual scenarios. Moreover, when the code processing model with better performance is applied to the actual development scenario, the efficiency of software development can be improved, and efficient completion of software development can be achieved, thereby avoiding the problem of not being able to provide services using the developed software in a timely manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] FIG1 is a schematic diagram of an application of a data processing method provided by an embodiment of the present disclosure;

[0035] FIG2 is a flow chart of a model training method provided by one embodiment of the present disclosure;

[0036] FIG3 is a schematic diagram of a sample code file of a model training method provided by one embodiment of the present disclosure;

[0037] FIG4 is a schematic diagram of a prompt of a model training method provided by an embodiment of the present disclosure;

[0038] FIG5 is a flowchart of a processing process of a model training method provided by one embodiment of the present disclosure;

[0039] FIG6 is a flowchart of a code processing method provided by one embodiment of the present disclosure;

[0040] FIG7 is a schematic diagram of the structure of a code processing platform provided by one embodiment of the present disclosure;

[0041] FIG8 is a schematic structural diagram of a model training device provided by one embodiment of the present disclosure;

[0042] FIG9 is a schematic structural diagram of a code processing device provided by an embodiment of the present disclosure;

[0043] FIG10 is a structural block diagram of a computing device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0044] The following description sets forth many specific details to facilitate a full understanding of the present disclosure. However, the present disclosure can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of the present disclosure. Therefore, the present disclosure is not limited to the specific implementations disclosed below.

[0045] The terms used in one or more embodiments of the present disclosure are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of the present disclosure. The singular forms "a", "the", and "the" used in one or more embodiments of the present disclosure and the appended claims are also intended to include plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of the present disclosure refers to and includes any or all possible combinations of one or more associated listed items.

[0046] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present disclosure, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of one or more embodiments of the present disclosure, 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".

[0047] 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 the present disclosure 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 relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0048] In one or more embodiments of the present disclosure, a large model refers to a deep learning model with large-scale model parameters, which typically contains hundreds of millions, tens of billions, hundreds of billions, trillions, or even more than ten trillion model parameters. A large model can also be called a cornerstone model / foundation model (Foundation Model), which is pre-trained by using 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 capabilities, such as a large-scale language model (LLM), a multi-modal pre-training model, etc.

[0049] When large models are 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. Large models can be widely used in natural language processing (NLP), computer vision and other fields. Specifically, they can be applied to computer vision tasks such as visual question answering (VQA), image caption (IC), and 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 large models include digital assistants, intelligent robots, search, online education, office software, e-commerce, and intelligent design.

[0050] First, the terms involved in one or more embodiments of the present disclosure are explained.

[0051] Intelligent Coding Assistant: Utilizes big model technology to enhance programming tasks in the software development process and improve developers' coding efficiency. Its main capabilities include automatic code completion, code Q&A, automatic generation of unit tests, and automatic code optimization.

[0052] Code auto-completion: While developers are writing code, it predicts and suggests possible code completion items in real time, improving their coding speed and accuracy.

[0053] AST (Abstract Syntax Tree) is an intermediate representation of source code, used to abstract and parse the source code structure in a tree-like structure. An abstract syntax tree, also known as a syntax tree, is an abstract representation of the grammatical structure of the source code. It represents the grammatical structure of a programming language in a tree-like format, with each node in the tree representing a structure in the source code. Each layer of structure is also called a node. An AST can consist of a single node or hundreds or thousands of nodes. Together, they describe the program syntax for static analysis.

[0054] Cross-file call dependency: If a class or function defined in file B is called in file A, there is a cross-file call dependency from B to A. Resolving call dependencies requires AST syntax parsing.

[0055] Code Big Models: These are deep learning-based AI models specifically designed to understand and generate computer program code. By learning to extract patterns from large amounts of source code data, these models can automatically generate code snippets based on natural language descriptions or other programming-related contextual information, perform code completion, correct code errors, write documentation, and build algorithmic logic.

[0056] The illusion of large code models: In real-world applications, users may mistakenly believe that large code models fully understand the execution logic and intent behind the code, just like human programmers, and can always accurately generate code that meets all requirements. However, while large code models have made significant progress and can generate high-quality code in many scenarios, they still have some limitations. For example, while models can generate code based on a given context, they may not have the same deep understanding and grasp of complex execution logic or specific domain knowledge as experienced developers.

[0057] Prompt: An input text paragraph or phrase serves as a starting point or guide for generating model output. This text can be a question, a description, a conversation, or any other form of text input. The model generates the corresponding output text based on the context and semantic information provided by the prompt. The main idea of ​​prompts is to use templates to convert different training data into a common format for model training, thereby improving training efficiency.

[0058] With the continuous development of computer technology, many organizations such as institutions or enterprises will develop software according to actual needs to provide services for themselves or users. In the process of software development, developers need to manually write software code. In the daily development process of developers, it is a very common phenomenon to call classes, functions, and member variables defined in file B in file A. In some of the training processes for large code models provided by the present disclosure, the automatic completion of code training is often based on a single file, while ignoring the information import of classes, functions and member variables defined across files, which makes the trained large code models often have obvious call hallucination problems. For example, the present disclosure provides two solutions. One solution is to take a single code source file during the training process, and randomly find the end position of the code above and the start position of the code below. Then use all the codes between the two positions as the prediction results to construct<prefix,suffix,middle> However, this solution has a major flaw. It only trains code autocompletion based on a single file, but ignores the import of information about classes, functions, and member variables defined across files. This causes the trained code model to often exhibit obvious call hallucination issues.

[0059] Another solution is to concatenate files with closer calling relationships under the same project during training, so that the classes / functions / variables defined in file B called by file A appear before the sequence of file A.

[0060] However, this solution also has significant drawbacks. Because each file often defines a large number of classes, functions, and variables, hallucinations can still be a serious problem even with limited training sequence length. Furthermore, during the prediction process, not all classes, functions, and variables imported from the current file can be entered via prompts (also due to sequence length limitations). This creates a significant gap between training and prediction, leading to significant hallucinations during the final prediction.

[0061] Based on this, the present disclosure provides a code processing method, which also involves a model training method, a code completion method, a data processing device, a model training device, a code completion device, a computing device, a computer-readable storage medium, and a computer program product, which are described in detail one by one in the following embodiments.

[0062] Referring to Figure 1, Figure 1 shows an application diagram of a code processing method provided according to an embodiment of the present disclosure. Based on Figure 1, it can be seen that in the code processing method provided in one or more embodiments of the present disclosure, the user can upload the written code data to be completed to the server 104 through the code processing interface in the terminal 102, and the server 104 inputs the code data to be completed into the trained code automatic completion model to obtain the code completion data output by the code automatic completion model, wherein the code completion data corresponds to the code data to be completed and can complete the code data to be completed. Then, the server 104 sends the code completion data to the terminal 102. The terminal 102 can display the code completion data to the user through the code processing interface, allowing the user to use the code completion data generated by the code automatic completion model for software development. It should be noted that before the server 104 uses the code automatic completion model to process the code data to be completed, it is necessary to perform model training on the code automatic completion model. The model can be trained by performing AST parsing on the original code data to find the call dependencies of cross-file classes or functions, obtaining the call dependency metadata, and putting the cross-file call definition statements and call dependency metadata contained in the code file into the prompt as training samples to train the code auto-completion model, thereby eliminating the illusion problem of cross-file calls in the code auto-completion model. The code auto-completion model can be used to better improve the efficiency of software development.

[0063] Referring to FIG2 , FIG2 shows a flow chart of a model training method provided according to an embodiment of the present disclosure, which specifically includes the following steps.

[0064] Step 202: Determine a first sample code file and a second sample code file corresponding to the code processing model to be trained, wherein a calling relationship exists between the first sample code file and the second sample code file.

[0065] Among them, the code processing model to be trained can be understood as a code processing model that needs to be trained. The code processing model can be understood as a model that can process the code data to be processed and determine the target code data. The code processing method in one or more embodiments of the present disclosure is applied to different scenarios, and the target code data is also different. For example, when the code processing method is applied to the code completion scenario, the code processing model can be a code completion model, the code data to be processed can be the code data to be completed, and the target code data can be the code completion data. By inputting the code data to be completed into the code completion model, the code completion data is obtained.

[0066] When the code processing method is applied to a code prediction scenario, the code processing model can be a code prediction model, the code data to be processed can be the code data to be predicted, and the target code data can be the code prediction data. By inputting the code data to be predicted into the code prediction model, code prediction data is obtained. The code data to be predicted can be understood as one or more code statements written by the user, such as two code statements. The code prediction data can be understood as the next one or more code statements corresponding to the code data to be predicted. Subsequently, by displaying the code prediction data to the user, the code prediction data is recommended to the user, thereby realizing code snippet recommendation for the user, improving the user's development efficiency, and avoiding the problem of low development efficiency caused by the user manually writing code statements during the development process.

[0067] In the case where the code processing method is applied to a code detection scenario, the code processing model can be a code detection model, the code data to be processed can be the code data to be detected, and the target code data can be the code detection result. By inputting the code data to be detected into the code detection model, a code detection result is obtained. Among them, the code data to be detected can be understood as one or more code statements written by the user, such as two code statements. The code detection result can be understood as a code statement with errors in the code data to be detected. Alternatively, the code detection result can be understood as a repair code statement for repairing the code statement with errors in the code data to be detected. Based on this, code data detection or code data repair is implemented for the user, the user's development efficiency is improved, and the problem of code statement errors caused by manual writing of code statements by the user during the development process is avoided.

[0068] It should be noted that in one or more embodiments provided in the present disclosure, the code processing model provided in the present disclosure may be a large model or a code large model.

[0069] The first sample code file can be understood as a source code file serving as training data, and the second sample code file can also be understood as a source code file serving as training data. The first sample code file contains a calling code statement that calls the second sample code file. In other words, there is a calling relationship between the first sample code file and the second sample code file.

[0070] In one or more embodiments provided by the present disclosure, before training the code processing model to be trained, it is necessary to collect training data (i.e., a first sample code file and a second sample code file). Specifically, two methods can be used. One method is to select a first sample code file and a second sample code file as samples from the code files written by the user. In the process of collecting a large amount of source code data as training data, the collected data (the first sample code file and the second sample code file) involves a variety of programming languages ​​and fields, so that the code processing model can learn from the rich source code data, so that the data seen in the training process is close to the user's real development scenario, and at the same time improve the knowledge density and generalization ability of the code processing model, so that valuable completion suggestions can be provided in any development scenario of any developer.

[0071] Another way is to obtain the first sample code file and the second sample code file from a preset training dataset. For example, one option is based on the The-Stack dataset, which collects and processes a large number of source data files, including source code data of projects in various languages, totaling about 3T of data.

[0072] In one or more embodiments provided by the present disclosure, determining the first sample code file and the second sample code file corresponding to the code processing model to be trained includes:

[0073] Determine multiple sample code files corresponding to the code processing model to be trained, and perform syntax analysis on each sample code file to obtain call code data in each sample code file;

[0074] Based on the calling code data, the first sample code file and the second sample code file having a calling relationship with the first sample code file are determined from the sample code files.

[0075] The sample code file can be understood as a source code file as a sample, which is used to train the code processing model to be trained. The first sample code file and the second sample code file are determined from the plurality of sample code files.

[0076] Here, parsing each sample code file can be understood as parsing the source code data in each sample code file to obtain the calling code data in each sample code file. The calling code data can be understood as meta-information that can be called across files, such as the classes defined in each sample code file, functions contained in or outside the classes, and member variables contained in the classes.

[0077] The calling relationship can be understood as a cross-file calling dependency relationship, which can be understood as a calling relationship or a dependency relationship, and refers to a relationship between files that represents calling and being called. In one or more embodiments provided in the present disclosure, the first sample code file can be a calling sample code file that initiates a call in the calling dependency relationship, and the second sample code file can be a called sample code file that is called by the first sample code file (i.e., the calling sample code file) in the calling dependency relationship.

[0078] Taking the application of the model training method provided by this disclosure in resolving the cross-file call illusion scenario as an example, the model training method provided by this disclosure is explained. During the model training operation, the model training method provided by this disclosure requires grammatical parsing of the source code data and parsing out the cross-file dependencies. Specifically, by performing AST grammatical parsing on the source code, meta-information such as the classes defined in each file, functions contained within or outside of the class, and member variables contained in the class that will be called across files is obtained.

[0079] After completing the syntax parsing, it is necessary to parse out the cross-file dependencies. Referring to Figure 3, Figure 3 is a schematic diagram of a sample code file of a model training method provided by an embodiment of the present disclosure. Among them, the current file in Figure 3 can be understood as the first sample code file, and the file (file_reader) that the current file calls and the file (sorter) that the current file calls and depends on can be understood as the second sample code file. In other words, the first sample code file can be one or more, and each first sample code file can have one or more corresponding second sample code files. Based on Figure 3, it can be seen that in order to parse out the cross-file dependencies, it is necessary to parse the call statements of the classes and functions in the "sorter" file or the "file_reader" file in the source code of the current file, where "data=file_reader.read_json(data_path)" is the class call statement for the "file_reader" file in the current file, and "Sorter=sorter()" is the class call statement for the "sorter" file. The call dependency relationship between files is established based on the calling relationship between the classes and functions between files.

[0080] In addition, in the process of parsing cross-file dependencies, a dependency analysis tool can be used. For example, the dependency analysis tool can be based on a tree-sitter tool that can analyze dependencies.

[0081] Step 204: Determine first sample code data and a sample code tag based on the first sample code file.

[0082] Among them, the first sample code data can be understood as one or more code statements obtained from the first sample code file as training samples. In one or more embodiments provided by the present disclosure, the first sample code data and the sample code label can be extracted from the first sample code data. Through this step, the model training is achieved by using the sample code data and the sample code label with a high correlation, thereby improving the performance of the code processing model in code processing. And the code processing model with higher performance is used to efficiently process the code data to be processed, thereby improving the efficiency of software development and avoiding problems caused by low software development efficiency. In addition, through the step of "the first sample code data and the sample code label can be extracted from the first sample code data", the problem of poor performance of the trained model due to the technical solution of separating samples and labels is avoided. The technical solution of separating samples and labels can be understood as a technical solution of taking the source code file as a sample and adding a corresponding label to the sample. Since the sample and label in this solution are independent of each other and have low correlation, it will lead to poor performance of the trained model.

[0083] The sample code tag can be understood as one or more code calling statements obtained from the first sample code file and serving as sample tags, wherein the code calling statement can be understood as a calling statement in the first sample code file that can call the second sample code file.

[0084] In one or more embodiments provided by the present disclosure, determining the first sample code data and the sample code label based on the first sample code file includes:

[0085] determining, from the first sample code file, a calling code statement for calling the second sample code file, and determining the calling code statement as the sample code tag;

[0086] Other code statements except the sample code tags are determined from the first sample code file, and the other code statements are determined as the first sample code data.

[0087] The calling code statement can be understood as a code statement in the first sample code file involving cross-file calling of the second sample code file, for example, "data=file_reader.read_json(data_path)", where file_reader can be the source code file being called (i.e., the second sample code file).

[0088] Continuing with the above example, the code processing model can be a repair code auto-completion model. To construct training data, as shown in Figure 3, this model training method first samples a statement in the current file (the first sample code file) involving a cross-file call: "data = file_reader.read_json(data_path)." This is a call statement. After identifying the call statement, it can be used as a sample code label.

[0089] Specifically, when parsing call statements in the current file, they are divided into two categories: class call statements and function call statements. Class call statements primarily define classes. Function call statements primarily call functions in other files to obtain desired output results. Their purpose is to retrieve content from other files. For example, some call statements aim to obtain the sorting results of bubble sort and quick sort. These call statements involve cross-file calls to classes and functions and can serve as targets (sample code labels) during model training.

[0090] Then, the code content above the call statement in the current file is used as the code context, and the code content below the call statement is used as the code context. The code context and the code context are used as training samples (first sample code data). After obtaining the first sample code data and sample code labels for model training, the model's prediction goal is to predict the complete call statement.

[0091] Therefore, by obtaining the first sample code data and sample code labels, model training is achieved using sample code data and sample code labels with high correlation, thereby improving the code processing performance of the code processing model. Furthermore, the high-performance code processing model is used to efficiently process the code data to be processed, thereby improving software development efficiency and avoiding problems caused by low software development efficiency.

[0092] Step 206: Determine second sample code data based on the second sample code file, and determine sample code data based on the first sample code data and the second sample code data.

[0093] The second sample code data can be understood as calling code data serving as training samples. The calling code data can be understood as data / variables in a source code file that are called by other source code files. For example, the calling code data can be data that is called across files, such as classes defined in a source code file, functions contained within a class, functions contained outside a class, or member variables contained within a class.

[0094] The sample code data can be understood as code data used as training samples for training the code processing model. The sample code data includes first sample code data and second sample code data.

[0095] In one or more embodiments provided by the present disclosure, determining the second sample code data based on the second sample code file includes:

[0096] determining initial calling code data from the second sample code file;

[0097] The initial calling code data is subjected to data screening processing to obtain target calling code data, and the target calling code data is used as the second sample code data.

[0098] Specifically, the model training method provided in one or more embodiments of the present disclosure includes a two-stage processing step for the second sample code data during the process of constructing model training data. First, initial call code data is obtained from the second sample code file. Then, data filtering is performed on the initial call code data to obtain target call code data after the data filtering. The target call code data is used as the second sample code data, and the model training is performed using the call code data after the data filtering, thereby further improving the performance of code processing. Based on this, the second sample code data is obtained from the second sample code file.

[0099] In one or more embodiments provided by the present disclosure, determining the initial calling code data from the second sample code file includes:

[0100] determining code data in the second sample code file, and performing syntax analysis on the code data to obtain a plurality of calling code data in the code data;

[0101] The calling code data are concatenated to obtain the initial calling code data.

[0102] The code data may be understood as the source code in the second sample code file. The syntax analysis may be understood as performing syntax parsing on the source code data, and the syntax parsing may be implemented based on AST.

[0103] Continuing with the above example, the current file can import "from file_reader import FileReader" and "from sorter import Sorter," meaning there are dependencies from file_reader.py to main.py and from sorter.py to main.py. File_reader.py and sorter.py can be considered the second sample code file. Therefore, you need to parse the class / function / member variable information defined in file_reader.py and sorter.py separately.

[0104] Based on this, we use AST to parse the two files file_reader.py and sorter.py to obtain metadata from the parsed call dependencies, such as the call data in Figure 3. The parsed metadata includes the FileReader class in file_reader.py, which contains multiple functions and parses out the definition statements of these multiple functions. The metadata also includes the Sorter class in sorter.py, which contains multiple functions and parses out the definition statements of these multiple functions.

[0105] In addition, the calling data in FIG. 3 can be understood as the second sample code data parsed from the second sample code file.

[0106] Finally, all the parsed data are spliced ​​together to obtain the metadata of all the contents that the current file depends on. In other words, the call dependency metadata (i.e., the target call code data) contains all the information about the classes / functions / member variables in other files that the current file depends on, and this information is the basis for resolving the call illusion.

[0107] In one or more embodiments provided by the present disclosure, when constructing a call to dependency metadata <import>When using the target code data, there are some issues to be aware of: 1. The current file may contain a large number of import statements, but not all of the imported information may actually be called in the source code. 2. The dependent file (the second sample code file) may define a large number of classes and functions, but most of these classes and functions may not actually be called.

[0108] Because of these two problems, the constructed call dependency metadata may eventually be very long, which will not only greatly interfere with model prediction, but also cause the context length to expand sharply, slowing down the inference speed. In order to solve this problem, the model training method provided by one or more embodiments of the present disclosure proposes the use of negative sampling to ensure that the definition information corresponding to the actual call statement appears in the dependency metadata, and does not cause the context length of the dependency metadata to be too long. The specific process is as follows.

[0109] Performing data screening on the initial call code data to obtain target call code data includes:

[0110] Determining first calling code data, second calling code data, and third calling code data from the initial calling code data, wherein the first calling code data is data called by the first sample code file, the second calling code data is data imported into the second sample code file, and the third calling code data is globally defined data;

[0111] determining a first data quantity of the first calling code data;

[0112] Based on the first data quantity and a preset quantity ratio, selecting fourth call code data corresponding to the first call code data from the second call code data and the third call code data;

[0113] The first calling code data and the fourth calling code data are determined as the target calling code data.

[0114] The first call code data can be understood as the classes / functions / member variables that are definitely called in all call statements in the source code file. The second call code data can be understood as the classes / functions / member variables that are not called but imported in all import statements in the source code file. The third call code data can be understood as the classes / functions / member variables that are not called or imported but defined in all import statements in the source code file.

[0115] The first data quantity can be understood as the number of data corresponding to the first call code data. In the case where the first call code data is call-dependent metadata, the first data quantity can be the number of metadata in the call-dependent metadata. The preset quantity ratio can be set according to the actual application scenario, and this disclosure does not impose specific restrictions on this.

[0116] Continuing with the above example, the method of negative sampling of call dependency metadata is as follows: parse all defined classes / functions / member variables under the project corresponding to the current file (i.e., the second sample call file); parse all import statements in the current file to obtain classes / functions / member variables that may be imported; parse all call statements in the current file to obtain classes / functions / member variables that must be called, as positive data, and store them in the call dependency metadata; sample some classes / functions / member variables that are not called but imported, as negative data, and store them in the call dependency metadata; sample some classes / functions / member variables that are not imported but defined, as negative data, and store them in the call dependency metadata; it should be noted that in the process of optimizing the call dependency metadata by negative sampling, the ratio of positive data to negative data is controlled to be about 1:5 (i.e., the preset quantity ratio);

[0117] The call dependency metadata finally obtained through the above steps not only includes the classes / functions / member variables that are definitely called, but also some classes / functions / member variables that are imported but not called or defined. In the case of the coexistence of positive and negative data, this can help the code processing model learn to refer to the call dependency metadata information, thereby assisting in writing subsequent call statements and eliminating the call illusion problem as much as possible.

[0118] Step 208: Based on the sample code data and the sample code label, perform model training on the code processing model to be trained to obtain a trained code processing model.

[0119] In one or more embodiments provided in the present disclosure, performing model training on the code processing model to be trained based on the sample code data and the sample code label to obtain a trained code processing model includes:

[0120] Inputting the sample code data into the code processing model to be trained to obtain target code data corresponding to the sample code data;

[0121] determining a loss value based on target code data corresponding to the sample code data and the sample code label;

[0122] Model training is performed on the code processing model to be trained based on the loss value until a model training stop condition is reached, thereby obtaining the trained code processing model.

[0123] Following the above example, the code auto-completion model is trained using training samples, and the training method is as follows: first, the training sample (sample code data) is input into the code auto-completion model to obtain the predicted call statement output by the model (the target code data corresponding to the sample code data); secondly, the loss value is calculated using the predicted call statement and the sample label (sample code label); specifically, the model training method in one or more embodiments of the present disclosure can use a loss function to calculate the loss value according to the actual application scenario. The loss function can be a mean square error loss function, which can calculate the average square distance between the model prediction value (i.e., the predicted call statement) and the true target value (i.e., the sample label), and use the average square distance as the loss value. It should be noted that in one or more embodiments provided in the present disclosure, the loss value can be calculated according to the steps of forward propagation, loss calculation, averaging, backpropagation and optimization.

[0124] Finally, the code auto-completion model parameters are adjusted based on the loss value until the model training stop condition is reached, obtaining a trained code auto-completion model. The model training stop condition can be set according to the actual scenario, for example, when the model training reaches a preset number of rounds or the loss value reaches convergence.

[0125] Based on this, when a trained code processing model is obtained, the trained code processing model can be used to process the code data to be processed in the software development process, thereby improving the efficiency of software development and avoiding the problem of a large amount of time and manpower costs being wasted in the software development process.

[0126] In one or more embodiments provided in the present disclosure, the performing model training on the code processing model to be trained based on the sample code data and the sample code label to obtain the trained code processing model includes:

[0127] Processing the sample code data and the sample code labels using a training data template to obtain model training data;

[0128] Model training is performed on the code processing model to be trained based on the model training data to obtain the trained code processing model.

[0129] The training data template can be understood as a template that converts different training data into a common format for model training. The training data template can be a prompt.

[0130] Continuing with the above example, after obtaining the sample code data and the sample code label, it is necessary to construct training data based on the sample code data and the sample code label. Specifically, for a large number of code blocks containing cross-file call statements, the code block's upper code (i.e., the preceding code) and the following code (i.e., the following code) are used as context. The goal is for the model to correctly write the call statement. At the same time, the content containing the definition part of the call statement needs to be added to the prompt, thereby eliminating the call illusion problem during the model training process. In other words, the call dependency metadata parsed in the above embodiment is also put into the prompt as additional information. For example, the prompt (training data) that is finally organized as follows can be: <filename>Current file name <import>Call dependency metadata<fim_prefix> Code before<fim_suffix> After the code<fim_middle> For the target call statement, please refer to Figure 4 for details. Figure 4 is a schematic diagram of the prompt of a model training method provided by an embodiment of the present disclosure.

[0131] In one or more embodiments provided in the present disclosure, the model training method further includes:

[0132] Determine the code data to be processed;

[0133] The code data to be processed is input into the trained code processing model, and the trained code processing model is used to perform a data adjustment operation on the code data to be processed to obtain target code data corresponding to the code data to be processed, wherein the data adjustment operation includes a code completion operation, a code generation operation, or a code repair operation.

[0134] The code data to be processed can be understood as code data that needs to be processed by the code processing model. The code data to be processed can be one or more code statements, such as "data_p**th="data.j**on". Alternatively, the code data to be processed can be one or more code files. In one or more embodiments provided in the present disclosure, the code data to be processed can be code data to be completed. The code data to be completed can be understood as one or more uncompleted code statements to be completed, or uncompleted code files to be completed; for example, "data_p**th=", the code statement to be completed contains some uncompleted content.

[0135] The code completion operation can be understood as an operation of completing the unfinished code data to be completed.

[0136] The code generation operation can be understood as an operation of generating corresponding subsequent code data for a portion of the code that has already been written; the code generation operation can generate corresponding subsequent code based on a portion of the code in an unfinished code file, thereby obtaining a complete code file that has been written.

[0137] A code repair operation can be understood as an operation that repairs code data that needs to be repaired during the software development process. For example, if a piece of code data is completed but has a defective code statement, it can be repaired through a code repair operation to obtain a completed piece of code data with no defective code statements.

[0138] In one or more embodiments provided by the present disclosure, determining the code data to be processed includes:

[0139] Obtain the code data to be processed written by the user through the client;

[0140] The user may encode the code data to be processed through the code writing system, and during the writing process, the code data to be processed written by the user may be obtained.

[0141] The code writing system can be understood as an intelligent coding assistant. Based on advanced artificial intelligence technology, the intelligent coding assistant can deeply understand the developer's programming intent and contextual information, and can implement functions such as automatic code completion, code snippet recommendations, and error detection and repair, significantly improving the developer's coding efficiency. One or more code processing models provided in this disclosure can be deployed in the code writing system to assist developers in their development work and improve development efficiency.

[0142] Specifically, obtaining the code data to be processed written by the user can be understood as detecting the code data to be processed written by the user, thereby obtaining the code data to be processed. Alternatively, after the user writes the code data to be processed, the code data to be processed can be provided to the server through the task processing interface in the client, so that the server can obtain the code data to be processed. This facilitates the subsequent use of the code processing model to process the code data to be processed, thereby improving software development efficiency. The server can be understood as the server applied by the code processing method in one or more embodiments of the present disclosure.

[0143] In one or more embodiments provided by the present disclosure, after a trained code processing model is obtained through sample code data and sample code labels, the code data to be processed is input into the code processing model to obtain target code data corresponding to the code data to be processed.

[0144] In one or more embodiments provided by the present disclosure, after inputting the code data to be processed into a code processing model and obtaining target code data corresponding to the code data to be processed, the process further includes:

[0145] The object code data is sent to the client, so that the client provides the object code data to the user.

[0146] Specifically, after the code data to be processed written by the user is input into the code processing model and the target code data corresponding to the code data to be processed is obtained, the target code data can be sent to the client, so that the client provides the target code data to the user, thereby facilitating the user to carry out efficient software development work based on the target code data and improving software development efficiency.

[0147] The model training method in one or more embodiments of the present disclosure can determine a first sample code file and a second sample code file that has a calling relationship with the first sample code file, and perform model training by determining first sample code data and a sample code label based on the first sample code file and second sample code data based on the second sample code file. In this way, during the model training process, the code processing model is trained using sample code files that have a calling relationship with each other, so that the trained code processing model can process code data with relatively complex calling relationships in actual development scenarios, thereby improving the performance of the code processing model in actual scenarios. Moreover, when the code processing model with better performance is applied to the actual development scenario, the efficiency of software development can be improved, and efficient completion of software development can be achieved, thereby avoiding the problem of not being able to provide services using the developed software in a timely manner.

[0148] The following, in conjunction with Figure 5, further illustrates the model training method provided by the present disclosure, using the application of the model training method provided by the present disclosure in a scenario where a cross-file call hallucination occurs in a code auto-completion model. Figure 5 shows a flowchart of the processing process of a model training method provided by one embodiment of the present disclosure, which specifically includes the following steps.

[0149] Step 502: Collect source code data.

[0150] Specifically, this step collects a large amount of source code data for model training. This source code data is collected in two ways:

[0151] One way is to collect source code data written by developers in various fields and various program products in their daily work, so that the training data in the training process is close to the user's actual development scenario.

[0152] Another way is to determine source code data from the The-Stack dataset. This dataset mainly crawls and processes massive repositories in Github, containing source code data of projects in various languages, totaling about 3TB of data.

[0153] Step 504: Resolve cross-file dependencies.

[0154] First, perform AST syntax parsing on the received source code data to obtain the encoded data that will be called across files, such as the classes defined in the current file (referring to a written source code data file), the functions contained in or outside the class, and the member variables contained in the class;

[0155] Secondly, all the parsed data of the file is stitched together to finally obtain the metadata of all the content that the file depends on.

[0156] It should be noted that, by performing the above operations on each file, the metadata of each file (ie, call data, or call-dependent metadata) is determined.

[0157] Finally, resolve cross-file dependencies.

[0158] Specifically, resolving dependencies can be achieved in two ways.

[0159] One way is:

[0160] First, based on the metadata parsed in step 504, determine the classes and functions in file B that are called by file A;

[0161] Secondly, based on the classes and functions called between file A and file B, determine to establish a calling dependency relationship between file B and file A.

[0162] Another way is to determine the calling dependency between file A and file B based on the tree-sitter tool.

[0163] Among them, tree-sitter is a parser generation tool and incremental parsing library that can parse code source files into specific syntax trees, thereby parsing most languages.

[0164] Step 506: Sample call statements to construct training data.

[0165] The specific execution method of this step is:

[0166] 1. Determine to sample a statement in the current file that involves a cross-file call and use it as the target call statement;

[0167] 2. In the current file, the content above the target call statement is used as the code context, and the content below the target call statement is used as the code context;

[0168] 3. Use the negative sampling method to optimize the metadata and obtain the optimized metadata.

[0169] Due to some issues, the constructed call may depend on a large amount of metadata content, which greatly interferes with model prediction and causes the context length to expand sharply, slowing down the inference speed.

[0170] Based on this, the negative sampling method is used to optimize metadata. The specific implementation methods include:

[0171] ① Parse all defined classes / functions / member variables under the project corresponding to the current file.

[0172] ② Parse all import statements in the current file to obtain possible imported classes / functions / member variables.

[0173] ③ Parse all call statements in the current file, obtain certain called classes / functions / member variables, and store them as forward data in the call dependency metadata.

[0174] ④ Sample some classes / functions / member variables that have not been called but imported, store them as negative data in the call dependency metadata.

[0175] ⑤ Sample some classes / functions / member variables that are not imported but defined, store them as negative data in the call dependency metadata.

[0176] It should be noted that during the optimization process, the ratio of positive data to negative data is controlled at approximately 1:5.

[0177] 4. Use the target call statement as the sample label, and the code context, code context, and optimized metadata as training samples to complete the construction of training data.

[0178] 5. Put the training samples and labels into Prompt to construct a training data.

[0179] Step 508: Train the model.

[0180] The specific execution method of this step is:

[0181] First, input the training sample into the code auto-completion model to obtain the predicted call statement output by the model;

[0182] Secondly, the loss value is calculated using the predicted call statement and the sample label (target call statement);

[0183] Finally, the model parameters of the code automatic completion model are adjusted based on the loss value until the model training stop condition is reached, and the trained code automatic completion model is obtained.

[0184] In addition, it should be noted that after the code auto-completion model is trained, it can be applied to code completion scenarios. The specific application steps include:

[0185] First, obtain the code data to be completed written by the programmer;

[0186] Secondly, the code data to be completed is input into the trained code automatic completion model to obtain the predicted code (code completion data) output by the code automatic completion model, wherein the predicted code corresponds to the code data to be completed and can complete the code data to be completed.

[0187] Finally, the prediction code is displayed to the user, allowing the user to use the code to automatically complete the prediction code generated by the model.

[0188] Based on the above steps, it can be seen that the model training method provided by one or more embodiments of the present disclosure proposes a method for repairing the cross-file call illusion of the code automatic completion model, by performing AST parsing on the original code data to find the call dependencies of cross-file classes or functions, obtaining the call dependency metadata, and putting the cross-file call definition statements and call dependency metadata contained in the current file into the prompt for training, thereby eliminating the cross-file call illusion problem of the model.

[0189] In addition, the model training method provided by one or more embodiments of the present disclosure proposes to obtain call dependency metadata for cross-file calls based on AST syntax parsing. This metadata (i.e., call dependency metadata) integrates information on classes, functions, and member variables across files, thereby alleviating the call illusion problem.

[0190] The model training method provided by one or more embodiments of the present disclosure proposes summarizing cross-file call information into call dependency metadata containing definition statements, and training through negative sampling technology, which greatly shortens the context length and eliminates the gap between training and prediction, thereby solving the problem of alleviating call hallucinations.

[0191] In addition, the model training method provided by one or more embodiments of the present disclosure proposes a solution for obtaining call-dependent metadata, and integrates the information of the call-dependent metadata through negative sampling technology, adding some classes and functions that have not been called, thereby helping to improve the model learning to correctly call the classes and functions defined in the metadata.

[0192] Referring to FIG. 6 , FIG. 6 shows a flowchart of a code processing method provided according to an embodiment of the present disclosure, which specifically includes the following steps.

[0193] Step 602: Receive code data to be processed sent by the user through the code processing interface in the client.

[0194] Step 604: Input the code data to be processed into a code processing model, and use the code processing model to perform a data adjustment operation on the code data to be processed to obtain target code data corresponding to the code data to be processed, wherein the code processing model is trained according to the above-mentioned model training method, and the data adjustment operation includes a code completion operation, a code generation operation, or a code repair operation.

[0195] Step 606: Send the target code data to the client, so that the client displays the target code data to the user through the code processing interface.

[0196] Among them, the code processing interface can be understood as an interface displayed on the client for allowing the user to perform code processing. The code processing interface can be an application interface, an Internet page, etc. The code processing interface includes various types of code processing controls (such as buttons, text boxes), and the user can process the code data to be processed through the code processing controls. For example, the code data to be processed is entered in the text box, and by clicking the code data processing button, the code data to be processed is provided to the server to which the code processing method is applied, so that the code to be processed is processed by the code processing method.

[0197] In one or more embodiments provided by the present disclosure, the code data to be processed is code data to be completed;

[0198] The step of inputting the code data to be processed into a code processing model, and performing a data adjustment operation on the code data to be processed using the code processing model to obtain target code data corresponding to the code data to be processed includes:

[0199] Inputting the code data to be completed into the code processing model, performing the code completion operation on the code data to be completed using the code processing model, and obtaining code completion data corresponding to the code data to be completed;

[0200] The sending of the target code data to the client, so that the client displays the target code data to the user through the code processing interface, includes:

[0201] The code completion data is sent to the client, so that the client displays the code completion data to the user through the code processing interface.

[0202] The code data to be completed can be understood as one or more unfinished code statements or unfinished code files. For example, the code statement "data_p**th=" is an unfinished code statement. After the code processing model performs code completion on it, the corresponding code completion data can be obtained. For example, the code statement "data_p**th="data.j**on" can be the code completion data corresponding to the code data to be completed.

[0203] In one or more embodiments provided by the present disclosure, the code data to be processed is code data to be repaired;

[0204] The step of inputting the code data to be processed into a code processing model, and performing a data adjustment operation on the code data to be processed using the code processing model to obtain target code data corresponding to the code data to be processed includes:

[0205] Inputting the code data to be repaired into the code processing model, performing the code repair operation on the code data to be repaired using the code processing model, and obtaining code repair data corresponding to the code data to be repaired;

[0206] The sending of the target code data to the client, so that the client displays the target code data to the user through the code processing interface, includes:

[0207] The code repair data is sent to the client, so that the client displays the code repair data to the user through the code processing interface.

[0208] Among them, the code data to be repaired can be understood as one or more code statements to be repaired that have defects in the code writing process, or a code file to be repaired that has defects in the code writing process. The code repair data can be understood as one or more repaired code statements or repaired code files obtained after the code repair operation is performed on the code data to be repaired through the code processing model. During the code writing process, there may be defects such as spelling errors and code logic errors in some statements. For these defects, the code data to be repaired with the defects can be input into the code processing model to obtain code repair data. For example, the code statement "data_='data.j**on'" has a spelling error problem, and the "data_p**th" in the code statement is missing "p**th". By inputting the code statement into the code processing model and performing a code repair operation, a complete and correct code statement "data_p**th='data.j**on'" is obtained.

[0209] It should be noted that the client can be understood as a terminal.

[0210] The code processing method provided in one or more embodiments of the present disclosure can, after receiving the code data to be processed sent by the user through the code processing interface in the client, use the code processing model to perform data adjustment operations such as code completion operations, code generation operations or code repair operations on the code data to be processed, and obtain target code data, thereby providing assistance to the user's code writing work during the software development process, thereby improving the efficiency of software development and saving time and manpower costs in the software development process. In addition, since the code processing model is used to process the code data to be processed, the problem of a large amount of computing resources of computer equipment being wasted due to low software development efficiency during the process of developers using computer equipment for software development is avoided.

[0211] It should be noted that the technical solution of the code processing method and the technical solution of the above-mentioned model training method belong to the same concept. For details not described in detail in the technical solution of the code processing method, please refer to the description of the technical solution of the above-mentioned model training method.

[0212] 7 , which shows a schematic structural diagram of a code processing platform provided according to an embodiment of the present disclosure. The code processing platform 700 includes a request receiving unit 702 , a code processing unit 704 , and a response unit 706 .

[0213] The request receiving unit 702 is configured to receive a code processing request and determine, based on the code processing request, code data to be processed and a code processing model identifier corresponding to the code data to be processed;

[0214] The code processing unit 704 is configured to determine a code processing model based on the code processing model identifier, input the code data to be processed into the code processing model, and perform a data adjustment operation on the code data to be processed using the code processing model to obtain target code data corresponding to the code data to be processed, wherein the code processing model is trained according to the above-mentioned model training method, and the data adjustment operation includes a code completion operation, a code generation operation, or a code repair operation;

[0215] The response unit 706 is configured to output the target code data.

[0216] Among them, the code processing platform can be understood as a platform for processing code data to be processed, and the code processing platform provides relevant services for code writing during the software development process. Developers can write code in the code processing platform. In one or more embodiments provided in the present disclosure, the code processing platform can be understood as an intelligent coding assistant. The intelligent coding assistant can be based on advanced artificial intelligence technology and can achieve functions such as automatic code completion, code snippet recommendation, error detection and repair by deeply understanding the developer's programming intentions and context information, thereby significantly improving the developer's coding efficiency.

[0217] The request receiving unit 702 can be understood as a module in the code processing platform for receiving code processing requests. In the code processing platform provided in one or more embodiments of the present disclosure, when a user sends a code processing request to the code processing platform through the code processing interface of the client, the request receiving unit 702 in the code processing platform receives the code processing request; and, the code data to be processed and the code processing model identifier can also be determined from the code processing request.

[0218] The code processing model identifier may be information that uniquely identifies the code processing model. For example, the code processing model identifier may be information such as the code processing model name and number, or the code processing model identifier may be a code processing model address corresponding to the code processing model.

[0219] The code processing unit 704 may be understood as a unit in the code processing platform for performing code adjustment operations such as code completion, code generation, or code repair on the code data to be processed; the code adjustment operation is implemented using a code processing model.

[0220] The response unit 706 can be understood as a module in the code processing platform for outputting target code data. After the code processing unit 704 obtains the target code data corresponding to the code data to be processed using the code processing model, the response unit 706 outputs the target code data.

[0221] It should be noted that, in the code processing platform provided in one or more embodiments of the present disclosure, the request receiving unit 702 , the code processing unit 704 , and the response unit 706 may be hardware modules or software modules.

[0222] In one or more embodiments provided by the present disclosure, the request receiving unit 702 is configured to determine, from the code processing request, the code data to be processed and the code processing model identifier corresponding to the code data to be processed;

[0223] Specifically, during the code processing process, the code processing platform may receive a code processing request containing the code data to be processed and a code processing model identifier corresponding to the code data to be processed. In this case, the code data to be processed and the code processing model identifier corresponding to the code data to be processed can be determined from the code processing request. The code data to be processed and the code processing model identifier can then be sent to the code processing unit 704. The code processing unit 704 then performs code adjustment operations on the code data to be processed based on the code processing model corresponding to the code processing model identifier to obtain the target code data.

[0224] In one or more embodiments provided by the present disclosure, the code processing platform also includes a code question and answer function, and the user can input the code generation text to the code processing platform through the code processing interface on the client. The code processing platform generates corresponding code data based on the code generation text, thereby meeting the actual application needs of the user. Specifically, the request receiving unit 702 is used to determine the code generation text in the code processing request and the processing prompt information corresponding to the code generation text, input the code generation text into the code generation model based on the processing prompt information, obtain the code data to be processed, and determine the code processing model identifier corresponding to the code data to be processed.

[0225] The code generation text can be understood as text used to generate a code, and the code generation text can be understood as code description text for the code data to be generated. For example, a user can enter the text data "Generate lottery code", and the code processing platform can generate the corresponding lottery code data based on the "Generate lottery code" text.

[0226] The processing prompt information can be understood as prompt information that instructs the code processing platform on what operation to perform on the code generation text. Since the code processing platform provides a variety of processing functions for code data to meet the needs of software development work. Based on this, the code processing platform needs to process the code generation file based on the processing prompt information to avoid the problem of not being able to meet user needs due to incorrect processing of the code generation file. The processing prompt information can be a description of the processing process of the code generation text. For example, the processing prompt information can be: first, use the code generation model to generate the code data to be processed corresponding to the code generation text, then use the code processing model to identify the corresponding code processing model, perform code adjustment operations on the code data to be processed, and obtain the target code data.

[0227] A code generation model can be understood as a model that generates corresponding code data based on code generation text. For example, if the text data "Generate lottery code" is input into the code generation model, the code generation model will generate the lottery code data corresponding to "Generate lottery code".

[0228] The code processing platform is explained using a code question-and-answer scenario as an example. The code generation text can be "Generate lottery code." Based on this, the user sends a code processing request to the code processing platform through the code processing interface on the client. This code processing request carries the code generation text and corresponding processing prompt information. After receiving the code processing request, the request receiving unit 702 obtains the code generation text "Generate lottery code" and the corresponding processing prompt information in the code processing request. Based on the processing prompt information, "Generate lottery code" is then input into the code generation model to obtain lottery code data.

[0229] After obtaining the lottery code data, in order to ensure the correctness or integrity of the code data, it is necessary to determine the code processing model identifier of the code processing model that performs a code completion operation or a code repair operation on the lottery code data from the processing prompt information. The code processing model identifier and the lottery code data are then sent to the code processing unit 704.

[0230] The code processing unit 704 determines the code processing model corresponding to the code processing model identifier, and uses the code processing model to perform a code completion operation or a code repair operation on the lottery code data, thereby obtaining lottery code data with correctness and integrity.

[0231] After obtaining accurate and complete lottery code data, the response module sends this data to the client, which then displays it to the user through a code processing interface. This allows the corresponding target code data to be generated from the code generation text during the software development process, avoiding the low coding efficiency and high error rate caused by manual coding by users, thereby improving software development efficiency.

[0232] In the code processing platform provided in one or more embodiments of the present disclosure, a request receiving unit can determine the code data to be processed and the code processing model identifier corresponding to the code data to be processed based on the received code processing request. The code processing unit can use the code processing model to perform data adjustment operations such as code completion, code generation, or code repair on the code data to be processed to obtain target code data. Finally, the target code data is output through the response unit; thus, through the mutual cooperation between the various units, it is achieved to provide assistance to the user's code writing work during the software development process, thereby improving the efficiency of software development and saving time and labor costs in the software development process. In addition, since the code processing model is used to process the code data to be processed, the problem of a large amount of computing resources of computer equipment being wasted due to low software development efficiency during the process of developers using computer equipment for software development is avoided.

[0233] It should be noted that the technical solution of the code processing platform and the technical solution of the above-mentioned code processing method or model training method belong to the same concept. For details not described in detail in the technical solution of the code processing platform, please refer to the description of the technical solution of the above-mentioned code processing method or model training method.

[0234] Corresponding to the above method embodiment, the present disclosure also provides an embodiment of a model training device. FIG8 shows a schematic diagram of the structure of a model training device provided by an embodiment of the present disclosure. As shown in FIG8 , the device includes:

[0235] The code file determination module 802 is configured to determine a first sample code file and a second sample code file corresponding to the code processing model to be trained, wherein the first sample code file and the second sample code file have a calling relationship;

[0236] A first sample determination module 804 is configured to determine first sample code data and a sample code label based on the first sample code file;

[0237] A second sample determination module 806 is configured to determine second sample code data based on the second sample code file, and determine sample code data based on the first sample code data and the second sample code data;

[0238] The model training module 808 is configured to perform model training on the code processing model to be trained based on the sample code data and the sample code label to obtain a trained code processing model.

[0239] Optionally, the model training device further includes a code processing module configured to:

[0240] Determine the code data to be processed;

[0241] The code data to be processed is input into the trained code processing model, and the trained code processing model is used to perform a data adjustment operation on the code data to be processed to obtain target code data corresponding to the code data to be processed, wherein the data adjustment operation includes a code completion operation, a code generation operation, or a code repair operation.

[0242] Optionally, the first sample determination module 804 is further configured to:

[0243] determining, from the first sample code file, a calling code statement for calling the second sample code file, and determining the calling code statement as the sample code tag;

[0244] Other code statements except the sample code tags are determined from the first sample code file, and the other code statements are determined as the first sample code data.

[0245] Optionally, the second sample determination module 806 is further configured to:

[0246] determining initial calling code data from the second sample code file;

[0247] The initial calling code data is subjected to data screening processing to obtain target calling code data, and the target calling code data is used as the second sample code data.

[0248] Optionally, the second sample determination module 806 is further configured to:

[0249] determining code data in the second sample code file, and performing syntax analysis on the code data to obtain a plurality of calling code data in the code data;

[0250] The calling code data are concatenated to obtain the initial calling code data.

[0251] Optionally, the second sample determination module 806 is further configured to:

[0252] Determining first calling code data, second calling code data, and third calling code data from the initial calling code data, wherein the first calling code data is data called by the first sample code file, the second calling code data is data imported into the second sample code file, and the third calling code data is globally defined data;

[0253] determining a first data quantity of the first calling code data;

[0254] Based on the first data quantity and a preset quantity ratio, selecting fourth call code data corresponding to the first call code data from the second call code data and the third call code data;

[0255] The first calling code data and the fourth calling code data are determined as the target calling code data.

[0256] Optionally, the code file determination module 802 is further configured to:

[0257] Determine multiple sample code files corresponding to the code processing model to be trained, and perform syntax analysis on each sample code file to obtain call code data in each sample code file;

[0258] Based on the calling code data, the first sample code file and the second sample code file having a calling relationship with the first sample code file are determined from the sample code files.

[0259] Optionally, the model training module 808 is further configured to:

[0260] Processing the sample code data and the sample code labels using a training data template to obtain model training data;

[0261] Model training is performed on the code processing model to be trained based on the model training data to obtain the trained code processing model.

[0262] The model training device provided in one or more embodiments of the present disclosure can determine a first sample code file and a second sample code file that has a calling relationship with the first sample code file, and perform model training by determining first sample code data and a sample code label based on the first sample code file and second sample code data based on the second sample code file. In this way, during the model training process, the code processing model is trained using sample code files that have a calling relationship with each other, so that the trained code processing model can process code data with relatively complex calling relationships in actual development scenarios, thereby improving the performance of the code processing model in actual scenarios. Moreover, when the code processing model with better performance is applied to the actual development scenario, the efficiency of software development can be improved, and efficient completion of software development can be achieved, thereby avoiding the problem of not being able to provide services using the developed software in a timely manner.

[0263] The above is a schematic scheme of a model training device of this embodiment. It should be noted that the technical scheme of the model training device and the technical scheme of the above-mentioned model training method are of the same concept. For details not described in detail in the technical scheme of the model training device, please refer to the description of the technical scheme of the above-mentioned model training method.

[0264] Corresponding to the above method embodiment, the present disclosure also provides a code processing device embodiment. FIG9 shows a schematic diagram of the structure of a code processing device provided by an embodiment of the present disclosure. As shown in FIG9, the device includes:

[0265] The code data receiving module 902 is configured to receive the code data to be processed sent by the user through the code processing interface in the client;

[0266] The code data processing module 904 is configured to input the code data to be processed into a code processing model, and use the code processing model to perform a data adjustment operation on the code data to be processed to obtain target code data corresponding to the code data to be processed, wherein the code processing model is trained according to the above-mentioned model training method, and the data adjustment operation includes a code completion operation, a code generation operation, or a code repair operation;

[0267] The code data sending module 906 is configured to send the target code data to the client, so that the client displays the target code data to the user through the code processing interface.

[0268] Optionally, the code data to be processed is code data to be completed;

[0269] The code data processing module 904 is further configured to:

[0270] Inputting the code data to be completed into the code processing model, performing the code completion operation on the code data to be completed using the code processing model, and obtaining code completion data corresponding to the code data to be completed;

[0271] The code data sending module 906 is further configured to:

[0272] The code completion data is sent to the client, so that the client displays the code completion data to the user through the code processing interface.

[0273] Optionally, the code data to be processed is code data to be repaired;

[0274] The code data processing module 904 is further configured to:

[0275] Inputting the code data to be repaired into the code processing model, performing the code repair operation on the code data to be repaired using the code processing model, and obtaining code repair data corresponding to the code data to be repaired;

[0276] The code data sending module 906 is further configured to:

[0277] The code repair data is sent to the client, so that the client displays the code repair data to the user through the code processing interface.

[0278] The code processing device provided in one or more embodiments of the present disclosure can, after receiving the code data to be processed sent by the user through the code processing interface in the client, use the code processing model to perform data adjustment operations such as code completion operations, code generation operations or code repair operations on the code data to be processed, and obtain target code data, thereby providing assistance to the user's code writing work during the software development process, thereby improving the efficiency of software development and saving time and manpower costs in the software development process. In addition, since the code processing model is used to process the code data to be processed, the problem of a large amount of computing resources of computer equipment being wasted due to low software development efficiency during the process of developers using computer equipment for software development is avoided.

[0279] The above is a schematic diagram of a code processing device according to this embodiment. It should be noted that the technical solution of the code processing device and the technical solution of the aforementioned code processing method are based on the same concept. For details not described in detail in the technical solution of the code processing device, please refer to the description of the technical solution of the aforementioned code processing method.

[0280] Figure 10 shows a block diagram of a computing device 1000 according to one embodiment of the present disclosure. Components of the computing device 1000 include, but are not limited to, a memory 1010 and a processor 1020. The processor 1020 is connected to the memory 1010 via a bus 1030, and a database 1050 is used to store data.

[0281] The computing device 1000 also includes an access device 1040 that enables the computing device 1000 to communicate via one or more networks 1060. Examples of such 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 1040 may include one or more of any type of network interface (e.g., a network interface controller (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, or a near field communication (NFC) interface.

[0282] In one embodiment of the present disclosure, the aforementioned components of the computing device 1000 and other components not shown in FIG10 may also be connected to each other, for example, via a bus. It should be understood that the computing device structure block diagram shown in FIG10 is for illustrative purposes only and does not limit the scope of the present disclosure. Those skilled in the art may add or replace other components as needed.

[0283] Computing device 1000 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, personal digital assistant, laptop computer, notebook computer, netbook computer, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smartwatch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or personal computer (PC). Computing device 1000 may also be a mobile or stationary server.

[0284] Among them, the processor 1020 is used to execute the following computer program / instructions, which, when executed by the processor, implement the steps of the above-mentioned model training method or code processing method.

[0285] Each embodiment of this disclosure is described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences from other embodiments. In particular, the computing device embodiment is generally similar to the model training method or code processing method embodiment, so the description is relatively simple. For relevant parts, refer to the partial description of the model training method or code processing method embodiment.

[0286] An embodiment of the present disclosure also provides a computer-readable storage medium storing a computer program / instruction, which implements the steps of the above-mentioned model training method or code processing method when executed by a processor.

[0287] Each embodiment of the present disclosure is described in a progressive manner. Similar portions between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences from other embodiments. In particular, the computer-readable storage medium embodiment is generally similar to the model training method or code processing method embodiment, so the description is relatively simple. For relevant portions, refer to the partial description of the model training method or code processing method embodiment.

[0288] An embodiment of the present disclosure also provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned model training method or code processing method when executed by a processor.

[0289] The above is a schematic scheme of a computer program product of this embodiment. It should be noted that the technical scheme of this computer program product and the technical scheme of the above-mentioned model training method or code processing method are based on 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 model training method or code processing method.

[0290] The foregoing description describes specific embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0291] The computer instructions include computer program code, which may be in source code form, object code form, executable file, or some intermediate form. 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. 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 does not include electric carrier signals and telecommunication signals.

[0292] It should be noted that for the aforementioned 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 the present disclosure are not limited by the order of the actions described, because according to the embodiments of the present disclosure, certain 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 the present disclosure.

[0293] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0294] The preferred embodiments of the present disclosure disclosed above are only used to help illustrate the present disclosure. The optional embodiments do not describe all details in detail, nor do they limit the invention to only the specific embodiments described. Obviously, many modifications and variations can be made based on the content of the embodiments of the present disclosure. The present disclosure selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of the present disclosure, so that those skilled in the art can better understand and utilize the present disclosure. The present disclosure is limited only by the claims and their full scope and equivalents.< / import> < / filename> < / import>

Claims

1. A model training method, comprising: Determining a first sample code file and a second sample code file corresponding to the code processing model to be trained, wherein a calling relationship exists between the first sample code file and the second sample code file; Determining first sample code data and a sample code label based on the first sample code file; determining second sample code data based on the second sample code file, and determining sample code data based on the first sample code data and the second sample code data; Based on the sample code data and the sample code label, model training is performed on the code processing model to be trained to obtain a trained code processing model.

2. The model training method according to claim 1, further comprising: Determine the code data to be processed; The code data to be processed is input into the trained code processing model, and the trained code processing model is used to perform a data adjustment operation on the code data to be processed to obtain target code data corresponding to the code data to be processed, wherein the data adjustment operation includes a code completion operation, a code generation operation, or a code repair operation.

3. The model training method according to claim 1 or 2, wherein determining the first sample code data and the sample code label based on the first sample code file comprises: determining, from the first sample code file, a calling code statement for calling the second sample code file, and determining the calling code statement as the sample code tag; Other code statements except the sample code tags are determined from the first sample code file, and the other code statements are determined as the first sample code data.

4. The model training method according to any one of claims 1 to 3, wherein determining the second sample code data based on the second sample code file comprises: determining initial calling code data from the second sample code file; The initial calling code data is subjected to data screening processing to obtain target calling code data, and the target calling code data is used as the second sample code data.

5. The model training method according to claim 4, wherein determining the initial call code data from the second sample code file comprises: determining code data in the second sample code file, and performing syntax analysis on the code data to obtain a plurality of calling code data in the code data; The calling code data are concatenated to obtain the initial calling code data.

6. The model training method according to claim 4 or 5, wherein the step of performing data screening on the initial call code data to obtain target call code data comprises: Determining first calling code data, second calling code data, and third calling code data from the initial calling code data, wherein the first calling code data is data called by the first sample code file, the second calling code data is data imported into the second sample code file, and the third calling code data is globally defined data; determining a first data quantity of the first calling code data; Based on the first data quantity and a preset quantity ratio, selecting fourth call code data corresponding to the first call code data from the second call code data and the third call code data; The first calling code data and the fourth calling code data are determined as the target calling code data.

7. The model training method according to any one of claims 1 to 6, wherein determining the first sample code file and the second sample code file corresponding to the code processing model to be trained comprises: Determine multiple sample code files corresponding to the code processing model to be trained, and perform syntax analysis on each sample code file to obtain call code data in each sample code file; Based on the calling code data, the first sample code file and the second sample code file having a calling relationship with the first sample code file are determined from the sample code files.

8. The model training method according to any one of claims 1 to 7, wherein the performing model training on the code processing model to be trained based on the sample code data and the sample code label to obtain the trained code processing model comprises: Processing the sample code data and the sample code labels using a training data template to obtain model training data; Model training is performed on the code processing model to be trained based on the model training data to obtain the trained code processing model.

9. A code processing method, comprising: Receive the code data to be processed sent by the user through the code processing interface in the client; Inputting the code data to be processed into a code processing model, and performing a data adjustment operation on the code data to be processed using the code processing model to obtain target code data corresponding to the code data to be processed, wherein the code processing model is trained according to the model training method according to any one of claims 1 to 8, and the data adjustment operation includes a code completion operation, a code generation operation, or a code repair operation; The target code data is sent to the client, so that the client displays the target code data to the user through the code processing interface.

10. The code processing method according to claim 9, wherein the code data to be processed is code data to be completed; The step of inputting the code data to be processed into a code processing model, and performing a data adjustment operation on the code data to be processed using the code processing model to obtain target code data corresponding to the code data to be processed includes: Inputting the code data to be completed into the code processing model, performing the code completion operation on the code data to be completed using the code processing model, and obtaining code completion data corresponding to the code data to be completed; The sending of the target code data to the client, so that the client displays the target code data to the user through the code processing interface, includes: The code completion data is sent to the client, so that the client displays the code completion data to the user through the code processing interface.

11. The code processing method according to claim 9, wherein the code data to be processed is code data to be repaired; The step of inputting the code data to be processed into a code processing model, and performing a data adjustment operation on the code data to be processed using the code processing model to obtain target code data corresponding to the code data to be processed includes: Inputting the code data to be repaired into the code processing model, performing the code repair operation on the code data to be repaired using the code processing model, and obtaining code repair data corresponding to the code data to be repaired; The sending of the target code data to the client, so that the client displays the target code data to the user through the code processing interface, includes: The code repair data is sent to the client, so that the client displays the code repair data to the user through the code processing interface.

12. A code processing platform comprising a request receiving unit, a code processing unit and a response unit; The request receiving unit is configured to receive a code processing request and determine, based on the code processing request, code data to be processed and a code processing model identifier corresponding to the code data to be processed; the code processing unit being configured to determine a code processing model based on the code processing model identifier, input the code data to be processed into the code processing model, and perform a data adjustment operation on the code data to be processed using the code processing model to obtain target code data corresponding to the code data to be processed, wherein the code processing model is trained according to the model training method according to any one of claims 1 to 8, and the data adjustment operation includes a code completion operation, a code generation operation, or a code repair operation; The response unit is used to output the target code data.

13. The code processing platform according to claim 12, wherein the request receiving unit is configured to determine the code data to be processed and the code processing model identifier corresponding to the code data to be processed from the code processing request; or The request receiving unit is used to determine the code generation text in the code processing request and the processing prompt information corresponding to the code generation text, input the code generation text into the code generation model based on the processing prompt information, obtain the code data to be processed, and determine the code processing model identifier corresponding to the code data to be processed.

14. 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 program / instructions are executed by the processor, the steps of the model training method described in any one of claims 1 to 8 and the code processing method described in any one of claims 9 to 11 are implemented.

15. A computer-readable storage medium storing a computer program / instruction, which, when executed by a processor, implements the steps of the model training method described in any one of claims 1 to 8 and the code processing method described in any one of claims 9 to 11.

16. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the model training method described in any one of claims 1 to 8 and the code processing method described in any one of claims 9 to 11.

Citation Information

Patent Citations

  • Code generation method, system and equipment and computer readable storage medium

    CN115951897A

  • Code processing model training method and device, electronic equipment and storage medium

    CN116820429A

  • Sample construction method, code generation method, electronic equipment and storage medium

    CN117556263A

  • Task processing method, code completion method, code question and answer method and task processing model training method

    CN117648079A

  • Code generation for deployment of a machine learning model

    US20220129789A1