Java code generation method and system and storage medium

By extracting keywords and semantic entities of the design text, combining large models and multi-agent architectures, analyzing and iterative evaluation of detailed design contents, and generating high-quality Java code, the problem of poor code generation quality in the existing technology is solved and the accuracy and efficiency of code generation is improved.

CN119883274APending Publication Date: 2025-04-25WEBANK (CHINA)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411935710.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

In the prior art, the Java code generation method cannot correctly understand the business logic requirements and the specific implementation of code engineering due to the coarse granularity of the design text description, resulting in poor quality of the generated Java code.

Method used

By receiving design text, extracting keywords and semantic entities, combining large models and entity extraction models for analysis, a list of data entities, semantic entities and functional points for detailed design content is generated, and a multi-agent architecture and RAG technology is used for searching and generation, and iterative evaluation is performed, and high-quality java code is finally generated.

Benefits of technology

It improves the quality and generation quality of code knowledge retrieval, solves the problem of excessive granularity of design text description, and the generated Java code is more in line with business logic needs, improving the work efficiency of developers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883274A_ABST
    Figure CN119883274A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a java code generation method and system and a storage medium. The method comprises the steps that detailed design content of a design text is received, the detailed design content is analyzed and extracted to obtain keywords, the keywords are matched with a stock data table and key fields in a service system, and a data entity list of the detailed design content is obtained; extracting universal semantic entity fragments in the detailed design content through an entity extraction algorithm to obtain a semantic entity list contained in the detailed design content; and inputting the code / document knowledge and the final implementation plan into the large model as a third cue word to obtain a code specification, performing review and implementation degree evaluation on the code specification, and outputting a finally generated code after the evaluation is passed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer software technology, and specifically relates to a Java code generation method, system and storage medium. Background Art

[0002] Existing code generation methods include: performing sliding window segmentation on the detailed design text (for example, cutting at intervals of N characters), calling a vectorization model for each text segment, and generating vectors. The same method is used to segment the source code / related technical documents and generate corresponding vectors as a knowledge base. The text vectors of the detailed design are searched in the knowledge base to obtain similar knowledge fragments. The detailed design text and similar knowledge fragments are combined and input into the large model, and the large model is used for code generation.

[0003] The description granularity of the design text in the existing technology is coarse, and there is a huge logical and semantic gap between the code and the natural language itself. When input into the large model, it is impossible to correctly understand the logical requirements of the business and the specific implementation in the code engineering, resulting in poor quality of the generated Java code. Summary of the invention

[0004] The present application provides a Java code generation method, system and storage medium, which can effectively identify various sensitive data of long text data, realize the identification of various sensitive data, and improve the identification efficiency and recognition effect.

[0005] In a first aspect, the present application provides a method for generating a Java code, the method comprising the following steps:

[0006] Receive detailed design content of a design text, analyze and extract keywords from the detailed design content, match the keywords to stock data tables and key fields in a business system, and obtain a data entity list of the detailed design content; extract common semantic entity fragments from the detailed design content through an entity extraction algorithm to obtain a semantic entity list contained in the detailed design content; after understanding the detailed design content, extract and summarize the function / operation implementation in the detailed design content to obtain a functional point list of the detailed design content; splice the data entity list, the semantic entity list, and the functional point list to obtain a functional point text list;

[0007] According to the detailed design content, a search is performed in the disassembly knowledge base to obtain system framework knowledge, similar disassembly cases and relationship maps between functions associated with the detailed design content; the system framework knowledge, similar disassembly cases, relationship maps between functions and detailed design content are input as first prompt words into the large model to obtain an implementation plan of the detailed design content; according to the detailed design content, a search is performed in the inspection knowledge base to obtain inspection knowledge associated with the detailed design content; the inspection knowledge and the implementation plan are input as second prompt words into the large model to obtain a final implementation plan of the detailed design content;

[0008] An iterative search is performed based on the function point text list to obtain the code / document knowledge associated with the function point text list, the code / document knowledge and the final implementation plan are input into the large model as the third prompt word to obtain the code specification, the code specification is reviewed and the degree of implementation is evaluated, and after the evaluation passes, the final generated code is output.

[0009] In a second aspect, a Java code generation system is provided, the system comprising:

[0010] An acquisition unit, used for receiving detailed design content of a design document;

[0011] An analysis and processing unit is used to analyze and extract keywords from the detailed design content, match the keywords to stock data tables and key fields in the business system, and obtain a data entity list of the detailed design content; extract common semantic entity fragments from the detailed design content through an entity extraction algorithm to obtain a semantic entity list contained in the detailed design content; after understanding the detailed design content, extract and summarize the function / operation implementation in the detailed design content to obtain a functional point list of the detailed design content; and splice the data entity list, the semantic entity list, and the functional point list to obtain a functional point text list;

[0012] The analysis and processing unit is further used to retrieve the system framework knowledge, similar disassembly cases and relationship maps between functions associated with the detailed design content in the disassembly knowledge base according to the detailed design content; input the system framework knowledge, similar disassembly cases, relationship maps between functions and detailed design content as first prompt words into the large model to obtain the implementation plan of the detailed design content; retrieve the inspection knowledge base according to the detailed design content to obtain the inspection knowledge associated with the detailed design content; input the inspection knowledge and the implementation plan into the large model as second prompt words to obtain the final implementation plan of the detailed design content;

[0013] A retrieval and evaluation unit is used to perform iterative retrieval based on the function point text list to obtain the code / document knowledge associated with the function point text list, input the code / document knowledge and the final implementation plan as the third prompt word into the large model to obtain the code specification, review the code specification and evaluate the degree of implementation, and output the final generated code after the evaluation is passed.

