Adaptive code generation method and device for multi-source heterogeneous input drive, equipment and medium

By using a multimodal input-driven adaptive code generation method, the inefficiency and compliance issues of traditional coding methods are solved, achieving efficient and reliable code generation and management, and ensuring seamless integration of code with existing libraries and legal compliance.

CN120803416APending Publication Date: 2025-10-17SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510693326.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-27
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

Traditional coding methods are inefficient and prone to human error. Existing code generation tools cannot integrate multimodal information, making it difficult to integrate generated code with existing code repositories. Furthermore, the lack of open-source code license management leads to compliance risks.

Method used

By receiving multimodal input, parsing structured requirement information, dynamically indexing existing codebases, constructing semantic graphs, using large language models to generate full-stack code, performing duplicate code detection and correction, and adding source declarations.

Benefits of technology

It improves software development efficiency, ensures seamless integration of generated code with existing code bases, reduces integration and maintenance difficulties, avoids compliance risks, and improves code quality and maintainability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120803416A_ABST
    Figure CN120803416A_ABST
Patent Text Reader

Abstract

The invention provides a multi-source heterogeneous input driven adaptive code generation method and device, equipment and a medium, and belongs to the technical field of software development. The method comprises the steps that multi-modal input for describing a target software function is received; analyzing the multi-modal input, and extracting structured demand information of a target software function; performing dynamic indexing on an existing code library of an item to which the target software function belongs, analyzing a dependency relationship of codes related to the target software function in the existing code library, and constructing a semantic map for the existing code library; based on the structured demand information and the semantic map, using a large language model to generate a full-stack code for a target software function, and performing duplicate code detection and correction on the full-stack code; and adding a traceability declaration to a file header or an annotation part of the full-stack code subjected to duplicate code detection and correction. By receiving the multi-mode input and automatically generating the full-stack code, the workload of manual code writing is reduced, and the software development period is shortened.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of software development, and particularly relates to a multi-source heterogeneous input driven adaptive code generation method, device, equipment and medium. BACKGROUND

[0002] With the development of the software industry, the requirements for software openness efficiency and quality are becoming higher and higher. The traditional code writing method has the following problems: it relies on the manual code writing of developers, which is time-consuming and laborious, and the implementation of a function often needs to go through multiple links such as requirement analysis, design, coding and testing, involving a large amount of manual code writing work, long development cycle, low efficiency and easy to introduce human errors.

[0003] With the development of artificial intelligence technology, some code generation tools have gradually emerged, but these tools usually only support a single input source and cannot fully utilize multi-modal information. In addition, the codes generated by these tools often have poor context fusion effect with existing code libraries, making subsequent integration and maintenance difficult. In the use of open source codes, due to the lack of effective license management mechanism, it may also cause ownership disputes, such as unauthorized use of restricted open source code fragments, which brings potential risks to enterprises.

[0004] In summary, the traditional manual code writing method is low in efficiency and easy to introduce human errors. Code generation tools cannot integrate multi-modal inputs, resulting in generated codes that cannot fully reflect the requirements; the dependency relationship and structure of the generated codes with existing code libraries lack effective association, increasing the difficulty of integration; and the license management of open source codes is insufficient, which may generate codes that do not meet the compliance requirements. SUMMARY

[0005] In a first aspect, the embodiments of the application provide a multi-source heterogeneous input driven adaptive code generation method, including the following steps: S1. receiving multi-modal inputs describing a target software function, including natural language description, design document and user interface draft; S2. parsing the multi-modal inputs and extracting structured requirement information of the target software function; S3. dynamically indexing the existing code library of the project to which the target software function belongs, analyzing the dependency relationship of the codes related to the target software function in the existing code library, and constructing a semantic graph for the existing code library; S4. based on the structured requirement information and the semantic graph, using a large language model to generate full-stack code for the target software function, and detecting and correcting repeated codes in the full-stack code; S5. adding a traceability declaration in the file header or comment part of the full-stack code after completing the repeated code detection and correction.

