Thinking acceleration automatic code generation method and device, electronic equipment and storage medium

By generating the basic code of the dialogue model and using the large language model for expansion and improvement, combining code optimization and verification, the problems of high labor costs, low efficiency and insufficient flexibility in traditional code generation methods are solved, and more efficient and flexible code generation is achieved.

CN119556937AInactive Publication Date: 2025-03-04BEIJING HANGXING YONGZHI TECH

Patent Information

Application Number
CN202411725608.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-03-04
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional code generation methods have problems such as high labor costs, low efficiency, large resource consumption and insufficient flexibility, especially when facing large data volumes, high real-time requirements and complex and variable data types.

Method used

By generating templates and user-entered code parameters based on user-defined code, the basic code of the dialogue model is generated and inputted into the large language model for processing, the expansion and improvement suggestions are obtained, and the code is finally optimized and verified to generate the final code.

Benefits of technology

It reduces labor costs and resource consumption, improves the efficiency, accuracy and flexibility of code generation, and can better support new types of data and new application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119556937A_ABST
    Figure CN119556937A_ABST
Patent Text Reader

Abstract

The invention provides a thinking acceleration automatic code generation method and device, electronic equipment and a storage medium, and relates to the technical field of computers.The method comprises the steps that basic codes of a dialogue model are generated based on a user-defined code generation template and code parameters input by a user; inputting the basic code of the dialogue model into the large language model for processing to obtain a diffusion and perfection suggestion of the basic code of the dialogue model, and generating a first code based on an operation of a user for the diffusion and perfection suggestion; and optimizing and checking the first code to obtain a second code. According to the method, the labor cost and resource consumption can be reduced, and the code generation efficiency, accuracy and flexibility are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device, electronic device and storage medium for automatic code generation by accelerated thinking. Background Art

[0002] Traditional code generation methods are often based on fixed algorithms and rules. Although they can meet basic data processing needs to a certain extent, their limitations gradually become apparent when faced with large amounts of data, high real-time requirements, and complex and changeable data types.

[0003] Specifically, traditional code generation methods have the following four main problems.

[0004] 1) Huge labor costs: Traditional code generation methods usually require professional code writers to manually write code, which not only consumes a lot of human resources, but may also cause code errors or inconsistencies due to human factors. Especially when the code system needs to be frequently updated or maintained, the problem of labor costs is particularly prominent. In addition, code writers also need to constantly learn and master new code technologies and standards to maintain their professional competitiveness, which also increases the labor costs of enterprises.

[0005] 2) Low efficiency and low accuracy: Traditional code generation methods often use manual code writing rules, which may be inadequate when processing large amounts of data or complex data types, resulting in low code writing efficiency. Manual code writing is not only limited in speed, but also prone to errors, affecting the timeliness and accuracy of data processing.

[0006] 3) High resource consumption: Traditional code generation methods may require a large amount of computing resources and storage space during the code writing process, which not only increases hardware costs, but may also have a negative impact on the performance and stability of the system. The problem of resource consumption is particularly prominent when processing large-scale data sets.

[0007] 4) Insufficient flexibility: With the continuous development of information technology, data types and application scenarios are becoming increasingly diversified. Traditional code generation methods are often difficult to adapt to such changes and lack flexible support for new types of data or new application scenarios, which limits the widespread application and further development of code generation methods. Summary of the invention

[0008] The present invention provides a method, device, electronic device and storage medium for automatic code generation by accelerating thinking, so as to achieve the purpose of reducing labor costs and resource consumption and improving code generation efficiency, accuracy and flexibility.

[0009] The present invention provides a method for automatically generating code by accelerating thinking, comprising: Generate the basic code of the dialogue model based on the user-defined code generation template and the code parameters entered by the user; Inputting the basic code of the dialogue model into the large language model for processing, obtaining expansion and improvement suggestions for the basic code of the dialogue model, and generating a first code based on the user's operation on the expansion and improvement suggestions; The first code is optimized and verified to obtain a second code.

[0010] According to a method for automatic code generation by accelerated thinking provided by the present invention, the code generation template and the code parameters are determined by the following steps: Determining the code generation template based on a user's naming operation on a database table and a modification operation on a primary and foreign key relationship in the database table; At least one of the code parameters, including a class name, a method name, and a property name, is determined based on a user input operation on the code parameter.

