Code generation method and device based on large model, medium and equipment

By combining a large language model and dynamic model library with a code rule base and sandboxed verification, automated compilation from natural language to machine language is achieved. This solves the problems of accuracy and universality in code generation in existing technologies, reduces operation and maintenance costs and cross-domain migration difficulty, and is suitable for code generation needs in multiple fields.

CN121560293APending Publication Date: 2026-02-24INNOVATION QIZHI TECH GRP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511713153.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-20
Publication Date
2026-02-24

AI Technical Summary

Technical Problem

Existing AutoML tools lack a high-precision mechanism for associating natural language descriptions with code constraints, which requires non-professional developers to repeatedly debug and consult documentation. This results in poor universality, and the cost of migrating code generation tools to different fields is high, making it difficult to meet compliance requirements.

Method used

By acquiring key tags that match the user's task description through a large language model, initial code is generated and validated through code rule bases and domain rule bases. Combined with dynamic model library and sandboxed verification, automated compilation and compliance assurance from natural language to machine language are achieved.

Benefits of technology

It improves the accuracy and efficiency of code generation, reduces operation and maintenance costs, is applicable to multiple fields, supports instant integration with new frameworks, reduces the risk of runtime crashes, and meets the rapid migration needs of scenarios with strong compliance requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121560293A_ABST
    Figure CN121560293A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of code generation, and particularly provides a code generation method and device based on a large model, a medium and equipment, and the method can comprise the steps: obtaining a key tag matched with a task type described by a user task; wherein the task type comprises a classification task or a regression task; different task types correspond to different key tags, and the number of the key tags is one or more; generating an initial code based on a large language model and the key tag; and checking the initial code to obtain a target code matched with the user task description. According to the embodiment of the invention, the code generation precision can be improved, and the method is suitable for non-professional research and development personnel and high in universality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of code generation technology, and more specifically, to a method, apparatus, medium, and device for code generation based on a large model. Background Technology

[0002] With the continuous development of Internet technology, in order to improve R&D efficiency, various code generation solutions are constantly emerging in the current fields of automated machine learning (AutoML) and code generation technology.

[0003] Currently, existing AutoML tools rely on precisely configured technical parameters (such as GridSearchCV(scoring='roc_auc')) to generate corresponding code. However, this approach fails to establish a deep semantic connection between natural language descriptions and code constraints. Moreover, traditional methods only perform simple conversions through keyword matching, lacking the ability to quantify and analyze ambiguous descriptions such as "high precision." This forces non-professional developers to repeatedly debug and consult documentation to meet their needs, severely restricting the widespread application of the technology.

[0004] Therefore, how to provide a technical solution for a code generation method based on a large model with high universality has become a technical problem that needs to be solved. Summary of the Invention

[0005] The purpose of some embodiments of this application is to provide a method, apparatus, medium and device for code generation based on a large model. The technical solutions of the embodiments of this application can improve the accuracy and efficiency of code generation, are suitable for non-professional developers, do not require manual parameters and have high universality.

[0006] In a first aspect, some embodiments of this application provide a method for code generation based on a large model, including: obtaining key tags that match the task type described in the user task description; wherein the task type includes classification tasks or regression tasks; different task types correspond to different key tags, and the key tags are one or more; generating initial code based on the large language model and the key tags; verifying the initial code to obtain target code that matches the user task description.

[0007] Some embodiments of this application obtain key tags corresponding to the task type described in the user's task description, and then combine them with a large language model to generate initial code; finally, the initial code is verified to obtain the target code. The code generated by the embodiments of this application can meet user needs, improve the accuracy and efficiency of code generation, and has high universality; moreover, it is low-cost and easy to maintain.

[0008] In some embodiments, obtaining the key tag that matches the task type in the user task description includes: performing semantic parsing on the user task description to obtain the task type; and obtaining the key tag that matches the task type through a task mapping table.

[0009] Some embodiments of this application obtain the task type by semantically parsing the user task description, and then obtain the corresponding key tags through the task mapping table, thereby realizing semantic-level analysis and providing support for generating code that meets user needs.

[0010] In some embodiments, generating initial code based on a large language model and the key tags includes: determining the model type corresponding to the key tags; and using the large language model to generate the initial code corresponding to the model type and the key tags.