[0006] Further, the step S1 has the following specific steps: S11. Receiving the requirement description of the target software function in natural language form by the developer; S12. Obtaining the design document of the target software function provided by the developer, which describes the structural relationship between the classes involved in the target software function; S13. Obtaining the user interface draft drawn by the developer by hand or using a drawing tool, which describes the display position and style of the UI components of the target software function on the page.

[0007] Further, the step S2 has the following specific steps: S21. Identifying the class name and relationship description between the classes in the design document through OCR; S22. Image segmentation of the user interface draft through the Mask R-CNN algorithm to divide the boundaries of each UI component and determine the component position, size and display hierarchy; S23. Processing the requirement description in natural language form input by the developer through the pre-trained NLP model of the Transformer architecture, extracting the key verbs, key names and related constraints, generating a structured task description, and determining the functional requirements and business logic of the target software function.

[0008] Further, the step S3 has the following specific steps: S31. Dynamic indexing of the existing code base of the project to which the target software function belongs through the code scanning tool, and analyzing the dependency relationship of the code related to the target software function: Determining the functional modules in the target software function; Tracking the calling relationship and parameter passing relationship between functions in each functional module through static code analysis; Combing the usage of API interfaces in each functional module, including input and output parameters and calling frequency of API interfaces; S32. Using graph neural networks to construct the semantic graph of the existing code base by taking classes, functions and variables in the existing code base as nodes and the relationship between nodes as edges.

[0009] Further, the step S4 has the following specific steps: S41. Fine-tuning the large language model in advance according to the requirements of software development; S42. Using the fine-tuned large language model, combining the structured requirement information and the semantic graph of the existing code base to generate the code framework and basic code of the front end, back end and database for the target software function, and obtaining the full-stack code, which is as follows: Generate front-end HTML, CSS, and JavaScript code for the target software functions to build the page layout, style, and interactive effects of the target software functions; Generate backend processing logic code for target software functions; Generate corresponding data table structure in the database for target software function generation to store user data; S43. Use a similarity matching algorithm and an IF-IDF algorithm based on text features to compare the full-stack code with the code in the open source code base, and determine whether there is duplicate code in the full-stack code with a code fragment in the open source code base whose similarity is greater than a threshold; If yes, go to step S44; If not, proceed to step S5; S44. Use compliance firewalls to remediate duplicate code to comply with open source license requirements.

[0010] Furthermore, in step S42, the fine-tuned large language model is pre-trained; The training dataset is constructed by taking the developer's requirements description, design documents, and user interface draft diagrams in natural language as input and the actual full-stack code of the target software function as output; Review the data source and copyright information of the actual full-stack code in the training dataset to ensure legal compliance; Pre-train a large language model for fine-tuning using a vetted training dataset.

[0011] Furthermore, the specific steps of the similarity matching algorithm in step S43 are as follows: Use the BERT model to encode the full-stack code and the open source code base fragments into vectors, calculate the cosine similarity, and determine if the cosine similarity is higher than the first threshold as a potential duplicate. For potential duplicate code segments, the TF-IDF algorithm is used to extract key text features and calculate the feature overlap rate. If the feature overlap rate is higher than the second threshold, it is confirmed as duplicate code; For confirmed duplicate code, check the corresponding open source license type. If the license has commercial use restrictions, trigger the compliance firewall for correction.

[0012] In a second aspect, an embodiment of the present application further provides an adaptive code generation device driven by multi-source heterogeneous input, comprising: A multimodal input receiving module, configured to receive multimodal input describing the target software function, including natural language description, design documents, and user interface draft diagrams; Multimodal parsing module, used to parse multimodal input and extract structured requirement information of target software functions; The semantic graph construction module is configured to dynamically index an existing code base of a project to which the target software function belongs, analyze dependency relationships of codes related to the target software function in the existing code base, and construct a semantic graph for the existing code base; The code generation and correction module is configured to generate full-stack codes for the target software function based on the structured requirement information and the semantic graph using a large language model, and detect and correct repeated codes in the full-stack codes. The risk avoidance module is configured to add a traceability declaration in a file header or a comment part of the full-stack codes after the detection and correction of the repeated codes.