[0014] In a third aspect, the present application provides a computer storage medium storing a computer program for electronic data exchange, wherein the computer program enables a computer to execute some or all of the steps described in the first aspect of the present application.

[0015] The embodiments of the present application have the following beneficial effects:

[0016] The technical solution of this application relies on the intelligent agent to extract the detailed design elements of the original detailed design, and combines the semantic understanding of the big model, the entity extraction model, the data table, DDL and other business-related specifications for keyword matching. It can completely identify and obtain the semantic entities, data entities | fields and functional points involved in this detailed design and other elements that need to be retrieved, effectively improving the retrieval quality of code knowledge retrieval, and thereby improving the generation quality of Java business code under the overall framework. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 is a schematic diagram of the structure of a computer provided in an embodiment of the present application;

[0019] Figure 2 It is a flowchart of a method for generating a Java code provided in an embodiment of the present application;

[0020] Figure 3 It is a structural diagram of a Java code generation system provided in an embodiment of the present application;

[0021] Figure 4 It is a structural diagram of a Java code generation system provided by this application. DETAILED DESCRIPTION

[0022] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0023] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, systems, products or devices. The " / " in this application means "or".

[0024] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0025] The following is an introduction to the relevant terms involved in this application.

[0026] Sensitive data refers to data that may cause serious harm to society or individuals if leaked. It includes personal privacy data, such as name, ID number, address, phone number, bank account, email, password, medical information, educational background, etc. It also includes data that is not suitable for enterprises or social institutions to publish, such as the business situation of the enterprise, the network structure of the enterprise, IP address list, etc.

[0027] LLM (Large Language Model) is a deep learning model trained with a large amount of text data. It can perform a variety of natural language processing tasks, such as text classification, question answering, and dialogue. They usually use the Transformer architecture and are trained through self-supervised learning methods.

[0028] Multi-Agent Architecture Multi-agent architecture is a distributed system architecture in which each agent can perform tasks independently while interacting and collaborating with other agents to achieve the overall goal.

[0029] RAG (Retrieval-Augmented Generation) is a technology that combines information retrieval and natural language generation, and enhances text generation capabilities by retrieving external knowledge bases. The RAG model combines language models and information retrieval technology. When it needs to generate text or answer questions, it retrieves relevant information from a large collection of documents, and then uses this information to guide text generation, thereby improving the quality and accuracy of predictions. It can provide external knowledge sources for large models to generate accurate and contextual answers while reducing model hallucinations.

[0030] A large model prompt is a language or sentence used to interact with an artificial intelligence model. Its main function is to provide the AI ​​model with context and parameter information for input information, thereby guiding the model to generate the desired output. In the context of large models, prompts are like a magic spell that can stimulate the potential of models and guide them to generate text, answer questions, or perform tasks according to instructions.

[0031] DDL (Data Definition Language) is a concept closely related to database operations. DDL is a subset of SQL (Structured Query Language) and is specifically used to define and manage the structure of a database. Specifically, DDL allows database administrators, developers, and other users to create, modify, and delete objects in a database, such as tables, indexes, views, etc. It is used to define database objects: databases, tables, columns, etc. Java programs can manage database structures by executing DDL statements.

[0032] Vectorization model: used to vectorize text. The cosine distance between the obtained vectors can be calculated, which can be used to approximate the similarity between the texts corresponding to the two vectors (the larger the cosine distance, the more similar the two texts are).

[0033] Rearrangement model: used to reorder the retrieval obtained by vector retrieval, putting the retrieval blocks that are more similar to the target text in front.

[0034] The following describes the system architecture of a computer related to an embodiment of the present application.

[0035] The present application also provides a computer 10, such as Figure 1As shown, it includes at least one processor 11 and a memory 12, and may also include a communications interface 14 and a bus 13. The processor 11, the memory 12 and the communications interface 14 may communicate with each other through the bus 13. The communications interface 14 may transmit information. The processor 11 may call the logic instructions in the memory 12 to execute the method in the above embodiment.

[0036] In addition, the logic instructions in the above-mentioned memory 12 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. The above-mentioned logic instructions can also become an operating system, application program or computer program, etc.

[0037] The memory 12 is a computer-readable storage medium that can be configured to store software programs, computer executable programs, such as program instructions or modules corresponding to the methods in the embodiments of the present disclosure. The processor 11 executes functional applications and data processing by running the software programs, instructions or modules stored in the memory 12, that is, implementing the methods in the above embodiments.

[0038] The memory 12 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the computer 10, etc. In addition, the memory 12 may include a high-speed random access memory and may also include a non-volatile memory. For example, a variety of media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, may also be a transient storage medium.

[0039] It is understandable that the computer in this embodiment can be understood as a server, for example, the server includes a cloud server or an edge server, and no unique limitation is made here. Of course, in an optional technical scenario, the above-mentioned computer can also be a personal computer (PC), a tablet computer, a laptop computer, and other smart devices. This application does not limit the specific form of the above-mentioned computer, as long as the above-mentioned computer has an operating system and shortcuts.

[0040] The specific methods are introduced in detail below.

[0041] See also Figure 2 , this application also provides a method for generating java code, Figure 2 A flow chart of a method for generating a Java code provided by the present application, the method can be used in Figure 1 The computer shown in the figure can be a personal computer, a server, a tablet computer, a laptop computer or other smart devices. The computer can form a blockchain network or a cloud network. The method is as follows: Figure 2 As shown, the following steps are included:

[0042] Step S21, receiving the detailed design content of the design text, analyzing and extracting the detailed design content to obtain keywords, matching the keywords with the stock data tables and key fields in the business system, and obtaining a data entity list of the detailed design content; extracting common semantic entity fragments in the detailed design content through an entity extraction algorithm to obtain a semantic entity list contained in the detailed design content; after understanding the detailed design content, extracting and summarizing the function / operation implementation in the detailed design content to obtain a functional point list of the detailed design content; splicing the data entity list, the semantic entity list and the functional point list to obtain a functional point text list;

[0043] The above-mentioned detailed design content of the example may specifically be all the content input by the user, for example: the detailed design content may be: querying work order information, order information, and call records according to the customer's ID and primary key, and converting the customer ID field.

[0044] For example, the implementation method of the above step S201 may specifically include:

[0045] The detailed design content is input into the language model to perform keyword extraction to obtain keywords, the keywords are matched with the existing data tables and key fields in the business system, and a data entity list of the detailed design content is obtained, and the above-mentioned data entity list can also be called a data field list; the language model is called to extract the common semantic entity fragments in the detailed design content through the entity extraction algorithm to obtain a semantic entity list contained in the detailed design content; after calling the language model to understand the detailed design content, the function / operation implementation in the detailed design content is extracted and summarized to obtain a list of functional key points of the detailed design content, and then the data entity list, the semantic entity list and the functional key point list are spliced ​​according to a preset format to obtain a text list of functional points.

[0046] For example, the language model of the above-mentioned keyword extraction, entity extraction algorithm and functional key point algorithm can be the same model, such as the LLM model. Of course, in other application scenarios, different models can also be used to implement the above-mentioned functions. This application does not limit the specific form of expression of the above-mentioned language model.

[0047] For example, the above preset format can be, according to the data entity list, the semantic entity list and the function point list are arranged in the order of the preset format to obtain the function point text list. Of course, the above arrangement method can also be adopted in other ways, for example, the semantic entity list, the data entity list, and the function point list are arranged in the order of the preset format to obtain the function point text list. Taking the above design content as an example, the language model can be used to perform keyword matching to obtain the data entity list: [collateral work order table, customer id field], the language model can be used to perform entity extraction algorithm to obtain the semantic entity list: [work order, order, call record], and the language model can be used to perform function / operation implementation to extract and summarize to obtain the function point list: [query work order information according to the primary key, and convert the customer id field to a string type]; the spliced ​​function point list can be: [query work order information according to the primary key, and convert the customer id field to a string type] [work order, order, call record] [collateral work order table, customer id field].

[0048] Step S22: searching the disassembly knowledge base according to the detailed design content to obtain system framework knowledge, similar disassembly cases and relationship maps between functions associated with the detailed design content; inputting the system framework knowledge, similar disassembly cases, relationship maps between functions and detailed design content as first prompt words into the large model to obtain an implementation plan for the detailed design content; searching the inspection knowledge base according to the detailed design content to obtain inspection knowledge associated with the detailed design content; inputting the inspection knowledge and the implementation plan into the large model as second prompt words to obtain a final implementation plan for the detailed design content;

[0049] Step S23, perform iterative retrieval based on the function point text list to obtain the code / document knowledge associated with the function point text list, input the code / document knowledge and the final implementation plan as the third prompt word into the large model to obtain the code specification, review the code specification and evaluate the degree of implementation, and after the evaluation passes, output the final generated code.

[0050] The technical solution provided in this application relies on the intelligent agent to extract the detailed design elements of the original detailed design, and combines the semantic understanding of the big model, the entity extraction model, the data table, DDL and other business-related specifications for keyword matching. It can completely identify and obtain the semantic entities, data entities | fields and functional points involved in this detailed design and other elements that need to be retrieved, effectively improving the retrieval quality of code knowledge retrieval, and thereby improving the generation quality of Java business code under the overall framework.

[0051] For example, the iterative search performed according to the function point text list to obtain the code / document knowledge associated with the function point text list specifically includes:

[0052] Obtain the number of function points c, the number of candidate methods n, and the number of candidate categories k in the function point text list, and construct a relevance score matrix M, wherein the matrix M includes the relevance scores of c, n, and k; specifically, including:

[0053] Extract the first category from the candidate categories, obtain the maximum value of the c function point association scores of the first candidate method in the first category, traverse all candidate methods to obtain the maximum value of all candidate methods, add up the maximum values ​​of all candidate methods and obtain the sum as the score of the first category, traverse k categories to obtain k scores corresponding to k categories; select the i-th category corresponding to the maximum value among the k scores, delete the association scores of other categories (except the i-th category) in the matrix M to obtain an iterative matrix M1, if the number of methods in the matrix M1 is greater than or equal to k, determine that the methods in the matrix M1 are the code / document knowledge associated with the function point text list.

[0054] For example, the above method may further include:

[0055] If the number of methods in matrix M1 is less than k, perform a secondary iterative operation on the associated scores of other categories and the number of methods in matrix M1 to obtain matrix M2, calculate all categories in matrix M2 to obtain the scores of all categories, obtain the i+1th category corresponding to the maximum score, add the methods and scores corresponding to the i+1th category to matrix M1 to obtain matrix M3, arrange all scores in matrix 3 in descending order to obtain a first sequence, and select the methods corresponding to the first k scores in the first sequence as the code / document knowledge associated with the function point text list.

[0056] The specific implementation of the above iterative search may include:

[0057] Step 1: Determine the relevance score matrix M. The number of function points is c, and the number of candidate methods is n. The matrix includes cxn relevance scores. At the same time, we initialize a candidate class list Lc (classes involved in all candidate methods), a candidate method list Lf (all candidate methods), and a selected method matrix Mf (initialized as an empty matrix, recording the final score of each selected method on all function points).

[0058] Step 2: Iterate and update the above M. The specific update method may include:

[0059] For each function point, execute:

[0060] Step 2.1: Based on Mf, calculate the final sum of scores of all selected methods at this function point, denoted as Sa.

[0061] Step 2.2: For each method corresponding to the function point, let its original score in M ​​be S, and its updated score be S'. The formula is:

[0062] S'=gamma ∧ Sa×S

[0063] Where gamma is a custom attenuation coefficient. Thus, a new correlation score matrix can be obtained to update M.

[0064] Step 3: For each class in the candidate class list Lc, calculate the class score according to the following formula (assuming the current class is c and the class score is Sc):

[0065]

[0066] That is, for each candidate method whose corresponding class is c, find its maximum value among all function points in M, add them all up, and the obtained score is the class score.

[0067] Step 4: Select the class with the highest score as the target class of the current round. The method corresponding to the class is the target method of the current round. Delete the corresponding information in Lc and Lf, and add the score of each function point of the selected method to Mf.

[0068] Step 5: When the length of Lf is less than k, return to step 2 and continue iterating; when it is equal to k, directly output the method recorded in Mf as the final selected method; when it is greater than k, execute:

[0069] Step 5.1: For each method in Mf, take its highest score among all functions as the final score and sort them;

[0070] Step 5.2: Output the top k methods as the final selection.

[0071] In an optional technical scenario, assuming there are two function points, there are five candidate Java methods, k is 3, gamma is 0.8, and the correlation scores of each method and each function are as follows:

[0072] Candidate Class Class A Class A Class B Class B Class C Candidate methods Method 1 Method 2 Method 3 Method 4 Method 5 Feature 1 0.9 0.1 0.85 0.1 0.1 Feature 2 0.1 0.5 0.1 0.8 0.9

[0073] Iteration round 1:

[0074] 0 classes and 0 methods have been selected, the correlation score matrix remains unchanged, and the scores of each candidate class are calculated directly according to the above table:

[0075] Class A score: max(0.9,0.1)+max(0.1,0.5)=1.4

[0076] Class B score: max(0.85,0.1)+max(0.1,0.8)=1.65

[0077] Class C score: max(0.1,0.9)=0.9

[0078] Among them, class B has the highest score. In this round, class B is selected, and the selected methods are method 3 and method 4. The selected method matrix Mf is updated as follows:

[0079] Candidate methods Method 3 Method 4 Feature 1 0.85 0.1 Feature 2 0.1 0.8

[0080] Since the number of selected methods is 2, which is less than 3 (the value of k), the iteration continues.

[0081] Iteration 2:

[0082] Selected class: Class B, selected methods: Method 3, Method 4. Calculate the current benchmark score matrix:

[0083] According to the table above, the total score of the currently selected methods for function 1 is 0.85+0.1=0.95. According to the formula, let the original score of each method corresponding to function 1 be S1 and the new score be S1', then:

[0084] S1'=0.8^0.95x S1

[0085] Similarly, the total score of the currently selected methods of function 2 is 0.1+0.8=0.9. According to the formula, let the original score of each method corresponding to function 2 be S2 and the new score be S2', then:

[0086] S2'=0.8^0.9x S2

[0087] The new correlation score matrix can be obtained:

[0088] Candidate Class Class A Class A Class C Candidate methods Method 1 Method 2 Method 5 Feature 1 0.728 0.081 0.081 Feature 2 0.082 0.409 0.736

[0089] From this we can get:

[0090] Class A score: max(0.728,0.082)+max(0.081,0.409)=1.137

[0091] Class C score: max(0.081,0.736)=0.736

[0092] Among them, class A has the highest score. In this round, class A is selected. The selected methods are method 1 and method 2. The selected method matrix Mf is updated as follows:

[0093] Candidate methods Method 3 Method 4 Method 1 Method 2 Feature 1 0.85 0.1 0.728 0.081 Feature 2 0.1 0.8 0.082 0.409

[0094] At this point, the number of selected methods is 4. Since 4 is greater than 3 (the value of k), the iteration is stopped. For each method, the highest score among all functions is taken as the final score, and the results are sorted.

[0095] kind Class B Class B Class A Class A method Method 3 Method 4 Method 1 Method 2 Fraction 0.85 0.8 0.728 0.409

[0096] Select the three items with the highest scores as the final output, that is, the final selection: Method 3, Method 4, Method 1

[0097] In the existing scheme, if you want to select 3 out of the 5 candidate methods, for each method, the highest score among all functions will be taken as the final score, and then the top 3 will be directly sorted and output as the result, that is, the corresponding selected methods are:

[0098] Select Class Class A Class C Class B Selection Method Method 1 Method 5 Method 3 Fraction 0.9 0.9 0.85

[0099] It can be found that this solution will select three different classes for implementation, which does not meet the user's retrieval requirement of completing the detailed design with fewer classes. The retrieved methods are likely to be just approximate descriptions, but may not necessarily meet the required methods (the methods required to complete the same detailed design are basically in a limited number of classes).

[0100] For example, the iterative search performed according to the function point text list to obtain the code / document knowledge associated with the function point text list specifically includes:

[0101] The number c of function points, the number n of candidate methods and the number k of candidate categories in the function point text list are obtained, and a first vector of the function point text list is constructed according to the number c of function points, the number n of candidate methods and the number k of candidate categories, and annotations of all java codes in a preset java code knowledge base are obtained, and vectorization is performed on the annotations of each java code to obtain an annotation vector of each java code to obtain multiple annotation vectors, and the similarity between the first vector and the annotation vector is calculated, and java codes with similarities greater than a similarity threshold are used as candidate codes / document knowledge, and α annotations of java codes in the candidate codes / document knowledge are extracted, and β java codes corresponding to β annotations containing the semantic entity list are queried from the α annotations to be determined as the code / document knowledge associated with the function point text list.

