A natural language and meta-model driven code generation system

By using a code generation system driven by natural language and meta-models, we have solved the problems of insufficient natural language understanding, model abstraction and code generation adaptability of low-code platforms. This system enables efficient and flexible code generation and cross-platform adaptation, thereby improving development efficiency and code quality.

CN121209875BActive Publication Date: 2026-05-01CHINA DATANG GRP DIGITAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA DATANG GRP DIGITAL TECH CO LTD
Filing Date
2025-08-20
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing low-code/no-code platforms suffer from insufficient natural language understanding capabilities, a lack of model abstraction and generality, and weak code generation adaptability, making it difficult to achieve a smooth transition from natural language to machine language and cross-platform code generation.

Method used

We employ a code generation system driven by natural language and meta-models. Through the AI ​​layer, we perform intent recognition, entity extraction, and context analysis to generate structured metadata. We then use a meta-model engine and a code template engine to generate code, and combine this with a visual development toolset for graphical display and management.

Benefits of technology

It achieves efficient conversion from natural language to structured code, lowers the development threshold, improves development efficiency and the flexibility and accuracy of code generation, ensures consistency in the style, architecture and quality of generated code, and supports cross-platform adaptation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121209875B_ABST
    Figure CN121209875B_ABST
Patent Text Reader

Abstract

The application discloses a natural language and meta-model driven code generation system, which comprises an AI layer containing multiple intelligent agents working cooperatively, the AI layer being configured to receive natural language instructions and perform intent recognition, entity extraction, context analysis and constraint verification through the intelligent agents to generate structured metadata; a meta-model engine configured to construct and instantiate one or more meta-model objects according to the structured metadata generated by the AI layer; and a code template engine configured to match one or more corresponding code templates from a code template library according to the content and type of the meta-model objects, and generate executable code or configuration files in one or more target languages through rendering. According to the scheme, natural language is converted into a meta-model decoupled from technology through AI, and high-quality standardized code is automatically generated through a template engine, thereby improving development efficiency and enabling developers to focus on core business innovation.
Need to check novelty before this filing date? Find Prior Art

Description

A code generation system driven by natural language and metamodel Technical Field

[0001] This application generally relates to the field of computer software development technology. More specifically, this application relates to a code generation system based on natural language and meta-model driven by natural language. Background Technology

[0002] As enterprises deepen their digital transformation, the market demand for software applications is growing, and business changes are becoming more frequent. Traditional software development models, such as the waterfall model or agile development, while having mature processes, have long development cycles and high labor costs, making it difficult to fully meet the urgent needs of modern enterprises for rapid business deployment and agile iteration.

[0003] To address this challenge, low-code / no-code development platforms have emerged. These platforms significantly lower the barrier to entry for development and improve development efficiency by providing a visual development interface and pre-built components, thus alleviating productivity bottlenecks to some extent.

[0004] However, existing low-code / no-code platforms and some rudimentary AI-integrated code generation tools still have significant limitations: First, insufficient natural language understanding: Most systems' understanding of natural language is limited to simple instruction or keyword matching, lacking deep semantic understanding and contextual analysis capabilities for complex and ambiguous business requirements. This results in low conversion accuracy and an inability to truly achieve a smooth transition from "human language" to "machine language." Second, a lack of model abstraction and generality: Existing platforms are typically tied to specific technology stacks or business scenarios, with low levels of abstraction in their underlying models and poor generality. When faced with complex or highly customized business logic, it is difficult to describe and drive it using a unified model, leading to limited scalability and reusability. Third, weak adaptability of code generation: The generated code is often template-based, making it difficult to adapt to changing backend architectures, frontend frameworks, or cross-platform deployment requirements. The system lacks fine-grained control over models, templates, and generation rules, making it difficult to achieve cross-language and cross-platform code generation.

[0005] In view of this, there is an urgent need to provide a code generation solution based on natural language and meta-model to solve the above problems and achieve end-to-end automatic conversion from natural language descriptions to structured, executable function definitions. Summary of the Invention

[0006] To address at least one or more of the technical problems mentioned above, this application proposes a code generation scheme based on natural language and meta-model driven in several aspects.

[0007] This application provides a code generation system based on natural language and metamodels, comprising: an AI layer containing multiple collaborative agents, the AI ​​layer being configured to receive natural language instructions input by a user on a client, and to perform intent recognition, entity extraction, context analysis, and constraint verification through the agents to generate structured metadata; a metamodel engine connected to the AI ​​layer, configured to construct and instantiate one or more metamodel objects based on the structured metadata generated by the AI ​​layer; and a code template engine connected to the metamodel engine, configured to match one or more corresponding code templates from a code template library based on the content and type of the metamodel objects, and to generate executable code or configuration files in one or more target languages ​​through rendering.

[0008] In some embodiments, the system further includes a visual development toolset that provides a graphical user interface configured to graphically display and manage the structure of the metamodel objects, and supports users to assemble business processes of the metamodel objects by dragging, referencing, and combining them, as well as supporting real-time preview of the assembly results.

