Code processing method, training data processing method and model fine tuning method

By extracting the graph data and node features of the code, we determine the word vectors that adapt to the large language model, which solves the problem of poor performance of the large language model in code processing and improves the effectiveness of tasks such as code translation.

CN118860412APending Publication Date: 2024-10-29ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411075167.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-06
Publication Date
2024-10-29

AI Technical Summary

Technical Problem

Large language models perform poorly when processing application code and cannot accurately complete code processing tasks such as code translation.

Method used

Extract the graph data of the code, extract node features and determine word vectors adapted to the large language model. Map the code to the feature space of the large language model through embedded neural networks and graph processing neural network models, and fine-tune the model to improve code processing capabilities. .

Benefits of technology

It improves the large language model's ability to understand code and the effect of code processing tasks, such as improving the accuracy and application scope of code translation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118860412A_ABST
    Figure CN118860412A_ABST
Patent Text Reader

Abstract

The invention provides a code processing method, a training data processing method and a model fine tuning method.The code processing method comprises the steps that graph data of a to-be-processed code is extracted, and the graph data comprises a plurality of nodes and connection relations between the different nodes; according to a code snippet corresponding to at least one node in the graph data in the to-be-processed code, respectively extracting features of the at least one node in the graph data; according to the feature of at least one node in the graph data and the connection relation between at least two nodes, a word vector corresponding to the graph data is determined, and the word vector is the word vector suitable for the feature space of the large language model. According to the method, the code can be processed into the equivalent word vector adaptive to the feature space of the large language model, so that the code can be accessed to the large language model, and the capability of the large language model for acquiring the meaning of the code is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present specification relate to the field of artificial intelligence technology, and in particular, to a code processing method, a training data processing method, and a model fine-tuning method. Background Art

[0002] In recent years, artificial intelligence technology has developed rapidly, and technological innovation has been launched in many fields, which has brought great convenience to people's work and life. For example, the parameter scale and pre-training data volume of large language models (LLMs) represented by the GPT series have grown rapidly, achieving a performance leap in text processing, and the latest large language models can use their powerful reasoning ability and world knowledge obtained in pre-training to process non-text modal data such as images and speech.

[0003] However, in the related art, large language models have poor capabilities in processing application codes and are unable to accurately complete code processing-related tasks such as code translation. Summary of the invention

[0004] In view of this, one or more embodiments of the present specification provide a code processing method, a training data processing method, and a model fine-tuning method.

[0005] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:

[0006] According to a first aspect of one or more embodiments of this specification, a code processing method is proposed, the method comprising:

[0007] Extracting graph data of the code to be processed, wherein the graph data includes a plurality of nodes and connection relationships between different nodes;

[0008] Extracting features of at least one node in the graph data respectively according to code snippets in the code to be processed corresponding to at least one node in the graph data;

[0009] According to the features of at least one node in the graph data and the connection relationship between at least two nodes, a word vector corresponding to the graph data is determined, wherein the word vector is a word vector adapted to the feature space of a large language model.

[0010] In a possible embodiment of the present specification, the type of the node in the graph data is a node type shared by different types of code languages.

[0011] In a possible embodiment of the present specification, the graph data includes at least one of the following: an abstract syntax tree, a data flow, and a control flow.

[0012] In a possible embodiment of the present specification, extracting features of at least one node in the graph data according to code snippets in the code to be processed corresponding to at least one node in the graph data, respectively, includes:

[0013] The code snippets in the code to be processed corresponding to at least one node in the graph data are respectively input into the embedded neural network model to obtain the characteristics of the at least one node output by the embedded neural network model.

[0014] In a possible embodiment of the present specification, determining the word vector corresponding to the graph data according to the feature of at least one node in the graph data and the connection relationship between at least two nodes includes:

[0015] The features of at least one node in the graph data and the connection relationship between at least two nodes are input into a graph processing neural network model, and the output of the graph processing neural network model is input into an adaptation layer to obtain a word vector corresponding to the graph data output by the adaptation layer.