[0013] In a third aspect, an electronic device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the adaptive code generation method driven by multi-source heterogeneous inputs according to the first aspect when executing the program.

[0014] In a fourth aspect, a storage medium is provided, which stores a computer program, and the computer program implements the steps of the adaptive code generation method driven by multi-source heterogeneous inputs according to the first aspect when executed by a processor.

[0015] From the above technical solutions, the present application has the following advantages: The adaptive code generation method, device, equipment and medium driven by multi-source heterogeneous inputs provided by the present application automatically generate full-stack codes by receiving multi-modal inputs, reduce the workload of manually writing codes, shorten the software development cycle, and enable developers to focus more on the solution of complex problems; dynamically index the existing code base, analyze the dependency relationships, and construct a semantic graph, so that the generated codes are seamlessly integrated with the existing codes of the project, avoid dependency conflicts and calling errors, and reduce the difficulty and cost of code integration and maintenance; from the selection of training data to the traceability declaration of output codes, the use of commercial authorization data sets to train models, automatic replacement of risk parts in repeated codes, and addition of traceability declaration to output codes ensure the legality of code use and avoid disputes caused by code license problems; through Mask R-CNN, pre-trained NLP models of Transformer architecture, and graph neural networks, the input information is accurately parsed to ensure the quality and maintainability of the generated codes; the traceability declaration is added to the generated codes to clearly indicate the source and license information of the codes, which facilitates subsequent review, maintenance and version tracking. BRIEF DESCRIPTION OF DRAWINGS

[0016] In order to more clearly illustrate the technical solutions of the present application, the drawings required to be used in the description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without any creative effort on the basis of these drawings.

[0017] Figure 1 A flowchart of the multi-source heterogeneous input driven adaptive code generation method of the present application.

[0018] Figure 2 A schematic diagram of the multi-source heterogeneous input driven adaptive code generation device of the present application. DETAILED DESCRIPTION

[0019] In the following detailed description of the specific steps of the multi-source heterogeneous input driven adaptive code generation method, various embodiments of the present disclosure will be described more fully. The present disclosure can have various embodiments, and adjustments and changes can be made therein. However, it should be understood that there is no intention to limit various embodiments of the present disclosure to the specific embodiments disclosed herein, but the present disclosure should be understood to cover all adjustments, equivalents and / or alternatives falling within the spirit and scope of various embodiments of the present disclosure.

[0020] Exemplarily, in the current development of the software industry, the efficiency and quality of software development are expected to be higher and higher. However, the traditional code writing mode exposes many drawbacks: it relies heavily on the manual code writing of developers, and goes through a series of links such as demand analysis, design conception, coding implementation, and test verification, each of which cannot be separated from a large amount of manual code writing, which undoubtedly prolongs the development cycle, reduces the development efficiency, and also easily causes human errors in tedious manual operations.

[0021] Even with the rise of artificial intelligence technology, some code generation tools have emerged on the market, but these tools have obvious limitations. First of all, they generally only support a single input source and cannot integrate multi-modal information for code generation, which leads to the inability of the generated code to fully and accurately map the real requirements of software functions. Secondly, the code generated by such tools often does not adapt when integrated with the existing code base of the project, because they do not handle the dependency relationship with the existing code base well, and do not fully fit the architecture of the existing code base, which undoubtedly brings difficulties to the subsequent code integration and long-term maintenance work. Thirdly, in the use of open source code, due to the lack of a perfect license management mechanism, these tools may inadvertently use unauthorized and restricted open source code fragments, which may trigger ownership disputes and pose potential risks to the development of enterprises, causing unnecessary trouble to the development of enterprises.

[0022] In summary, the traditional manual code writing method has been difficult to meet the fast-paced and high-quality development needs of today's software industry, and the existing code generation tools cannot fundamentally solve the problems left over by the traditional development mode due to their own imperfect functions.