[0009] In some embodiments, the intelligent agent includes: a semantic intelligent agent configured to identify the operational intent corresponding to a natural language instruction; an entity intelligent agent configured to extract structured entity information from the natural language instruction, wherein the entity information includes field names, data types, and verification rules; a context intelligent agent configured to identify the module or scenario to which the natural language instruction belongs; and a verification intelligent agent configured to receive and integrate the operational intent identified by the semantic intelligent agent, the entity information extracted by the business object intelligent agent, and the module or scenario determined by the context intelligent agent, and perform logical and business compliance checks on the integration result.

[0010] In some embodiments, the verification agent employs a multi-dimensional constraint mechanism to perform logical and business compliance checks on the integrated results. This multi-dimensional constraint mechanism includes: semantic domain restriction, configured to limit the parsing scope of operational intent and entity information to a preset semantic knowledge graph or terminology dictionary related to the current business domain; intent template constraint, configured to limit the identifiable semantic structure by matching natural language instructions with preset intent templates; entity type mapping constraint, configured to map entity information extracted from natural language instructions to a predefined meta-field format supported by the system; context scope restriction, configured to dynamically narrow the range of parsable operational intent and entities based on the module or scenario to which the natural language instruction belongs; and a semantic conflict detection and feedback mechanism, configured to introduce logical detection, identify and interrupt natural language instructions containing business contradictions, and provide feedback to the client.

[0011] In some embodiments, a multi-agent collaborative parsing mechanism is used to form a multi-stage parsing task link. During the execution of the multi-stage parsing task link, the following steps are performed: the semantic agent identifies the operation intent corresponding to the natural language instruction; the entity agent and the context agent extract structured entity information and the module or scenario to which the natural language instruction belongs in parallel or serially; the verification agent receives and integrates the operation intent identified by the semantic agent, the entity information extracted by the business object agent, and the module or scenario determined by the context agent, and performs logic and business compliance checks on the integration result.

[0012] In some embodiments, the metamodel engine is further configured to support the combination, inheritance, or nesting of multiple metamodel objects to form a composite metamodel structure.

[0013] In some embodiments, the code template engine includes a template matching and adaptation unit, a parameter binding and placeholder replacement engine, and a generation task orchestration and output management unit. The template matching and adaptation unit is configured to determine the macro-structure and template category to be followed by code generation by identifying the functional paradigm to which the meta-model object belongs, and using this category as navigation, combined with index information, to match one or more corresponding code templates from the code template library. The parameter binding and placeholder replacement engine is configured to map and replace the structured placeholders defined in the code template with the business data carried in the meta-model object, and instantiate the code template after replacing the structured placeholders into a code file through logical rendering operations. The generation task orchestration and output management unit is configured to organize the instantiation process of the code file into an automated task sequence, and to perform path configuration, naming rule setting, and merging strategy management for the final output file set.

[0014] In some embodiments, the functional paradigms include forms, lists, processes, and interface services.

[0015] In some embodiments, the index information includes keywords, model types, and tag classifications.

[0016] In some embodiments, the logical rendering operation includes object iteration, condition judgment, and function call.

[0017] Through the code generation scheme based on natural language and metamodels provided above, this application embodiment firstly leverages the deep understanding of natural language through the AI ​​layer. This significantly reduces the threshold and complexity of software development, enabling developers and even business analysts to quickly define functions through dialogue, thereby disruptively improving the efficiency of requirements communication and prototype design. Secondly, the metamodel engine, acting as an intermediary, achieves a perfect decoupling between business logic and technical implementation. This decoupling brings extremely high flexibility and scalability, meaning the system can easily adapt to any new front-end framework or back-end language by simply adding the corresponding template library. Finally, the code template engine ensures that all final output code is highly consistent in style, architecture, and quality, and conforms to best practices, completely eliminating the inefficiency and potential errors caused by manually writing repetitive boilerplate code, allowing developers to focus more on core business innovation.

[0018] Furthermore, in some embodiments, a visual development toolset is used to graphically display the abstract meta-models generated by AI, greatly improving the system's transparency and understandability, allowing users to intuitively review and manage business blueprints. Secondly, the introduction of visual operations empowers users with the ability to finely orchestrate complex business processes. This compensates for the shortcomings of relying solely on natural language to accurately describe complex logic and relationships, achieving efficient collaboration where AI handles rapid creation and humans handle precise assembly. Finally, the real-time preview function constructs an instant feedback loop, significantly reducing trial-and-error costs and allowing users to immediately see results at every step of the design process, thereby significantly accelerating the iteration speed from concept to finished product.

[0019] Furthermore, in some embodiments, a complex natural language understanding task is decomposed into three specialized and independent subtasks: operation intent recognition handled by the semantic agent, structured information extraction handled by the entity agent, and module and scenario determination handled by the context agent. This collaborative parsing chain ensures that the initial analysis of user input is both comprehensive and in-depth. Secondly, by verifying the agent and its multi-dimensional constraint mechanisms, it goes beyond simply integrating the results of preceding agents. Instead, it uses a series of explicit rules, such as semantic domain restrictions, intent template constraints, entity type mapping, context scope restrictions, and semantic conflict detection, to perform mandatory logical and business compliance checks on the integrated data. This process significantly improves the system's reliability and accuracy in handling instructions, proactively identifying and intercepting instructions containing business contradictions or not conforming to preset specifications, and providing feedback to the user.