[0016] According to a second aspect of one or more embodiments of this specification, a method for processing training data applied to fine-tuning a large language model is proposed, the method comprising:

[0017] Based on the code processing method described in any of the above embodiments, the code samples in the original training data are processed to obtain word vectors corresponding to the code samples;

[0018] The word vector corresponding to the code sample is used as a word vector sample, and the code sample corresponding to the word vector sample is marked as a label of the word vector sample to obtain target training data.

[0019] In a possible embodiment of this specification, the method further includes:

[0020] The types of nodes and / or the connection relationships between nodes in the graph data corresponding to the word vector sample are marked as labels of the word vector sample.

[0021] According to a third aspect of one or more embodiments of this specification, a model fine-tuning method is proposed, the method comprising:

[0022] Using the original training data and the target training data obtained by the training data processing method described in any of the above embodiments, the pre-trained large language model is fine-tuned to obtain a large language model for processing the target task, wherein the code samples in the original training data are marked with labels related to the target task.

[0023] In a possible embodiment of the present specification, the method of using the original training data and the target training data obtained by the training data processing method described in any of the above embodiments to fine-tune the pre-trained large language model to obtain a large language model for processing the target task includes:

[0024] Alternately use a batch of code samples in the original training data and a batch of word vector samples in the target training data obtained by the training data processing method described in any of the above embodiments to fine-tune the pre-trained large language model to obtain a large language model for processing the target task.

[0025] In a possible embodiment of the present specification, the target task includes at least one of the following: code translation, code summary, code repair, code vulnerability detection, code clone detection, code completion, code synthesis and code filling.

[0026] According to a fourth aspect of one or more embodiments of this specification, a code processing device is provided, the device comprising:

[0027] A graph data module, used to extract graph data of the code to be processed, wherein the graph data includes a plurality of nodes and connection relationships between different nodes;

[0028] A feature module, used to extract features of at least one node in the graph data according to code snippets in the code to be processed corresponding to at least one node in the graph data;

[0029] A word vector module is used to determine the word vector corresponding to the graph data based on the characteristics of at least one node in the graph data and the connection relationship between at least two nodes, wherein the word vector is a word vector adapted to the feature space of a large language model.

[0030] In a possible embodiment of the present specification, the type of the node in the graph data is a node type shared by different types of code languages.

[0031] In a possible embodiment of the present specification, the graph data includes at least one of the following: an abstract syntax tree, a data flow, and a control flow.

[0032] In a possible embodiment of this specification, the feature module is used to:

[0033] The code snippets in the code to be processed corresponding to at least one node in the graph data are respectively input into the embedded neural network model to obtain the characteristics of the at least one node output by the embedded neural network model.

[0034] In a possible embodiment of the present specification, the word vector module is used to:

[0035] The features of at least one node in the graph data and the connection relationship between at least two nodes are input into a graph processing neural network model, and the output of the graph processing neural network model is input into an adaptation layer to obtain a word vector corresponding to the graph data output by the adaptation layer.

[0036] According to a fifth aspect of one or more embodiments of this specification, a device for processing training data for fine-tuning a large language model is provided, the device comprising:

[0037] A processing module, configured to process the code samples in the original training data based on the code processing method described in any of the above embodiments, so as to obtain word vectors corresponding to the code samples;

[0038] The marking module is used to use the word vector corresponding to the code sample as a word vector sample, and mark the code sample corresponding to the word vector sample as a label of the word vector sample to obtain target training data.

[0039] In a possible embodiment of this specification, the marking module is further used for:

[0040] The types of nodes and / or the connection relationships between nodes in the graph data corresponding to the word vector sample are marked as labels of the word vector sample.

[0041] According to a sixth aspect of one or more embodiments of this specification, a model fine-tuning device is provided, the device comprising:

[0042] A fine-tuning module is used to fine-tune the pre-trained large language model using original training data and target training data obtained by the training data processing method described in any of the above embodiments to obtain a large language model for processing a target task, wherein the code samples in the original training data are marked with labels related to the target task.