[0023] To solve the above problems, the embodiment provides a multi-source heterogeneous input driven adaptive code generation method, which integrates multi-modal input analysis, context semantic analysis, full-stack code generation and correction, and legal risk avoidance, and realizes an efficient, accurate and safe and reliable code generation solution.

[0024] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to 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. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor are within the scope of protection of the present application.

[0025] Please refer to Figure 1 The flowchart of the multi-source heterogeneous input driven adaptive code generation method in a specific embodiment is shown, and the method comprises the following steps: S1. Receive multi-modal input describing the target software function, including natural language description, design document and user interface draft; It should be noted that receiving multi-modal input of natural language description, design document and user interface draft can comprehensively obtain relevant information of the target software function, so that the subsequent code generation can meet the actual needs and avoid code rework caused by incomplete information. Receiving requirement description in the form of natural language can obtain the software function expectation expressed naturally and intuitively by the developer. Design document and user interface draft supplement details from the structure and visual display, so that the requirement understanding is more accurate. S2. Analyze the multi-modal input and extract structured requirement information of the target software function; It should be noted that converting various information in the multi-modal input into structured requirement information provides a clear guidance for subsequent code generation, ensuring that the generated code can accurately realize the target software function. By extracting key verbs, nouns and constraint conditions, the core points of the software function can be determined, avoiding code generation deviation caused by information redundancy or ambiguity. S3. Dynamically index the existing code library of the project to which the target software function belongs, analyze the dependency relationship of the code related to the target software function in the existing code library, and build a semantic graph for the existing code library; It should be noted that the dynamic index has a code library, analyzes the dependency relationship and constructs a semantic graph, so as to comprehensively understand the architecture and function of the existing code of the project, and provide a basis for generating compatible code; through understanding and analysis of the existing code library, it is ensured that the newly generated code can be combined with the existing code, reducing the workload of later integration, improving the overall consistency and stability of the code; S4. Based on the structured requirement information and the semantic graph, a large language model is used to generate full-stack code for the target software function, and the full-stack code is detected and corrected for repeated code; It should be noted that based on the structured requirement information and the semantic graph, a large language model is used to generate full-stack code, which improves the development efficiency and code quality of the code framework and basic code; repeated code detection and correction of generated code can avoid risks caused by code plagiarism, while also optimizing code quality, improving code readability and maintainability; S5. Adding a traceability declaration in the file header or comment part of the full-stack code after completing repeated code detection and correction; It should be noted that adding a traceability declaration in the code clearly indicates the source and license information of the code, providing a basis for code use, facilitating copyright review and avoiding potential disputes; through the traceability declaration, subsequent code maintenance and updates are provided with reference, so that maintenance personnel can quickly understand the code generation background and basis, facilitating accurate assessment of the impact range and risk of code modification.

[0026] The embodiment improves the efficiency and quality of software development, and also solves the shortcomings of traditional code writing and existing code generation tools in multi-modal information utilization, code context fusion and compliance guarantee, providing a comprehensive code generation method for the software development industry.

