Code analysis and generation method and system based on large model
Through the code analysis and generation method based on large-models, the problem of lack of semantic understanding, structural analysis and style control of code analysis and generation in the existing technology is solved, and efficient and intelligent code generation is realized, adapting to different programming languages and development frameworks. Improve development efficiency and code quality.
Patent Information
- Application Number
- CN202411192606.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2025-02-07
AI Technical Summary
The existing technology lacks semantic understanding, structural analysis and style control in code analysis and generation, resulting in semantic errors and logical errors in generated code, ignoring the code structure and organizational form, and inconsistent styles, making it difficult to meet the team's development needs.
Using a large model-based code analysis and generation method, the target functional module and its execution order are determined by obtaining the generation requirements of user input, and the code analysis module and the large model agent module are used for code analysis and generation to ensure that the generated code conforms to the semantics and Syntax specifications and adapt to different programming languages and development frameworks.
It realizes efficient and intelligent code analysis and generation, reduces the coding burden of developers, reduces development costs, improves development efficiency and code quality, and adapts to diversified development needs.
Smart Images

Figure CN119396400A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software engineering, and in particular to a code analysis and generation method and system based on a large model. Background Art
[0002] With the rapid development of information technology, software is increasingly used in various fields, and its scale and complexity are constantly increasing. In order to ensure software quality and development efficiency, code analysis and generation technology has become an important research direction in the field of software engineering. Traditional code analysis methods mainly rely on manual experience and rule bases, such as static code analysis tools and code review processes, but these methods are inefficient, lack automation and intelligence, and are difficult to meet the needs of large-scale software development. Similarly, traditional code generation methods such as template generation and rule-based generation also have problems such as poor flexibility, poor scalability, and low generation quality.
[0003] In recent years, the rapid development of deep learning technology has enabled big models to make significant progress in the field of natural language processing, providing new solutions for code analysis and generation. Big models can learn patterns and rules in massive amounts of code data, and generate code that conforms to semantic and grammatical specifications based on context and requirements. However, existing big model applications often lack specific optimization for the code field, resulting in semantic and logical errors in the generated code, ignoring the structure and organization of the code, and inconsistent styles, making it difficult to meet the development needs of the team.
[0004] Therefore, an efficient and intelligent code analysis and generation method is urgently needed. Summary of the invention
[0005] The present invention provides a code analysis and generation method and system based on a large model, so as to solve the defects of the related art in lacking code semantic understanding, structural analysis and style control.
[0006] The present invention provides a code analysis and generation method based on a large model, comprising the following steps.
[0007] Obtain generation requirements from user input; Based on the generation requirements, determine the target function modules to be called from a set of code function modules, and determine the execution order of the target function modules, wherein the set of code function modules includes a code analysis module and a large model proxy module of various code generation functions; The target function modules are called in sequence based on the execution order to obtain codes corresponding to the generation requirements.
[0008] The code analysis and generation method based on the large model provided by the present invention also includes: Get the first code entered by the user; The execution sequence calls the target function modules in sequence to obtain codes corresponding to the generation requirements, including: The target function modules are called in sequence based on the execution order to obtain a second code corresponding to the generation requirement and the first code.
[0009] According to the large model-based code analysis and generation method provided by the present invention, when the target function module includes a code analysis module and at least one large model proxy module,
[0010] The calling the target function modules in sequence based on the execution order to obtain a second code corresponding to the generation requirement and the first code includes: Based on the code analysis module, perform code analysis on the first code to obtain an analysis result of the first code; Based on the execution order, at least one of the large model proxy modules is called in sequence to apply the analysis result to execute the code generation function to obtain the second code.
[0011] According to the large model-based code analysis and generation method provided by the present invention, the code function module set also includes a retrieval module; In the case where the target function module also includes the retrieval module,
[0012] The step of sequentially calling the at least one large model proxy module based on the execution order and applying the analysis result to execute the code generation function to obtain the second code comprises: Based on the search module, searching for code snippets in the first code and / or keywords in the analysis result to obtain search results; Based on the execution order, the at least one large model proxy module is called in sequence to apply the analysis result and the retrieval result to execute the code generation function to obtain the second code.
[0013] According to the large model-based code analysis and generation method provided by the present invention, the code analysis of the first code based on the code analysis module includes: Based on the code analysis module, at least one of grammatical analysis, semantic analysis, code structure analysis, code feature extraction, semantic feature extraction and keyword extraction is performed on the first code.
[0014] According to the large model-based code analysis and generation method provided by the present invention, the large model proxy module is obtained by fine-tuning the large language model in the code field.
[0015] The present invention also provides a code analysis and generation device based on a large model, comprising: An acquisition unit, used for acquiring generation requirements input by a user; A logic control unit, configured to determine, based on the generation requirement, a target function module to be called from a set of code function modules, and determine an execution order of the target function modules, wherein the set of code function modules includes a code analysis module and a large model proxy module of various code generation functions; An execution unit is used to call the target function modules in sequence based on the execution order to obtain codes corresponding to the generation requirements.
[0016] The present invention also provides a large model-based code analysis and generation system, including the code analysis and generation device, and a code function module set; The large model-based code analysis and generation device is deployed in a distributed computing cluster.
[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 program, any of the code analysis and generation methods described above is implemented.
[0018] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the code analysis and generation method described in any one of the above is implemented.
[0019] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the code analysis and generation method described above is implemented.
[0020] The present invention provides a code analysis and generation method and system based on a large model, which reduces the coding burden of developers, reduces development costs, and improves development efficiency by automatically generating code snippets that meet the specifications. At the same time, the large model proxy technology is efficiently used to improve the accuracy of analysis and the efficiency of code analysis through automated code analysis, and reduce the workload of manual review. In addition, the system can adapt to different programming languages and development frameworks, provide cross-platform and cross-language code analysis and generation services, and meet diverse development needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the present invention or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. 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 code analysis and generation method provided by the present invention.
[0023] Figure 2 It is a code analysis and generation flow chart provided by the present invention in the presence of a first code.
[0024] Figure 3 It is a code analysis and generation flow chart for calling a retrieval module provided by the present invention.
[0025] Figure 4 It is a structural schematic diagram of the code analysis and generation device provided by the present invention.
[0026] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0027] 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.
[0028] With the rapid development of information technology, software is increasingly used in various fields, and its scale and complexity are constantly increasing. In order to ensure software quality and development efficiency, code analysis and generation technology has become an important research direction in software engineering. Traditional code analysis methods mainly rely on manual experience and rule bases, such as static code analysis tools and code review processes. These methods are not only inefficient, but also lack automation and intelligence, making it difficult to meet the needs of large-scale software development. Similarly, template generation and rule-based traditional code generation methods also have many problems in flexibility, scalability and generation quality.
[0029] In recent years, the rapid progress of deep learning technology has enabled large models to achieve remarkable achievements in the field of natural language processing (NLP), bringing new solutions to code analysis and generation. Large models, also known as large language models (LLMs), refer to natural language processing models with large parameter scales. Large models can learn patterns and rules in large amounts of code data and generate grammatical and semantic code based on context and requirements. However, these models often lack specific optimizations for the code field, resulting in semantic and logical errors in the generated code, ignoring code structure and organization, and inconsistent styles, making it difficult to meet team development needs.
[0030] Therefore, there is an urgent need for an efficient and intelligent code analysis and generation method that can deeply understand the code semantics, analyze the code structure and control the code style, so as to adapt to complex development scenarios and improve the quality and maintainability of code generation.
[0031] In view of the above problems, an embodiment of the present invention provides a code analysis and generation method based on a large model. Figure 1 It is a flowchart of the code analysis and generation method provided by the present invention, such as Figure 1 As shown, the method includes: Step 110: Obtain the generation requirement input by the user.
[0032] Specifically, the code analysis and generation process first needs to obtain the generation requirements input by the user. The specific operations of this process include the user inputting detailed requirements through a user interface. These requirements can cover multiple aspects, such as target programming language, functional description, performance requirements, code style preferences, and specific business logic. In addition, the code analysis and generation system provided by the present invention can support natural language input, allowing users to describe generation requirements in a more natural way. This step is the basis of the entire code analysis and generation process. Accurately and detailed acquisition of user requirements helps the subsequently generated code to be more in line with user expectations and actual usage scenarios.
[0033] Step 120, based on the generation requirements, determine the target function module to be called from the code function module set, and determine the execution order of the target function module, the code function module set includes a code analysis module and a large model proxy module of various code generation functions.
[0034] Specifically, the code analysis and generation system can use the natural language processing capabilities of the big model to parse the user's generation requirements to extract specific functional requirements and constraints. Then, based on the extracted specific functional requirements and constraints, the system will retrieve the code function module set to determine the target function module to be called. The set includes the code analysis module and the big model proxy modules of various code generation functions.
[0035] Among them, the code analysis module is a key component in the code analysis and generation method, which is used to parse and understand the existing code and provide accurate basic information for the subsequent code generation process. The large model proxy module of various code generation functions covers various functions that may be applied in code generation, such as code generation, code translation, code error correction, code modification, etc. These functional modules can perform their corresponding code generation functions. For example, some large model proxy modules can complete according to the context, fill in missing logic, and optimize the structure and performance of existing code. For example, some large model proxy modules can also identify potential syntax and logic errors in the code generation process to ensure the correctness of the generated code.
[0036] Based on the generation requirement analysis results input by the user through natural language, it is converted into a specific code generation task, so as to realize the generation requirement, and select the target function module from the code analysis module and the big model proxy module of the code function module set. The target function module thus selected may include a code analysis module and / or a big model proxy module. Both the code analysis module and the big model proxy module adopt big model technology. Big model technology can parse the functions and constraints described by the user, identify the specific functional points that need to be implemented, and automatically generate corresponding code snippets.
[0037] Once all the required target function modules are determined, the system will determine the execution order of these target function modules based on the logical relationship and dependency relationship. The confirmation of the execution order ensures that each target function module can operate in the normal order, thereby generating a complete code that meets the requirements.
[0038] Step 130: Call the target function modules in sequence based on the execution order to obtain codes corresponding to the generation requirements.
[0039] Specifically, the system calls the selected functional modules one by one according to the determined execution order. When each functional module is called, it will perform its specific function according to the user's generation requirements and the output of the previous step. For example, if the user's requirement is to refactor a piece of code, the system will first call the code analysis module to analyze the user input code, and then call the code reconstruction agent module in the large model agent module to refactor the input code. After the reconstruction process is completed, the system will use the code optimization agent module to further optimize and complete the code. The optimized code is fully checked by the error detection and repair agent module. Finally, the complete reconstructed code is obtained.
[0040] The code analysis and generation method provided in the embodiment of the present invention uses large model proxy technology to automatically generate code snippets that meet the specifications, which reduces the coding burden of developers, reduces development costs, and improves development efficiency. At the same time, through automated code analysis, the accuracy of analysis is improved, the efficiency of code analysis is improved, and the workload of manual review is reduced. In addition, the system can adapt to different programming languages and development frameworks, provide cross-platform, cross-language code analysis and generation services, and meet diverse development needs.
[0041] Based on the above embodiment, the code analysis and generation method based on the large model further includes: Get the first code entered by the user; The execution sequence calls the target function modules in sequence to obtain codes corresponding to the generation requirements, including: The target function modules are called in sequence based on the execution order to obtain a second code corresponding to the generation requirement and the first code.
[0042] Specifically, the user's input is not limited to generating requirements. The user can upload existing code or code snippets, i.e., first code, through the user interface. The first code can be a partially implemented function, an existing algorithm implementation, a preliminary code framework, or code to be optimized.
[0043] Figure 2 1 is a flowchart of code analysis and generation in the presence of the first code provided by the present invention. Figure 2 As shown, after obtaining the first code, the code analysis and generation system will call the target function module in sequence based on the execution order, that is, the code analysis module analyzes the first code to obtain the code analysis result, and inputs the user's generation requirements and the code analysis result into the large model proxy module, thereby generating the code corresponding to the user's generation requirements, that is, the second code. The second code is the output code obtained by completing, optimizing or reconstructing the first code on the basis of meeting the user's requirements.
[0044] Based on the above embodiment, when the target function module includes a code analysis module and at least one large model proxy module, in step 130, the target function modules are called in sequence based on the execution order to obtain a second code corresponding to the generation requirement and the first code, including: Based on the code analysis module, perform code analysis on the first code to obtain an analysis result of the first code; Based on the execution order, at least one of the large model proxy modules is called in sequence to apply the analysis result to execute the code generation function to obtain the second code.
[0045] Specifically, when the user input includes not only generation requirements but also the first code, the target function module includes a code analysis module and at least one large model proxy module. After the first code and the generation requirements are input into the code analysis and generation system, the system will call the code analysis module to analyze the first code input by the user. The analysis of the first code includes at least one of grammatical analysis, semantic analysis, code structure analysis, code feature extraction, semantic feature extraction and keyword extraction. The analysis result of the first code provides the necessary data and basis for the subsequent code generation.
[0046] Next, based on the execution order, the system will sequentially call at least one large model proxy module, and use the analysis results obtained by the code analysis module and the first code to perform the code generation function. Specifically, each large model proxy module is responsible for different code generation tasks. For example, one proxy module may be responsible for the implementation of the optimized algorithm, one proxy module may be responsible for the reconstruction of the code, and another proxy module may be responsible for the generation of equivalent code, etc.
[0047] When calling these large model proxy modules, the system will gradually generate new code snippets based on the user's generation requirements and the analysis results of the first code. After receiving the analysis results, each large model proxy module will generate the corresponding code part according to its own generation function and the user's specific needs. The system will ensure that these generated code snippets can be integrated to obtain the second code corresponding to the user's generation requirements and the first code.
[0048] Based on the above embodiment, the code function module set further includes a retrieval module; In the case where the target function module also includes the retrieval module,
[0049] The step of sequentially calling the at least one large model proxy module based on the execution order and applying the analysis result to execute the code generation function to obtain the second code comprises: Based on the search module, searching for code snippets in the first code and / or keywords in the analysis result to obtain search results; Based on the execution order, the at least one large model proxy module is called in sequence to apply the analysis result and the retrieval result to execute the code generation function to obtain the second code.
[0050] Specifically, when the code function module set includes a retrieval module, it is also necessary to retrieve the code snippet of the first code and / or the keywords in the analysis result. The retrieval result, the analysis result of the first code and the generation requirement are used as inputs of the large model proxy module to generate the second code.
[0051] Figure 3This is a code analysis and generation flow chart for calling a search module provided by the present invention. Figure 3 As shown, the code analysis module analyzes the first code input by the user, and uses the analysis result as the input of the retrieval module to obtain the retrieval result. Thereafter, the code analysis result, the user's generation requirements and the retrieval result will all serve as the basis for the large model proxy module to generate the second code. Whether the retrieval module is called or not is determined by an intention recognition large model in the system. In the case of determining to call the retrieval module, the system first calls the code analysis module to perform a comprehensive code analysis on the first code input by the user. The output of the code analysis module is the detailed analysis result of the first code, which provides the necessary data and basis for subsequent code generation. After completing the code analysis, the system will call the retrieval module based on the execution order. The retrieval module is responsible for retrieving the code snippets in the first code and / or the keywords in the analysis results. This step will find code snippets that match the user's requirements and the existing code in the relevant code library and development framework, and provide additional semantic information. The code snippets of the first code, based on the analysis results of the first code, and the retrieval results based on the analysis results are input into at least one large model proxy module together, and the code generation function is executed to obtain the second code.
[0052] The main function of the retrieval module is to retrieve relevant code bases and development frameworks, and provide additional semantic information and code examples to improve the accuracy and diversity of code analysis and generation. First, collect and organize relevant code bases and development frameworks, and build knowledge graphs to store semantic relationships and dependencies between code elements. These knowledge graphs contain rich code element information, including function definitions, class structures, API calls, and dependencies between code snippets, ensuring the comprehensiveness and accuracy of the retrieval results. Next, based on the keywords or code snippets extracted by the code analysis module, the system performs semantic retrieval in the constructed knowledge graph. Through semantic retrieval, the system can find code examples and development documents that are highly relevant to user needs. This not only includes direct code implementation, but also covers best practices, performance optimization solutions, and detailed API usage instructions to help generate code that better meets user needs.
[0053] Based on the above embodiment, performing code analysis on the first code based on the code analysis module includes: Based on the code analysis module, at least one of grammatical analysis, semantic analysis, code structure analysis, code feature extraction, semantic feature extraction and keyword extraction is performed on the first code.
[0054] Specifically, the code analysis and generation system performs at least one of grammatical analysis, semantic analysis, code structure analysis, code feature extraction, semantic feature extraction, and keyword extraction on the first code based on the code analysis module. Syntactic analysis is to parse the basic structure of the code to understand whether the code conforms to the grammatical rules of the target programming language; semantic analysis analyzes the use of variables and functions, data flow, and control flow by understanding the logic and meaning of the code; code structure analysis understands the overall architecture of the code by parsing the organizational form of the code, such as the structure of classes and modules, the calling relationship of functions, and the dependency relationship.
[0055] Code feature extraction is to identify and extract important features in the code, such as loop structures, conditional statements, function calls, etc. These features provide basic data for subsequent code generation and optimization, helping the system understand the specific implementation details and common patterns of the code. While performing code feature extraction, the system also performs semantic feature extraction. Semantic feature extraction involves extracting deep-level features related to functions and logic from the code, such as key variables, important logical branches, core algorithms, etc. These features help the system better understand the core functions and logical implementation of the code, ensuring that the generated code can accurately reproduce and optimize existing functions. Keyword extraction is to identify and extract words or phrases with specific meanings from the code, such as function names, variable names, class names, method names, library and framework names, API calls, specific grammatical structures, comments and document tags, etc. These keywords are used for subsequent semantic retrieval and code snippet matching to help the system find relevant code resources and best practices.
[0056] Based on the above embodiment, the large model proxy module is obtained by fine-tuning the large language model in the code field.
[0057] The present invention adopts large model proxy technology, utilizes pre-trained large language models, and performs fine-tuning for the code field, so that it can understand the syntax and semantics of the programming language and learn the structure and logic of the code.
[0058] First, select a suitable pre-trained large language model as the base model. These models are trained on large-scale text data and have strong natural language processing capabilities, which provides a foundation for the subsequent fine-tuning process.
[0059] The next key step is to fine-tune the model in the code domain. Fine-tuning means further training the model on the basis of the pre-trained model using a specialized code dataset so that it can adapt to the specific needs of code generation and analysis. This process is crucial because it transforms general language processing capabilities into a deep understanding and operational capabilities of programming languages. The fine-tuning process first requires the preparation of a large number of code datasets, which should cover multiple programming languages (such as Python, Java, C++, etc.) and different types of code (such as algorithm implementation, API calls, framework usage, etc.). These datasets should not only contain high-quality code snippets, but also comments and documentation so that the model can learn the syntax and logic of the code while understanding the intent and functionality of the code. During the fine-tuning process, the model will be exposed to various code generation tasks. These tasks include but are not limited to code completion, code translation, and code summarization. For example, in the code completion task, the model will receive incomplete code snippets and need to predict and complete the missing parts. This not only trains the model's syntax generation ability, but also strengthens its understanding of code logic and structure. In the code translation task, the model learns to convert code from one programming language to another language, which helps the model grasp the grammatical and semantic differences between different programming languages. In the code summarization task, the model needs to generate concise code descriptions or comments, which trains the model's semantic understanding and expression capabilities.
[0060] The entire fine-tuning process is not only to retrain the model, but also to verify and optimize the model's capabilities. After each task training, the model's performance is evaluated to ensure that the generated code snippets are of high quality in terms of syntax, logic, and performance. Evaluation indicators may include code correctness, efficiency, readability, and maintainability. These indicators help adjust and improve the model so that it can better meet the needs of developers in practical applications.
[0061] Through the above systematic fine-tuning process, the pre-trained large language model can effectively adapt to the specific needs of the code field. Ultimately, the fine-tuned model has strong code understanding and generation capabilities, can provide accurate and efficient solutions in various programming tasks, and significantly improve the efficiency and accuracy of code generation and optimization.
[0062] The code analysis and generation device provided by the present invention is described below. The code analysis and generation device described below and the code analysis and generation method described above can be referenced to each other.
[0063] Figure 4 is a schematic diagram of the structure of the code analysis and generation device provided by the present invention, such as Figure 4 As shown, the device comprises: An acquisition unit 410 is used to acquire a generation requirement input by a user; A logic control unit 420, configured to determine, based on the generation requirement, a target function module to be called from a set of code function modules, and determine an execution order of the target function modules, wherein the set of code function modules includes a code analysis module and a large model proxy module of various code generation functions; The execution unit 430 is used to call the target function modules in sequence based on the execution order to obtain codes corresponding to the generation requirements.
[0064] The code analysis and generation device of the present invention realizes an automated and efficient code generation process. Combining code analysis and large model proxy technology, the device can generate high-quality code snippets that meet user needs, significantly improving development efficiency and code quality. In addition, the device can adapt to a variety of programming languages and development frameworks, providing cross-platform and cross-language code generation services.
[0065] The embodiment of the present invention also provides a code analysis and generation system based on a large model, including the code analysis and generation device and a set of code function modules; The large model-based code analysis and generation system is deployed in a distributed computing cluster.
[0066] The code analysis and generation system mainly includes four parts, namely the logic control module, the code analysis module, the large model proxy module and the retrieval module. Among them, the logic control module is responsible for coordinating the workflow between the modules and determining the execution order of each module. This module contains an intention recognition large model to determine the target functional module to be called. The code analysis module is responsible for performing at least one of grammatical analysis, semantic analysis, code structure analysis, code feature extraction, semantic feature extraction and keyword extraction on the first code input by the user. The large model proxy module uses large model technology to combine the user's generation requirements, code analysis results (if any), and retrieval results (if any) to generate the second code. The retrieval module provides additional semantic information and code examples by retrieving relevant code libraries and development frameworks to enhance the accuracy and diversity of code analysis and generation.
[0067] In order to improve the processing speed of code analysis and generation, the present invention adopts a high-performance distributed deployment method. Specifically, the code analysis and generation system is deployed on a high-performance computing cluster, which is composed of multiple high-performance servers with powerful computing and storage capabilities. By utilizing distributed computing technology, the system can decompose complex code analysis and generation tasks into multiple subtasks and process them in parallel. This parallel processing mechanism enables the system to process multiple tasks at the same time, greatly shortening the overall processing time.
[0068] In addition, the system also implements load balancing technology. The load balancer will dynamically monitor the load of each server in the cluster and intelligently distribute tasks to ensure load balancing among servers, avoiding overloading of some servers and affecting system performance. This not only improves the stability and reliability of the system, but also further optimizes resource utilization, making code analysis and generation more efficient.
[0069] Through these technical means, the present invention can significantly improve the speed of code analysis and generation, meet the needs of large-scale, high-complexity code processing, and provide users with faster and more efficient services.
[0070] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 550, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 550. The processor 510 may call the logic instructions in the memory 530 to execute the code analysis and generation method based on the large model, and the method includes: Obtain generation requirements from user input; Based on the generation requirements, determine the target function modules to be called from a set of code function modules, and determine the execution order of the target function modules, wherein the set of code function modules includes a code analysis module and a large model proxy module of various code generation functions; The target function modules are called in sequence based on the execution order to obtain codes corresponding to the generation requirements.
[0071] In addition, the logic instructions in the above-mentioned memory 530 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, or the part that contributes to the relevant technology 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 to enable 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 and other media that can store program codes.
[0072] On the other hand, the present invention further provides a computer program product, the computer program product comprising 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 code analysis and generation method based on the large model provided by the above methods, the method comprising: Obtain generation requirements from user input; Based on the generation requirements, determine the target function modules to be called from a set of code function modules, and determine the execution order of the target function modules, wherein the set of code function modules includes a code analysis module and a large model proxy module of various code generation functions; The target function modules are called in sequence based on the execution order to obtain codes corresponding to the generation requirements.
[0073] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the large model-based code analysis and generation method provided by the above methods, the method comprising: Obtain generation requirements from user input; Based on the generation requirements, determine the target function modules to be called from a set of code function modules, and determine the execution order of the target function modules, wherein the set of code function modules includes a code analysis module and a large model proxy module of various code generation functions; The target function modules are called in sequence based on the execution order to obtain codes corresponding to the generation requirements.
[0074] 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.
[0075] 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 relevant technology 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 embodiment.
[0076] 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 code analysis and generation method based on a large model, characterized in that: include: Obtain generation requirements from user input; Based on the generation requirements, determine the target function modules to be called from a set of code function modules, and determine the execution order of the target function modules, wherein the set of code function modules includes a code analysis module and a large model proxy module of various code generation functions; The target function modules are called in sequence based on the execution order to obtain codes corresponding to the generation requirements.
2. The code analysis and generation method based on a large model according to claim 1, characterized in that: Also includes: Get the first code entered by the user; The execution sequence calls the target function modules in sequence to obtain codes corresponding to the generation requirements, including: The target function modules are called in sequence based on the execution order to obtain a second code corresponding to the generation requirement and the first code.
3. The code analysis and generation method based on a large model according to claim 2, characterized in that: In the case where the target functional module includes a code analysis module and at least one large model proxy module, The calling the target function modules in sequence based on the execution order to obtain a second code corresponding to the generation requirement and the first code includes: Based on the code analysis module, perform code analysis on the first code to obtain an analysis result of the first code; Based on the execution order, at least one of the large model proxy modules is called in sequence to apply the analysis result to execute the code generation function to obtain the second code.
4. The code analysis and generation method based on a large model according to claim 3 is characterized in that: The code function module set also includes a retrieval module; In the case where the target function module also includes the retrieval module, The step of sequentially calling the at least one large model proxy module based on the execution order and applying the analysis result to execute the code generation function to obtain the second code comprises: Based on the search module, searching for code snippets in the first code and / or keywords in the analysis result to obtain search results; Based on the execution order, the at least one large model proxy module is called in sequence to apply the analysis result and the retrieval result to execute the code generation function to obtain the second code.
5. The code analysis and generation method based on a large model according to claim 3 is characterized in that: The performing code analysis on the first code based on the code analysis module includes: Based on the code analysis module, at least one of grammatical analysis, semantic analysis, code structure analysis, code feature extraction, semantic feature extraction and keyword extraction is performed on the first code.
6. The code analysis and generation method based on a large model according to any one of claims 1 to 5, characterized in that: The large model proxy module is obtained by fine-tuning the large language model in the code field.
7. A code analysis and generation device based on a large model, characterized in that: include: An acquisition unit, used for acquiring generation requirements input by a user; A logic control unit, configured to determine, based on the generation requirement, a target function module to be called from a set of code function modules, and determine an execution order of the target function modules, wherein the set of code function modules includes a code analysis module and a large model proxy module of various code generation functions; An execution unit is used to call the target function modules in sequence based on the execution order to obtain codes corresponding to the generation requirements.
8. A code analysis and generation system based on a large model, characterized in that: Comprising the code generating device as claimed in claim 7, and a set of code function modules; The large model-based code analysis and generation system is deployed in a distributed computing cluster.
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 program, the code analysis and generation method according to any one of claims 1 to 6 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 code analysis and generation method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Code generation method and device, electronic equipment and storage medium
CN116560642A
Code repairing system and method based on large language model
CN116991467A
Code processing method and device, all-in-one machine and computer program product
CN117130589A
Code generation method and system based on large model, terminal and medium
CN118113271A
Cited By
Scene-based code generation strategy optimization method
CN119847496A
Scenario-based Code Generation Strategy Optimization Method
CN119847496B
Automatic control code generation and verification method and device, equipment and storage medium
CN120406914A
Resource data end-to-end full-process visual auditing method and system based on data topology
CN120763606A
Module linking method and device based on identifier analysis and medium
CN120856758A