[0043] In a possible embodiment of the present specification, the fine-tuning module is used to:

[0044] Alternately use a batch of code samples in the original training data and a batch of word vector samples in the target training data obtained by the training data processing method described in any of the above embodiments to fine-tune the pre-trained large language model to obtain a large language model for processing the target task.

[0045] In a possible embodiment of the present specification, the target task includes at least one of the following: code translation, code summary, code repair, code vulnerability detection, code clone detection, code completion, code synthesis and code filling.

[0046] According to a seventh aspect of one or more embodiments of the present specification, a computer program product is proposed, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method described in the first aspect, the second aspect or the third aspect.

[0047] According to an eighth aspect of one or more embodiments of this specification, an electronic device is provided, including:

[0048] processor;

[0049] a memory for storing processor-executable instructions;

[0050] The processor implements the method as described in the first aspect, the second aspect or the third aspect by running the executable instructions.

[0051] According to a ninth aspect of one or more embodiments of the present specification, a computer-readable storage medium is proposed, on which computer instructions are stored. When the instructions are executed by a processor, the steps of the method described in the first aspect, the second aspect or the third aspect are implemented.

[0052] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:

[0053] The code processing method provided in the embodiment of this specification first extracts the graph data of the code to be processed, and then extracts the features of at least one node in the graph data according to the code fragments corresponding to at least one node in the graph data in the code to be processed, and finally determines the word vector corresponding to the graph data according to the features of at least one node in the graph data and the connection relationship between at least two nodes. Graph data is a feature that is extracted by program analysis tools such as compilers and interpreters and is independent of the programming language type of the code, and can represent the meaning represented by the code in the form of nodes and connection relationships between nodes. The word vector determined based on the features of the nodes in the graph data and the connection relationship between nodes can accurately represent the meaning of the code, and because the word vector is adapted to the feature space of the large language model, the method can process the code into an equivalent word vector adapted to the feature space of the large language model, so that the code can be connected to the large language model and improve the ability of the large language model to obtain the meaning of the code. If this method is applied to tasks related to code processing, the processing effect of the large language model on code processing related tasks such as code translation can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 It is a flowchart of a code processing method provided by an exemplary embodiment.

[0055] Figure 2 It is a model architecture diagram of code processing provided by an exemplary embodiment.

[0056] Figure 3 is a flowchart of a method for processing training data provided by an exemplary embodiment.

[0057] Figure 4 It is a structural schematic diagram of a device provided by an exemplary embodiment.

[0058] Figure 5 is a block diagram of a code processing device provided by an exemplary embodiment.

[0059] Figure 6 is a block diagram of a device for processing training data provided by an exemplary embodiment. DETAILED DESCRIPTION

[0060] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0061] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.

[0062] First, some concepts involved in this specification are explained.

[0063] Graph data: refers to data extracted from the code, such as the abstract syntax tree (AST), data flow (DFG), control flow (CFG), etc., which are represented by graph data structures. They can represent the meaning of the code and are independent of the programming language type of the code.

[0064] Cross-modal alignment: In the context of a large language model, it refers to the technology of mapping data in modalities other than text, such as images, audio, video, time series, etc., into the feature space of a large language model so that it can be processed by the large language model.

[0065] Pre-training: In large language models, it refers to training the model on a large amount of unannotated corpus to acquire general language representation capabilities and world knowledge.

[0066] Fine-tuning: In large language models, it refers to further training a pre-trained model based on data related to a specific task to enhance the model's ability on that task.

[0067] Since the code corpus of programming languages ​​(such as parallel corpora of different programming language types for code translation) is far less than the amount of natural language data, the large language models in related technologies have limited ability to acquire and understand codes of various programming language types. The training effect on code processing-related tasks such as code translation is average, and the task processing effect is poor.

[0068] Based on this, at least one embodiment of the present specification provides a code processing method, which can achieve cross-modal alignment of code and text through the features and connection relationships of nodes in the code graph data, that is, mapping the code to the feature space of the large language model, so that the large language model can accurately understand the code, thereby improving the performance of the large language model in code processing-related tasks such as code translation, for example, improving the accuracy of code translation, expanding the types of programming languages ​​applicable to code translation, etc.