[0027] Further, as a refinement and extension of the above embodiment, in order to fully describe the specific implementation process in this embodiment, another adaptive code generation method driven by multi-source heterogeneous input is provided, which includes the following steps: S1. Receive multi-modal input describing the target software function, including natural language description, design document and user interface draft; step S1 includes the following steps: S11. Receive the requirement description of the target software function in natural language form by the developer; For example, "We need to implement a product recommendation function based on user browsing history and purchase records on the e-commerce platform. When the user logs in, 5 recommended products are displayed on the home page. The recommendation logic is to prioritize recommending products that the user has browsed but not purchased in the same category and have high sales rankings, while also considering the inventory situation of the products, and prioritizing recommending products with sufficient inventory." S12. Obtain the design document of the target software function provided by the developer, which describes the structural relationship between classes involved in the target software function; Exemplarily, the UML describes the association between the user class, the product class, the browsing history class, and the recommendation algorithm class, as well as the attributes and methods of each class, which are provided by the commodity recommendation function; S13. Obtain the user interface draft drawn by the developer by hand or using a drawing tool, which describes the display position and style of the UI components of the target software function on the page; Exemplarily, the recommendation area in the user interface draft of the commodity recommendation function is a rectangular area, which displays the basic information of the product picture, name, and price in a grid layout, and also contains a “more recommendations” button; S2. Analyze the multi-modal input and extract the structured requirement information of the target software function; the specific steps of step S2 are as follows: S21. Recognize the text information in the design document by OCR to determine the class name and the relationship description between classes; Exemplarily, the UML text information in the design document is recognized by OCR, such as the class names “User (user class)”, “Product (product class)”, and “BrowsingHistory (browsing history class)”, and the relationship description between classes, such as “User and BrowsingHistory are in a one-to-many association relationship”; S22. Perform image segmentation on the user interface draft by the Mask R-CNN algorithm to divide the boundaries of each UI component and determine the component position, size, and display hierarchy; Exemplarily, the Mask R-CNN algorithm is used to perform image segmentation on the user interface draft to accurately divide the boundaries of each UI component and determine the size, position, and hierarchical relationship of each product information display component in the recommendation product display area, such as determining that the product picture is located at the top left of the recommendation area, the name is below the picture, and the price is below the name; S23. Process the natural language requirement description input by the developer by the pre-trained NLP model based on the Transformer architecture to extract the key verbs, key names, and related constraints, generate a structured task description, and determine the functional requirements and business logic of the target software function; Specifically, the pre-trained NLP model extracts key verbs such as "implement", "show", "recommend", key nouns such as "e-commerce", "commodity recommendation function", "user", "browsing history", "purchase record", "home page", "recommended goods", and related constraints such as "5 recommended goods", "same category", "browsed but not purchased", "top sales ranking", and "sufficient inventory"; S3. Dynamically index the existing code base of the project to which the target software function belongs, analyze the dependency relationship of the code related to the target software function in the existing code base, and build a semantic graph for the existing code base; Step S3 is specifically as follows: S31. Dynamically index the existing code base of the project to which the target software function belongs by using a code scanning tool, and analyze the dependency relationship of the code related to the target software function: Determine the function modules in the target software function; Trace the calling relationship and parameter passing relationship between functions in each function module by static code analysis; For example, find the existing user login authentication module and commodity management module in the project, trace the function call chain, and determine the calling order and parameter passing relationship between functions in the function module, such as returning user basic information including user ID, browsing history, and other data after successful user login, which will be used as input parameters for the recommendation algorithm; Sort out the usage of API interfaces in each function module, including input and output parameters and calling frequency of API interfaces; S32. Use a graph neural network to construct a semantic graph for the existing code base by taking classes, functions, and variables in the existing code base as nodes and taking the relationship between nodes as edges; Specifically, the relationship between nodes includes inheritance, calling, and dependency; For example, the "User" class, "getBrowsingHistory" function, "Product" class, and "recommendProducts" function are constructed in the semantic graph; It should be noted that through the message passing mechanism, each node obtains relevant context information, providing comprehensive and accurate context support for code generation, ensuring that the recommended function code can be seamlessly integrated with the existing code base, avoiding dependency conflicts and calling errors; S4. Based on the structured requirement information and the semantic graph, use a large language model to generate full-stack code for the target software function, and detect and correct duplicate code in the full-stack code; Step S4 is specifically as follows: S41. Fine-tune the large language model in advance according to the requirements of software development; S42. Using the fine-tuned large language model, generate the code framework and basic code of the front end, back end, and database for the target software function in combination with the structured requirement information and the semantic graph of the existing code library, to obtain the full-stack code, as follows: Generate the HTML, CSS, and JavaScript code of the front end for the target software function to build the page layout, style, and interactive effect of the target software function; For example, generate the corresponding grid layout code according to the user interface draft, set the style of the product information display, and add a JavaScript event that triggers a request for new recommended product data when the “More Recommendations” button is clicked; Generate the code of the back-end processing logic for the target software function; For example, define a recommendation algorithm function that receives a user ID parameter, queries the database for qualified products based on the user's browsing history and purchase records, and returns the top 5 product data sorted by sales; Generate the corresponding data table structure in the database for the target software function to store user data; For example, user data includes user browsing history and product information data; S43. Use the similarity matching algorithm and the IF-IDF algorithm based on text features to compare the full-stack code with the code in the open source code library to determine whether there is duplicate code in the full-stack code that has a similarity greater than a threshold value with the code fragments in the open source code library; If yes, go to step S44; If no, go to step S5; S44. Use the compliance firewall to correct the duplicate code to meet the requirements of the open source license; S5. Add a provenance declaration to the file header or comment section of the full-stack code after detecting and correcting the duplicate code.