[0020] Furthermore, in some embodiments, by identifying the functional paradigm of the metamodel object, code templates with correct macrostructure and template categories are accurately matched. This ensures that code generation follows a preset technical framework and structure from the outset, guaranteeing the directionality and structural correctness of the generation. By accurately mapping and replacing the business data carried by the metamodel into the structured placeholders of the template, and instantiating it into code files through logical rendering operations, the accuracy and complete implementation of business details in the code are guaranteed. By organizing the instantiation process of multiple code files into an automated task sequence, and managing the output file set with unified path configuration, naming rules, and merging strategies, the final delivered code is guaranteed to have a clear and standardized engineering organizational structure. Attached Figure Description

[0021] The above and other objects, features, and advantages of exemplary embodiments of this application will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of this application are illustrated by way of example and not limitation, and the same or corresponding reference numerals denote the same or corresponding parts, wherein:

[0022] Figure 1 shows an exemplary structural block diagram of a code generation system based on natural language and meta-model driven by an embodiment of this application;

[0023] Figure 2 shows an exemplary composition diagram of the intelligent agent according to an embodiment of this application;

[0024] Figure 3 shows an exemplary flowchart of the multi-stage parsing task chain in an embodiment of this application;

[0025] Figure 4 shows an exemplary composition diagram of the code template engine of an embodiment of this application. Detailed Implementation

[0026] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0027] It should be understood that the terms "comprising" and "including" used in the specification and claims of this application indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0028] It should also be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application. As used in this specification and claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this specification and claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations.

[0029] Figure 1 shows an exemplary structural block diagram of a code generation system 100 based on natural language and meta-model driven according to an embodiment of this application.

[0030] As shown in Figure 1, the code generation system 100 based on natural language and metamodels includes an AI layer 110, a metamodel engine 120, a code template engine 130, and a visual development toolset 140. In the embodiments of this application, the AI ​​layer 110, the metamodel engine 120, the code template engine 130, and the visual development toolset 140 may be separate units or integrated into the same controller; this application does not impose any limitations on these aspects.

[0031] Specifically, the AI ​​layer 110 includes multiple collaborative intelligent agents 10. The AI ​​layer 110 is configured to receive natural language instructions input by the user on the client and perform intent recognition, entity extraction, context analysis, and constraint verification through the aforementioned intelligent agents to generate structured metadata.

[0032] Specifically, the metamodel engine 120 connects to the AI ​​layer 110 and is configured to construct and instantiate one or more metamodel objects based on the structured metadata generated by the AI ​​layer. Simultaneously, the metamodel engine 120 supports the combination, inheritance, or nesting of multiple metamodel objects to form a composite metamodel structure. For example, an "approval process" can be assembled from sub-models such as "table cell model," "approval node," and "role permissions," with the system automatically handling dependencies, generation order, and rendering configuration. The metamodel objects are used to uniformly describe the data structure, business logic, or user interface of business functions.

[0033] Specifically, the code template engine 130 is connected to the metamodel engine 120 and is configured to match one or more corresponding code templates from the code template library based on the content and type of the metamodel object, and generate executable code or configuration files in one or more target languages ​​through rendering.

[0034] Specifically, the visual development toolset 140 provides a graphical user interface configured to graphically display and manage the structure of the aforementioned metamodel objects, and supports users to assemble business processes of the metamodel objects by dragging, referencing, and combining them, as well as to support real-time preview of the assembly results.

[0035] In the embodiments of this application, the specific composition of the intelligent agent 10 can be seen in Figure 2.

[0036] Figure 2 shows an exemplary composition diagram of the intelligent agent according to an embodiment of this application.

[0037] As shown in Figure 2, the intelligent agent 10 includes a semantic intelligent agent 11, an entity intelligent agent 12, a context intelligent agent 13, and a verification intelligent agent 14. Specifically, the semantic intelligent agent 11 is configured to identify the operation intent corresponding to the natural language command input by the user on the client. The entity intelligent agent 12 is configured to extract structured entity information from the aforementioned natural language command. The context intelligent agent 13 is configured to identify the module or scenario to which the natural language command belongs. The verification intelligent agent 14 is configured to receive and integrate the operation intent identified by the semantic intelligent agent, the entity information extracted by the business object intelligent agent, and the module or scenario determined by the context intelligent agent, and perform logical and business compliance checks on the integration result.

[0038] In the embodiments of this application, entity information includes field names, data types, and validation rules.

[0039] In this embodiment, the verification agent uses a multi-dimensional constraint mechanism to perform logical and business compliance checks on the integration results.

[0040] In the embodiments of this application, the multi-dimensional constraint mechanism includes semantic domain restrictions, intent template constraints, entity type mapping constraints, context scope restrictions, and semantic conflict detection and feedback mechanisms.