[0069] Please refer to the attached Figure 1 , which exemplarily shows the flow of the code processing method, including steps S101 to S103.

[0070] In step S101, graph data of the code to be processed is extracted, wherein the graph data includes a plurality of nodes and connection relationships between different nodes.

[0071] The code to be processed may be the code targeted when training or processing a large language model, such as a code sample when fine-tuning a large language model, or the source code targeted when the large language model processes a code translation task.

[0072] The types of nodes in the graph data are node types shared by different types of code languages. For example, the graph data includes at least one of the following: an abstract syntax tree, a data flow, and a control flow.

[0073] Exemplarily, graph data may be extracted from the code to be processed based on a unified program analysis framework such as a compiler or an interpreter.

[0074] In step S102, features of at least one node in the graph data are extracted respectively according to code snippets in the code to be processed corresponding to at least one node in the graph data.

[0075] Exemplarily, the code snippets in the code to be processed corresponding to at least one node in the graph data are respectively input into the embedded neural network model to obtain the features of the at least one node output by the embedded neural network model. For example, the embedded neural network model can select the CodeT5+ embedded model, etc.

[0076] Preferably, the code snippets in the code to be processed corresponding to each node in the graph data are respectively input into the embedded neural network model to obtain the features extracted by the embedded neural network model for the code snippets corresponding to each node, that is, the features of each node.

[0077] In step S103, a word vector corresponding to the graph data is determined based on the features of at least one node in the graph data and the connection relationship between at least two nodes, wherein the word vector is a word vector adapted to the feature space of a large language model.

[0078] Exemplarily, the features of at least one node in the graph data and the connection relationship between at least two nodes are input into a graph processing neural network model, and the output of the graph processing neural network model is input into an adaptation layer to obtain a word vector corresponding to the graph data output by the adaptation layer.

[0079] The graph processing neural network model is used to encode the graph data, that is, to serve as an encoder for the graph data. For example, the graph processing neural network model may select a Duplex model or the like.

[0080] The adaptation layer is used to map the output of the encoder to the feature space of the large language model. For example, the adaptation layer can select a cross-attention network, etc. After the output of the encoder is input into the cross-attention network, the output of the encoder can be used as the key and value of the cross-attention network, and the word vector format in the feature space of the large language model is used as the query of the cross-attention network, so that the cross-attention network maps the output of the encoder to the feature space of the large language model and outputs the word vector.

[0081] Preferably, the features of each node in the graph data and the connection relationship between different nodes in the graph data (i.e., the connection relationship involving all nodes in the graph data) are input into a graph processing neural network model, and the output of the graph processing neural network model is input into an adaptation layer to obtain a word vector corresponding to the graph data output by the adaptation layer.

[0082] Please refer to the attached Figure 2, which exemplarily shows the model architecture and processing flow of executing the code processing method obtained by combining the above-mentioned various embodiments. The flow of the method can be further understood by referring to the figure.

[0083] The code processing method provided in the embodiment of this specification first extracts the graph data of the code to be processed, and then extracts the features of at least one node in the graph data according to the code fragments corresponding to at least one node in the graph data in the code to be processed, and finally determines the word vector corresponding to the graph data according to the features of at least one node in the graph data and the connection relationship between at least two nodes. Graph data is a feature that is extracted by program analysis tools such as compilers and interpreters and is independent of the programming language type of the code, and can represent the meaning represented by the code in the form of nodes and connection relationships between nodes. The word vector determined based on the features of the nodes in the graph data and the connection relationship between nodes can accurately represent the meaning of the code, and because the word vector is adapted to the feature space of the large language model, the method can process the code into an equivalent word vector adapted to the feature space of the large language model, so that the code can be connected to the large language model and improve the ability of the large language model to obtain the meaning of the code. If this method is applied to tasks related to code processing, the processing effect of the large language model on code processing related tasks such as code translation can be improved.