[0011] Some embodiments of this application can improve the accuracy and efficiency of initial code generation by using a large language model to generate the corresponding initial code after determining the model type corresponding to the key label.

[0012] In some embodiments, the initial code includes at least one interface; the at least one interface is obtained by: calling the at least one interface from the dynamic model library using the large language model; if the at least one interface is a public type, then adding the at least one interface to the initial code; if the at least one interface is a private type, then configuring the at least one interface and adding it to the initial code.

[0013] Some embodiments of this application establish a dynamic model library, determine the type of at least one interface to be called, call it from the dynamic model library, and add the called interface to the initial code, thereby achieving accurate code generation.

[0014] In some embodiments, the step of verifying the initial code to obtain target code that matches the user task description includes: verifying the initial code using a code rule base; if the initial code contains disabled code from the code rule base, then replacing the disabled code in the initial code to obtain the target code.

[0015] Some embodiments of this application use a code rule base to verify the initial code to obtain the target code, thereby determining the validity and reliability of the generated code.

[0016] In some embodiments, verifying the initial code to obtain target code that matches the user task description includes: if the initial code conforms to the coding standards, using the initial code as the target code; if the initial code does not conform to the coding standards, correcting the initial code according to the coding standards to obtain the target code.

[0017] Some embodiments of this application verify the initial code through code writing standards to ensure that the generated code conforms to standard specifications.

[0018] In some embodiments, after obtaining the target code matching the user task description, the method further includes: testing the target code to obtain test results; wherein the types of tests include static compatibility testing and dynamic environment testing; and if the test results are abnormal, repairing the target code to obtain the repaired code.

[0019] Some embodiments of this application test the target code and can automatically repair it if the test results are abnormal, thereby obtaining repaired code. This can improve the accuracy of code generation and reduce the risk of subsequent runtime anomalies.

[0020] In some embodiments, after obtaining the target code that matches the user task description, the method further includes: determining the use case of the target code; obtaining semantic keywords that match the use case from a domain rule base; and injecting the compliance code module corresponding to the semantic keywords into the target code to obtain the target scenario code.

[0021] Some embodiments of this application can rewrite the target code to obtain the target scenario code through the domain rule base, realizing the customization requirements of the code in different scenarios, and have wide applicability.

[0022] Secondly, some embodiments of this application provide a code generation apparatus based on a large model, comprising: a matching module for obtaining key tags that match the task type described in the user task description; wherein the task type includes a classification task or a regression task; different task types correspond to different key tags, and the key tags are one or more; a generation module for generating initial code based on the large language model and the key tags; and a verification module for verifying the initial code to obtain target code that matches the user task description.

[0023] Thirdly, some embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the method described in any embodiment of the first aspect.

[0024] Fourthly, some embodiments of this application provide an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, can implement the method as described in any embodiment of the first aspect.

[0025] Fifthly, some embodiments of this application provide a computer program product, the computer program product including a computer program, wherein the computer program, when executed by a processor, can implement the method described in any embodiment of the first aspect. Attached Figure Description

[0026] To more clearly illustrate the technical solutions of some embodiments of this application, the accompanying drawings used in some embodiments of this application will be briefly described below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0027] Figure 1 System diagrams for code generation based on large models provided for some embodiments of this application; Figure 2 One of the flowcharts for a method of code generation based on a large model provided for some embodiments of this application; Figure 3 Flowchart 2 of the method for code generation based on a large model provided for some embodiments of this application; Figure 4 A block diagram of an apparatus for code generation based on a large model provided for some embodiments of this application; Figure 5 A schematic diagram of an electronic device provided for some embodiments of this application. Detailed Implementation

[0028] The technical solutions of some embodiments of this application will now be described with reference to the accompanying drawings.

[0029] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0030] In related technologies, traditional AutoML frameworks (such as Auto-Sklearn / H2O) achieve automated modeling through pre-built algorithm libraries and parameter optimization, but they have limitations such as lack of code generation capabilities, rigid architecture, and reliance on static configuration; visualization tools (such as Google AutoML Tables) provide GUI interfaces but output non-transparent models, with fixed processes and poor scalability; low-code platforms (such as Ludwig) use declarative configuration but still require specialized syntax, with weak dynamic adaptability and domain customization capabilities; code generation tools (such as Copilot) can only perform fragmented completion and lack systematic pipeline construction and domain constraints.