[0028] It should be understood that the size of the serial number of each step in the above embodiments does not mean the order of execution, and 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.

[0029] As Figure 2 shown below is an embodiment of a multi-source heterogeneous input driven adaptive code generation apparatus provided by the embodiments of the present disclosure. The system and the multi-source heterogeneous input driven adaptive code generation method of each of the above embodiments belong to the same inventive concept. Details not described in the embodiment of the multi-source heterogeneous input driven adaptive code generation apparatus can be referred to the embodiment of the multi-source heterogeneous input driven adaptive code generation method described above.

[0030] The apparatus comprises: a multi-modal input receiving module configured to receive multi-modal inputs describing a target software function, including natural language descriptions, design documents, and user interface sketches; a multi-modal analysis module configured to analyze the multi-modal inputs and extract structured requirement information of the target software function; a semantic graph construction module configured to dynamically index an existing code base of a project to which the target software function belongs, analyze dependency relationships of codes related to the target software function in the existing code base, and construct a semantic graph for the existing code base; a code generation and correction module configured to generate full-stack codes for the target software function based on the structured requirement information and the semantic graph using a large language model, and detect and correct duplicate codes in the full-stack codes; a risk avoidance module configured to add provenance declarations in a file header or a comment section of the full-stack codes after the detection and correction of the duplicate codes.

[0031] The multi-modal input receiving module, the multi-modal analysis module, the semantic graph construction module, the code generation and correction module, and the risk avoidance module interact and cooperate with each other to improve the convenience and efficiency of software development.

[0032] The multi-source heterogeneous input driven adaptive code generation method provided by the embodiments of the present application can be applied to an electronic device. Those skilled in the art can understand that the electronic device structure involved in the embodiments of the present application does not constitute a limitation on the electronic device, and the electronic device can include more or fewer components than the illustration, or combine certain components, or different component arrangements. In the embodiments of the present application, the electronic device includes but is not limited to a laptop computer, a desktop computer, a workstation, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of the present application described and / or claimed herein.

[0033] The electronic device can include a processor, an external memory interface, an internal memory, a universal serial bus (USB) interface, a charge management module, a power management module, a battery, a wireless communication module, an audio module, a speaker, a microphone, a sensor module, a key, a camera, a display screen, and a SIM card interface, etc.

[0034] It can be understood that the structure shown in the embodiments of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device can include more or fewer components than shown, or combine certain components, or split certain components, or different arrangement of components. The components shown can be implemented in hardware, software, or a combination of software and hardware.

[0035] The processor can include one or more processing units, such as: the processor can include a central processing unit (CPU), an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units can be independent devices, or can be integrated in one or more processors.

[0036] Among them, the processor can be the nerve center and command center of the electronic device. The controller can generate operation control signals according to instruction operation codes and timing signals, and complete the control of fetching and executing instructions.

[0037] The processor can also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor is a cache memory. The memory can save instructions or data that the processor has just used or repeatedly uses. If the processor needs to use the instructions or data again, it can directly call from the memory. Avoiding repeated access, reducing the waiting time of the processor, thus improving the efficiency of the system.