[0084] At least one embodiment of the present specification also provides a method for processing training data applied to fine-tuning a large language model. The method can process code samples in training data for code processing-related tasks such as code translation, so that the processed training data can promote the large language model's understanding of the programming language during the large language model fine-tuning stage, and increase the effectiveness of the large language model in performing code processing-related tasks.

[0085] Please refer to the attached Figure 3 , which exemplarily shows a flow chart of the method, including steps S301 to S302.

[0086] In step S301, based on the code processing method provided in any of the above embodiments, the code samples in the original training data are processed to obtain the word vectors corresponding to the code samples.

[0087] Among them, the original training data can be training data for fine-tuning a large language model. The original training data is used to fine-tune tasks related to code processing of the large language model. The original training data includes a large number of code samples. The code samples are code snippets of any programming language type, and the code samples are marked with labels related to specific tasks.

[0088] Exemplarily, the code samples in the original training data are processed in the following manner:

[0089] First, graph data of the code sample is extracted, wherein the graph data includes a plurality of nodes and connection relationships between different nodes.

[0090] The types of nodes in the graph data are node types shared by different types of code languages. For example, the graph data includes at least one of the following: an abstract syntax tree, a data flow, and a control flow. For example, graph data can be extracted from the code to be processed based on a unified program analysis framework such as a compiler or an interpreter.

[0091] Next, according to the code snippets in the code sample corresponding to the at least one node in the graph data, features of the at least one node in the graph data are respectively extracted.

[0092] For example, the code snippet in the code sample corresponding to each node in the graph data is input into an embedded neural network model such as the CodeT5+ embedding model to obtain the features of each node output by the embedded neural network model such as the CodeT5+ embedding model.

[0093] Finally, based on the features of at least one node in the graph data and the connection relationship between at least two nodes, a word vector corresponding to the code sample is determined, wherein the word vector is a word vector adapted to the feature space of a large language model.

[0094] For example, the features of each node in the graph data and the connection relationship between different nodes in the graph data are input into a graph processing neural network model such as a Duplex model, and the output of the graph processing neural network model is input into an adaptation layer such as a cross-attention network to obtain the word vector corresponding to the graph data output by the adaptation layer.

[0095] In step S302, the word vector corresponding to the code sample is used as a word vector sample, and the code sample corresponding to the word vector sample is marked as a label of the word vector sample to obtain target training data.

[0096] For example, the type of nodes in the graph data corresponding to the word vector sample and / or the connection relationship between nodes may be marked as the label of the word vector sample. For example, the parent node and child node of a node may be marked as its label.

[0097] This embodiment follows the Figure 1The code processing method shown processes the original training data used for fine-tuning the large language model, thereby mapping the code samples in the original training data to the feature space of the large language model, obtaining the corresponding word vectors, and then using the word vectors and the original training data to construct new target training data that helps the large language model understand the code content and program language; using the obtained target training data to fine-tune the large language model can promote the large language model's understanding of the program language during the large language model fine-tuning stage, and improve the effect of the large language model in performing code processing-related tasks.

[0098] At least one embodiment of the present specification also provides a model fine-tuning method, which can fine-tune the pre-trained large language model based on at least the target training data obtained in any of the above embodiments, so that the fine-tuned large language model can understand the programming language more accurately, thereby performing better results in code processing related tasks such as code translation.

[0099] The method comprises the following steps: using original training data and target training data obtained by the training data processing method described in any of the above embodiments, fine-tuning the pre-trained large language model to obtain a large language model for processing the target task.

[0100] Among them, the target task is the task targeted by this fine-tuning, that is, the purpose of this fine-tuning is to enable the large language model to have the ability to handle the target task. The target task is a related task to be processed, for example, it can include at least one of the following: code translation, code summary, code repair, code vulnerability detection, code clone detection, code completion, code synthesis and code filling. The code translation refers to compiling a section of program code from one program language type to another program language; the code summary refers to outputting a text for describing the function of a section of program code; the code repair refers to outputting the result of fixing the vulnerability of the code for a section of program code; the code vulnerability detection refers to detecting whether there is a vulnerability in a section of program code; the code clone detection refers to judging whether the functions of two sections of program code are the same; the code completion refers to outputting the remaining part of the unfinished program code at the end; the code synthesis refers to outputting the corresponding program code for the code function described according to the natural language; the code filling refers to outputting the blank part of the code for a section of unfinished program code in the middle.