[0031] For example, current systems commonly use pre-compiled algorithm libraries (such as the 27 fixed models in Auto-Sklearn) as their technical foundation. Their rigid architecture cannot meet two key needs: first, custom modifications to the model's internal mechanisms (such as adjustments to the Transformer's attention mechanism); and second, immediate support for newly released frameworks (such as large models like Gemma and Mistral). This technology lock-in effect forces system update cycles to extend to 6-12 months, severely lagging behind the iteration speed of AI technology. Mainstream visual AutoML tools use binary model files (such as .pkl) as output, which has shortcomings in three key dimensions: untraceable feature engineering logic, unadjustable training parameters, and non-portable generated code snippets. This black-box operation not only hinders technical auditing but also makes it difficult to meet regulatory requirements in highly compliant fields such as finance and healthcare, resulting in a lack of transparency and controllability in the code generation process. Moreover, existing code generation tools (such as Copilot) suffer from design flaws in several key areas: memory management lacks dynamic control (e.g., adaptive batch size adjustment), data structure compatibility checks are missing (e.g., feature dimensions matching model input), and runtime monitoring modules are not integrated (e.g., feature drift detection). These flaws severely impact the industrial usability of the generated code, and the systemic security mechanisms for runtime are weak. Current low-code platforms (such as Ludwig) require manual implementation of domain-specific adaptations, including core requirements such as HIPAA-compliant encryption in the medical field and PSI feature stability monitoring in the financial field. This high barrier to entry severely limits the rapid deployment of AI technology in vertical fields, resulting in a relatively low degree of automation in cross-domain knowledge transfer.

[0032] As can be seen from the aforementioned technologies, existing technologies rely on preset rules or manually configured parameters (such as `scoring='accuracy'`), failing to translate natural language instructions like "high-precision interpretable models" into technical constraints, leading to a disconnect between requirements and implementation. Traditional AutoML is limited by pre-built algorithm libraries (such as Scikit-learn), unable to support custom architectures (such as Transformer fine-tuning), and new framework adaptation cycles can take more than 6 months, resulting in delayed algorithm library solidification and expansion. Code reliability assurance mechanisms are lacking; generative tools (such as Copilot) produce unverified code with a runtime crash rate exceeding 22% (dimensional errors, memory leaks, etc.), relying on manual debugging and incurring high maintenance costs. Furthermore, different domain knowledge (such as HIPAA compliance) requires repeated development; for example, migrating from finance to healthcare can take over 40 person-days, resulting in high cross-domain migration costs.

[0033] In view of this, some embodiments of this application provide a code generation method based on a large model. This method matches corresponding key tags based on the task type described in the user's task description, then combines this with a pre-trained large language model to generate initial code; finally, the initial code is validated to obtain the target code. Embodiments of this application can generate initial code that meets user needs through semantic-level parsing; the validation method can generate compliant code and significantly reduce runtime crash rates. It is widely applicable to various code generation scenarios, has broad applicability, and low maintenance costs.

[0034] The following is in conjunction with the appendix Figure 1 The overall composition structure of a code generation system based on a large model provided by some embodiments of this application is illustrated by way of example.

[0035] like Figure 1As shown, some embodiments of this application provide a system diagram for code generation based on a large model. This system may include a terminal 100 and a generation server 200. The terminal 100 can communicate with the generation server 200. Specifically, a user can input their actual code requirements (as a specific example of a user task description) on the terminal 100 and send it to the generation server 200. The task definition layer of the large language model deployed on the generation server 200 can perform semantic parsing of the user's actual requirements to obtain the task type; then, the constraint parsing layer can perform parameter mapping on the task type to determine its corresponding key labels; the model generation layer can determine the model type corresponding to the key labels, and then generate initial code corresponding to the model type; finally, the boundary control layer can verify the initial code to obtain the target code. Through the above implementation process, the complete automated compilation from natural language to machine language (i.e., target code) can be achieved. Moreover, this application is applicable to both professional and non-professional R&D personnel; non-professional R&D personnel can input a relatively simple task description according to their code requirements and provide it to the generation server 200; the generation server 200 will then automatically compile the natural language into machine semantics according to the above process.