[0038] The electronic device realizes the receiving of multi-modal input describing a target software function, including natural language description, design document and user interface draft, of the adaptive code generation method driven by multi-source heterogeneous input of the application; analyzing the multi-modal input and extracting structured requirement information of the target software function; dynamically indexing the existing code base of the project to which the target software function belongs, analyzing the dependency relationship of the code related to the target software function in the existing code base, and constructing a semantic graph for the existing code base; based on the structured requirement information and the semantic graph, using a large language model to generate full-stack code for the target software function, and detecting and correcting repeated code of the full-stack code; adding a traceability declaration in the file header or the comment part of the full-stack code after the repeated code detection and correction, which improves the efficiency and quality of software development, solves the shortcomings of traditional code writing and existing code generation tools in multi-modal information utilization, code context fusion and compliance guarantee, and provides a comprehensive code generation method for the software development industry.

[0039] In the storage medium provided by the application, a program product capable of realizing the adaptive code generation method driven by multi-source heterogeneous input is stored.

[0040] The adaptive code generation method driven by multi-source heterogeneous input includes: receiving multi-modal input describing a target software function, including natural language description, design document and user interface draft; analyzing the multi-modal input and extracting structured requirement information of the target software function; dynamically indexing the existing code base of the project to which the target software function belongs, analyzing the dependency relationship of the code related to the target software function in the existing code base, and constructing a semantic graph for the existing code base; based on the structured requirement information and the semantic graph, using a large language model to generate full-stack code for the target software function, and detecting and correcting repeated code of the full-stack code; adding a traceability declaration in the file header or the comment part of the full-stack code after the repeated code detection and correction.

[0041] In some possible implementations, the adaptive code generation method driven by multi-source heterogeneous input of the present disclosure can be implemented in the form of a program product, which includes program code for causing the terminal device to execute the steps of various exemplary embodiments of the present disclosure described in the above "Exemplary Method" section of the specification when the program product is running on the terminal device.

[0042] The storage medium of the present disclosure can employ any combination of one or more computer-readable media. The computer-readable media can be a computer- readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include the following: an electrical connection having one or more wires, a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0043] The foregoing description of the disclosed embodiments enables a person skilled in the art to implement or use the invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the generic principles defined herein can be applied to other embodiments without departing from the spirit or scope of the invention. Accordingly, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for adaptive code generation driven by multi-source heterogeneous input, characterized in that: The steps include: S1. Receive multimodal input describing the target software functionality, including a natural language description, design documents, and user interface draft diagrams; S2. Parse multimodal input and extract structured requirement information of target software functions; S3. Dynamically index the existing code base of the project to which the target software function belongs, analyze the dependencies of the code in the existing code base that are related to the target software function, and construct a semantic graph for the existing code base; S4. Based on the structured requirements information and semantic graph, a large language model is used to generate full-stack code for the target software function, and duplicate code is detected and corrected in the full-stack code. S5. Add a traceability statement to the file header or comment section of the full-stack code that has completed duplicate code detection and correction.

2. The adaptive code generation method driven by multi-source heterogeneous input according to claim 1, characterized in that: The specific steps of step S1 are as follows: S11. Receive the developer's description of the target software's functional requirements in natural language; S12 obtains the design document of the target software function provided by the developer, the design document describes the structural relationship between the classes involved in the target software function; S13. Obtain a user interface draft diagram drawn by the developer by hand or using a drawing tool, wherein the user interface draft diagram describes the display position and style of the UI components of the target software function on the page.

3. The adaptive code generation method driven by multi-source heterogeneous input according to claim 2, characterized in that: The specific steps of step S2 are as follows: S21. Use OCR to identify text information in the design document and determine the class name and the relationship description between the classes; S22. Use the Mask R-CNN algorithm to segment the UI sketch, delineate the boundaries of each UI component, and determine the component position, size, and display hierarchy. S23. The pre-trained NLP model of the Transformer architecture processes the natural language requirement descriptions input by developers, extracts key verbs, key names, and related constraints, generates structured task descriptions, and determines the functional requirements and business logic of the target software functions.