[0101] The code samples in the original training data are marked with labels related to the target task. If the target task is a code translation task of translating source code into a target program language type, the label of the code sample is a code with the same content as the code sample and the type of the target program language type. If the target task is a code summary, the label of the code sample is a text used to describe the function of the code sample. If the target task is code repair, the label of the code sample is the result after the vulnerability in the code sample is repaired. If the target task is code vulnerability detection, the label of the code sample is the presence or absence of a vulnerability. If the target task is code clone detection, the code sample is two sections of program code, and the label is whether the functions of the program codes at both ends are the same or different. If the target task is code completion, the code sample is a section of unfinished program code at the end, and the label is the remaining part of the section of code. If the target task is code synthesis, the code sample is a natural language describing the function of the code, and the label is the corresponding program code. If the target task is code filling, the code sample is a section of unfinished program code with a blank in the middle, and the label is the blank part in the section of code.

[0102] For example, this step can alternately use a batch of code samples in the original training data and a batch of word vector samples in the target training data obtained by the training data processing method described in any of the above embodiments to fine-tune the pre-trained large language model to obtain a large language model for processing the target task. That is, first use a batch of code samples in the original training data to fine-tune the pre-trained large language model, then use a batch of word vector samples in the target training data obtained by the training data processing method described in any of the above embodiments to fine-tune the large language model, then use a batch of code samples in the original training data to fine-tune the pre-trained large language model, then use a batch of word vector samples in the target training data obtained by the training data processing method described in any of the above embodiments to fine-tune the large language model, ..., and so on, until the large language model meets the convergence conditions of fine-tuning, and a large language model for processing the target task is obtained.

[0103] For another example, this step may alternately use the original training data and the target training data obtained by the training data processing method described in any of the above embodiments to perform a round of fine-tuning on the pre-trained large language model to obtain a large language model for processing the target task. That is, first use the original training data to perform a round of fine-tuning on the pre-trained large language model, then use the target training data obtained by the training data processing method described in any of the above embodiments to perform a round of fine-tuning on the large language model, then use the original training data to perform a round of fine-tuning on the pre-trained large language model, then use the target training data obtained by the training data processing method described in any of the above embodiments to perform a round of fine-tuning on the large language model... and so on, until the large language model meets the convergence conditions of fine-tuning, and a large language model for processing the target task is obtained.

[0104] This embodiment uses the attached Figure 3 The target training data obtained by the training data processing method shown and the original training data are used to fine-tune the pre-trained large language model, so that the large language model can understand the meaning of the programming language more accurately, and thus show better results on the target tasks related to the original training data.

[0105] Figure 4 is a schematic structural diagram of a device provided by an exemplary embodiment. Figure 4 At the hardware level, the device includes a processor 402, an internal bus 404, a network interface 406, a memory 408, and a non-volatile memory 410, and may also include hardware required for other tasks. One or more embodiments of this specification may be implemented based on software, such as the processor 402 reading the corresponding computer program from the non-volatile memory 410 into the memory 408 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0106] Please refer to Figure 5 , the code processing device can be applied to Figure 4 In the device shown in the figure, the technical solution of this specification is implemented. The code processing device may include:

[0107] A graph data module 501 is used to extract graph data of the code to be processed, wherein the graph data includes a plurality of nodes and connection relationships between different nodes;

[0108] A feature module 502 is used to extract features of at least one node in the graph data according to code snippets in the code to be processed corresponding to at least one node in the graph data;

[0109] The word vector module 503 is used to determine the word vector corresponding to the graph data based on the characteristics of at least one node in the graph data and the connection relationship between at least two nodes, wherein the word vector is a word vector adapted to the feature space of a large language model.