[0041] In embodiments of this application, the semantic domain restriction configuration is used to limit the scope of parsing operational intent and entity information to a preset semantic knowledge graph or terminology dictionary related to the current business domain. By restricting the semantic domain, intents and entities are parsed only within the specified domain semantic scope, avoiding cross-domain misunderstandings or generalized generation.

[0042] In some embodiments of this application, a user is configuring an enterprise approval process, with the semantic domain limited to "approval process". The knowledge graph / dictionary contains terms such as "node", "applicant", "approver", "cc", "conditional branch", "amount", "budget", "role", and "permission". When the user inputs a natural language instruction: "If the reimbursement amount is greater than X yuan, a CFO approval node needs to be added and copied to the department head", the intelligent agent 10 receives the natural language instruction and activates the "approval process" semantic domain. It recognizes words such as "reimbursement amount", "greater than 5000 yuan", "CFO", "approval node", "cc", and "department head" in the instruction. Since all these words exist in the terminology dictionary of "approval process", the intelligent agent 10 can accurately parse them as: amount (entity) > X (condition), add (operation) + approval node (entity), CFO (role), cc (operation), department head (role).

[0043] In embodiments of this application, the intent template constraint configuration is used to limit the identifiable semantic structure by matching natural language instructions with preset intent templates. Unmatched free statements will be prompted as unsupported formats or guided supplementary information, thereby avoiding the generation of illegal or incomplete metamodel fragments.

[0044] In the embodiments of this application, the preset intent templates include: Create + [page / module / entity], Add + [field / button / validation], Modify + [field attribute / page name], Configure + [permission / process], Delete + [page / field], etc.

[0045] In some embodiments of this application, when the user inputs a natural language instruction such as "Please add an address field for the customer entity", the intelligent agent 10 matches this sentence with the intent template. It successfully matches the add + [field] template, the instruction is valid, and the intelligent agent 10 continues to perform subsequent operations.

[0046] In some embodiments of this application, when the user inputs the natural language instruction "the customer's address," the intelligent agent 10 attempts to match this sentence with all intent templates. It cannot find a specific verb (such as create, add, or modify), and therefore cannot match any intent template. At this point, parsing fails, and a guiding prompt is returned to the client, such as "Instruction incomplete. Regarding 'the customer's address,' do you want to 'add,' 'modify,' or 'delete' it?"

[0047] In the embodiments of this application, entity type mapping constraint configuration is used to map entity information extracted from natural language instructions to predefined meta-field formats supported by the system. By restricting field names, data types, validation rules, etc., in natural language instructions to be mapped only to meta-field definition formats supported by the system, structural consistency and code generation feasibility are ensured.

[0048] In some embodiments of this application, when the user inputs a natural language instruction such as "Add a supplier's 'contact phone number,' which is text and cannot be empty," the intelligent agent 10 recognizes the entity "contact phone number" and includes the descriptions "text" and "cannot be empty." "Contact phone number" is mapped to the system field name contactPhone, "text" is mapped to the data type string, and "cannot be empty" is mapped to the validation rule required:true.

[0049] In the embodiments of this application, the context scope restriction configuration is used to dynamically narrow the scope of parsable operation intent and entities based on the module or scenario to which the natural language instruction belongs. By determining which functional module the user is currently operating in (e.g., in the "User Management" module or the "Report Design" module), and then only allowing the execution of legal operations under that module, the possibility of the user performing invalid or dangerous operations in the wrong place is greatly avoided.

[0050] In some embodiments of this application, the user's current interface is in the "Dashboard Design" module. The permitted intents in this context are creating charts, adding data sources, and modifying layouts. The prohibited intents in this context are creating users and configuring approval workflows. When the user inputs the natural language instruction "Create a new user here," agent 10 detects that the current scope is the "Dashboard Design" module, parses the user's intent as "create + user," and queries the rules to find that the intent to create a user is outside the allowed list of the "Dashboard Design" module. Therefore, the parsing is interrupted, and the user is prompted: "Currently in the Dashboard Design module, the 'create user' operation cannot be performed. Please go to the 'System Management - User Management' module to perform the operation."

[0051] In the embodiments of this application, a semantic conflict detection and feedback mechanism is configured to introduce logical detection, identify and interrupt natural language instructions containing business contradictions, and provide feedback to the client. For example, a user cannot require a field to be both "required and allowed to be empty." When such a logically inconsistent instruction is detected, the agent 10 will immediately stop and require the user to clarify their true intention, thereby ensuring that the final generated configuration is valid and executable.

[0052] In one embodiment of this application, when a user inputs a natural language instruction that "I want a 'Stock Quantity' field, which must be filled in, and if no one fills it in, let it default to null," agent 10 parses two constraints on the "Stock Quantity" field: constraint 1 and constraint 2. Constraint 1 comes from "Required" -> required: true, and constraint 2 comes from "Default Value: null." The system has a built-in rule: IF(required == true && default Value == null) THEN ConflictDetected = true. Agent 10 detects a logical conflict. A field cannot simultaneously satisfy both the conditions of "required" and "default value: null," because "required" means that the field must have a non-null value when it is created. Therefore, parsing is interrupted, and a clear prompt appears to the user: "The instruction has a logical conflict: the field 'Stock Quantity' is set to 'required,' but at the same time, 'default value: null' is required. Please choose one: 1. Cancel the requirement and allow the default value to be null. 2. Keep the requirement and provide a valid default value (such as 0)."