[0011] According to a method for automatic code generation for accelerated thinking provided by the present invention, the basic code of the dialogue model is generated based on a user-defined code generation template and a code parameter input by the user, including: The code parameters input by the user are used to replace the corresponding placeholders in the user-defined code generation template; Based on the replaced logical structure in the user-defined code generation template, the basic code of the dialogue model is generated.

[0012] According to a method for automatic code generation for accelerated thinking provided by the present invention, the basic code of the dialogue model is input into a large language model for processing to obtain expansion and improvement suggestions for the basic code of the dialogue model, including: The large language model is used to evaluate the basic code of the dialogue model, and based on the evaluation results, expansion and improvement suggestions for the basic code of the dialogue model are generated; the expansion and improvement suggestions include: at least one of adding comments, optimizing code structure and supplementing missing functions.

[0013] According to a method for automatic code generation by accelerating thinking provided by the present invention, the first code is generated based on the operation of the user on the expansion and improvement suggestions, including: If the user's operation on the expansion and improvement suggestion is to accept the expansion and improvement suggestion, the basic code of the dialogue model is expanded and improved based on the expansion and improvement suggestion to generate the first code.

[0014] According to a method for automatic code generation by accelerated thinking provided by the present invention, the first code is optimized and verified to obtain a second code, including: Performing a syntax check on the first code, and performing syntax optimization on the first code based on a syntax check result; Performing performance optimization on the first code after syntax optimization; The code style of the first code after performance optimization is unified to obtain the second code.

[0015] A method for automatic code generation by accelerating thinking provided by the present invention also includes: The second code is output to a specified project directory and integrated into a software development environment.

[0016] The present invention also provides a device for automatically generating code for accelerating thinking, comprising: A basic code generation module is used to generate the basic code of the dialogue model based on the user-defined code generation template and the code parameters input by the user; An expansion and improvement module, configured to input the basic code of the dialogue model into a large language model for processing, obtain expansion and improvement suggestions for the basic code of the dialogue model, and generate a first code based on a user's operation on the expansion and improvement suggestions; The optimization and verification module is used to optimize and verify the first code to obtain a second code.

[0017] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for automatic code generation by accelerating thinking as described in any one of the above is implemented.

[0018] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method for automatically generating code by accelerating thinking as described in any one of the above is implemented.

[0019] The present invention also provides a computer program product, comprising a computer program, which, when executed by a processor, implements any of the above-described methods for automatic code generation by accelerating thinking.

[0020] The method, device, electronic device and storage medium for automatic code generation for accelerated thinking provided by the present invention first generate the basic code of the dialogue model based on the user-defined code generation template and the code parameters input by the user, without manual basic code generation, which can reduce labor costs and flexibly support new types of data or new application scenarios; then, the basic code of the dialogue model is input into the large language model for processing, and the expansion and improvement suggestions of the basic code of the dialogue model are obtained, and the first code is generated based on the user's operation on the expansion and improvement suggestions, and the basic code of the dialogue model can be quickly expanded and improved through the large language model, thereby improving the accuracy and efficiency of the code; finally, the first code is optimized and verified to obtain the second code, which can improve the readability and maintainability of the code. In addition, the whole process does not require a large amount of computing resources and storage space. Therefore, the present invention can reduce labor costs and resource consumption, and improve code generation efficiency, accuracy and flexibility. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0022] Figure 1 It is a flowchart of the method for automatic code generation by accelerating thinking provided by an embodiment of the present invention.

[0023] Figure 2 It is a structural diagram of a device for automatically generating code by accelerating thinking provided by an embodiment of the present invention.

[0024] Figure 3 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0026] Combine the following Figure 1 The present invention describes the method of automatic code generation by thought acceleration.

[0027] Please refer to Figure 1 , Figure 11 is a flow chart of the method for automatic code generation by accelerating thinking provided by an embodiment of the present invention. Figure 1 As shown, the method may include steps 101 to 104.

[0028] Step 101: Generate basic code for a dialog model based on a user-defined code generation template and code parameters input by the user.