4. The adaptive code generation method driven by multi-source heterogeneous input according to claim 3, characterized in that: The specific steps of step S3 are as follows: S31. Use code scanning tools to dynamically index the existing code base of the project to which the target software function belongs, and analyze the dependencies of the code related to the target software function: Determine the functional modules in the target software function; Track the calling relationship and parameter transfer relationship between functions in each functional module through static code analysis; Sort out the usage of API interfaces in each functional module, including the input and output parameters and call frequency of the API interfaces; S32. Use graph neural networks to construct a semantic graph of the existing code base by treating classes, functions, and variables in the existing code base as nodes and the relationships between nodes as edges.

5. The adaptive code generation method driven by multi-source heterogeneous input according to claim 4, characterized in that: The specific steps of step S4 are as follows: S41. Fine-tune the large language model in advance according to software development requirements; S42. Using the fine-tuned large language model, combined with the structured requirements information and the semantic graph of the existing code base, we generate the front-end, back-end, and database code frameworks and foundational code for the target software functionality, resulting in the full-stack code, as follows: Generate front-end HTML, CSS, and JavaScript code for the target software functions to build the page layout, style, and interactive effects of the target software functions; Generate backend processing logic code for target software functions; Generate corresponding data table structure in the database for target software function generation to store user data; S43. Use a similarity matching algorithm and an IF-IDF algorithm based on text features to compare the full-stack code with the code in the open source code base, and determine whether there is duplicate code in the full-stack code with a code fragment in the open source code base whose similarity is greater than a threshold; If yes, go to step S44; If not, proceed to step S5; S44. Use compliance firewalls to remediate duplicate code to comply with open source license requirements.

6. The adaptive code generation method driven by multi-source heterogeneous input according to claim 5, characterized in that: In step S42, the fine-tuned large language model is also pre-trained; The training dataset is constructed by taking the developer's requirements description, design documents, and user interface draft diagrams in natural language as input and the actual full-stack code of the target software function as output; Review the data source and copyright information of the actual full-stack code in the training dataset to ensure legal compliance; Pre-train a large language model for fine-tuning using a vetted training dataset.

7. The adaptive code generation method driven by multi-source heterogeneous input according to claim 5, characterized in that: The specific steps of the similarity matching algorithm in step S43 are as follows: Use the BERT model to encode the full-stack code and the open source code base fragments into vectors, calculate the cosine similarity, and determine if the cosine similarity is higher than the first threshold as a potential duplicate. For potential duplicate code segments, the TF-IDF algorithm is used to extract key text features and calculate the feature overlap rate. If the feature overlap rate is higher than the second threshold, it is confirmed as duplicate code; For confirmed duplicate code, check the corresponding open source license type. If the license has commercial use restrictions, trigger the compliance firewall for correction.

8. An adaptive code generation device driven by multi-source heterogeneous input, characterized in that: include: A multimodal input receiving module, configured to receive multimodal input describing the target software function, including natural language description, design documents, and user interface draft diagrams; Multimodal parsing module, used to parse multimodal input and extract structured requirement information of target software functions; A semantic graph construction module is used to dynamically index the existing code base of the project to which the target software function belongs, analyze the dependencies of the code in the existing code base that are related to the target software function, and build a semantic graph for the existing code base; The code generation and correction module is used to generate full-stack code for target software functions based on structured requirement information and semantic graphs using a large language model, and to detect and correct duplicate code in the full-stack code; The risk avoidance module is used to add a traceability statement to the file header or comment section of the full-stack code that has completed duplicate code detection and correction.

9. An electronic device, characterized in that: The method comprises 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 method implements the steps of the adaptive code generation method driven by multi-source heterogeneous input as claimed in any one of claims 1 to 7.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the adaptive code generation method driven by multi-source heterogeneous input are implemented as claimed in any one of claims 1 to 7.