[0053] In the embodiments of this application, a multi-agent collaborative parsing mechanism is used to form agents into a multi-stage parsing task chain.

[0054] In the embodiments of this application, all agents are registered upon system startup or configuration. When a user inputs a command, the system captures the command and the current context (e.g., the user is on the "Customer Details Page" of a "Sales Management System"). Based on this context and task type (natural language parsing), the system dynamically selects and activates agent 10 to prepare for forming a task chain. According to task requirements, the system sequentially and automatically calls the most suitable agent in a logical order of "understanding-extraction-modeling-verification". The system can automatically determine the agent to be called based on the parsing context, current semantic state, and task type, and supports seamless switching between different agents, maintaining semantic integrity and task continuity during the switching process. Simultaneously, when role switching occurs during collaborative parsing by multiple agents, the system can automatically transfer and share contextual information, including historical dialogues, entity states, model dependencies, and task objectives, to ensure parsing consistency, reduce information loss, and improve the processing capability for fuzzy semantics or cross-round commands.

[0055] In the embodiments of this application, the specific process of executing the multi-stage parsing task chain can be referred to Figure 3.

[0056] Figure 3 shows an exemplary flowchart of the multi-stage parsing task chain in an embodiment of this application.

[0057] As shown in Figure 3, in step S310, the semantic agent identifies the operational intent corresponding to the natural language instruction. In step S320, the entity agent and the context agent extract structured entity information and the module or scenario to which the natural language instruction belongs in parallel or serially. In step S330, the verification agent receives and integrates the operational intent identified by the semantic agent, the entity information extracted by the business object agent, and the module or scenario determined by the context agent, and performs logical and business compliance checks on the integration result.

[0058] In some embodiments of this application, the natural language instruction entered by the user on the client is "Create a customer management page, including name, level, and mobile phone number fields, and support administrator approval." At this time, the semantic agent 11 identifies the core operation instruction by analyzing the predicate and object of the sentence. It filters out auxiliary descriptions and outputs the operation intent as "Create + Customer Management Page".

[0059] Simultaneously, entity agent 12 extracts structured field information from the natural language commands input by the user on the client. It identifies nouns and their associated attributes. Specifically, it identifies the "customer name" and, based on a pre-defined knowledge base or model, classifies it as a string. It identifies the "customer level" and, based on predefined business rules, classifies it as an enum (e.g., ordinary, VIP, strategic customer). It identifies the "phone number," classifies it as a string, and further associates it with pre-defined regular expression validation rules for "phone number" in the system. Then, it outputs entity information, including name (string), level (enum), and phone number (string + validation rules).

[0060] Meanwhile, the context-aware agent 13 locates the context in which the command occurred from the natural language instructions input by the user on the client. It makes this determination by recognizing locations, module nouns, or based on the user's current session state. In this example, it directly identifies the key phrase "in the management system." Therefore, its output determines the module or scenario as the management system module.

[0061] Next, the verification agent 14 integrates the outputs from semantic agent 11, entity agent 12, and context agent 13, along with constraint information from the natural language instructions: "Mobile number is required" and "This operation requires supervisor approval." Analyzing the phrase "Mobile number is required," and combining it with the mobile number field extracted by the entity agent, it adds a "required" attribute to this field. Simultaneously, it confirms that this field requires format validation. It then analyzes the phrase "This operation requires supervisor approval" and queries the approval process corresponding to the operation of creating a customer management page within the management system context. It verifies whether the process indeed has role restrictions (such as the "supervisor" role). The final output is: Mobile number field: required + format validated; Approval process: Role restrictions exist.

[0062] In the embodiments of this application, firstly, the semantic agent 11 identifies the core intent of the user instruction and constructs the operational skeleton of the metadata. Next, the entity agent extracts and standardizes specific business entity information (such as field names, types, and constraints) from the instruction and populates the corresponding parts of the metadata. Simultaneously, the context agent 13 identifies the module or scenario to which the instruction belongs, providing environmental background information for the metadata. Finally, the verification agent integrates and verifies all information to ensure its logical consistency and business compliance, ultimately encapsulating it into a complete and standardized set of structured metadata. The entire process strictly follows the predefined general metamodel system specifications.

[0063] The structured metadata output from AI layer 110 is a highly standardized, machine-readable format such as JSON or XML, fully conforming to the pre-built general metamodel system. This metadata uniformly describes the structure of data entities (name, fields, field types, constraints, etc.). Whether in data entities, UI components, or business processes, the description of the same concept will follow the specifications of the metamodel system. Because the metamodel is universal, this metadata can be shared and reused across different functional modules (such as access control and approval processes) and even different systems. Simultaneously, this structured metadata can be directly used as input to Software Development Kits (SDKs) for various languages ​​and platforms. For example, it can be input to a code generator to automatically generate Java / Python backend entity class code, database table structure scripts (DDL), and frontend form component definition code based on the metadata. Another example is input to a script renderer to dynamically render or adjust the layout and components of the UI interface based on the metadata. Through this multi-agent collaborative parsing and metadata output mechanism, AI layer 110 successfully transforms the user's natural language instructions into a high-level abstract description that the platform can understand, execute, and automatically generate code for, thereby realizing the core capability of low-code / no-code development.