[0029] Specifically, users can flexibly customize code generation templates and input code parameters as needed. The basic code of the dialogue model can be generated based on the code generation template and code parameters. In this way, there is no need to manually generate the basic code, which can reduce labor costs. In addition, it can flexibly support new types of data or new application scenarios.

[0030] In one embodiment, the code generation template and code parameters are determined by the following steps: based on the user's naming operation on the database table and the modification operation of the primary and foreign key relationships in the database table, the code generation template is determined; based on the user's input operation on the code parameter, at least one code parameter among the class name, method name and attribute name is determined.

[0031] Specifically, in response to the user's naming operation on the database table, the name of the database table is changed. For example: the database table is named A01 table, B01 table, etc. In response to the user's modification operation on the primary-foreign key relationship in the database table, the primary-foreign key relationship in the database table is changed. For example: the content corresponding to the B01 table is displayed in a drop-down manner on the page corresponding to the A01 table, so the primary-foreign key relationship also needs to be modified accordingly. A code generation template is obtained based on the modified database table naming and primary-foreign key relationship. A user interface for inputting code parameters is provided to receive at least one code parameter among the class name, method name and attribute name input by the user. These code parameters can be used to replace the placeholders in the code generation template.

[0032] In one embodiment, step 101 includes: replacing corresponding placeholders in a user-defined code generation template with code parameters input by the user; and generating basic code for the dialog model based on the logical structure in the replaced user-defined code generation template.

[0033] Specifically, the specific class name, method name and attribute name input by the user are used to replace the corresponding placeholders in the user-defined code generation template, such as ${className}, ${methodName}, ${attributeName}, etc. A basic code containing the basic structure is automatically generated according to the logical structure in the replaced code generation template. For example: for a Java class, the generated basic code may include class definition, attribute declaration and basic construction method, etc.

[0034] Step 102: input the basic code of the dialogue model into the large language model for processing, obtain expansion and improvement suggestions for the basic code of the dialogue model, and generate a first code based on the user's operation on the expansion and improvement suggestions.

[0035] Specifically, the large language model is used to intelligently process the basic code of the dialogue model, and generate suggestions for expanding and improving the basic code of the dialogue model. Users can choose to accept or reject these suggestions for expanding and improving the basic code of the dialogue model, and make manual adjustments as needed. In this way, the basic code of the dialogue model can be quickly expanded and improved through the large language model, thereby improving the accuracy and efficiency of the code.

[0036] In one embodiment, the step 102 of inputting the basic code of the dialog model into the large language model for processing to obtain expansion and improvement suggestions for the basic code of the dialog model includes: using the large language model to evaluate the basic code of the dialog model, and generating expansion and improvement suggestions for the basic code of the dialog model based on the evaluation results. The expansion and improvement suggestions include: adding comments, optimizing code structure, and supplementing missing functions.

[0037] Specifically, the basic code of the dialogue model is input into the large language model for evaluation. The evaluation results may include which statements in the basic code of the dialogue model are missing comments, what shortcomings exist in the code structure, and which functions are missing. Then, the large language model generates expansion and improvement suggestions based on these evaluation results. The expansion and improvement suggestions may include which comments to add in which locations, optimization suggestions for the code structure, and which missing functions to supplement.

[0038] In one embodiment, generating the first code based on the user's operation on the expansion and improvement suggestions in step 102 includes: if the user's operation on the expansion and improvement suggestions is to accept the expansion and improvement suggestions, then expanding and improving the basic code of the dialogue model based on the expansion and improvement suggestions to generate the first code.

[0039] Optionally, if the user's operation on the expansion and improvement suggestion is to reject the expansion and improvement suggestion, the basic code of the dialogue model is directly output as the first code.

[0040] Step 103: Optimize and verify the first code to obtain a second code.

[0041] Specifically, optimizing and verifying the first code to obtain the second code can improve the readability and maintainability of the code.

[0042] In one embodiment, step 103 includes: performing a syntax check on the first code, and performing syntax optimization on the first code based on the syntax check result; performing performance optimization on the syntax-optimized first code; and performing code style unification on the performance-optimized first code to obtain a second code.

[0043] Specifically, check which syntax errors exist in the first code, and optimize the syntax of the syntax-error statements to ensure that the code has no syntax errors. Then, the first code after syntax optimization is subjected to performance optimization and style unification processing to improve the readability and maintainability of the code.