[0110] In a possible embodiment of the present specification, the type of the node in the graph data is a node type shared by different types of code languages.

[0111] In a possible embodiment of the present specification, the graph data includes at least one of the following: an abstract syntax tree, a data flow, and a control flow.

[0112] In a possible embodiment of this specification, the feature module is used to:

[0113] The code snippets in the code to be processed corresponding to at least one node in the graph data are respectively input into the embedded neural network model to obtain the characteristics of the at least one node output by the embedded neural network model.

[0114] In a possible embodiment of the present specification, the word vector module is used to:

[0115] The features of at least one node in the graph data and the connection relationship between at least two nodes are input into a graph processing neural network model, and the output of the graph processing neural network model is input into an adaptation layer to obtain a word vector corresponding to the graph data output by the adaptation layer.

[0116] Please refer to Figure 6 , the processing device for training data applied to fine-tuning a large language model can be applied to Figure 4 The training data processing device may include:

[0117] A processing module 601 is used to process the code samples in the original training data based on the code processing method described in any of the above embodiments to obtain the word vector corresponding to the code sample;

[0118] The marking module 602 is used to use the word vector corresponding to the code sample as a word vector sample, and mark the code sample corresponding to the word vector sample as a label of the word vector sample to obtain target training data.

[0119] In a possible embodiment of this specification, the marking module is further used for:

[0120] The types of nodes and / or the connection relationships between nodes in the graph data corresponding to the word vector sample are marked as labels of the word vector sample.

[0121] The fine-tuning device can be used for Figure 4 The fine-tuning device may include:

[0122] A fine-tuning module is used to fine-tune the pre-trained large language model using original training data and target training data obtained by the training data processing method described in any of the above embodiments to obtain a large language model for processing a target task, wherein the code samples in the original training data are marked with labels related to the target task.

[0123] In a possible embodiment of the present specification, the fine-tuning module is used to:

[0124] Alternately use a batch of code samples in the original training data and a batch of word vector samples in the target training data obtained by the training data processing method described in any of the above embodiments to fine-tune the pre-trained large language model to obtain a large language model for processing the target task.

[0125] In a possible embodiment of the present specification, the target task includes at least one of the following: code translation, code summary, code repair, code vulnerability detection, code clone detection, code completion, code synthesis and code filling.

[0126] One or more embodiments of the present specification also provide a computer program product, including a computer program / instruction, which implements the steps of the method provided in any of the above embodiments when executed by a processor.

[0127] One or more embodiments of the present specification further provide a computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method provided in any of the above embodiments.

[0128] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.

[0129] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0130] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0131] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0132] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

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

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

[0135] 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 this manual 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.

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

[0137] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.

Claims

1. A code processing method, the method comprising: Extracting graph data of the code to be processed, wherein the graph data includes a plurality of nodes and connection relationships between different nodes; Extracting features of at least one node in the graph data respectively according to code snippets in the code to be processed corresponding to at least one node in the graph data; According to the features of at least one node in the graph data and the connection relationship between at least two nodes, a word vector corresponding to the graph data is determined, wherein the word vector is a word vector adapted to the feature space of a large language model.

2. According to the code processing method according to claim 1, the type of the node in the graph data is a node type shared by different types of code languages.

3. According to the code processing method according to claim 1 or 2, the graph data includes at least one of the following: an abstract syntax tree, a data flow, and a control flow.

4. The code processing method according to claim 1, wherein the extracting the features of at least one node in the graph data according to the code fragments in the code to be processed corresponding to at least one node in the graph data comprises: The code snippets in the code to be processed corresponding to at least one node in the graph data are respectively input into the embedded neural network model to obtain the characteristics of the at least one node output by the embedded neural network model.

5. The code processing method according to claim 1, wherein determining the word vector corresponding to the graph data according to the characteristics of at least one node in the graph data and the connection relationship between at least two nodes comprises: The features of at least one node in the graph data and the connection relationship between at least two nodes are input into a graph processing neural network model, and the output of the graph processing neural network model is input into an adaptation layer to obtain a word vector corresponding to the graph data output by the adaptation layer.