[0102] For example, the above-mentioned querying out β Java codes corresponding to β annotations containing the semantic entity list from α annotations and determining them as the code / document knowledge associated with the function point text list specifically includes:

[0103] If the number of β java codes is greater than k, the second list is obtained by arranging them in descending order according to the similarity, and the methods corresponding to the first k scores in the second list are selected as the code / document knowledge associated with the function point text list;

[0104] If the number of β java codes is less than k, β' java codes containing a list of key points of function points are queried from α annotations and added to the β java codes to obtain β+β' codes, and the β+β' codes are arranged in descending order according to the similarity to obtain a third list, and the method corresponding to the first k scores in the third list is selected as the code / document knowledge associated with the function point text list.

[0105] For example, the above similarity calculation method can adopt the cosine similarity calculation method, and of course other methods can also be adopted, such as the Euclidean distance similarity calculation method, etc.

[0106] For example, the above-mentioned review of the code specification and implementation evaluation, after passing the evaluation, outputting the final generated code may specifically include:

[0107] The inspection knowledge associated with the detailed design content is used as the context of the detailed design content and combined with the detailed design content to obtain the large model prompt word of the evaluation request, and the large model prompt word is input into the estimation model for review and feasibility evaluation. If the evaluation passes, the final generated code is output, and if the evaluation fails, the modification item is output. The above modification item is used to prompt the modification method or modification content of the java code.

[0108] For example, the above-mentioned large model can be a model of a general model after professional training, and this application does not limit the specific form of expression of the above-mentioned model.

[0109] Embodiment 1

[0110] This application implements a method for generating a java code. Figure 3 , Figure 3 A flowchart of a method for generating a Java code provided for implementing the present application is provided. The method can be performed in Figure 1 The computer shown in the figure can be a personal computer, a server, a tablet computer, a laptop computer or other smart devices. The computer can form a blockchain network or a cloud network. The method is as follows: Figure 3 As shown, the following steps are included

[0111] Step S101, the retrieval and extraction agent receives the detailed design input by the user 1, analyzes, extracts and summarizes the text content of the detailed design to obtain a list of functional points of the detailed design content;

[0112] Step S102: The retrieval and extraction agent performs keyword matching on the detailed design, matches the existing data tables in the business system and the key fields of the DDL, and obtains a list of data entities associated with the detailed design.

[0113] Step S103: The retrieval and extraction agent calls an entity extraction algorithm on the detailed design text, extracts common semantic entity fragments in the text, and obtains a list of semantic entities included in the detailed design.

[0114] Step S104, the retrieval and extraction agent understands the content of the large model called in the detailed design, extracts and summarizes the functions / operations designed in the detailed design by assembling the large model promotion words, and obtains a list of functional key points involved in the detailed design.

[0115] Examples of detailed elements are as follows:

[0116] Data entity / field list: [collateral work order table, customer id field]

[0117] Semantic entity list: [work order, order, call record]

[0118] Functional points list: [Query work order information according to the primary key and convert the customer ID field to string type]

[0119] Step S105: organize and sort the detailed design elements based on the functional points, and output a text list of functional points.

[0120] The text list of the above function points is for example [query work order information according to the primary key and convert the customer ID field into a string type], [work order, order, call record], [collateral work order table, customer ID field].

[0121] Step S201, the detailed design disassembly Agent-disassembly generation module receives the detailed design input by the user 1, and analyzes and disassembles the detailed design text content.

[0122] Step S202: Detailed design of the disassembly agent to perform RAG search on the disassembly knowledge base according to the detailed design, and search for the system framework knowledge involved, similar disassembly cases and the relationship graph between functions.

[0123] Step S203: The retrieved relevant disassembly knowledge is used as context and combined with the detailed design to form a large model prompt word for the disassembly request.

[0124] An example of the above prompt words is: [You are a master of Java detailed design disassembly. You need to make necessary supplementary rewrites and subtask disassembly plans for the current detailed design based on relevant disassembly knowledge], and input it into the large model.

[0125] Step S204: The large model module of the detailed design disassembly Agent receives the disassembly prompt word, performs task disassembly on the detailed design, and specifies the output of an implementation plan for realizing the detailed design.

[0126] The following is an example of the above implementation plan:

[0127] The interface parameter class is encapsulated using class A to generate the Resp class. The properties include: id field and num field

[0128] Controller class: Add function B to implement the following function description: receive the HTTP request configured by the query rule, parse the request parameter code, call function C for business processing, and return the response result in json format.

[0129] Service class: Add D function, and turn on the Dao class to reference E function. Function description:

[0130] (a) Implement order rule configuration, query the order table in the background to find the id field configuration that meets the conditions, check whether the input parameter is empty, and whether all the input parameter fields contain the order number

[0131] (b) parse and obtain the order fields that meet the inspection conditions, and add a new field to return the order information, all in json format.

[0132] Step S205: Detailed setting and disassembly of the Agent-plan evaluation module to perform usability evaluation on the implementation plan content generated in step S204.

[0133] Step S206, setting up the detailed disassembly Agent-plan evaluation module to perform RAG search on the inspection knowledge base, and retrieve the inspection knowledge such as the system development specifications, historical similar cases, function map paths, etc. involved.

[0134] Step S207, the detailed design disassembly Agent-plan evaluation module uses the retrieved relevant inspection knowledge as context and assembles it into a large model prompt word for the planning evaluation request together with the detailed design content.

[0135] An example of the prompt words for the above large model is: [You are a Java implementation planning assessment master. You need to conduct a feasibility assessment on the current detailed design based on relevant specification knowledge. If it meets the requirements, it will be passed. If it does not meet the requirements, output the items to be modified], which is input into the large model.