[0044] In one embodiment, after step 103, the process further includes: outputting the second code to a specified project directory and integrating it into a software development environment, such as an integrated development environment (IDE), so that developers can further edit and debug the second code.

[0045] The method for automatic code generation by accelerating thinking provided by the embodiment of the present invention first generates the basic code of the dialogue model based on the user-defined code generation template and the code parameters input by the user, without manual basic code generation, which can reduce labor costs and flexibly support new types of data or new application scenarios; then, the basic code of the dialogue model is input into the large language model for processing, and suggestions for expansion and improvement of the basic code of the dialogue model are obtained, and the first code is generated based on the user's operation on the expansion and improvement suggestions, and the basic code of the dialogue model can be quickly expanded and improved through the large language model, thereby improving the accuracy and efficiency of the code; finally, the first code is optimized and verified to obtain the second code, which can improve the readability and maintainability of the code. Moreover, the whole process does not require a large amount of computing resources and storage space. Therefore, the embodiment of the present invention can reduce labor costs and resource consumption, and improve code generation efficiency, accuracy and flexibility.

[0046] The following is a description of the thinking acceleration automatic code generation device provided by the present invention. The thinking acceleration automatic code generation device described below and the thinking acceleration automatic code generation method described above can be referenced to each other.

[0047] Please refer to Figure 2 , Figure 2 Schematic diagram of the structure of the automatic code generation device for accelerating thinking provided by an embodiment of the present invention. Figure 2 As shown, the device may include: A basic code generation module 10, used to generate the basic code of the dialogue model based on the user-defined code generation template and the code parameters input by the user; An expansion and improvement module 20, configured to input the basic code of the dialogue model into a large language model for processing, obtain expansion and improvement suggestions for the basic code of the dialogue model, and generate a first code based on a user's operation on the expansion and improvement suggestions; The optimization and verification module 30 is used to optimize and verify the first code to obtain a second code.

[0048] In one embodiment, the apparatus further comprises: The template definition module is used to determine the code generation template based on the user's naming operation on the database table and the modification operation of the primary and foreign key relationships in the database table; The parameter input module is used to determine at least one code parameter among a class name, a method name and an attribute name based on a user's input operation on the code parameter.

[0049] In one embodiment, the basic code generation module 10 is specifically used for: The code parameters input by the user are used to replace the corresponding placeholders in the user-defined code generation template; Based on the replaced logical structure in the user-defined code generation template, the basic code of the dialogue model is generated.

[0050] In one embodiment, the expansion and improvement module 20 is specifically used to: use a large language model to evaluate the basic code of the dialogue model, and generate expansion and improvement suggestions for the basic code of the dialogue model based on the evaluation results; the expansion and improvement suggestions include: adding comments, optimizing code structure and supplementing missing functions.

[0051] In one embodiment, the expansion and improvement module 20 is specifically used for: if the user's operation on the expansion and improvement suggestion is to accept the expansion and improvement suggestion, then the basic code of the dialogue model is expanded and improved based on the expansion and improvement suggestion to generate the first code.

[0052] In one embodiment, the optimization and verification module 30 is specifically used for: Performing a syntax check on the first code, and performing syntax optimization on the first code based on the syntax check result; Performing performance optimization on the first code after syntax optimization; The code style of the first code after performance optimization is unified to obtain the second code.

[0053] In one embodiment, the apparatus further comprises: The output and integration module is used to output the second code to a specified project directory and integrate it into the software development environment.

[0054] Figure 3 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 3 As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330 and a communication bus 340, wherein the processor 310, the communication interface 320 and the memory 330 communicate with each other through the communication bus 340. The processor 310 may call the logic instructions in the memory 330 to execute the automatic code generation method for accelerated thinking, which includes: generating the basic code of the dialogue model based on the user-defined code generation template and the code parameters input by the user; inputting the basic code of the dialogue model into the large language model for processing, obtaining the expansion and improvement suggestions of the basic code of the dialogue model, and generating the first code based on the user's operation on the expansion and improvement suggestions; optimizing and verifying the first code to obtain the second code.