[0064] In the embodiments of this application, the metamodel engine 120 assembles the scattered metadata (such as field name "username", data type "string", operation "add") output by the AI ​​layer 110 into one or more formal metamodel objects conforming to its internal specifications, according to preset rules. This object is a machine-readable business model containing a complete context. Furthermore, this object is multi-dimensional, including data structure, business logic, UI structure, and process relationships. Specifically, the data structure defines which data fields are required, such as user ID, order amount, and product name. The business logic defines the operation rules, such as "automatic reminder when inventory is less than 10". The UI structure defines the basic layout and elements of the interface, such as login form and data list. The process relationships define the order and dependencies of operations, such as "login is required to create an order".

[0065] In the embodiments of this application, the specific composition of the code template engine 130 can be seen in Figure 4.

[0066] Figure 4 shows an exemplary composition diagram of the code template engine of an embodiment of this application.

[0067] As shown in Figure 4, the code template engine 130 includes a template matching and adaptation unit 131, a parameter binding and placeholder replacement engine 132, and a generation task orchestration and output management unit 133.

[0068] In the embodiments of this application, the template matching and adaptation unit 131 is configured to determine the macro structure and template category that code generation needs to follow by identifying the functional paradigm to which the metamodel object belongs, and using this category as navigation, combined with index information, to match one or more corresponding code templates from the code template library.

[0069] In embodiments of this application, functional paradigms include forms, lists, processes, and interface services. Specifically, the identified functional paradigms determine the overall architecture and major categories of templates that code generation must follow.

[0070] In embodiments of this application, the index information includes keywords, model types, and tag classifications.

[0071] In the embodiments of this application, a coarse-grained classification (identifying functional paradigms) is first performed. Then, based on this classification, a refined search is performed using index information such as keywords and model types. Ultimately, structural-level adaptation (ensuring the correctness of the overall code framework) and context-level precise matching (ensuring the applicability of details and specific scenarios) are achieved, and one or more code templates most suitable for the current meta-model are found from the template library.

[0072] In the embodiments of this application, the structure of the code templates in the code template library is consistent with the meta-model, ensuring that the templates can understand and correctly process the data and logic in the meta-model. Each code template represents a specific, reusable functional pattern. This functional pattern includes CRUD operations, approval workflows, and data visualization. Specifically, CRUD operations are standard operations for creating, reading, updating, and deleting data. Approval workflows are used to handle business processes that require multi-step approval. Data visualizations are used to present data to users in the form of lists, charts, etc.

[0073] Meanwhile, the code template library supports various technical formats. Specifically, the code template library supports backend services, frontend pages, and configuration scripts. Backend services are used to generate server-side business logic, API interfaces, and other code; frontend pages are used to generate user interfaces such as forms and lists; and configuration scripts are used to generate script files required for deployment and environment configuration.

[0074] Furthermore, the template engine intelligently matches multiple collaborative code templates based on the specific definition of the metamodel. For example, a complete business function might match a backend API template, a frontend form template, and an access control template. The backend API template generates the API for handling data requests. The frontend form template generates the page for users to input and submit data. The access control template generates the logic code for controlling which users can access the function.

[0075] In the embodiments of this application, the parameter binding and placeholder replacement engine 132 is used to map and replace the structured placeholders defined in the code template with the business data carried in the metamodel object, and instantiate the code template after replacing the structured placeholders into a code file through logical rendering operations.

[0076] In the embodiments of this application, the logical rendering operation includes object iteration, condition judgment, and function call.

[0077] In the embodiments of this application, placeholders are predefined variable markers that await being filled with real data. For example, {{field.name}} and {{api.endpoint}} are both placeholders, where "." indicates a hierarchical relationship, meaning that the engine can understand and access nested data structures.

[0078] In the embodiments of this application, the metamodel object is a structured data object that carries specific information extracted from business requirements (such as field names, API paths, data types, etc.).

[0079] During the parameter binding and placeholder replacement engine 132's operation, it automatically analyzes all placeholders in the code template and then maps and binds these placeholders to the data structures in the metamodel object. For example, it binds the variable `{{field.name}}` in the template to the `name` property of the `field` object in the metamodel object. Next, the parameter binding and placeholder replacement engine 132 executes a rendering process, which includes complex logical operations such as object iteration, conditional judgment, and function calls. If the metamodel contains a list (such as a form with multiple fields), the parameter binding and placeholder replacement engine 132 can iterate through this list, repeatedly generating a piece of code for each item, thus achieving object iteration. The parameter binding and placeholder replacement engine 132 can determine whether to generate a certain piece of code based on a value in the metamodel, thus achieving conditional judgment. For example, `if field.is Required...` adds "required" validation logic to that field. Function calls support calling predefined functions in the template to process data. For example, use {{formatDate(field.createTime)}} to format a date, or use {{toCamelCase(field.name)}} to change the naming style.