[0136] Step S208: The large model module of the detailed disassembly agent receives the planning assessment prompt and evaluates whether the planning assessment complies with the corresponding specifications.

[0137] Step S209: Detailed setting of disassembly Agent: if the disassembly Agent determines that the requirements are met, the next step is executed.

[0138] If not, the item to be modified is output as feedback and steps S201 - S208 are iterated.

[0139] Step S301: The knowledge retrieval agent calls the knowledge generation module to generate annotations for the code engineering library and generate a code knowledge base.

[0140] Step S302: The knowledge retrieval agent receives the function point text list output in step S105, calls the iterative retrieval module to perform iterative retrieval on the detailed elements, and retrieves and recalls relevant code / document knowledge.

[0141] Step S303, the code generation agent receives the relevant code / document knowledge outputted in step S302 and the implementation plan outputted in step S208, assembles them together into a large model prompt word of the code generation request, and calls the code generation module to generate specific Java code for the detailed design.

[0142] The example of the above large model prompt is: [You are a Java code generation master. You need to implement the Java code logic step by step according to the given implementation plan based on the relevant system code framework and Java code functions.]

[0143] Step S304: The code generation agent calls the code checking module to perform code specification review and detailed design implementation evaluation on the Java code output in step S303.

[0144] An example of a prompt is: [You are a Java code review master. You need to conduct a normative evaluation and a detailed design matching evaluation on the current Java code based on the code development specification and the given detailed design requirements. If it meets the requirements, it will be passed. If it does not meet the requirements, output the items to be modified.]

[0145] Step S305: If the code generation agent-code checking module passes the evaluation, the final generated Java code is output.

[0146] If the evaluation in the above step S305 fails, the item to be modified is output.

[0147] The technical solution of the embodiment of the present application relies on the intelligent agent to extract the detailed design elements of the original detailed design, and combines the semantic understanding of the big model, the entity extraction model, the data table, DDL and other business-related specifications for keyword matching, which can completely identify and obtain the semantic entities, data entities | fields and functional points involved in this detailed design. Compared with direct retrieval of the original text, it eliminates the pollution of irrelevant semantics on the retrieval effect, effectively improves the retrieval quality of code knowledge retrieval, and thus improves the generation quality of Java business code under the overall framework; relying on the intelligent agent to disassemble and supplement the original detailed design, it can better implement the specific details of the business logic, solve the problems caused by the coarse granularity of the original detailed description, the lack of supplementary specifications for the detailed steps, and the existence of semantic ambiguity. Compared with the original detailed design directly generating code with a big model, the Java code generated by this solution has better generation quality and is more readable; the big model Agent generates class / function annotations for the code knowledge base to solve the problem of mismatching the semantics of the Java code source code described in natural language; and through iterative retrieval, the problem of insufficient accuracy of conventional vector matching retrieval and insufficient distinction of similar samples is solved. By improving these two aspects and combining them with detailed design element generation, the precision and recall of natural language retrieval code knowledge can be effectively improved, thereby achieving higher quality Java business code generation. Different from the mainstream solution for generating general code in the industry, this solution builds a framework system for business detailed design-Java code generation based on Multi-Agent architecture and large models, and disassembles and optimizes the process links involved in Java in actual business scenarios using multi-agent collaboration, retrieves related knowledge, effectively improves the quality of Java code generation in specific business scenarios, and improves the work efficiency of developers.

[0148] Refer to the figure, Figure 4 The present application provides a schematic diagram of the structure of a Java code generation system, the system comprising:

[0149] An acquisition unit, used for receiving detailed design content of a design document;

[0150] An analysis and processing unit is used to analyze and extract keywords from the detailed design content, match the keywords to stock data tables and key fields in the business system, and obtain a data entity list of the detailed design content; extract common semantic entity fragments from the detailed design content through an entity extraction algorithm to obtain a semantic entity list contained in the detailed design content; after understanding the detailed design content, extract and summarize the function / operation implementation in the detailed design content to obtain a functional point list of the detailed design content; and splice the data entity list, the semantic entity list, and the functional point list to obtain a functional point text list;

[0151] The analysis and processing unit is further used to retrieve the system framework knowledge, similar disassembly cases and relationship maps between functions associated with the detailed design content in the disassembly knowledge base according to the detailed design content; input the system framework knowledge, similar disassembly cases, relationship maps between functions and detailed design content as first prompt words into the large model to obtain the implementation plan of the detailed design content; retrieve the inspection knowledge base according to the detailed design content to obtain the inspection knowledge associated with the detailed design content; input the inspection knowledge and the implementation plan into the large model as second prompt words to obtain the final implementation plan of the detailed design content;

[0152] A retrieval and evaluation unit is used to perform iterative retrieval based on the function point text list to obtain the code / document knowledge associated with the function point text list, input the code / document knowledge and the final implementation plan as the third prompt word into the large model to obtain the code specification, review the code specification and evaluate the degree of implementation, and output the final generated code after the evaluation is passed.

[0153] For example,

[0154] The retrieval evaluation unit is specifically used to obtain the number of function points c, the number of candidate methods n, and the number of candidate categories k in the function point text list, and construct a relevance score matrix M, wherein the matrix M includes c, n, and k relevance scores; specifically includes:

[0155] Extract the first category from the candidate categories, obtain the maximum value of the c function point association scores of the first candidate method in the first category, traverse all candidate methods to obtain the maximum value of all candidate methods, add up the maximum values ​​of all candidate methods and obtain the sum as the score of the first category, traverse k categories to obtain k scores corresponding to k categories; select the i-th category corresponding to the maximum value among the k scores, delete the association scores of other categories in the matrix M to obtain an iterative matrix M1, if the number of methods in the matrix M1 is greater than or equal to k, determine that the methods in the matrix M1 are the code / document knowledge associated with the function point text list.

