Methods, apparatus, devices, and storage media for enhancing the code capabilities of large models
By crawling and cleaning code corpora, storing them in a search engine retrieval library, and constructing query statements, the large model was fine-tuned, solving the problem of insufficient code generation capability of large models and achieving more accurate code generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-15
- Publication Date
- 2026-03-10
AI Technical Summary
Large models lack code generation capabilities during training, mainly because code corpus accounts for a very small proportion of the pre-training corpus and code language differs significantly from natural language.
By crawling and cleaning the code corpus, storing it in the search engine's retrieval library, constructing query statements corresponding to user questions, and using the query results and manually annotated output results to fine-tune the large model.
It improves the code generation capabilities of large models, enabling them to output code content that is more relevant and accurate to user questions.
Smart Images

Figure CN118349715B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method, apparatus, device, and storage medium for enhancing the code capabilities of large models. Background Technology
[0002] A large model is a machine learning model with a large number of parameters and complex computational structures. These models are typically built from deep neural networks and have billions or even hundreds of billions of parameters. Large models are designed to improve the expressive power and predictive performance of models, enabling them to handle more complex tasks and data. Large models have wide applications in various fields, including natural language processing, computer vision, speech recognition, and recommender systems. By training on massive amounts of data to learn complex patterns and features, large models have stronger generalization capabilities and can make accurate predictions on unseen data. Therefore, it is worth considering using a trained large model to generate corresponding code for user questions.
[0003] However, in the current training process of large models, code corpora account for a very small proportion of the pre-training corpora, and code language is somewhat different from natural language, resulting in a lack of good code generation capabilities. Summary of the Invention
[0004] This invention provides a method, apparatus, device, and storage medium for improving the code generation capabilities of large models, thereby addressing the shortcomings of existing technologies in the lack of code generation capabilities for large models and effectively enhancing the code generation capabilities of large models.
[0005] This invention provides a method for improving the code capabilities of large models, including:
[0006] Crawl and clean the code corpus, and store the cleaned code corpus and the corresponding text data into the search engine retrieval library;
[0007] Construct a query statement corresponding to the user's question, and retrieve the query results of the query statement through the search engine database;
[0008] Based on the query results of the query statement, the user question, and the output results of manual annotation, the large model is fine-tuned.
[0009] According to the present invention, a method for improving the code capabilities of large models includes storing the cleaned code corpus and the corresponding text data into a search engine retrieval database.
[0010] The cleaned code corpus is then segmented at the paragraph level to obtain the code document;
[0011] The text data is segmented into words to obtain segmented text data;
[0012] The code document and the text segmentation data are stored in the search engine's retrieval database.
[0013] According to a method for improving the capabilities of large model code provided by the present invention, the step of storing the code document and the text segmentation data into the search engine retrieval library specifically includes:
[0014] An index structure is constructed for the text segmentation data, and each text segmentation data corresponds to a code document identifier list; the code document identifier list contains multiple code document identifiers corresponding to each text segmentation data.
[0015] Based on the index structure, the code document and the text segmentation data are stored in the search engine retrieval library.
[0016] According to a method for improving the coding capabilities of large models provided by the present invention, the fine-tuning of the large model based on the query results of the query statement, the user question, and the output results of manual annotation specifically includes:
[0017] A predetermined number of query results are selected from high to low relevance and, together with the user question, are used as positive samples in the fine-tuning corpus of the large model and input into the large model.
[0018] Based on the output of the manually labeled data, the large model is fine-tuned.
[0019] According to a method for improving the code capabilities of large models provided by the present invention, the method further includes:
[0020] The search engine is used to retrieve the query results corresponding to the user's input question.
[0021] The output of the large model is obtained by fine-tuning the query results corresponding to the input question and the user's question input.
[0022] According to a method for improving the code capabilities of large models provided by the present invention, the construction of the query statement corresponding to the user question includes one or more of the following:
[0023] Construct an exact match query statement for the user's question;
[0024] Construct a fuzzy matching query statement corresponding to the user's question;
[0025] Construct a Boolean query statement corresponding to the user's question.
[0026] The present invention also provides an apparatus for improving the code capabilities of large models, comprising:
[0027] The storage module is used to crawl and clean the code corpus, and store the cleaned code corpus and the corresponding text data into the search engine retrieval library.
[0028] The query module is used to construct a query statement corresponding to the user's question and retrieve the query results of the query statement through the search engine database.
[0029] The fine-tuning module is used to fine-tune the large model based on the query results of the query statement, the user question, and the output results of manual annotation.
[0030] According to the present invention, an apparatus for improving the capabilities of large model code is provided, wherein storing the cleaned code corpus and the corresponding text data into a search engine retrieval database specifically includes:
[0031] The cleaned code corpus is then segmented at the paragraph level to obtain the code document;
[0032] The text data is segmented into words to obtain segmented text data;
[0033] The code document and the text segmentation data are stored in the search engine's retrieval database.
[0034] According to the present invention, an apparatus for improving the capabilities of large model code is provided, wherein storing the code document and the text segmentation data into the search engine retrieval database specifically includes:
[0035] An index structure is constructed for the text segmentation data, and each text segmentation data corresponds to a code document identifier list; the code document identifier list contains multiple code document identifiers corresponding to each text segmentation data.
[0036] Based on the index structure, the code document and the text segmentation data are stored in the search engine retrieval library.
[0037] According to the present invention, an apparatus for improving the coding capabilities of large models includes fine-tuning the large model based on the query results of the query statement, the user question, and the output results of manual annotation. Specifically, this includes:
[0038] A predetermined number of query results are selected from high to low relevance and, together with the user question, are used as positive samples in the fine-tuning corpus of the large model and input into the large model.
[0039] Based on the output of the manually labeled data, the large model is fine-tuned.
[0040] According to the present invention, an apparatus for improving the code capabilities of large models is provided, the apparatus further comprising an acquisition module for:
[0041] The search engine is used to retrieve the query results corresponding to the user's input question.
[0042] The output of the large model is obtained by fine-tuning the query results corresponding to the input question and the user's question input.
[0043] According to an apparatus for enhancing the code capabilities of large models provided by the present invention, the construction of the query statement corresponding to the user question includes one or more of the following:
[0044] Construct an exact match query statement for the user's question;
[0045] Construct a fuzzy matching query statement corresponding to the user's question;
[0046] Construct a Boolean query statement corresponding to the user's question.
[0047] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method for enhancing large model code capabilities as described above.
[0048] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for improving the capabilities of large model code as described above.
[0049] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the method for improving the large model code capability as described above.
[0050] The present invention provides a method, apparatus, device, and storage medium for improving the code generation capabilities of large models. This involves crawling and cleaning code corpora, storing the cleaned code corpora and their corresponding text data in a search engine retrieval library, constructing a query statement corresponding to a user question, obtaining the query results from the search engine retrieval library, and then fine-tuning the large model based on the query results, the user question, and manually annotated output results. The fine-tuned large model can then output code content that is more relevant and accurate to the user question, thereby improving the code generation capabilities of the large model. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0052] Figure 1 A flowchart illustrating the method for improving the code capabilities of large models provided by this invention;
[0053] Figure 2 A schematic diagram of the structure of the device for improving the code capabilities of large models provided by the present invention;
[0054] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0055] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0056] Figure 1 This is a flowchart illustrating the method for improving the code capabilities of large models provided by the present invention, as shown below. Figure 1 As shown, the method includes the following steps:
[0057] Step 100: Crawl and clean the code corpus, and store the cleaned code corpus and the corresponding text data into the search engine retrieval database.
[0058] Step 101: Construct the query statement corresponding to the user's question, and retrieve the query results of the query statement through the search engine database.
[0059] Step 102: Fine-tune the large model based on the query results, user questions, and manually labeled output.
[0060] Specifically, in existing technologies, code corpora constitute a very small proportion of the pre-training corpus for large models, and code language differs somewhat from natural language, resulting in a lack of good code generation capabilities. Typically, no special training is performed on code generation capabilities during pre-training.
[0061] Therefore, this invention provides a method to improve the code capabilities of large models through Retrieval Augmented Generation (RAG). Retrieval Augmented Generation refers to acquiring relevant knowledge through retrieval and integrating it into prompts. The large model then uses this knowledge as a reference to provide reasonable answers.
[0062] First, code corpora can be crawled and cleaned. This can be pre-set to crawl and clean code corpora from high-quality code websites, such as GitHub and CSDN, and then clean the code corpora.
[0063] The main goal of cleaning code corpora is to transform raw, incomplete, and unreliable data into usable, reliable, and meaningful data. The specific process may include organizing and sorting the code corpus data, cleaning and populating the code corpus data, transforming and manipulating the code corpus data, and verifying and checking the code corpus data.
[0064] After cleaning the code corpus, the cleaned code corpus and its corresponding text data can be stored in a search engine retrieval library. This search engine retrieval library, such as Elasticsearch (ES), can store and retrieve data in real time.
[0065] Therefore, after storing the cleaned code corpus and its corresponding text data into the search engine's retrieval library, the keywords of the user questions input into the large model can be used to construct the query statements corresponding to the user questions based on specific matching requirements.
[0066] According to a method for improving the code capabilities of large models provided by the present invention, a query statement corresponding to a user question is constructed, including one or more of the following:
[0067] (1) Construct an exact match query statement corresponding to the user's question. Exact matching is usually used when it is necessary to accurately find and reference data. Therefore, when the user needs to accurately find code data, an exact match query statement corresponding to the user's question can be constructed.
[0068] (2) Construct a fuzzy matching query statement corresponding to the user's question. Fuzzy matching is usually used when it is necessary to quickly find approximate data. Therefore, when the user needs to quickly find approximate code data, a fuzzy matching query statement corresponding to the user's question can be constructed.
[0069] (3) Construct Boolean query statements corresponding to user questions. Boolean query refers to a query method that uses operators such as AND, OR, or NOT to connect multiple keyword items. Therefore, Boolean query statements corresponding to user questions can be constructed when users need to find corresponding code data based on multiple logical relationships.
[0070] After constructing the query statement corresponding to the user's question, the query results can be obtained through the search engine's database.
[0071] For example, when the search engine is Elasticsearch (ES), you can use the `match` statement provided by ES to execute a query and obtain the query results. The specific code is as follows:
[0072]
[0073] Once the search results from the search engine's database are obtained, the large model can be fine-tuned based on the query results, user questions, and manually annotated output.
[0074] The method for improving the coding capabilities of large models provided by this invention involves crawling and cleaning code corpora, storing the cleaned code corpora and their corresponding text data in a search engine retrieval library, constructing a query statement corresponding to the user question, obtaining the query results through the search engine retrieval library, and then fine-tuning the large model based on the query results, the user question, and the manually annotated output results. As a result, the fine-tuned large model can output code content that is more relevant and accurate to the user question, thereby improving the code generation capability of the large model.
[0075] According to the present invention, a method for improving the code capabilities of large models is provided, which involves storing the cleaned code corpus and the corresponding text data into a search engine retrieval database, specifically including:
[0076] The cleaned code corpus is then segmented into paragraphs to obtain code documentation.
[0077] The text data is segmented into words to obtain the segmented text data;
[0078] Store the code documentation and text segmentation data in the search engine's retrieval database.
[0079] Specifically, in the process of storing the cleaned code corpus and the corresponding text data into the search engine's retrieval database, the cleaned code corpus can first be segmented at the paragraph level to obtain multiple code documents.
[0080] During the process of importing the cleaned code corpus into the search engine's retrieval library, word segmentation can be performed, for example, using Whitespace Tokenizer, to obtain the segmented data.
[0081] For example, the text data corresponding to the cleaned code corpus is texts = [text1, text2, ..., text...]. n The text segmentation data obtained after text segmentation is:
[0082] terms = [[term 11 ,term 12 …,term 1n ],…,[term n1 ,term n2 …,term nn ]).
[0083] Once you have the code documentation and the segmented text data, you can store them in the search engine's retrieval database.
[0084] According to the present invention, a method for improving the capabilities of large model code is provided, which involves storing code documents and text segmentation data into a search engine retrieval database, specifically including:
[0085] An index structure is constructed for the text segmentation data, and each text segmentation data corresponds to a code document identifier list; the code document identifier list contains multiple code document identifiers corresponding to each text segmentation data.
[0086] Based on the index structure, code documents and text segmentation data are stored in the search engine's retrieval library.
[0087] Specifically, after obtaining the code document and text segmentation data, an index structure can be built for the text segmentation data using an inverted index method. Each text segmentation data corresponds to a code document identifier list, and each code document identifier list contains multiple code document identifiers corresponding to each text segmentation data.
[0088] For example, each text segmentation data (term) corresponds to a list of code document identifiers (IDs):
[0089] InvertedIndex(term ij )->[docID1,docID2…,docID n ]
[0090] In the formula, term ijThis represents the j-th text segmentation data of the i-th text data. InvertedIndex() represents the inverted index. One text segmentation data corresponds to n code document identifiers (docIDs).
[0091] Then, the various code documents and text segmentation data can be stored in the search engine's retrieval library using the constructed index structure.
[0092] According to the present invention, a method for improving the code capabilities of large models is provided, which fine-tunes the large model based on the query results of the query statement, user questions, and manually annotated output results, specifically including:
[0093] A predetermined number of query results, ranked from high to low relevance, are selected together with the user's question and used as positive samples in the fine-tuning corpus of the large model, which are then input into the large model.
[0094] The large model is fine-tuned based on the manually labeled output.
[0095] Specifically, after obtaining the query structure of the query statement, a preset number of query results can be selected from high to low relevance and used together with the user question as positive samples in the fine-tuning corpus of the large model, and then input into the large model.
[0096] In some implementations, the most relevant query results and user questions can be selected together as positive samples in the fine-tuning corpus of the large model and input into the large model.
[0097] For example, the most relevant query result, result0, is added to the prompt of the large model, along with the user question input = [v1, v2, ..., v n When pieced together, the input to the entire large model can be: ='The following information was retrieved from the code knowledge base:'+result0+'The user's question is:'+input+'Please answer the user's question based on the above information and generate code. This may involve code modification, line-by-line program explanation, script error identification, etc.'
[0098] Then, based on the output results of manual annotation, the large model can be fine-tuned to obtain a fine-tuned large model. The fine-tuned large model can output code content that is more relevant and accurate to the user's problem, thus improving the code generation capability of the large model.
[0099] According to the present invention, a method for improving the code capabilities of large models is provided, the method further includes:
[0100] The system retrieves query results corresponding to the user's input question by searching the database through a search engine.
[0101] The large model is obtained by fine-tuning the query results corresponding to the input question and the user's question input.
[0102] Specifically, in the process of obtaining the corresponding output results through the fine-tuned large model, the query results corresponding to the user's input question can be obtained first by searching the search engine database.
[0103] Then, the query results corresponding to the input question and the user's question input can be fine-tuned to obtain the output of the large model.
[0104] For example, the results retrieved from a search engine database are added to the prompt of a large model, along with the input input = [v1, v2, ..., v n The complete model input, when concatenated, is: model_input_text = 'The following information was retrieved from the code knowledge base:' + result0 + 'The user's question is:' + input + 'Please answer the user's question based on the above information and generate code. This may involve code modification, line-by-line program explanation, script error identification, etc.'.
[0105] Using `model_input` as the input to the large model, we can obtain the intermediate hidden states as [h1, h2, ..., h...]. n Then, after passing it through a multilayer perceptron (MLP), it is mapped to a probability distribution logits = [p1, p2, ..., p] on the vocabulary. vocab_size The word with the highest probability after softmax, `pred_label`, is then output as the next word. The model leverages its reasoning capabilities to selectively utilize and understand the coded text in the retrieval results before outputting it; this process can be seen in the following formula:
[0106]
[0107] The following examples, through specific application scenarios, further illustrate the method for improving the code capabilities of large models provided by the present invention.
[0108] This embodiment provides a method for enhancing the code creation capabilities of the Tongyi Qianwen (Tongyi Thousand Questions) model. Taking Tongyi Thousand Questions 14B as an example, the method includes the following steps:
[0109] (1) Crawling high-quality code corpora from websites such as GitHub and CSDN;
[0110] (2) Construct a corpus from the code corpus through methods such as continuation writing and question-and-answer;
[0111] Examples of ways to continue writing are as follows:
[0112]
[0113]
[0114] The following information was retrieved from a knowledge base: `re.match()` and `re.search()` are two functions in Python's regular expression module `re`, and they have some important differences in handling string matching with regular expressions. The `re.match()` function matches the regular expression from the beginning of the string. If the beginning of the string does not match the regular expression, `re.match()` will not attempt to match at other positions. For example, for the string "helloworld", the regular expression "he" will match the string because "he" is the beginning of the string. However, for the regular expression "el", it will not match the string because "el" is not at the beginning of the string. The `re.search()` function searches the entire string for parts that match the regular expression. If the beginning of the string does not match the regular expression, `re.search()` will continue matching at other positions in the string. Continuing with the example above, for the string "helloworld", the regular expression "el" will match the string because "el" appears in the "ello" part of the string. The user's question is: Please explain the difference between `re.match()` and `re.search()`. Please answer the user's question based on the information above and generate the code.
[0115] {"from":"assistant","value":"re.match() and re.search() are two functions in Python's regular expression module re, and they have some important differences in how they handle string matching with regular expressions."}
[0116] The `re.match()` function matches a regular expression at the beginning of the string. If the beginning of the string does not match the regular expression, `re.match()` will not attempt to match at other positions. For example, for the string "helloworld", the regular expression "he" will match the string because "he" is the beginning of the string. However, for the regular expression "el", it will not match the string because "el" is not at the beginning of the string. The `re.search()` function searches the entire string for a match to the regular expression. If the beginning of the string does not match the regular expression, `re.search()` will continue to match at other positions in the string. Continuing with the example above, for the string "helloworld", the regular expression "el" will match the string because "el" appears in the "ello" part of the string.
[0117] "}]
[0118] } ]
[0120] (3) The constructed fine-tuned corpus is sent into the Qianwen 14B large model for fine-tuning training.
[0121] This embodiment utilizes a method to enhance the code creation capabilities of a large-scale model based on generalized questions. This method incorporates high-quality code corpora into a retrieval database, recalling relevant code snippets containing textual descriptions in response to user queries. This enables efficient and accurate answers to users' code writing questions. Thus, without requiring retraining and fine-tuning of the large model, it outputs correct code creation content relevant to user queries, effectively mitigating the illusion of fact problem that is prone to occur in large-scale models.
[0122] The apparatus for enhancing the code capabilities of large models provided by the present invention will be described below. The apparatus for enhancing the code capabilities of large models described below can be referred to in correspondence with the method for enhancing the code capabilities of large models described above.
[0123] Figure 2 A schematic diagram of the structure of the device for improving the code capabilities of large models provided by the present invention is shown below. Figure 2 As shown, the device includes:
[0124] The storage module 200 is used to crawl and clean the code corpus, and store the cleaned code corpus and the corresponding text data into the search engine retrieval library.
[0125] The query module 210 is used to construct the query statement corresponding to the user's question and retrieve the query results of the query statement through the search engine database.
[0126] The fine-tuning module 220 is used to fine-tune the large model based on the query results of the query statement, user questions, and manually labeled output results.
[0127] According to the present invention, an apparatus for improving the capabilities of large model code stores the cleaned code corpus and the corresponding text data into a search engine retrieval database, specifically including:
[0128] The cleaned code corpus is then segmented into paragraphs to obtain code documentation.
[0129] The text data is segmented into words to obtain the segmented text data;
[0130] Store the code documentation and text segmentation data in the search engine's retrieval database.
[0131] According to the present invention, an apparatus for improving the capabilities of large model code stores code documents and text segmentation data into a search engine retrieval database, specifically including:
[0132] An index structure is constructed for the text segmentation data, and each text segmentation data corresponds to a code document identifier list; the code document identifier list contains multiple code document identifiers corresponding to each text segmentation data.
[0133] Based on the index structure, code documents and text segmentation data are stored in the search engine's retrieval library.
[0134] According to the present invention, an apparatus for improving the coding capabilities of large models is provided, which fine-tunes large models based on query results, user questions, and manually annotated outputs, specifically including:
[0135] A predetermined number of query results, ranked from high to low relevance, are selected together with the user's question and used as positive samples in the fine-tuning corpus of the large model, which are then input into the large model.
[0136] The large model is fine-tuned based on the manually labeled output.
[0137] According to the present invention, an apparatus for improving the code capabilities of large models is provided, the apparatus further comprising an acquisition module for:
[0138] The system retrieves query results corresponding to the user's input question by searching the database through a search engine.
[0139] The large model is obtained by fine-tuning the query results corresponding to the input question and the user's question input.
[0140] According to the present invention, an apparatus for enhancing the code capabilities of large models is provided to construct query statements corresponding to user questions, including one or more of the following:
[0141] Construct an exact match query statement for the user's question;
[0142] Construct a fuzzy matching query statement corresponding to the user's question;
[0143] Construct a Boolean query statement corresponding to the user's question.
[0144] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 3 As shown, the electronic device may include: a processor 310, a communications interface 320, a memory 330, and a communication bus 340, wherein the processor 310, the communications interface 320, and the memory 330 communicate with each other via the communication bus 340. The processor 310 can call logical instructions in the memory 330 to execute the methods provided above for improving the code capabilities of large models, including:
[0145] Crawl and clean the code corpus, and store the cleaned code corpus and the corresponding text data into the search engine retrieval library;
[0146] Construct the query statement corresponding to the user's question, and retrieve the query results through the search engine database;
[0147] The large model is fine-tuned based on the query results, user questions, and manually labeled output.
[0148] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0149] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, the computer is able to perform the methods provided above for improving the ability to code large models, the method comprising:
[0150] Crawl and clean the code corpus, and store the cleaned code corpus and the corresponding text data into the search engine retrieval library;
[0151] Construct the query statement corresponding to the user's question, and retrieve the query results through the search engine database;
[0152] The large model is fine-tuned based on the query results, user questions, and manually labeled output.
[0153] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method for performing the methods described above to enhance the capabilities of large model code, the method comprising:
[0154] Crawl and clean the code corpus, and store the cleaned code corpus and the corresponding text data into the search engine retrieval library;
[0155] Construct the query statement corresponding to the user's question, and retrieve the query results through the search engine database;
[0156] The large model is fine-tuned based on the query results, user questions, and manually labeled output.
[0157] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0158] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0159] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for improving large model code capability, characterized in that, The method comprises the following steps: Crawling and cleaning a code corpus, and storing the cleaned code corpus and text data corresponding to the cleaned code corpus into a search engine retrieval library; Constructing a query statement corresponding to a user question, and obtaining a query result of the query statement through the search engine retrieval library; The construction of the query statement corresponding to the user question comprises: Constructing an exact match query statement corresponding to the user question; Constructing a fuzzy match query statement corresponding to the user question; Constructing a Boolean query statement corresponding to the user question; Based on the query result of the query statement, the user question and the artificially annotated output result, the large model is fine-tuned to output code content that is more relevant and accurate to the user question after fine-tuning. The fine-tuning of the large model based on the query result of the query statement, the user question and the artificially annotated output result comprises: Selecting a preset number of query results from high to low according to the relevance, and inputting the selected query results and the user question into the large model as positive samples in the fine-tuning corpus of the large model; Based on the artificially annotated output result, the large model is fine-tuned.
2. The method for boosting large model code capability according to claim 1, wherein, The storing of the cleaned code corpus and the text data corresponding to the cleaned code corpus into the search engine retrieval library comprises: Segmenting the cleaned code corpus at the paragraph level to obtain code documents; Segmenting the text data to obtain text segmentation data; Storing the code documents and the text segmentation data into the search engine retrieval library.
3. The method for boosting large model code capability according to claim 2, wherein, The storing of the code documents and the text segmentation data into the search engine retrieval library comprises: Indexing the text segmentation data to obtain a code document identifier list corresponding to each text segmentation data, wherein the code document identifier list contains a plurality of code document identifiers corresponding to each text segmentation data; Based on the index structure, the code documents and the text segmentation data are stored into the search engine retrieval library.
4. The method for boosting large model code capability according to claim 1, wherein, The method further comprises: Obtaining a query result corresponding to an input question of a user through the search engine retrieval library; Inputting the query result corresponding to the input question and the user question into the fine-tuned large model to obtain an output result of the large model.
5. An apparatus for improving the code capability of a large model, applying the method for improving the code capability of a large model according to claim 1, characterized in that, The method comprises: A storage module for crawling and cleaning a code corpus, and storing the cleaned code corpus and text data corresponding to the cleaned code corpus into a search engine retrieval library; A query module for constructing a query statement corresponding to a user question, and obtaining a query result of the query statement through the search engine retrieval library; A fine-tuning module for fine-tuning a large model based on the query result of the query statement, the user question and the artificially annotated output result.
6. An electronic device comprising a memory, a processor, and a computer program stored on the memory and running on the processor, characterized in that, The processor executes the program to implement the method for improving the code capability of the large model according to any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the method for improving the code capability of the large model according to any one of claims 1 to 4.
8. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the method for improving the code capability of the large model according to any one of claims 1 to 4.
Citation Information
Patent Citations
Intelligent data analysis method and device based on large language model
CN117555986A
Word segmentation retrieval method, device and equipment based on large model fine tuning and storage medium
CN117555992A