[0036] In some embodiments of this application, terminal 100 can be a mobile terminal or a non-portable computer terminal; generation server 200 can be a local server or a cloud server; the embodiments of this application are not specifically limited herein. Additionally, the large language model can be pre-trained and then deployed on generation server 200.

[0037] The following is in conjunction with the appendix Figure 2 The present application provides an exemplary implementation of a code generation process based on a large model, performed by a generation server 200, according to some embodiments of this application.

[0038] Please see the appendix Figure 2 , Figure 2 A flowchart of a method for code generation based on a large model is provided for some embodiments of this application. This method for code generation based on a large model may include: S210, Obtain key tags that match the task type described in the user's task description. The task type includes classification tasks or regression tasks; different task types correspond to different key tags, and the key tags can be one or more. For example, in a specific embodiment of this application, the generation server 200 can receive user code generation requests (as a specific example of a user task description) sent by the terminal 100. By semantically parsing and matching the user code generation requests, corresponding key labels are obtained. In the field of machine learning, task types include classification tasks and regression tasks. Labels corresponding to classification tasks include broad category labels, such as binary classification labels, multi-class labels (such as multi-level classification), or multiple labels; key labels for regression tasks include numerical prediction labels, interval prediction labels, etc. Each label can also contain sub-labels; for example, binary classification labels can also include sub-category labels such as violation or compliance, positive examples or negative examples; the key labels matched by the task type can include broad category labels and / or sub-category labels.

[0039] In some embodiments of this application, S210 may include: performing semantic parsing on the user task description to obtain the task type; and obtaining the key tag that matches the task type through a task mapping table.

[0040] For example, in a specific embodiment of this application, a large language model is used to perform semantic parsing on the user's code generation requirements to obtain the task type to which the code belongs. The task type may include regression tasks, classification tasks, etc. Then, a task mapping table can be used to find key tags that match the task type. The task mapping table can be pre-built and stored in the large language model, and it includes at least one key tag corresponding to different task types. It can be flexibly set according to the actual application scenario, and this embodiment of the application does not impose specific limitations on it.

[0041] S220, based on the large language model and the key tags, generates initial code.

[0042] For example, in a specific embodiment of this application, the large language model can combine key tags to generate corresponding initial code.

[0043] In some embodiments of this application, S220 may include: determining the model type corresponding to the key tag; and generating the initial code corresponding to the model type and the key tag using the large language model.

[0044] For example, in a specific embodiment of this application, the model type corresponding to the code to be generated can be determined through key labels. The model type can be categorized as a classification model, regression model, etc. Then, the model type and key labels are input into the large language model, which can generate initial code that matches them. Alternatively, in other embodiments, the key labels can be directly input into the large language model, which generates corresponding initial code after parsing the key labels. For example, if the key labels are "violation" and "compliance" in binary classification, the large language model can generate a set of initial code that can detect whether the data is violation or compliance; the specific detection rules for the data can be set by the large model based on known industry-standard detection rules; or, the user can also define custom detection rules and input them as prompts into the large language model.

[0045] In some embodiments of this application, the initial code includes at least one interface; the at least one interface is obtained by the following steps: calling the at least one interface from the dynamic model library using the large language model; if the at least one interface is a public type, then adding the at least one interface to the initial code; if the at least one interface is a private type, then configuring the at least one interface and adding it to the initial code.

[0046] For example, in a specific embodiment of this application, the generation server 200 is also equipped with a dynamic model library linking mechanism, which can realize the calling of various interfaces. For example, when a large language model needs to call a certain interface during the code generation process, it can directly call it from the dynamic model library linking mechanism. For example, the {model_architecture} placeholder is designed to call the Hugging Face / PyTorch Hub API (Application Programming Interface) in real time, supporting one-click injection of new frameworks such as Gemma. Interfaces can be divided into public and private types. Public type interfaces can be directly called and added to the initial code. For private type interfaces, interface configuration is required during the call to meet the requirements for adding to the initial code. After configuration, they are added to the initial code, which also ensures the normal operation of subsequent code.

[0047] S230, the initial code is verified to obtain the target code that matches the user task description.

[0048] For example, in a specific embodiment of this application, in order to ensure the compliance and normal operation of the code, it is also necessary to verify the initial code, and then obtain the target code.