[0156] For example,

[0157] The retrieval evaluation unit is also used to, when the number of methods in the matrix M1 is less than k, perform a secondary iterative operation on the associated scores of other categories and the number of methods in the matrix M1 to obtain the matrix M2, calculate all categories in the matrix M2 to obtain the scores of all categories, obtain the i+1th category corresponding to the maximum score, add the methods and scores corresponding to the i+1th category to the matrix M1 to obtain the matrix M3, arrange all the scores in the matrix 3 in descending order to obtain a first sequence, and select the methods corresponding to the first k scores in the first sequence as the code / document knowledge associated with the function point text list.

[0158] For example,

[0159] The retrieval evaluation unit is further used to obtain the number of function points c, the number of candidate methods n and the number of candidate categories k in the function point text list, construct a first vector of the function point text list according to the number of function points c, the number of candidate methods n and the number of candidate categories k, obtain the annotations of all java codes in a preset java code knowledge base, perform vectorization on the annotations of each java code to obtain the annotation vector of each java code to obtain multiple annotation vectors, calculate the similarity between the first vector and the annotation vector, use the java code with a similarity greater than a similarity threshold as the candidate code / document knowledge, extract α annotations of the java code in the candidate code / document knowledge, query from the α annotations β java codes corresponding to the β annotations containing the semantic entity list to determine as the code / document knowledge associated with the function point text list.

[0160] The retrieval evaluation unit is further configured to, if the number of the β java codes is greater than k, arrange the codes in descending order of the similarity to obtain a second list, and select the methods corresponding to the first k scores in the second list as the code / document knowledge associated with the function point text list;

[0161] If the number of β java codes is less than k, β' java codes containing a list of key points of function points are queried from α annotations and added to the β java codes to obtain β+β' codes, and the β+β' codes are arranged in descending order according to the similarity to obtain a third list, and the method corresponding to the first k scores in the third list is selected as the code / document knowledge associated with the function point text list.

[0162] The retrieval and evaluation unit is also used to use the inspection knowledge associated with the detailed design content as the context of the detailed design content and combine it with the detailed design content to obtain a large model prompt word for the evaluation request, input the large model prompt word into the estimation model for review and feasibility evaluation, and output the final generated code if the evaluation passes.

[0163] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method described in the above method embodiments, and the above computer includes an electronic device.

[0164] The embodiment of the present application also provides a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program is operable to cause a computer to execute some or all of the steps of any method described in the method embodiment. The computer program product may be a software installation package, and the computer includes an electronic device.

[0165] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0166] In the several embodiments provided in the present application, it should be understood that the disclosed methods, systems and systems can be implemented in other ways. For example, the system embodiments described above are only schematic; for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or units, which can be electrical, mechanical or other forms.

[0167] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0168] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0169] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a volatile memory or a non-volatile memory. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM) or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM) and direct RAM bus RAM (DR RAM). Various media that can store program code are available.

[0170] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions without departing from the spirit and scope of the present invention, and can make various changes and modifications, including the combination of the above-mentioned different functions and implementation steps, including software and hardware implementation methods, all of which are within the scope of protection of the present invention.

Claims

1. A method for generating java code, characterized in that: The method comprises the following steps: Receive detailed design content of the design text, analyze and extract keywords from the detailed design content, match the keywords with stock data tables and key fields in the business system, and obtain a data entity list of the detailed design content; Extracting common semantic entity fragments from the detailed design content through an entity extraction algorithm to obtain a list of semantic entities contained in the detailed design content; after understanding the content of the detailed design content, extracting and summarizing the function / operation implementation in the detailed design content to obtain a list of functional key points of the detailed design content; The data entity list, the semantic entity list and the function point list are concatenated to obtain a function point text list; According to the detailed design content, a search is performed in the disassembly knowledge base to obtain system framework knowledge, similar disassembly cases and relationship maps between functions associated with the detailed design content; the system framework knowledge, similar disassembly cases, relationship maps between functions and the detailed design content are input as first prompt words into the large model to obtain an implementation plan for the detailed design content; Searching the inspection knowledge base according to the detailed design content to obtain inspection knowledge associated with the detailed design content; Inputting the inspection knowledge and the implementation plan as the second prompt words into the large model to obtain the final implementation plan of the detailed design content; An iterative search is performed based on the function point text list to obtain the code / document knowledge associated with the function point text list, the code / document knowledge and the final implementation plan are input into the large model as the third prompt word to obtain the code specification, the code specification is reviewed and the degree of implementation is evaluated, and after the evaluation passes, the final generated code is output.

2. The method for generating java code according to claim 1, characterized in that: The performing iterative search according to the function point text list to obtain the code / document knowledge associated with the function point text list specifically includes: Obtain the number of function points c, the number of candidate methods n, and the number of candidate categories k in the function point text list, and construct a relevance score matrix M, wherein the matrix M includes the relevance scores of c, n, and k; specifically, including: Extract the first category from the candidate categories, obtain the maximum value of the c function point association scores of the first candidate method in the first category, traverse all candidate methods to obtain the maximum value of all candidate methods, add up the maximum values ​​of all candidate methods and obtain the sum as the score of the first category, traverse k categories to obtain k scores corresponding to k categories; select the i-th category corresponding to the maximum value among the k scores, delete the association scores of other categories in the matrix M to obtain an iterative matrix M1, if the number of methods in the matrix M1 is greater than or equal to k, determine that the methods in the matrix M1 are the code / document knowledge associated with the function point text list.