6. A method for processing training data for fine-tuning a large language model, the method comprising: Based on the code processing method described in any one of claims 1 to 5, the code samples in the original training data are processed to obtain word vectors corresponding to the code samples; The word vector corresponding to the code sample is used as a word vector sample, and the code sample corresponding to the word vector sample is marked as a label of the word vector sample to obtain target training data.

7. The method for processing training data for fine-tuning a large language model according to claim 6, further comprising: The types of nodes and / or the connection relationships between nodes in the graph data corresponding to the word vector sample are marked as labels of the word vector sample.

8. A model fine-tuning method, the method comprising: Using original training data and target training data obtained by the training data processing method according to claim 6 or 7, fine-tuning the pre-trained large language model to obtain a large language model for processing the target task, wherein the code samples in the original training data are marked with labels related to the target task.

9. The model fine-tuning method according to claim 8, wherein the use of the original training data and the target training data obtained by the training data processing method according to claim 6 or 7 to fine-tune the pre-trained large language model to obtain a large language model for processing the target task comprises: Alternately use a batch of code samples in the original training data and a batch of word vector samples in the target training data obtained by the training data processing method described in claim 6 or 7 to fine-tune the pre-trained large language model to obtain a large language model for processing the target task.

10. According to the model fine-tuning method according to claim 8 or 9, the target task includes at least one of the following: code translation, code summary, code repair, code vulnerability detection, code clone detection, code completion, code synthesis and code filling.

11. A code processing device, the device comprising: A graph data module, used to extract graph data of the code to be processed, wherein the graph data includes a plurality of nodes and connection relationships between different nodes; A feature module, used to extract features of at least one node in the graph data according to code snippets in the code to be processed corresponding to at least one node in the graph data; A word vector module is used to determine the word vector corresponding to the graph data based on the characteristics of at least one node in the graph data and the connection relationship between at least two nodes, wherein the word vector is a word vector adapted to the feature space of a large language model.

12. The code processing device according to claim 11, wherein the feature module is used for: The code snippets in the code to be processed corresponding to at least one node in the graph data are respectively input into the embedded neural network model to obtain the characteristics of the at least one node output by the embedded neural network model.

13. The code processing device according to claim 11, wherein the word vector module is used for: The features of at least one node in the graph data and the connection relationship between at least two nodes are input into a graph processing neural network model, and the output of the graph processing neural network model is input into an adaptation layer to obtain a word vector corresponding to the graph data output by the adaptation layer.

14. A device for processing training data for fine-tuning a large language model, the device comprising: A processing module, configured to process the code samples in the original training data based on the code processing method according to any one of claims 1 to 5, so as to obtain word vectors corresponding to the code samples; The marking module is used to use the word vector corresponding to the code sample as a word vector sample, and mark the code sample corresponding to the word vector sample as a label of the word vector sample to obtain target training data.

15. According to the apparatus for processing training data for fine-tuning a large language model according to claim 14, the marking module is further used for: The types of nodes and / or the connection relationships between nodes in the graph data corresponding to the word vector sample are marked as labels of the word vector sample.

16. A model fine-tuning device, comprising: A fine-tuning module is used to fine-tune the pre-trained large language model using original training data and target training data obtained by the training data processing method according to claim 6 or 7 to obtain a large language model for processing a target task, wherein the code samples in the original training data are marked with labels related to the target task.

17. The model fine-tuning device according to claim 16, wherein the fine-tuning module is used for: Alternately use a batch of code samples in the original training data and a batch of word vector samples in the target training data obtained by the training data processing method described in claim 6 or 7 to fine-tune the pre-trained large language model to obtain a large language model for processing the target task.

18. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 10.

19. An electronic device comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 10 by running the executable instructions.

20. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 10.

Citation Information

Cited By

  • Structure-aware large model graph reasoning method and system

    CN119150996A