[0055] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product 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 all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0056] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the thinking acceleration automatic code generation method provided by the above-mentioned method embodiments, and the method includes: generating a basic code of a dialogue model based on a user-defined code generation template and a user-input code parameter; inputting the basic code of the dialogue model into a large language model for processing to obtain expansion and improvement suggestions for the basic code of the dialogue model, and generating a first code based on the user's operations on the expansion and improvement suggestions; optimizing and verifying the first code to obtain a second code.

[0057] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the thinking acceleration automatic code generation method provided by the above-mentioned method embodiments, the method comprising: generating a basic code of a dialogue model based on a user-defined code generation template and a code parameter input by a user; inputting the basic code of the dialogue model into a large language model for processing to obtain expansion and improvement suggestions for the basic code of the dialogue model, and generating a first code based on the user's operations on the expansion and improvement suggestions; optimizing and verifying the first code to obtain a second code.

[0058] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0059] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0060] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for automatic code generation by accelerating thinking, characterized in that: include: Generate the basic code of the dialogue model based on the user-defined code generation template and the code parameters entered by the user; Inputting the basic code of the dialogue model into the large language model for processing, obtaining expansion and improvement suggestions for the basic code of the dialogue model, and generating a first code based on the user's operation on the expansion and improvement suggestions; The first code is optimized and verified to obtain a second code.

2. The method for automatic code generation by accelerating thinking according to claim 1, characterized in that: The code generation template and the code parameters are determined by the following steps: Determining the code generation template based on a user's naming operation on a database table and a modification operation on a primary-foreign key relationship in the database table; At least one of the code parameters, including a class name, a method name, and a property name, is determined based on a user input operation on the code parameter.

3. The method for automatic code generation by accelerating thinking according to claim 1, characterized in that: The basic code of the dialogue model is generated based on the user-defined code generation template and the code parameters input by the user, including: The code parameters input by the user are used to replace the corresponding placeholders in the user-defined code generation template; Based on the replaced logical structure in the user-defined code generation template, the basic code of the dialogue model is generated.

4. The method for automatic code generation by accelerating thinking according to claim 1, characterized in that: The step of inputting the basic code of the dialogue model into the large language model for processing to obtain expansion and improvement suggestions for the basic code of the dialogue model includes: The large language model is used to evaluate the basic code of the dialogue model, and based on the evaluation results, expansion and improvement suggestions for the basic code of the dialogue model are generated; the expansion and improvement suggestions include: at least one of adding comments, optimizing code structure and supplementing missing functions.

5. The method for automatic code generation by accelerating thinking according to claim 1, characterized in that: The generating of the first code based on the user's operation on the expansion and improvement suggestion includes: If the user's operation on the expansion and improvement suggestion is to accept the expansion and improvement suggestion, the basic code of the dialogue model is expanded and improved based on the expansion and improvement suggestion to generate the first code.

6. The method for automatic code generation by accelerating thinking according to claim 1, characterized in that: The step of optimizing and verifying the first code to obtain a second code includes: Performing a syntax check on the first code, and performing syntax optimization on the first code based on a syntax check result; Performing performance optimization on the first code after syntax optimization; The code style of the first code after performance optimization is unified to obtain the second code.

7. The method for automatic code generation by accelerating thinking according to claim 1, characterized in that: Also includes: The second code is output to a specified project directory and integrated into a software development environment.

8. A device for automatically generating code by accelerating thinking, characterized in that: include: A basic code generation module is used to generate the basic code of the dialogue model based on the user-defined code generation template and the code parameters input by the user; An expansion and improvement module, configured to input the basic code of the dialogue model into a large language model for processing, obtain expansion and improvement suggestions for the basic code of the dialogue model, and generate a first code based on a user's operation on the expansion and improvement suggestions; The optimization and verification module is used to optimize and verify the first code to obtain a second code.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for automatic code generation by accelerating thinking as described in any one of claims 1 to 7 is implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for automatic code generation by accelerating thinking as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Code auxiliary system, code auxiliary processing method and device and electronic equipment

    CN117311683A

  • LLM-based code optimization system and method

    CN118069111A

  • Bidirectional intelligent question and answer code supplementing method and system based on large language model

    CN118426825A

  • Code automatic generation method and device, equipment and medium

    CN118796180A

  • Automated authoring of software solutions from a data model

    US20240378028A1

Cited By

  • Code generation method and system based on large language model

    CN122064346A