Method and apparatus for generating code based on large-scaled model, electronic device and storage medium
Patent Information
- Application Number
- JP2024209734
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-19
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-12-02
Smart Images

Figure 2025036437000001_ABST
Abstract
Description
[Technical field]
[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to the field of deep learning technology and large-scale model technology. In particular, the present disclosure relates to a code generation method, device, electronic device, storage medium, and program based on a large-scale model. [Background technology]
[0002] With the continuous development of artificial intelligence technology, technologies such as deep learning models and large language models (LLM) are also applied to various generation fields, such as large-scale model assistance developers to generate code.
[0003] However, different developers usually have different development styles, and the code they write also reflects multiple styles. Currently, the code generated by large-scale models has difficulty meeting the usage needs of developers. Summary of the Invention
[0004] The present disclosure provides a method, an apparatus, an electronic device, a storage medium, and a computer program for generating code based on a large-scale model.
[0005] According to one aspect of the present disclosure, there is provided a code generation method based on a large-scale model, including obtaining a first explanatory text input by a user and expressing a code need, searching for positive codes and negative codes matching the first explanatory text, where the positive codes and negative codes are determined based on a favorite operation by the user for a historical code output by the large-scale model, generating a second explanatory text using the first explanatory text and the positive codes and negative codes, and inputting the second explanatory text into the large-scale model and outputting a target code matching the code need.
[0006] According to another aspect of the present disclosure, a code generation device based on a large-scale model is provided, including an acquisition module for acquiring a first explanatory text input by a user and expressing code needs; a search module for searching for positive codes and negative codes matching the first explanatory text, where the positive codes and negative codes are determined based on a favorite operation by the user for historical codes output by the large-scale model; a first generation module for generating a second explanatory text using the first explanatory text, the positive codes and the negative codes; and a second generation module for inputting the second explanatory text into the large-scale model and outputting a target code matching the code needs.
[0007] According to another aspect of the present disclosure, there is provided an electronic device including at least one processor and a memory communicatively connected to the at least one processor, the memory storing instructions executable by the at least one processor, the instructions being executed by the at least one processor such that the at least one processor performs the method.
[0008] According to another aspect of the present disclosure, a non-transitory computer readable storage medium having stored thereon computer instructions for causing a computer to perform the method described above is provided.
[0009] According to another aspect of the present disclosure there is provided a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 8.
[0010] It should be understood that the contents described in this section are not intended to depict key points or important features of the embodiments of the present disclosure, and are not intended to limit the scope of the present disclosure. Other features of the present disclosure will be readily understood from the following description. [Brief description of the drawings]
[0011] The drawings are for better understanding of the present technical solution, and are not intended to limit the present application.
[0012] [Figure 1] FIG. 1 illustrates a schematic diagram of an exemplary system architecture to which the large-scale model-based code generation method and apparatus according to an embodiment of the present disclosure can be applied. [Diagram 2] FIG. 2 illustrates a schematic flow chart of a large-scale model-based code generation method according to an embodiment of the present disclosure. [Diagram 3] FIG. 3 illustrates a schematic diagram of a large-scale model-based code generation scenario according to one embodiment of the present disclosure. [Figure 4A] FIG. 4A illustrates a schematic flow chart of searching for positive and negative codes matching a first description text according to one embodiment of the present disclosure. [Figure 4B] FIG. 4B illustrates a schematic flow chart of searching for a positive code matching the first description text according to another embodiment of the present disclosure. [Diagram 5] FIG. 5 illustrates a schematic diagram of a second instruction text constructed based on a prompt template according to one embodiment of the present disclosure. [Figure 6] FIG. 6 illustrates a schematic diagram of a scenario for determining edit codes according to an embodiment of the present disclosure. [Figure 7] FIG. 7 illustrates a schematic diagram of a scenario for determining edit codes according to an embodiment of the present disclosure. [Figure 8] FIG. 8 illustrates a schematic block diagram of a large-scale model-based code generator according to an embodiment of the present disclosure. [Figure 9] FIG. 9 illustrates generally a block diagram of an electronic device 900 suitable for implementing large-scale model-based code generation methods according to embodiments of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0013] Hereinafter, exemplary embodiments of the present disclosure will be described with reference to the drawings. Hereinafter, various details of the embodiments of the present disclosure are included for easier understanding, and they should be considered as examples. Therefore, it should be understood that a person skilled in the art can make various changes and modifications to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for clarity and conciseness, the following description omits descriptions of well-known functions and configurations.
[0014] In the field of deep learning, the code generated by a large-scale model is difficult to meet the usage needs of developers. For this reason, in the related technology, the input of a large-scale model can be augmented by Retrieval-Augmented Generation (RAG) technology. RAG technology includes two main parts: information retrieval and generation. It mainly searches for domain knowledge text related to the question entered by the user in the information retrieval stage, and uses the retrieved domain knowledge text to augment the question entered by the user. For example, in the field of code generation, the traditional RAG technology can use the code domain knowledge text to augment the question entered by the user.
[0015] However, in the conventional RAG technology, it is generally difficult to use common domain knowledge text to augment the user's input and generate code that meets the usage needs of each user for a specific user. In addition, the domain knowledge text used in searching with the conventional RAG technology is often not in the training corpus of the large-scale model, so the code generated based on the input after the large-scale model is RAG-augmented is inaccurate. For example, the rapid development of large-scale models in deep learning allows deep learning developers to use large-scale models to develop code in the deep learning field. In the field of deep learning, a large amount of industry knowledge is not included in the pre-training corpus of the large-scale model, so the generated code is inaccurate.
[0016] Therefore, to generate accurate code that meets specific user code needs, embodiments of the present disclosure provide a code generation method based on a large-scale model.
[0017] FIG. 1 illustrates a schematic diagram of an exemplary system architecture to which the large-scale model-based code generation method and apparatus according to an embodiment of the present disclosure can be applied.
[0018] It should be noted that Fig. 1 is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical contents of the present disclosure, and does not mean that the embodiments of the present disclosure cannot be used in other facilities, systems, environments, or scenarios. For example, in another embodiment, an exemplary system architecture to which the large-scale model-based code generation method and apparatus can be applied may include a terminal device, but the terminal device does not need to interact with a server and can realize the content processing method and apparatus provided by the embodiments of the present disclosure.
[0019] 1, the system architecture 100 according to the present embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links.
[0020] A user can use the first terminal equipment 101, the second terminal equipment 102, and the third terminal equipment 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal equipment 101, the second terminal equipment 102, and the third terminal equipment 103, such as (by way of example only) a knowledge reading application, a web browser application, a search application, an instant messaging tool, an email client, and / or social platform software.
[0021] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be any electronic device equipped with a display and supporting web browsing, including, but not limited to, a smartphone, a tablet computer, a laptop computer, and a desktop computer.
[0022] The server 105 may be a server that provides various services, such as a back office server (by way of example only) that supports the content that users view using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The back office server can perform processing, such as analysis, on data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to the user requests) to the terminal devices.
[0023] The server is a cloud server, also known as a cloud computing server or cloud host, which is a host product of a cloud computing service system, solving the deficiencies of traditional physical hosts and VPS services ("Virtual Private Server" or "VPS" for short), such as difficult management and poor business scalability. The server can also be a distributed system server or a server combined with blockchain.
[0024] It should be noted that the large-scale model-based code generation method provided by the embodiment of the present disclosure can generally be executed by the first terminal device 101, the second terminal device 102, and the third terminal device 103. Correspondingly, the large-scale model-based code generation apparatus provided by the embodiment of the present disclosure may be provided in the first terminal device 101, the second terminal device 102, and the third terminal device 103.
[0025] Alternatively, the large-scale model-based code generation method provided by the embodiment of the present disclosure can also be executed by the server 105. Correspondingly, the large-scale model-based code generation device according to the embodiment of the present disclosure can generally be provided in the server 105. The large-scale model-based code generation method according to the embodiment of the present disclosure can also be executed by a server or server cluster that can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105, different from the server 105. Correspondingly, the large-scale model-based code generation device according to the embodiment of the present disclosure can also be provided in a server or server cluster that can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105, different from the server 105.
[0026] For example, when a user develops code through a first terminal device 101, a second terminal device 102, and a third terminal device 103, the first terminal device 101, the second terminal device 102, and the third terminal device 103 can obtain a first explanatory text input by the user representing code needs, search for positive codes and negative codes matching the first explanatory text, where the positive codes and negative codes are determined based on the user's favorite operation on the historical codes output by the large-scale model at least on the terminal device, generate a second explanatory text based on the first explanatory text, the positive codes and the negative codes, input the second explanatory text into the large-scale model, and output a target code matching the code needs.
[0027] Alternatively, the user can send a first explanatory text to the server 105 and use the server 105 to search for positive and negative codes that match the first explanatory text. A second explanatory text is generated based on the first explanatory text and the positive and negative codes obtained from the server 105, and the second explanatory text is input into the large-scale model to output a target code that matches the code needs.
[0028] Further alternatively, the first terminal device 101, the second terminal device 102, and the third terminal device 103 can obtain a first explanatory text input by a user and expressing a code need, and send the first explanatory text to the server 105. The server 105 obtains the first explanatory text input by a user and expressing a code need, searches for a positive code and a negative code matching the first explanatory text, where the positive code and the negative code are determined based on a favorite operation by the user on a history code output by the large-scale model, generates a second explanatory text by the first explanatory text, the positive code, and the negative code, inputs the second explanatory text into the large-scale model, and outputs a target code matching the code need.
[0029] It should be understood that the number of terminal devices, networks, and servers in Figure 1 is merely exemplary, and any number of terminal devices, networks, and servers may be included according to the needs of the implementation.
[0030] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure, application and other processing of the users' personal information shall all comply with the provisions of relevant laws and regulations, adopt necessary confidentiality measures, and not violate public order and morals.
[0031] In the technical proposal of the present disclosure, the user's permission or consent is obtained before obtaining or collecting the user's personal information.
[0032] FIG. 2 illustrates a schematic flow chart of a content processing method according to an embodiment of the present disclosure.
[0033] As shown in FIG. 2, the method includes operations S210 to S240.
[0034] In operation S210, a first explanatory text representing the chord needs input by the user is obtained.
[0035] The first explanatory text represents the user's code needs, i.e., usage needs. Specifically, the first explanatory text may include at least one of function explanatory information, grammar explanatory information, personalized coding style needs, etc.
[0036] The first explanatory text entered by the user is distinct from the code output by the large-scale model. It is usually understood that the code has strict grammatical requirements, such as parameter type definition, call statement, call sequence, return value, function format, etc. However, the first explanatory text is mainly used to explain the user's code needs, and can be in natural explanatory language in various explanation styles, such as "what style of code do you want", "what functions do you want", and other colloquial natural explanatory language.
[0037] For example, for a code generation task in the deep learning field, the first description text may include a description of the deep learning function, a specified deep learning framework, etc., which enables the large-scale model to automatically generate corresponding deep learning code.
[0038] In operation S220, positive and negative codes matching the first explanatory text are searched for, where the positive and negative codes are determined based on the user's favorite operations on the history codes output by the large-scale model.
[0039] Both the positive code and the negative code are history codes output by the large-scale model, and can be regarded as categories of the history codes output by the large-scale model. For example, the user who inputs the first explanatory text has used this large-scale model before and performed a favorite operation on the history code output by the large-scale model, so the category of the history code can be a positive code or a negative code.
[0040] The positive code is determined based on the user's active favorite operation on the history code output by the large-scale model, and the negative code is determined based on the user's inactive favorite operation on the history code output by the large-scale model. The active favorite operation represents an operation related to an active tendency such as liking, and the inactive favorite operation represents an operation related to an inactive tendency such as dislike or general.
[0041] Searching for positive codes and negative codes matching the first explanatory text includes calculating positive codes and negative codes matching the first explanatory text based on similarities, including a similarity between a first vector after transformation of the first explanatory text and a second vector after transformation of the positive codes, and a similarity between the first vector and a third vector after transformation of the negative codes.
[0042] In an embodiment of the present disclosure, a natural language processing (NLP) technique can be used to perform text / code vector conversion. Since the code itself is a text written in English and the first explanatory text is a text written in Chinese and / or English, the first explanatory text, the positive code, and the negative code can be converted into vectors through a model such as Bert. The similarity calculation can be calculated through at least one of similarity measure methods such as cosine similarity, inner product, and Euclidean distance.
[0043] In addition, for each coding process of the large-scale model, the output of the large-scale model and the input of the large-scale model have a one-to-one mapping relationship, so that the positive code and the negative code matching the first explanatory text can be searched for through the input of the large-scale model, where the input of the large-scale model can be a user input or an input augmented using the RAG technique.
[0044] In operation S230, a second explanatory text is generated based on the first explanatory text, the positive code and the negative code.
[0045] In an embodiment of the present disclosure, the second explanatory text can be generated by combining the first explanatory text, the positive code, and the negative code, or the second explanatory text can be generated by performing operations such as cutting, stitching, filling, etc. on the first explanatory text, the positive code, and / or the negative code.
[0046] From the perspective of the input of the large-scale model, the actual input of the large-scale model is called the second explanatory text, i.e., a text that extends the first explanatory text. In essence, the second explanatory text can simultaneously contain information of the input dimension, e.g., the first explanatory text, and information of the output dimension, e.g., positive and negative codes.
[0047] The first explanatory text is information input by the user in the current code generation stage, and the positive and negative codes are outputs of the large-scale model obtained by the same user in at least one historical code generation process. Therefore, in each code generation process, the input of the large-scale model can be further personalized and extended from the perspective of the historical output of the large-scale model by fusing the first explanatory text related to the input and the positive and negative codes related to the output that reflect the user's personalization characteristics, and a second explanatory text personalized and extended for the same user can be obtained.
[0048] In operation S240, the second explanatory text is input into the large scale model to output a target code matching the code needs.
[0049] The large-scale model may be a generative large-scale model, a conversational large-scale model, etc., so long as it can output a target code based on prompt information in the second explanatory text.
[0050] Since the target code output by the large-scale model is determined as a positive code and a negative code based on the favorite operation performed by the same user on the historical code, the positive code and the negative code obtained by the search can be regarded as an enrichment and an extension of the first explanatory text expressing the code need, so that the large-scale model outputs a code that further matches the code need. From this, the target code can be understood as a target code that matches the code need.
[0051] In the embodiment of the present disclosure, since both the positive code and the negative code are historical codes obtained by the same user using the same large-scale model, the positive code and the negative code represent the preferences of this user, and not only can guide the large-scale model more appropriately based on the preferences of the same user, but also output a personalized code corresponding to this user. In addition, both the positive code and the negative code can be the historical output of the large-scale model, and can reflect the internal generation logic of the large-scale model to a certain extent. As a result, the positive code, the negative code, and the second explanatory text generated based on the first explanatory text input by the user this time can reflect the current user's preferences and coding style in a personalized manner, guide the large-scale model to output a code with the user's characteristics, and achieve the effect of "the more you use it, the better it gets." In addition, the first explanatory text is expanded through the historical output (positive code and negative code), which compensates for the accuracy problem caused by the text searched during the conventional RAG expansion not being present in the training corpus of the large-scale model, and improves the accuracy of the code generation of the large-scale model.
[0052] With reference to the following FIGS. 3 to 6, the method shown in FIG. 2 will be further explained in combination with a specific embodiment.
[0053] FIG. 3 illustrates a schematic diagram of a large-scale model-based code generation scenario according to one embodiment of the present disclosure.
[0054] As shown in Fig. 3, in the code generation scenario of the embodiment 300, a user 301 can input a first explanatory text 302 expressing a code need, for example, "I want a repetitive sentence written in grammar A, and the repetition judgment condition is xxx". Furthermore, the user 301 is associated with a personalized database 303. The personalized database 303 associated with the user 301 includes at least one history code output by the user 301 using the large-scale model M1 historically, and the history code is also divided into a positive code and a negative code according to the favorite operation of the user 301.
[0055] It should be noted that for each user who uses the large-scale model M1, it is not necessary to fine-tune the large-scale model M1 for each user, but it is only necessary to extend the first explanatory text input each time through the personalized database associated with each user based on the user's historical usage information. This information is continuously enriched in the personalized database associated with the user as the user continues to use the large-scale model M1, realizing RAG self-feedback extension at the user granularity. Therefore, the more times the user uses the large-scale model M1, the more positive and negative codes that represent the user's favorite style will be, and the more accurate the positive and negative codes that match the searched first explanatory text input each time will be, and the effect of "the more you use it, the better it gets" will be achieved at the user granularity.
[0056] After the user 301 inputs the first explanatory text 302, the positive code 304 and the negative code 305 matching with the first explanatory text 302 can be searched in the personalization database 303 associated with the user 301. Then, the second explanatory text 306 is generated according to the first explanatory text 302, the positive code 304 and the negative code 305 matching with the first explanatory text 302. Compared with the first explanatory text 301, the second explanatory text 306 achieves the personalization enhancement of the user in terms of the history output of the large-scale model and the preferences of the user.
[0057] After the second explanatory text 306 is input to the large scale model M1, the large scale model M1 outputs a target code 307 that matches the code needs.
[0058] According to an embodiment of the present disclosure, searching for positive codes and negative codes matching the first explanatory text includes searching for at least one historical explanatory text similar to the first explanatory text from a personalization database associated with the user, determining at least one initial positive code and at least one initial negative code associated with the at least one historical explanatory text, and sorting at least one positive code and at least one negative code from the at least one initial positive code and the at least one initial negative code, respectively.
[0059] In the embodiment of the present disclosure, the code generation method based on the large-scale model may include operation S210, operation S230, and operation S240, and operation S220 adopts the above-mentioned implementation manner.
[0060] In each processing process of the large-scale model, there is usually a one-to-one mapping relationship between the input and output of the large-scale model, i.e., there is one output for one input. However, in multiple processing processes of every large-scale model, the same input may result in the same or different output. Therefore, for a history description text as an input of the large-scale model, it can be associated with at least one initial positive code and / or at least one initial negative code.
[0061] Therefore, the historical explanatory text corresponding to the positive and negative codes can be used to indirectly search for positive and negative codes that match the first explanatory text.
[0062] The historical description text and the first description text are texts used by the same user to describe different code needs. It can be understood that the historical description text and the first description text have the same expression style of the user. Therefore, when searching for at least one historical description text similar to the first description text, the search difference caused by the difference in expression style can be reduced.
[0063] In an embodiment of the present disclosure, searching a personalization database associated with the user for at least one historical explanatory text similar to the first explanatory text includes searching a personalization database associated with the user for one or more historical explanatory texts similar to the first explanatory text according to a level of similarity or a similarity threshold.
[0064] The similarity between the first explanatory text and the historical explanatory text can be calculated through various text similarity calculation methods, including, but not limited to, converting the first explanatory text and the historical explanatory text into a first vector and a fourth vector, respectively, and taking the similarity between the first vector and the fourth vector as the similarity between the first explanatory text and the historical explanatory text, or segmenting the first explanatory text and the historical explanatory text, respectively, extracting keywords therefrom to form a keyword set, calculating the similarity between the keyword set corresponding to the first explanatory text and the keyword set corresponding to the historical explanatory text, and taking the similarity as the similarity between the first explanatory text and the historical explanatory text, and further, or using a text comparison model, such as an n-gram language model, a TF-IDF model, a topic model (Latent Dirichlet Allocation, LDA), etc. to calculate the similarity between the first explanatory text and the historical explanatory text.
[0065] Determining at least one initial positive code and at least one initial negative code associated with at least one history description text includes: determining at least one initial positive code and / or at least one initial negative code associated with a history description text similar to a first description text, and then combining the at least one initial positive code and / or at least one initial negative code of each of the at least one history description text to obtain at least one initial positive code and at least one initial negative code. In this embodiment, for the same history description text, the initial positive code and the initial positive code can be selected simultaneously to improve the user's favorite distinction for the same history description text. Alternatively, for the same history description text, only the initial positive code or the initial positive code can be selected.
[0066] In an embodiment of the present disclosure, for at least one initial positive code, at least one positive code can be selected from the at least one initial positive code based on a similarity between the initial positive code and the first explanatory text. For at least one initial negative code, at least one negative code can be selected from the at least one initial negative code based on a similarity between the initial negative code and the first explanatory text.
[0067] Alternatively, the at least one initial positive code can be used directly as the at least one positive code and the at least one initial negative code can be used as the at least one negative code.
[0068] Further alternatively, code annotation texts for the initial positive codes may be obtained, and at least one positive code may be selected from the at least one initial positive code based on a similarity between the code annotation text and the first explanatory text. Code annotation texts for the initial negative codes may be obtained, and at least one negative code may be selected from the at least one initial negative code based on a similarity between the code annotation text and the first explanatory text.
[0069] In the embodiment of the present disclosure, based on the perspective of the input (historical explanatory text) of the large-scale model, at least one positive code and at least one negative code are indirectly searched from a personalized database associated with the user, thereby reducing the search difference caused by the different expression styles of users, improving the search accuracy, and improving the matching degree between the expanded second explanatory text and the code needs, which helps the large-scale model to output a target code that is more suitable for the characteristics of the user. In addition, by selectively creating the initial positive code and the initial negative code, the matching degree between the positive code and the negative code and the code needs can be further improved, which can further improve the matching degree between the expanded second explanatory text and the code needs, which helps to improve the accuracy of the output of the large-scale model.
[0070] FIG. 4A illustrates a schematic flow chart of searching for positive and negative codes matching a first description text according to one embodiment of the present disclosure.
[0071] As shown in FIG. 4A, in the embodiment 400A, a plurality of history explanatory texts similar to the first explanatory text 401 can be determined based on the similarity between the first explanatory text 401 and each history explanatory text in the personalization database, such as history explanatory text 402_1, history explanatory text 402_2, . . . history explanatory text 402_M. Each history explanatory text can be associated with at least one initial positive code and at least one initial negative code. For example, the history explanatory text 402_1 is associated with at least one initial positive code 4031_1 and at least one initial negative code 4031_2, . . . and the history explanatory text 402_M is associated with at least one initial positive code 403M_1 and at least one initial negative code 403M_2.
[0072] Based on the similarity, at least one positive code 4041 can be selected from the at least one initial positive code associated with each history description text, and at least one negative code 4042 can be selected from the at least one initial negative code associated with each history description text.
[0073] According to an embodiment of the present disclosure, searching for positive codes and negative codes matching the first explanatory text includes searching a personalization database associated with the user for at least one positive sample and at least one negative sample similar to the first explanatory text based on the history explanatory text and the code annotation text, both of which include the history explanatory text and the code annotation text, and determining positive codes and negative codes based on the positive code contained in each of the at least one positive sample and the negative code contained in each of the at least one negative sample.
[0074] In an embodiment of the present disclosure, the code generation method based on a large-scale model may include operation S210, operation S230, and operation S240, where operation S220 adopts the above-mentioned implementation scheme.
[0075] In an embodiment of the present disclosure, the personalized database includes positive samples and negative samples, both of which are in the form of text pairs, where the positive / negative samples include historical description texts as inputs of the large-scale model, the positive / negative samples as outputs of the large-scale model, and code annotation texts of the positive / negative samples.
[0076] The personalization database compiles a user's programming experience, expertise, programming preferences and style history, and can paint a portrait of the user of "thousands of people with thousands of faces", resulting in more accurate and customized code generation effects based on this personalization database.
[0077] The code annotation text may be included in the positive or negative code, separated from the code by an annotation symbol, and the code annotation text annotates the function, definition information, object type information, or parameter information, etc., of each line of code, e.g., input parameters, output parameters, etc. Alternatively, the code annotation text may be included individually in the positive or negative sample, annotating the overall function, definition information, object type information, or parameter information, etc., of the positive or negative code.
[0078] Code annotation text is used to enhance the readability of the code, is typically similar to the primary explanatory text, and can be in natural explanatory language for a variety of explanatory styles.
[0079] In an embodiment of the present disclosure, the history description text and the code annotation text can be stitched together, and at least one positive sample and at least one negative sample similar to the first description text can be searched for based on the similarity between the stitched text and the first description text. Alternatively, at least one initial positive sample and at least one initial negative sample can be searched for based on the similarity between the history description text (code annotation text) and the first description text, and at least one positive sample and at least one negative sample can be selected from the at least one initial positive sample and at least one initial negative sample based on the similarity between the code annotation text (history description text) and the first description text.
[0080] Then, a positive code contained in each of the at least one positive sample can be determined as a positive code that matches the first explanatory text, and a negative code contained in each of the at least one negative sample can be determined as a negative code that matches the first explanatory text.
[0081] An embodiment of the present disclosure introduces code annotation text similar to the first explanatory text, and uses both the first explanatory text and the code annotation text as criteria for searching positive samples and negative samples, thereby improving the search accuracy of determining positive samples and negative samples from the perspective of the input of the large-scale model (e.g., historical explanatory text) and the output of the large-scale model (such as code annotation text).
[0082] FIG. 4B illustrates a schematic flow chart of searching for a positive code matching the first description text according to another embodiment of the present disclosure.
[0083] 4B, in the embodiment 400B, the personalized data may include a plurality of positive samples and negative samples. For example, the positive sample 405_1 includes a history description text 405_11, a code annotation text 405_12, and a positive code 405_13.
[0084] Based on the similarity between the stitched text obtained by stitching the history explanatory text 405_11 and the code annotation text 405_12 and the first explanatory text 401, it can be determined whether the positive code 405_13 is used as a positive code matching the first explanatory text 401.
[0085] According to an embodiment of the present disclosure, generating a second explanatory text according to the first explanatory text, the positive code, and the negative code includes obtaining a first prompt word, a positive prompt word, and a negative prompt word, and combining the first prompt word, the positive prompt word, the negative prompt word, the first explanatory text, the positive code, and the negative code as the second explanatory text based on a prompt template.
[0086] In an embodiment of the present disclosure, the code generation method based on a large-scale model may include operation S210, operation S220, and operation S240, and operation S230 adopts the above-mentioned implementation scheme.
[0087] The first prompt word is associated with the first explanatory text, the positive prompt word is associated with the positive code, and the negative prompt word is associated with the negative code.
[0088] The prompt template is a pre-constructed prompt template used to guide the large-scale model. In this example, the positive and negative prompt words have identifiable active or inactive tendencies to guide the large-scale model to generate target codes by referencing the positive codes associated with the positive prompt words and the negative codes associated with the negative prompt words.
[0089] The positive and negative prompt words can be predefined, for example, in a prompt dictionary. Alternatively, the positive and negative prompt words can be extracted from the first explanatory text. Alternatively, if the positive and negative prompt words are not extracted from the first explanatory text, or if only the positive or negative prompt words are extracted, the positive and negative prompt words can be supplemented and obtained by a prompt dictionary.
[0090] In an embodiment of the present disclosure, the prompt template may also include a preset format for indicating the positional relationship between the first prompt word and the first explanatory text, the positional relationship between the positive prompt word and the positive code, and the positional relationship between the negative prompt word and the negative code, so as to quickly generate the second explanatory text by filling the first prompt word, the positive prompt word, the negative prompt word, the first explanatory text, the positive code, and the negative code into corresponding positions of the prompt template.
[0091] In addition, the first explanatory text, the positive code, and the negative code can be directly filled into the prompt template, or the first explanatory text, the positive code, or the negative code can be processed by cutting, supplementing, or the like, and the processed first explanatory text, the positive code, or the negative code can be filled into the prompt template.
[0092] According to an embodiment of the present disclosure, the code generation method based on a large-scale model may include operations S210 to S240, and before operation S240, further includes: searching for a code domain knowledge text matching the first explanation text from a personalized database; and updating the second explanation text using the code domain knowledge text and the second prompt word.
[0093] In the embodiment of the present disclosure, in addition to expanding the first explanatory text using positive and negative codes, the first explanatory text can also be expanded based on background knowledge in the code generation field. Specifically, the code domain knowledge text includes, but is not limited to, code domain knowledge such as textbooks, tutorials, interface documents, etc.
[0094] The personalized databases associated with different users can include generalized code domain knowledge, positive codes and negative codes personalized after the user has used the large-scale model.
[0095] In an embodiment of the present disclosure, a similarity between the first explanatory text and the domain knowledge text can be calculated, and at least one code domain knowledge text matching the first explanatory text can be searched for in a personalized database based on the similarity. Alternatively, the search can be performed not in the personalized database associated with the user but in another database that stores generalized domain knowledge text.
[0096] The above prompt template can also include a second prompt word related to the domain knowledge text, so that the retrieved code domain knowledge text can be filled into the prompt template to generate an updated second explanation text. The method of determining the second prompt word is similar to the method of determining the first prompt word, so it is not described again here.
[0097] In another embodiment, generating the second explanatory text from the first explanatory text, the positive code, and the negative code includes searching for at least one code domain knowledge text matching the first explanatory text, and constructing the second explanatory text from the first explanatory text, the code domain knowledge text, the positive code, the negative code, the first prompt word, the second prompt word, the positive prompt word, and the negative prompt word.
[0098] The embodiment of the present disclosure adds a new code domain knowledge text, and uses the first explanatory text as the input of the large-scale model, and the code domain knowledge text related to positive codes, negative codes, and domain background with favorites as the historical output of the large-scale model to jointly enhance the personalization level and content richness of the second explanatory text, which helps guide the large-scale model to further possess the user's characteristics, meet the user's needs, and output more accurate target codes.
[0099] FIG. 5 illustrates a schematic diagram of a second instruction text constructed based on a prompt template according to one embodiment of the present disclosure.
[0100] 5, the prompt template may include the following prompt words: a first prompt word 501, a second prompt word 507, a positive prompt word 503, and a negative prompt word 503. The first prompt word 501 may be, for example, "input text", the second prompt word 507 may be, for example, "background", the positive prompt word 503 may be, for example, "see", and the negative prompt word 503 may be, for example, "don't see".
[0101] The first explanatory text 502 entered by the user can be, for example, "I want a repetitive sentence written in grammar A, and the repetition judgment condition is xxx", the positive code 505 can be, for example, "while (condition xxx) {function xy;}", the negative code 506 can be, for example, "for (numeric assignment; condition xxx; change) {function xy;}", and the code domain knowledge text 508 can be, for example, "Grammar A specification format: AAAAAAA".
[0102] The prompt words in the filled prompt template can be combined with the input to obtain the second explanatory text.
[0103] In an embodiment of the present disclosure, a user can input a history description text, input a history description text personalized and expanded for the history description text into the large-scale model, and output a history code. For the history code output by the large-scale model, the user can divide the history code into a positive code and a negative code through a favorite operation.
[0104] According to an embodiment of the present disclosure, the step of determining positive codes and negative codes for the history codes output by the large-scale model includes determining the history code as a negative code associated with the history code based on a first favorite selection operation by the user for the history code, determining the history code as a positive code associated with the history code based on a second favorite selection operation by the user for the history code, and storing the positive codes and negative codes in a personalization database associated with the user.
[0105] In an embodiment of the present disclosure, the first favorite selection operation, i.e., the inactive favorite operation, is an operation such as discarding, closing, or canceling the target code, and the second favorite selection operation, i.e., the active favorite operation, is an operation such as selecting, copying, or confirming the target code.
[0106] In the embodiment of the present disclosure, the positive code or the negative code may be the complete code output by the large-scale model, or may be a partial code intercepted from the complete code output by the large-scale model.
[0107] When storing a positive code or a negative code, the positive code or negative code can be stored in association with the currently input historical explanatory text, just as the large-scale model quickly searches for positive and negative codes that match the first explanatory text based on the historical explanatory text during a subsequent personalized expansion operation.
[0108] By using the large-scale model multiple times, the user's own favorite operation is used to continuously supplement the personalized data to the personalized database, thereby achieving self-feedback expansion of the personalized database. Compared with the conventional RAG technology that rarely updates the search database or only supplements general field information, the embodiment of the present disclosure can effectively expand the code generation effect of the large-scale model through self-feedback expansion.
[0109] In the embodiment of the present disclosure, considering that the history code output by the large-scale model based on the history description text and the target code output based on the first description text may not completely meet the code needs, the user can edit the history code or the target code to a code that meets the code needs through a simple editing operation. Therefore, after the user performs a second favorite selection operation on the history code, an editing operation on the history code is supported to optimize the positive code that is fed back to the personalization database.
[0110] According to another embodiment of the present disclosure, the step of determining a positive code and a negative code further includes determining the history code determined based on the second favorite selection operation as an initial positive history code, and determining a history code based on a user editing operation on the initial positive history code, and determining the edited code as a positive code.
[0111] The code output by the large-scale model in the field of deep learning or other fields is usually a relatively framework code, so the user's editing operation is usually an insertion operation, that is, an operation of inserting parameters, functions, and other detailed code based on the output of the large model, and the editing operation may also be an operation such as correction, deletion, etc. of the output of the large-scale model.
[0112] Determining the edit code based on the user's edit operation on the initial positive history code includes determining the code at the edited position as the edit code. For example, the edit code can be determined by comparing the code before and after the edit operation line by line.
[0113] In an embodiment of the present disclosure, an edit code can be determined through a user's editing operation to incorporate a positive code that can be improved to meet the user's code needs without fine-tuning the large-scale model, and the edit code can be used as a positive code, which can improve the consistency between the output of the subsequent large-scale model and the user's code needs at a low cost, thereby improving the user's experience.
[0114] According to an embodiment of the present disclosure, determining an edit code in response to a user's editing operation on an initial positive history code includes determining an edit position where the editing operation starts and a code feature of the initial positive history code located after the edit position, and in response to determining that the user has ended the editing operation, obtaining an intermediate positive history code at an end time, and determining an edit code based on the code feature and the intermediate positive history code.
[0115] Since a user's editing operation on an initial positive history code usually takes time, when starting an editing operation, the editing position where the editing operation starts and the code features of the initial positive history code located after the editing position can be determined. Specifically, the initial positive history code output by the large-scale model can be used as the basis for the user's editing operation, and the editing position where the editing operation starts is determined based on the interaction between the user and the terminal device.
[0116] The edit location where the edit operation begins may be expressed as a line number of code, a target line of code that is the subject of the edit operation, or the like.
[0117] The edit position divides the initial positive history code into two parts, namely, the initial positive history code before the edit position and the initial positive history code after the edit position. Usually, the edit position where the edit operation starts is the start position of the edit code, so that the end position of the edit code can be determined based on the initial positive history code after the edit position, so that the initial positive history code between the start position and the end position is the edit code.
[0118] A code feature of the initial positive history code following the edit location is used to identify the end location of the edited code. Specifically, the code feature may be the initial positive history code itself following the edit location. Alternatively, the code feature may be the number of lines of code of the initial positive history code following the edit location. Still alternatively, the code feature may be the first line of code following the edit location.
[0119] Determining that the user has finished the edit operation includes receiving a user interactive operation on a preset control, such as a click on a "Submit" control, or determining that the user has finished the edit operation after a predetermined length of time. The predetermined length of time can be determined based on the current user's history edit time length. The user is considered to have completed the edit operation of the initial positive history code after the predetermined length of time. The end time is also a predetermined length of time from the start of the edit operation.
[0120] Regarding the method of determining when to end an editing operation after a predetermined length of time, the user may insensitively record intermediate positive history codes without any user action.
[0121] After the intermediate positive history code is determined, the end position of the edited code can be identified based on the code feature and the intermediate positive history code, so that the initial positive history code between the start position and the end position can be determined as the edited code.
[0122] For example, for an initial positive history code that contains a total of 10 lines of code, the edit position is the second line, and the code features of the initial positive history code after the edit position are 8 lines, that is, 8 lines remain. The intermediate positive history code obtained after the user edit operation is 12 lines, and the edit operation end position determined from the code features and the intermediate positive history code is the 4th line or the 9th line from the bottom. Therefore, the codes in the 2nd, 3rd, and 4th lines are the edit code.
[0123] The embodiment of the present disclosure can quickly identify edited codes by determining edited codes based on the code features of the initial positive history code and the intermediate positive history code following the edit position. Also, by using edited codes that were not learned by the large-scale model as positive codes, the user edited codes can be self-feedback expanded into the personalized database, which helps to guide the large-scale model to generate more accurate codes by storing fewer and more effective positive codes and using less space for second explanatory text.
[0124] In the embodiment of the present disclosure, for the target code output in operation S240, the user can also perform a favorite operation on the target code to generate a positive code or a negative code according to the target code. The first explanatory text, the positive code or the negative code of this code generation process is self-feeded back to the personalized database, so as to further enhance the user input in the next code generation process.
[0125] Similarly, the method of determining positive and negative codes for the target code is similar to the method of determining positive and negative codes for the history code, and will not be described again here.
[0126] FIG. 6 illustrates a schematic diagram of a scenario for determining edit codes according to an embodiment of the present disclosure.
[0127] 6, a scenario 600 includes an initial positive history code 601 and an intermediate positive history code 602. A user starts an editing operation on the third line of the initial positive history code 601 by operating a cursor 6011, that is, the editing position is the third line. The code feature of the initial positive history code after the editing position may be two lines, and two lines are intended to remain.
[0128] After a predetermined time period, for example 3 minutes, the intermediate positive history code 602 for the end time is obtained. By comparing the code features with the intermediate positive history code 602, an edit code 6021 is determined.
[0129] In order to facilitate understanding of the implementation method of the present disclosure, the following takes code generation in the field of deep learning as an example, and describes optional implementation schemes through FIG. 7.
[0130] FIG. 7 illustrates a schematic diagram of a scenario for determining edit codes according to an embodiment of the present disclosure.
[0131] In operation S701, a first explanatory text is input. A user can input a first explanatory text expressing a code need in the field of deep learning. A personalized database D1 associated with the user includes a code field knowledge text in the field of deep learning, a positive code and a negative code of the history of the user using the large-scale model M1.
[0132] In operation S702, a positive code is searched. For example, a positive code that matches the first explanatory text can be searched in a personalization database D1 associated with the user. The positive code can be a positive code that realizes a deep learning function, such as a positive code for building a deep learning model or a field deep learning model.
[0133] In operation S703, a negative code is searched. For example, a negative code that matches the first explanatory text can be searched in a personalization database D1 associated with the user. Similarly, the negative code can be a negative code that realizes a deep learning function, such as a negative code for building a deep learning model or a field deep learning model.
[0134] In operation S704, a second explanatory text is generated. The second explanatory text can be generated based on the prompt template according to the first explanatory text input in operation S701, the positive code retrieved in operation S702, and the negative code retrieved in operation S703.
[0135] In operation S705, a target code is output. The second explanatory text output in operation S704 is input to the large scale model M1, and a target code is output.
[0136] In operation S706, it is determined whether to adopt. The user can perform a first favorite operation or a second favorite operation on the target code to reflect whether to adopt the target code. Correspondingly, the terminal device can determine whether the user adopts based on the interaction with the user. If the target code is not adopted, it proceeds to operation S707, and if the target code is adopted, it proceeds to operation S708.
[0137] In operation S707, a negative sample is constructed, for example, the first explanatory text and the target code may be combined to construct the negative sample.
[0138] In operation S708, the cursor position and the code characteristic at the time of adoption are recorded. The cursor allows the user to specify the edit position of the edit operation, for example, the cursor position is the edit position. The code characteristic can be the number of lines of code after the edit position when the edit operation begins.
[0139] In operation S709, an intermediate positive history code is recorded when the editing operation is completed. For example, after a predetermined length of time, the user is deemed to have completed the editing operation, at which point an intermediate positive history code is recorded.
[0140] In operation S710, an edit code is determined. Based on the code characteristics and the intermediate positive history code, an edit code is determined.
[0141] In operation S711, a positive sample is constructed, for example, a first explanatory text and an edit code may be combined to construct the positive sample.
[0142] In addition, domain knowledge text can also be input through operation S712 to complete the initialization operation of the personalized database D1 associated with the user. As the user continues to use the large-scale model M1, the positive samples and negative samples are continuously combined and obtained to supplement the personalized database D1, and the effect of extending the code generation of the large-scale model becomes increasingly obvious, thereby realizing more accurate and customized code generation.
[0143] Therefore, the present disclosure can effectively extend the code generation effect of large-scale models in the field of deep learning through self-feedback extension, and at the same time realize automatic explanation of deep learning user (developer) portraits, customizablely meet the needs of users' specific programming preferences and style, and effectively improve the user experience.
[0144] FIG. 8 illustrates a schematic block diagram of a large-scale model-based code generator according to an embodiment of the present disclosure.
[0145] As shown in FIG. 8, the large-scale model-based code generator 800 includes an acquisition module 810, a search module 820, a first generation module 830, and a second generation module 840.
[0146] The acquisition module 810 is used to acquire a first explanatory text input by a user that represents the code needs.
[0147] The search module 820 is used to search for positive and negative codes that match the first explanatory text, and the positive and negative codes are determined based on the user's favorite operations on historical codes from which the large-scale model was output.
[0148] The first generating module 830 is used to generate a second explanatory text according to the first explanatory text, the positive code and the negative code.
[0149] The second generation module 840 is used to input the second explanatory text into the large-scale model and output a target code that matches the code needs.
[0150] According to an embodiment of the present disclosure, the search module includes a first search sub-module, a first determination sub-module, and a second determination sub-module.
[0151] The first search submodule is used to search a personalization database associated with the user for at least one historical explanatory text similar to the first explanatory text.
[0152] The first determination submodule is used to determine at least one initial positive code and at least one initial negative code associated with the at least one historical explanation text.
[0153] The second decision sub-module is used to sort at least one positive code and at least one negative code from the at least one initial positive code and the at least one initial negative code, respectively.
[0154] According to an embodiment of the present disclosure, the search module further includes a second search sub-module and a third determination sub-module.
[0155] The second search submodule is used to search at least one positive sample and at least one negative sample similar to the first description text from a personalization database associated with the user based on the history description text and the code annotation text, where both the positive sample and the negative sample include the history description text and the code annotation text.
[0156] The third determining submodule is used to determine a positive code and a negative code based on the positive code respectively included in the at least one positive sample and the negative code respectively included in the at least one negative sample.
[0157] According to an embodiment of the present disclosure, the first generating module includes an acquiring sub-module and a combining sub-module.
[0158] The acquisition sub-module is used to acquire a first prompt word, a positive prompt word, and a negative prompt word.
[0159] The combination submodule is used for combining the first prompt word, the positive prompt word, the negative prompt word, the first instruction text, the positive code, and the negative code as the second instruction text based on the prompt template.
[0160] According to an embodiment of the present disclosure, the large-scale model-based code generating apparatus 800 further includes a third search sub-module and an update sub-module.
[0161] The third search sub-module is used to search the domain knowledge text matching the first explanatory text from the personalized database.
[0162] The update sub-module is used to update the second explanation text using the domain knowledge text and the second prompt word.
[0163] According to an embodiment of the present disclosure, the large-scale model-based code generating apparatus 800 further includes a favorite chord determining module, which includes a first selecting sub-module, a second selecting sub-module, and a storing sub-module.
[0164] The first selection sub-module is used for determining the history code as a negative code associated with the history code according to a first favorite selection operation by the user for the history code.
[0165] The second selection sub-module is used for determining the history code as a positive code associated with the history code according to the user's second favorite selection operation for the history code.
[0166] The storage sub-module is used to store the positive and negative codes in a personalized database associated with the user.
[0167] According to an embodiment of the present disclosure, the favorite chord determination module further includes a fourth determination sub-module and an editing sub-module.
[0168] The fourth determination sub-module is used to determine the history code determined based on the second favorite selection action as an initial positive history code.
[0169] The editing sub-module is used to determine an editing code based on an editing operation by a user on an initial positive history code, and to determine the editing code as a positive code.
[0170] According to an embodiment of the present disclosure, the editing sub-module includes a first determining unit, an obtaining unit, and a second determining unit.
[0171] The first determination unit is used to determine an edit position where an edit operation is initiated and a code feature of an initial positive history code located after the edit position.
[0172] The obtaining unit is used for obtaining an intermediate positive history code at the end time in response to determining that the user has finished the editing operation.
[0173] The second determining unit is used to determine an edit code based on the code characteristics and the intermediate positive history code.
[0174] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program.
[0175] According to an embodiment of the present disclosure, an electronic device includes at least one processor and a memory communicatively connected to the at least one processor, the memory storing instructions executable by the at least one processor, the instructions being executed by the at least one processor such that the at least one processor performs the method.
[0176] According to an embodiment of the present disclosure, a non-transitory computer readable storage medium stores computer instructions that cause a computer to perform the method.
[0177] According to an embodiment of the present disclosure, a computer program implements the above method when executed by a processor.
[0178] 9 is a schematic block diagram of an electronic device 900 suitable for implementing a large-scale model-based code generation method according to an embodiment of the present disclosure. The electronic device may represent various types of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may further represent various types of mobile devices, such as personal digital processes, mobile phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely exemplary and are not intended to limit the implementation of the present disclosure as described and / or claimed herein.
[0179] 9, the device 900 includes a computing unit 901, which can execute various appropriate operations and processes based on a computer program stored in a read-only memory (ROM) 902 or loaded from a storage unit 908 into a random access memory (RAM) 903. The RAM 903 can further store various programs and data necessary for the operation of the device 900. The computing unit 901, the ROM 902, and the RAM 903 are interconnected by a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0180] Several components in device 900 are connected to an I / O interface 905, including an input unit 906, e.g. a keyboard, a mouse, etc., an output unit 907, e.g. various types of displays, speakers, etc., a storage unit 908, e.g. a magnetic disk, an optical disk, etc., and a communication unit 909, e.g. a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows device 900 to exchange information / data with other devices via a computer network, e.g. the Internet, and / or various telecommunication networks.
[0181] The computing unit 901 can be various general-purpose and / or dedicated processing modules having processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various running machine learning model algorithm computing units, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 901 executes the methods and processes described above, such as the large-scale model-based code generation method. For example, in some embodiments, the large-scale model-based code generation method is implemented as a computer software program and tangibly included in a machine-readable medium, such as the storage unit 908. In some embodiments, some or all of the computer program can be loaded and / or installed in the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the large-scale model-based code generation method described above can be executed. Alternatively, in other embodiments, the computing unit 901 may be arranged to perform the large-scale model-based code generation method in any other suitable manner (eg, firmware).
[0182] Various embodiments of the systems and techniques described herein may be realized in digital electronic circuitry systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include being embodied in one or more computer programs executed and / or interpreted by a programmable system including at least one programmable processor, which may be a special purpose or general purpose programmable processor, capable of receiving data and instructions from and transmitting data and instructions to a storage system, at least one input device, and at least one output device.
[0183] The program codes for implementing the methods of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general purpose computer, a special purpose computer or other programmable data processing apparatus, such that when the program code is executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are performed. The program codes can be fully executed on a machine, partially executed on a machine, partially executed as a separate software package on a device and partially executed on a remote machine, or entirely executed on a remote machine or server.
[0184] In the context of the present disclosure, a machine-readable medium may be a tangible medium, capable of containing or storing a program used by or in combination with an instruction execution system, device or apparatus. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium includes, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any suitable combination of the above. More specific examples of machine-readable storage media include one or more wire-based electrical connections, portable computer disks, hard disks, random access memories (RAMs), read-only memories (ROMs), erasable programmable read-only memories (EPROMs or flash memories), optical fibers, compact, convenient read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the above.
[0185] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user, and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also provide interaction with a user. For example, the feedback provided to the user can be any form of sensing feedback (e.g., visual feedback, auditory feedback, or tactile feedback), and can receive input from the user in any form (including voice input, speech input, or tactile input).
[0186] The systems and techniques described herein may be implemented in a computing system including background components (e.g., a data server), or a computing system including middleware components (e.g., an application server), or a computing system including front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user may interact with embodiments of the systems and techniques described herein), or a computing system including any combination of such background, middleware, or front-end components. The components of the system may be connected to each other by any form or medium of digital data communication (e.g., a communications network). Examples of communications networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0187] The computer system may include a client and a server. The client and the server are generally remote from each other and usually interact with each other through a communication network. The client-server relationship is created by a computer program running on a corresponding computer and having a client-server relationship with each other. The server may be a cloud server, a distributed system server, or a server combined with a blockchain.
[0188] It should be understood that various types of flows shown above may be used, and each operation may be rearranged, added, or deleted. For example, each step described in the present disclosure may be performed in parallel, sequentially, or in a different order, and the present disclosure is not limited thereto as long as it can achieve the desired results of the disclosed technical solution.
[0189] The above specific embodiments do not limit the scope of protection of the present disclosure. Those skilled in the art should understand that various modifications, combinations, subcombinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principle of the present disclosure should be included within the scope of protection of the present disclosure.
Claims
1. Obtaining a first explanatory text input by a user that represents a code need; Searching for positive codes and negative codes that match the first explanatory text, the positive codes and the negative codes being determined based on favorite operations by the user for history codes output by a large-scale model; generating a second explanatory text according to the first explanatory text, the positive code, and the negative code; inputting the second explanatory text into the large scale model and outputting target code matching the code needs. A method for code generation based on large-scale models.
2. retrieving positive and negative codes matching the first explanatory text, retrieving at least one historical explanatory text similar to the first explanatory text from a personalization database associated with the user; determining at least one initial positive code and at least one initial negative code associated with at least one of said historical explanatory texts; and selecting at least one of the positive code and at least one of the negative code from the at least one initial positive code and the at least one initial negative code, respectively. The method of claim 1.
3. retrieving positive and negative codes matching the first explanatory text, Searching a personalized database associated with the user for at least one positive sample and at least one negative sample similar to the first explanatory text by a history explanatory text and a code annotation text, wherein the positive sample and the negative sample both include the history explanatory text and the code annotation text; determining the positive code and the negative code from a positive code included in each of the at least one positive sample and a negative code included in each of the at least one negative sample. The method of claim 1.
4. generating a second explanatory text from the first explanatory text, the positive code, and the negative code, obtaining a first prompt word, a positive prompt word, and a negative prompt word; combining the first prompt word, the positive prompt word, the negative prompt word, the first instruction text, the positive code, and the negative code as the second instruction text based on a prompt template. The method of claim 2.
5. Searching the personalized database for code domain knowledge text matching the first explanatory text; and updating the second explanation text using the code domain knowledge text and second prompt words. The method according to claim 4.
6. Determining the positive code and the negative code includes: determining the history code as a negative code associated with the history code by a first favorite selection operation by the user for the history code; determining the history code as a positive code associated with the history code by a second favorite selection operation by the user for the history code; storing the positive code and the negative code in a personalized database associated with the user. The method according to any one of claims 1 to 5.
7. determining the history code determined based on the second favorite selection operation as an initial positive history code; determining an edited code based on an edit operation by the user on the initial positive history code, and determining the edited code as the positive code. The method according to claim 6.
8. Determining an edit code by an edit operation by the user on the initial positive history code, determining an edit location to begin the edit operation and a code feature of an initial positive history code located after the edit location; In response to the user determining that the editing operation is terminated, obtaining an intermediate positive history code at a termination time; determining the edit code according to the code features and the intermediate positive history code. The method of claim 7.
9. An acquisition module for acquiring a first explanatory text input by a user, the first explanatory text representing the code need; A search module for searching for positive codes and negative codes that match the first explanatory text, the positive codes and the negative codes being determined based on a favorite operation by the user for a history code output by a large-scale model; a first generation module for generating a second explanatory text according to the first explanatory text, the positive code, and the negative code; a second generation module that inputs the second explanatory text into the large-scale model and outputs target code that matches the code needs. A code generator based on large models.
10. The search module includes: a first search submodule for searching a personalization database associated with the user for at least one historical explanatory text similar to the first explanatory text; a first determination submodule for determining at least one initial positive code and at least one initial negative code associated with at least one of the historical explanatory texts; a second determination sub-module for sorting at least one of the positive codes and at least one of the negative codes from the at least one initial positive code and the at least one initial negative code, respectively.
10. The apparatus of claim 9.
11. The search module includes: a second search sub-module for searching at least one positive sample and at least one negative sample similar to the first description text from a personalized database associated with the user by using a history description text and a code annotation text, the positive sample and the negative sample both including the history description text and the code annotation text; and a third determination submodule for determining the positive code and the negative code according to a positive code included in each of the at least one positive sample and a negative code included in each of the at least one negative sample.
10. The apparatus of claim 9.
12. The first generation module: an acquisition submodule for acquiring a first prompt word, a positive prompt word, and a negative prompt word; a combination submodule for combining the first prompt word, the positive prompt word, the negative prompt word, the first instruction text, the positive code, and the negative code as the second instruction text based on a prompt template.
11. The apparatus of claim 10.
13. a third search sub-module for searching the personalized database for domain knowledge texts matching the first explanatory text; and an updating submodule for updating the second explanation text by using the domain knowledge text and the second prompt word.
13. The apparatus of claim 12.
14. Further comprising a favorite chord determination module; The favorite chord determination module includes: a first selection submodule for determining the history code as a negative code associated with the history code according to a first favorite selection operation by the user for the history code; a second selection sub-module for determining the history code as a positive code associated with the history code according to a second favorite selection operation by the user for the history code; a storage sub-module for storing the positive code and the negative code in a personalization database associated with the user. Apparatus according to any one of claims 9 to 13.
15. a fourth determination sub-module for determining the history code determined based on the second favorite selection operation as an initial positive history code; and an editing submodule for determining an edit code according to an editing operation by the user on the initial positive history code, and determining the edit code as the positive code.
15. The apparatus of claim 14.
16. The editing sub-module: a first determination unit for determining an edit position at which the edit operation starts and a code characteristic of an initial positive history code located after the edit position; an acquisition unit for acquiring an intermediate positive history code at a termination time in response to the user determining that the editing operation has been terminated; a second determining unit for determining the edit code according to the code characteristics and the intermediate positive history code.
16. The apparatus of claim 15.
17. At least one processor; a memory communicatively connected to the at least one processor; The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor such that the at least one processor performs the method of any one of claims 1 to 5. electronic equipment.
18. A non-transitory computer readable storage medium having stored thereon computer instructions for causing a computer to carry out the method according to any one of claims 1 to 5.
19. A computer program which, when executed by a processor, implements the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Automatic labeling of text data
JP2024524060A
Automatic labeling of text data
US20220414137A1
Systems and methods for a conversational framework of program synthesis
US20230280985A1
Cited By
Code conversion system and program
JP7829785B1