3. The method for generating java code according to claim 2, characterized in that: If the number of methods in matrix M1 is less than k, perform a secondary iterative operation on the associated scores of other categories and the number of methods in matrix M1 to obtain matrix M2, calculate all categories in matrix M2 to obtain the scores of all categories, obtain the i+1th category corresponding to the maximum score, add the methods and scores corresponding to the i+1th category to matrix M1 to obtain matrix M3, arrange all scores in matrix 3 in descending order to obtain a first sequence, and select the methods corresponding to the first k scores in the first sequence as the code / document knowledge associated with the function point text list.

4. The method for generating java code according to claim 1, characterized in that: The performing iterative search according to the function point text list to obtain the code / document knowledge associated with the function point text list specifically includes: The number c of function points, the number n of candidate methods and the number k of candidate categories in the function point text list are obtained, and a first vector of the function point text list is constructed according to the number c of function points, the number n of candidate methods and the number k of candidate categories, and annotations of all java codes in a preset java code knowledge base are obtained, and vectorization is performed on the annotations of each java code to obtain an annotation vector of each java code to obtain multiple annotation vectors, and the similarity between the first vector and the annotation vector is calculated, and java codes with similarities greater than a similarity threshold are used as candidate codes / document knowledge, and α annotations of java codes in the candidate codes / document knowledge are extracted, and β java codes corresponding to β annotations containing the semantic entity list are queried from the α annotations to be determined as the code / document knowledge associated with the function point text list.

5. The method for generating java code according to claim 4, characterized in that: The step of searching for β java codes corresponding to β annotations containing the semantic entity list from α annotations and determining them as the code / document knowledge associated with the function point text list specifically includes: If the number of β java codes is greater than k, the second list is obtained by arranging them in descending order according to the similarity, and the methods corresponding to the first k scores in the second list are selected as the code / document knowledge associated with the function point text list; If the number of β java codes is less than k, β' java codes containing a list of key points of function points are queried from α annotations and added to the β java codes to obtain β+β' codes, and the β+β' codes are arranged in descending order according to the similarity to obtain a third list, and the method corresponding to the first k scores in the third list is selected as the code / document knowledge associated with the function point text list.

6. The method for generating java code according to claim 1, characterized in that: The review of the code specification and the evaluation of the degree of implementation, after the evaluation is passed, outputting the final generated code specifically includes: The inspection knowledge associated with the detailed design content is used as the context of the detailed design content and combined with the detailed design content to obtain the large model prompt words of the evaluation request, and the large model prompt words are input into the estimation model for review and feasibility assessment. If the assessment passes, the final generated code is output.

7. A Java code generation system, characterized in that: The system comprises: An acquisition unit, used for receiving detailed design content of a design document; An analysis and processing unit is used to analyze and extract keywords from the detailed design content, match the keywords to stock data tables and key fields in the business system, and obtain a data entity list of the detailed design content; extract common semantic entity fragments from the detailed design content through an entity extraction algorithm to obtain a semantic entity list contained in the detailed design content; after understanding the detailed design content, extract and summarize the function / operation implementation in the detailed design content to obtain a functional point list of the detailed design content; and splice the data entity list, the semantic entity list, and the functional point list to obtain a functional point text list; The analysis and processing unit is further used to retrieve the system framework knowledge, similar disassembly cases and relationship maps between functions associated with the detailed design content in the disassembly knowledge base according to the detailed design content; input the system framework knowledge, similar disassembly cases, relationship maps between functions and detailed design content as first prompt words into the large model to obtain the implementation plan of the detailed design content; retrieve the inspection knowledge base according to the detailed design content to obtain the inspection knowledge associated with the detailed design content; input the inspection knowledge and the implementation plan into the large model as second prompt words to obtain the final implementation plan of the detailed design content; A retrieval and evaluation unit is used to perform iterative retrieval based on the function point text list to obtain the code / document knowledge associated with the function point text list, input the code / document knowledge and the final implementation plan as the third prompt word into the large model to obtain the code specification, review the code specification and evaluate the degree of implementation, and output the final generated code after the evaluation is passed.

8. The Java code generation system according to claim 7, characterized in that: The retrieval evaluation unit is specifically used to obtain the number of function points c, the number of candidate methods n, and the number of candidate categories k in the function point text list, and construct a relevance score matrix M, wherein the matrix M includes c, n, and k relevance scores; specifically includes: Extract the first category from the candidate categories, obtain the maximum value of the c function point association scores of the first candidate method in the first category, traverse all candidate methods to obtain the maximum value of all candidate methods, add up the maximum values ​​of all candidate methods and obtain the sum as the score of the first category, traverse k categories to obtain k scores corresponding to k categories; select the i-th category corresponding to the maximum value among the k scores, delete the association scores of other categories in the matrix M to obtain an iterative matrix M1, if the number of methods in the matrix M1 is greater than or equal to k, determine that the methods in the matrix M1 are the code / document knowledge associated with the function point text list.

9. The Java code generation system according to claim 8, characterized in that: The retrieval evaluation unit is also used to, when the number of methods in the matrix M1 is less than k, perform a secondary iterative operation on the associated scores of other categories and the number of methods in the matrix M1 to obtain the matrix M2, calculate all categories in the matrix M2 to obtain the scores of all categories, obtain the i+1th category corresponding to the maximum score, add the methods and scores corresponding to the i+1th category to the matrix M1 to obtain the matrix M3, arrange all the scores in the matrix 3 in descending order to obtain a first sequence, and select the methods corresponding to the first k scores in the first sequence as the code / document knowledge associated with the function point text list.

10. A computer storage medium storing a computer program for electronic data exchange, characterized in that: The computer program enables a computer to execute the steps of the method according to any one of claims 1 to 6.