[0049] In some embodiments of this application, S230 may include: verifying the initial code using a code rule base; if the initial code contains disabled code from the code rule base, then replacing the disabled code in the initial code to obtain the target code.

[0050] For example, in a specific embodiment of this application, a code rule base can be pre-maintained within the large language model or locally on the generation server 200. This code rule base includes some prohibited codes. The code rule base can be used to detect the initial code and confirm whether it contains prohibited codes; if so, the prohibited codes need to be removed and modified to obtain the target code that meets the requirements. If no prohibited codes are found, the initial code can be used as the target code.

[0051] In some other embodiments of this application, S230 may further include: if it is confirmed that the initial code conforms to the coding standards, using the initial code as the target code; if it is confirmed that the initial code does not conform to the coding standards, correcting the initial code according to the coding standards to obtain the target code.

[0052] For example, in a specific embodiment of this application, the code writing needs to conform to the code writing standards; therefore, the code writing standards can be used to automatically detect the internal syntax structure of the initial code; if there are no syntax problems, the initial code is used as the target code; otherwise, the syntax problems existing in the initial code are improved to obtain the target code that conforms to the code writing standards.

[0053] In some embodiments of this application, after executing S230, the method for generating code based on a large model may further include: testing the target code to obtain test results; wherein the types of tests include static compatibility testing and dynamic environment testing; and if the test results are abnormal, repairing the target code to obtain repaired code.

[0054] For example, in a specific embodiment of this application, sandbox technology is used to test the target code to reduce the risk of subsequent runtime crashes. The types of testing include static verification (as a specific example of static compatibility testing) and dynamic verification (as a specific example of dynamic environment testing). Static verification verifies the compatibility of tensor dimensions in AST (Abstract Syntax Tree) parsing; specifically, static analysis of the tensor operation code (i.e., the target code) is performed using AST to preemptively identify dimension mismatch issues and avoid runtime errors. For example, AST can parse the target code to generate the code's syntax structure, verifying whether the tensor dimensions conform to the operation rules, such as determining whether the tensor dimensions in the generated matrix multiplication code match. Verification is then performed through sandbox execution, forming a closed loop of "parsing-verification-feedback." Dynamic verification involves embedding a resource monitoring agent (e.g., CPU / memory circuit breaker) into the sandbox container to test the execution environment of the target code.

[0055] After conducting the two types of tests described above, test results are obtained. If the test results indicate that the target code contains anomalies, the problems in the target code are automatically repaired, and an error log is generated. This error log can record information such as the cause and location of the code anomaly. This error log can be used to optimize the large language model, thereby improving the accuracy of subsequent code generation.

[0056] It is understood that, in addition to the two test types of static verification and dynamic verification mentioned above, other test types can be added, and the embodiments of this application are not limited to this; in addition to using sandbox technology for testing, other testing technologies can also be implemented to perform independent testing on the target code to reduce the risk of subsequent runtime crashes.

[0057] In some embodiments of this application, after executing S230, the method for generating code based on a large model may further include: determining the use case of the target code; obtaining semantic keywords that match the use case from a domain rule base; and injecting the compliance code module corresponding to the semantic keywords into the target code to obtain the target scenario code.

[0058] For example, in a specific embodiment of this application, the generation server 200 can pre-maintain a domain rule base, which includes semantic keywords related to the code under different usage scenarios; for example, medical → differential privacy, finance → PSI monitoring. After determining the specific usage scenario of the target code, the semantic keywords corresponding to the usage scenario can be queried from the domain rule base. Based on the semantic keywords, a compliance code module can be automatically injected into the target code to obtain the target scenario code.

[0059] The following is in conjunction with the appendix Figure 3The present application provides an exemplary description of the specific process of code generation based on a large model, as illustrated in some embodiments of this application.

[0060] Please see the appendix Figure 3 , Figure 3 A flowchart of a method for code generation based on a large model is provided for some embodiments of this application.

[0061] The above process is illustrated below by example.

[0062] S310, retrieve user task description.

[0063] S320 performs semantic parsing on the user's task description to obtain the task type.

[0064] S330 retrieves key tags that match the task type through the task mapping table.

[0065] S340, Determine the model type corresponding to the key label.