[0080] After the binding, rendering, and replacement processes described above, all placeholders and logical directives in the template have been processed. This process ultimately instantiates the abstract template into one or more concrete, complete, and syntactically correct code files. The output is not fragmented text, but code that can be used and deployed directly. It can be a single file (such as a Java class) or a collection of related files (such as a front-end component containing HTML, CSS, and JS).

[0081] In the embodiments of this application, the task orchestration and output management unit 133 is configured to form an automated task sequence from the instantiation process of the aforementioned code files, and to perform path configuration, naming rule setting and merging strategy management on the final output file set.

[0082] In the embodiments of this application, during the process of assembling the instantiation process of code files into an automated task sequence, multiple independent code generation tasks (instantiation processes) are chained together into a logically ordered automated workflow. There are often dependencies between code generation tasks. For example, the backend API interface must be defined first so that the frontend page knows how to call it; the database table structure script must be generated first so that the business code can operate on it.

[0083] In one embodiment of this application, first, the "Backend API Generation" template is executed. Next, the "Frontend Page Generation" template is executed. Then, the "Database Script Generation" template is executed. Finally, the "Automated Test Script Generation" template is executed. This arrangement ensures the logical correctness of the entire generation process and the usability of the code.

[0084] In the embodiments of this application, by configuring paths, setting naming rules, and managing merging strategies for the final output file set, all generated code files are uniformly managed and configured to ensure they are correctly placed and organized. Output path configuration allows users to specify the directory where generated files should be saved. For example, all backend Java code can be configured to be placed in the path `src / main / java / com / example / `, all frontend Vue files in the path `src / views / `, and SQL scripts in the path `db / migrations / `. This ensures that the generated code can be seamlessly integrated into a standardized project directory structure. Naming rules allow users to define naming conventions for generated files. For example, rules can be set such that for a metamodel named `User`, the generated controller file is named `UserController.java`, the service layer file is named `UserService.java`, and the frontend page is named `UserManagement.vue`. This ensures naming consistency, readability, and maintainability of the codebase. Merging strategy management determines how the system should operate when a file with the same name already exists in the target location. For example, through merging, the system attempts to intelligently merge newly generated code into existing files.

[0085] In summary, through the code generation solution based on natural language and metamodels provided above, this application embodiment firstly leverages the deep understanding of natural language through the AI ​​layer. This significantly reduces the threshold and complexity of software development, enabling developers and even business analysts to quickly define functions through dialogue, thereby disruptively improving the efficiency of requirements communication and prototype design. Secondly, the metamodel engine, acting as an intermediary, achieves a perfect decoupling between business logic and technical implementation. This decoupling brings extremely high flexibility and scalability, meaning the system can easily adapt to any new front-end framework or back-end language by simply adding the corresponding template library. Finally, the code template engine ensures that all final output code is highly consistent in style, architecture, and quality, and conforms to best practices, completely eliminating the inefficiency and potential errors caused by manually writing repetitive boilerplate code, allowing developers to focus more on core business innovation.

[0086] Furthermore, in some embodiments, a visual development toolset is used to graphically display the abstract meta-models generated by AI, greatly improving the system's transparency and understandability, allowing users to intuitively review and manage business blueprints. Secondly, the introduction of visual operations empowers users with the ability to finely orchestrate complex business processes. This compensates for the shortcomings of relying solely on natural language to accurately describe complex logic and relationships, achieving efficient collaboration where AI handles rapid creation and humans handle precise assembly. Finally, the real-time preview function constructs an instant feedback loop, significantly reducing trial-and-error costs and allowing users to immediately see results at every step of the design process, thereby significantly accelerating the iteration speed from concept to finished product.

[0087] Furthermore, in some embodiments, a complex natural language understanding task is decomposed into three specialized and independent subtasks: operation intent recognition handled by the semantic agent, structured information extraction handled by the entity agent, and module and scenario determination handled by the context agent. This collaborative parsing chain ensures that the initial analysis of user input is both comprehensive and in-depth. Secondly, by verifying the agent and its multi-dimensional constraint mechanisms, it goes beyond simply integrating the results of preceding agents. Instead, it uses a series of explicit rules, such as semantic domain restrictions, intent template constraints, entity type mapping, context scope restrictions, and semantic conflict detection, to perform mandatory logical and business compliance checks on the integrated data. This process significantly improves the system's reliability and accuracy in handling instructions, proactively identifying and intercepting instructions containing business contradictions or not conforming to preset specifications, and providing feedback to the user.