[0066] S350 uses a large language model to generate initial code corresponding to key tags and model types.

[0067] S360 verifies the initial code and obtains the target code that matches the user's task description.

[0068] It is understood that the specific implementation process of S310~S360 can be referred to the method implementation examples provided above. To avoid repetition, detailed descriptions are omitted here.

[0069] As can be seen from the above embodiments of this application, the present application has made the following improvements to address the problems existing in the prior art: 1) The layered prompt word compilation architecture proposed in this application achieves automated compilation from natural language to technical instructions (i.e., code) through a task definition layer (semantic parsing), a constraint parsing layer (parameter mapping), a template generation layer (code filling), and a boundary control layer (monitoring injection). This improvement eliminates the need for manual configuration, enabling the system to intelligently parse user instructions and seamlessly translate them into code implementation; the improvement effects include seamless connection between requirements and execution, allowing users to directly guide model construction with natural language, improving usability and efficiency.

[0070] 2) The dynamic model library linking mechanism in this application introduces the {model_architecture} placeholder to call external APIs (such as Hugging Face or PyTorch Hub) in real time, enabling one-click injection and deployment of new frameworks. This improvement breaks the dependence on static libraries, enabling the system to dynamically expand algorithm support; the improvement is reflected in significantly reducing the adaptation threshold of new technologies, supporting the instant integration of custom model architectures, and enhancing the system's scalability and responsiveness to cutting-edge frameworks.

[0071] 3) This application's sandboxed dynamic verification closed loop combines static verification (such as AST parsing tensor compatibility), dynamic verification (sandbox container built-in resource monitoring agent), and self-healing mechanisms (error log feedback reinforcement learning fine-tuning) to form a comprehensive automated assurance system. This improvement fills a gap in the verification mechanism, proactively preventing errors through multi-level monitoring and adaptive repair. The improvements include a comprehensive improvement in code quality, reduced runtime crash risk, more reliable automated output, and reduced maintenance burden.

[0072] 4) The domain knowledge circuit breaker injection engine in this application constructs a modular rule base (i.e., a domain rule base, such as medical differential privacy or financial PSI monitoring), which automatically identifies and injects compliant code modules based on semantic keywords. This improvement replaces manual custom development through the abstraction and intelligent matching of the rule base. The improvement results in significantly reducing the complexity of cross-domain migration, enabling seamless reuse of knowledge and rapid adaptation to scenarios, and improving the system's portability and compliance efficiency.

[0073] In summary, this application systematically addresses the inherent shortcomings of existing technologies in natural language understanding, such as generalization limitations, algorithmic lag, lack of code reliability, and high cross-domain migration costs, through four core technologies: a layered semantic compilation architecture, a dynamic model linking mechanism, a sandboxed verification loop, and a domain knowledge circuit breaker engine. This application enables AutoML systems to possess human-like semantic understanding capabilities and self-evolutionary characteristics, significantly reducing compliance costs for cross-domain applications while supporting complex customization needs and ensuring industrial-grade code reliability. Its automated compilation and verification architecture provides out-of-the-box intelligent solutions for highly complex and compliant vertical scenarios such as healthcare and finance, marking a crucial step towards the reliable engineering implementation of generative AI and demonstrating broad industrial application prospects.

[0074] Please refer to Figure 4 , Figure 4The diagram illustrates the composition of an apparatus for code generation based on a large model, provided in some embodiments of this application. It should be understood that this apparatus corresponds to the method embodiments described above and is capable of performing the various steps involved in the method embodiments. The specific functions of this apparatus can be found in the description above; detailed descriptions are omitted here to avoid repetition.

[0075] Figure 4 The large-model-based code generation device includes at least one software functional module that can be stored in a memory or embedded in the large-model-based code generation device in the form of software or firmware. The large-model-based code generation device includes: a matching module 410, used to obtain key tags that match the task type described in the user task description; wherein, the task type includes classification tasks or regression tasks; different task types correspond to different key tags, and the key tags are one or more; a generation module 420, used to generate initial code based on the large language model and the key tags; and a verification module 430, used to verify the initial code and obtain target code that matches the user task description.

[0076] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the aforementioned method, and will not be elaborated further here.

[0077] Some embodiments of this application also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can perform the operation of any of the methods corresponding to the methods provided in the above embodiments.