[0088] Furthermore, in some embodiments, by identifying the functional paradigm of the metamodel object, code templates with correct macrostructure and template categories are accurately matched. This ensures that code generation follows a preset technical framework and structure from the outset, guaranteeing the directionality and structural correctness of the generation. By accurately mapping and replacing the business data carried by the metamodel into the structured placeholders of the template, and instantiating it into code files through logical rendering operations, the accuracy and complete implementation of business details in the code are guaranteed. By organizing the instantiation process of multiple code files into an automated task sequence, and managing the output file set with unified path configuration, naming rules, and merging strategies, the final delivered code is guaranteed to have a clear and standardized engineering organizational structure.

[0089] While numerous embodiments of this application have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will arise for those skilled in the art without departing from the spirit and intent of this application. It should be understood that various alternatives to the embodiments of this application described herein may be employed in the practice of this application. The appended claims are intended to define the scope of protection of this application and therefore cover equivalents or alternatives within the scope of these claims.

Claims

1. A code generation system based on natural language and meta-model driven by natural language, characterized in that... The system includes: an AI layer containing multiple collaborative agents configured to receive natural language commands input by the user on the client side, and to perform intent recognition, entity extraction, context analysis, and constraint verification through the agents to generate structured metadata; a metamodel engine connected to the AI ​​layer, configured to construct and instantiate one or more metamodel objects based on the structured metadata generated by the AI ​​layer; and a code template engine connected to the metamodel engine, configured to match one or more corresponding code templates from a code template library based on the content and type of the metamodel objects, and to generate executable code or configuration files in one or more target languages ​​through rendering. The agents include: a semantic agent configured to recognize the operational intent corresponding to the natural language commands; an entity agent configured to extract structured entity information from the natural language commands, wherein the entity information includes field names, data types, and verification rules; a context agent configured to identify the module or scenario to which the natural language commands belong; and a verification agent configured to receive... The system integrates the operational intent identified by the semantic agent, the entity information extracted by the business object agent, and the module or scenario determined by the context agent, and performs logical and business compliance checks on the integration result. The verification agent uses a multi-dimensional constraint mechanism to perform logical and business compliance checks on the integration result. The multi-dimensional constraint mechanism includes: semantic domain restriction, configured to limit the parsing scope of operational intent and entity information to a preset semantic knowledge graph or terminology dictionary related to the current business domain; intent template constraint, configured to limit the recognizable semantic structure by matching natural language instructions with preset intent templates; entity type mapping constraint, configured to map the entity information extracted from natural language instructions to a predefined meta-field format supported by the system; context scope restriction, configured to dynamically narrow the range of parsable operational intent and entities according to the module or scenario to which the natural language instruction belongs; and a semantic conflict detection and feedback mechanism, configured to introduce logical detection, identify and interrupt natural language instructions containing business contradictions, and feed back to the client.

2. The code generation system based on natural language and meta-model driven according to claim 1, characterized in that... The system also includes a visual development toolset, which provides a graphical user interface configured to graphically display and manage the structure of the metamodel objects, and supports users to assemble business processes of the metamodel objects by dragging, referencing, and combining them, as well as supporting real-time preview of the assembly results.

3. The code generation system based on natural language and meta-model driven according to claim 1, characterized in that... A multi-agent collaborative parsing mechanism is adopted to form a multi-stage parsing task link. During the execution of the multi-stage parsing task link, the following steps are performed: the semantic agent identifies the operation intent corresponding to the natural language instruction; the entity agent and the context agent extract the structured entity information and the module or scenario to which the natural language instruction belongs in parallel or serially; the verification agent receives and integrates the operation intent identified by the semantic agent, the entity information extracted by the business object agent, and the module or scenario determined by the context agent, and performs logical and business compliance checks on the integration result.

4. The code generation system based on natural language and meta-model driven according to claim 1, characterized in that... The metamodel engine is further configured to support the combination, inheritance, or nesting of multiple metamodel objects to form a composite metamodel structure.

5. The code generation system based on natural language and meta-model driven according to claim 1, characterized in that... The code template engine includes a template matching and adaptation unit, a parameter binding and placeholder replacement engine, and a generation task orchestration and output management unit. The template matching and adaptation unit is configured to determine the macro-structure and template category to be followed by code generation by identifying the functional paradigm to which the meta-model object belongs, and using this category as navigation, combined with index information, to match one or more corresponding code templates from the code template library. The parameter binding and placeholder replacement engine is used to map and replace the structured placeholders defined in the code template with the business data carried in the meta-model object, and instantiate the code template after replacing the structured placeholders into code files through logical rendering operations. The generation task orchestration and output management unit is configured to organize the instantiation process of the code files into an automated task sequence, and to perform path configuration, naming rule setting, and merging strategy management for the final output file set.

6. The code generation system based on natural language and meta-model driven according to claim 5, characterized in that... The functional paradigms include forms, lists, processes, and interface services.

7. The code generation system based on natural language and meta-model driven according to claim 5, characterized in that... The index information includes keywords, model type, and tag classification.

8. The code generation system based on natural language and meta-model driven according to claim 5, characterized in that... The logical rendering operation includes object iteration, condition judgment, and function call.

Citation Information

Patent Citations

  • Business logic code-free development method based on natural language understanding and conversion

    CN113791791A

  • Robot code generation system based on natural language programming and use method thereof

    CN118113270A