[0078] Some embodiments of this application also provide a computer program product, which includes a computer program, wherein when the computer program is executed by a processor, it can implement the operation of any of the methods corresponding to the above embodiments provided in the above embodiments.

[0079] like Figure 5 As shown, some embodiments of this application provide an electronic device 500, which includes a memory 510, a processor 520, and a computer program stored in the memory 510 and executable on the processor 520. When the processor 520 reads the program from the memory 510 via a bus 530 and executes the program, it can implement the methods of any of the above embodiments.

[0080] Processor 520 can process digital signals and can include various computing architectures. For example, it can be a complex instruction set computer architecture, a reduced instruction set computer architecture, or an architecture that implements multiple instruction set combinations. In some examples, processor 520 can be a microprocessor.

[0081] The memory 510 can be used to store instructions executed by the processor 520 or data related to the execution of instructions. These instructions and / or data may include code for implementing some or all of the functions of one or more modules described in the embodiments of this application. The processor 520 of this disclosure embodiment can be used to execute the instructions in the memory 510 to implement the methods shown above. The memory 510 includes dynamic random access memory, static random access memory, flash memory, optical memory, or other memories well known to those skilled in the art.

[0082] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0083] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0084] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A method for code generation based on a large model, characterized in that, include: Obtain key tags that match the task type described in the user's task description; wherein, the task type includes classification tasks or regression tasks; different task types correspond to different key tags, and the key tags may be one or more; Based on the large language model and the aforementioned key tags, initial code is generated; The initial code is validated to obtain the target code that matches the user task description.

2. The method as described in claim 1, characterized in that, The acquisition of key tags that match the task type described in the user's task description includes: Perform semantic parsing on the user task description to obtain the task type; The key tag matching the task type is obtained through the task mapping table.

3. The method as described in claim 1 or 2, characterized in that, The process of generating initial code based on the large language model and the key tags includes: Determine the model type corresponding to the key label; The initial code corresponding to the model type and the key tag is generated using the large language model.

4. The method as described in claim 1 or 2, characterized in that, The initial code includes at least one interface; the at least one interface is obtained through the following steps: The large language model is used to call at least one of the interfaces from the dynamic model library; If the at least one interface is of a public type, then the at least one interface is added to the initial code; If the at least one interface is of a private type, then the at least one interface is configured and added to the initial code.

5. The method according to any one of claims 1-2, characterized in that, The step of validating the initial code and obtaining the target code that matches the user task description includes: The initial code is validated using a code rule base. If the initial code contains prohibited code from the code rule base, the prohibited code in the initial code is replaced to obtain the target code.

6. The method according to any one of claims 1-2, characterized in that, The step of validating the initial code and obtaining the target code that matches the user task description includes: If the initial code is confirmed to conform to coding standards, the initial code will be used as the target code. If it is confirmed that the initial code does not conform to the code writing specifications, the initial code is corrected in accordance with the code writing specifications to obtain the target code.

7. The method according to any one of claims 1-2, characterized in that, After obtaining the target code that matches the user task description, the method further includes: The target code is tested to obtain test results; wherein, the types of tests include static compatibility testing and dynamic environment testing; If the test result is abnormal, the target code is repaired, and the repaired code is obtained.

8. The method according to any one of claims 1-2, characterized in that, After obtaining the target code that matches the user task description, the method further includes: Determine the use cases for the target code; Obtain semantic keywords that match the usage scenario from the domain rule base; The compliance code module corresponding to the semantic keywords is injected into the target code to obtain the target scenario code.

9. A device for code generation based on a large model, characterized in that, include: The matching module is used to obtain key tags that match the task type described in the user's task description; wherein, the task type includes classification tasks or regression tasks; different task types correspond to different key tags, and the key tags can be one or more. A generation module is used to generate initial code based on the large language model and the key tags; The verification module is used to verify the initial code and obtain the target code that matches the user task description.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program is executed by a processor to perform the method as described in any one of claims 1-8.

11. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored on the memory and running on the processor, wherein the computer program is executed by the processor to perform the method as described in any one of claims 1-8.

12. A computer program product, characterized in that, The computer program product includes a computer program, wherein the computer program is executed by a processor to perform the method as described in any one of claims 1-8.