Component code generation method and device based on artificial intelligence, equipment and medium
Through the component code generation method based on artificial intelligence, the problem that fixed package components are difficult to meet personalized needs is solved, and the personalized generation and flexible application of component code is realized, which reduces development efficiency.
Patent Information
- Application Number
- CN202510310778.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-14
- Publication Date
- 2025-07-01
AI Technical Summary
Components in fixed packaging are difficult to meet the personalized needs of different business scenarios and lack dynamics and flexibility.
Using an artificial intelligence-based component code generation method, the component requirement description information is obtained, and the target component code is generated by obtaining the trained code generation model. This model trains the original code generation model by learning code samples and requirement description information of different components in different business scenarios to ensure that the generated component code can be adapted to specific application scenarios and basic features.
It realizes personalized generation of component code, can flexibly meet the needs of different business scenarios, and reduces the efficiency of component code development.
Smart Images

Figure CN120233998A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of artificial intelligence, fintech, and medical technology, and particularly relates to a method, device, equipment, and medium for generating component code based on artificial intelligence. Background Art
[0002] Currently, the business code of front-end project pages is mostly built from basic atomic contents such as tables, icons, and forms. Here, the so-called atoms are the most basic elements that make up a page and are indivisible. After these atoms are organized and encapsulated in a specific way, components are formed for reuse during development, such as table components, icon components, form components, etc.
[0003] Most developers build user interfaces based on the components encapsulated in a component library to improve development efficiency. However, when using these components, they can only be operated in accordance with the fixed reference and parameter passing forms of the components, and the application of components lacks dynamics and flexibility, making it difficult to meet the personalized needs of different business scenarios. Summary of the Invention
[0004] The present invention provides a method, device, equipment, and medium for generating component code based on artificial intelligence to solve the technical problem that components with fixed encapsulation are difficult to meet the personalized needs of different business scenarios.
[0005] In a first aspect, a method for generating component code based on artificial intelligence is provided, including: Obtaining requirement description information of a component, where the requirement description information includes component basic information and component application information, and the component application information is used to characterize the application situation of the component in a business scenario; Inputting the requirement description information into a trained code generation model, so that the trained code generation model generates target component code according to the component basic information and the component application information; The trained code generation model is obtained by training an original code generation model according to component code samples of different components in different business scenarios and requirement description information corresponding to the component code samples.
[0006] In a second aspect, a device for generating component code based on artificial intelligence is provided, including: An obtaining module, configured to obtain requirement description information of a component, where the requirement description information includes component basic information and component application information, and the component application information is used to characterize the application situation of the component in a business scenario; A code generation module, configured to input the requirement description information into a trained code generation model, so that the trained code generation model generates target component code according to the component basic information and the component application information; The trained code generation model is obtained by training an original code generation model according to component code samples of different components in different business scenarios and requirement description information corresponding to the component code samples.
[0007] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for generating component code based on artificial intelligence provided in the first aspect are implemented.
[0008] In a fourth aspect, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for generating component code based on artificial intelligence provided in the first aspect are implemented.
[0009] In the solution implemented by the method, device, device, and medium for generating component code based on artificial intelligence described above, first, requirement description information of a component is obtained, and then the requirement description information is input into a trained code generation model. The trained code generation model generates target component code according to the component basic information and the component application information provided in the requirement description information. In the present invention, an original code generation model is pre-trained according to component code samples of different components in different business scenarios and requirement description information corresponding to each component code sample, so that the trained code generation model can learn to generate component code according to the component basic information and the component application information in the requirement description information of any component, and ensure that the generated component code can adapt to the application situation required by the component application information and the basic characteristics required by the component basic information. Therefore, when a user needs to configure component code for a certain business page, by providing the requirement description information of the component, a target component code that can adapt to the component basic information and the component application information can be obtained, so as to provide various component codes for the user that can achieve a certain application in a certain business scenario, realizing personalized generation of component code. This code generation method can flexibly provide various component codes that meet the requirements for the user, can cope with the personalized requirements of different business scenarios, and at the same time reduce the development efficiency of component code. Description of the Drawings
[0010] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for the description of the embodiments of the present invention. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0011] Figure 1 It is a schematic diagram of an application environment of a component code generation method based on artificial intelligence in an embodiment of the present invention; Figure 2 It is a schematic flowchart of a component code generation method based on artificial intelligence in an embodiment of the present invention; Figure 3 It is a schematic flowchart of a component code generation method based on artificial intelligence in another embodiment of the present invention; Figure 4 It is a schematic flowchart of a component code generation method based on artificial intelligence in another embodiment of the present invention; Figure 5 It is a schematic structural diagram of a component code generation device based on artificial intelligence in another embodiment of the present invention; Figure 6 It is a schematic structural diagram of a computer device in an embodiment of the present invention. Detailed implementation manners
[0012] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are some but not all of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts belong to the scope of protection of the present invention.
[0013] The component code generation method based on artificial intelligence provided by the embodiments of the present invention can be applied in, for example Figure 1In the application environment, the client communicates with the server through the network. The server can obtain user input through the client, extract the requirement description information of the component from the user input, and then input the requirement description information into the trained code generation model. The trained code generation model extracts the component basic information and component application information from the requirement description information, and generates the target component code according to the component basic information and component application information. The server can send the target component code to the client so that the client can display the target component code on the user interface. In the present invention, the server pre-trains the original code generation model according to the component code samples of different components in different business scenarios and the requirement description information corresponding to each component code sample, so that the code generation model can learn to generate component code according to the component basic information and component application information in the requirement description information of a component, and ensure that the generated component code can adapt to the application situation required by the component application information and the basic characteristics required by the component basic information. Thus, when the user needs to configure component code for a certain business page, the user can provide the requirement description information of the component to the server and obtain the target component code that can adapt to the component basic information and component application information from the server, providing the user with component code that can achieve a certain application in a certain business scenario, realizing the personalized generation of component code. This code generation method can flexibly provide various component codes that meet the needs of users, can cope with the personalized needs of different business scenarios, and at the same time reduce the development efficiency of component code.
[0014] Among them, the client can include but is not limited to various personal computers, laptop computers, smart phones, tablet computers, and portable wearable devices. The server can be implemented by an independent server or a server cluster composed of multiple servers. The present invention will be described in detail through specific embodiments below.
[0015] Please refer to Figure 2 as shown in Figure 2 FIG. 10 is a schematic flowchart of a method for generating component code based on artificial intelligence provided by an embodiment of the present invention, including the following steps: S201, obtain the requirement description information of the component, where the requirement description information includes component basic information and component application information, and the component application information is used to characterize the application situation of the component in the business scenario.
[0016] The component code generation method provided by the present invention can be applied to a question-and-answer platform built based on a generative large model. This component code generation method can be executed by the server of the question-and-answer platform to obtain the requirement description information of the component from the user input received by the client of the question-and-answer platform, and then return to the user the component code generated according to the component basic information and component application information in the requirement description information, which can meet the application requirements of a certain business scenario. This method can generate personalized component codes for front-end developers in various application fields. For example, in the fintech field involved in software development such as insurance, credit, and banking, or in the medical technology field involved in software development such as intelligent medical consultation and health information, front-end developers of application programs can describe information such as the type of the component, the functions required by the component, and the business scenario involved by the component through the above-mentioned question-and-answer platform, and then obtain the required component code.
[0017] Exemplarily, the requirement description information may include but is not limited to the following: component basic information and component application information. The component basic information can be understood as the basic information used to distinguish different components, which can characterize the basic attributes of the component, the component type, the component name, etc. For example, the component basic information includes: component basic attributes (such as: default selected value, disabled state of the dropdown menu, etc.) and / or component type (such as: single-selection dropdown menu) and / or component name (such as: dropdown menu component). Then, through these component basic information, it can be determined that the component is a dropdown menu component, and the trained code generation model can generate the target component code based on the code generation logic of the dropdown menu component learned in the training stage and the component application information input into the model.
[0018] The component application information can be understood as the information that can reflect the application situation of a certain component in a certain business scenario. For example, the component application information may include the function description of a certain component for which the code needs to be generated by the developer, the description of the business scenario to which the component needs to be applied, user behavior data (such as clicks, inputs, searches, etc.), the interaction data between the user and the component (such as displaying a dropdown menu after clicking, and what information is displayed in the dropdown menu), etc.
[0019] For example, in the medical technology scenario, if it is necessary to obtain the component code of the department selection dropdown menu component of the hospital appointment registration system, the user input obtained from the question-and-answer platform may be the following example: In the hospital's online appointment registration system, this dropdown menu component is located on the appointment registration page, guiding patients to select the department for treatment. The dropdown menu initially displays "Please select a department". When clicked, it expands to list all the departments in the hospital. When the mouse hovers over the name of each department, a brief introduction of the department is displayed.
[0020] Then, through technologies such as rule-based text parsing or natural language processing, the following information can be obtained from the above user input: Component basic information: 1.1. Component name: Drop-down menu component; 1.2. Component basic attributes: Placeholder: By default, it shows "Please select a department". Component application information: 2.1. Business scenario description: The business system is the online appointment registration system of a hospital, and the page is the appointment registration page; 2.2. Function description: Guide patients to select the department for treatment; 2.3. Interaction behavior: When the user clicks, it expands and lists all the departments of the hospital; when the mouse hovers over each department name, a brief introduction of the department is displayed.
[0021] It should be noted that the above description of the specific content included in the component basic information and component application information is only an example provided for the component basic information and component application information, and does not limit its content.
[0022] S202. Input the requirement description information into the trained code generation model, so that the trained code generation model generates the target component code according to the component basic information and component application information.
[0023] Exemplarily, after the server obtains the requirement description information of the component, it inputs the requirement description information into the trained code generation model, and the trained code generation model will generate the target component code according to the code generation logic learned in the training stage and the component basic information and component application information in the requirement description information.
[0024] In this embodiment, the trained code generation model is obtained by training the original code generation model with component code samples of different components in different business scenarios and the requirement description information corresponding to each component code sample.
[0025] Among them, the requirement description information corresponding to each component code sample includes the component basic information and component application information of the component code sample.
[0026] For example, use component codes such as tables, forms, and icons used on different business pages of an insurance platform and a bank client as component code samples; further, requirement description information can be constructed based on the business pages where each table, form, icon, etc. are located, the business processes they participate in, the user behaviors involved in the business processes, interaction data, etc.
[0027] The original code generation model can be trained using component code samples and the requirement description information corresponding to the component code samples, so that the code generation model learns the mapping relationship between code logic, component basic information, and component application information through training, so that the trained code generation model can generate target component code for a component based on the requirement description information of the component.
[0028] Among them, the original code generation model can be constructed based on a deep neural network, or a large model based on artificial intelligence-generated content technology can be used as the original code generation model. This application does not make restrictions.
[0029] In summary, a component code generation method based on artificial intelligence provided by this application first obtains the requirement description information of the component, and then inputs the requirement description information into the trained code generation model. The trained code generation model generates target component code according to the component basic information and component application information provided in the requirement description information. In the present invention, the original code generation model is pre-trained according to component code samples of different components in different business scenarios and the requirement description information corresponding to each component code sample, so that the code generation model can learn to generate component code according to the component basic information and component application information in the requirement description information of a component, and ensure that the generated component code can adapt to the application situation required by the component application information and the basic characteristics required by the component basic information. Thus, when the user needs to configure component code for a certain business page, by providing the requirement description information of the component, the target component code that can adapt to the component basic information and component application information can be obtained, so as to provide the user with various component codes that can achieve a certain application in a certain business scenario, realizing the personalized generation of component code. This code generation method can flexibly provide the user with various component codes that meet the requirements, can meet the personalized needs of different business scenarios, and at the same time reduce the development efficiency of component code.
[0030] In some embodiments, the original code generation model can be trained in the following manner, such as Figure 3 shown, which may include the following steps: S301, input the component code samples of different components in different business scenarios and the requirement description information corresponding to the component code samples into the original code generation model to obtain a code generation result.
[0031] Exemplarily, organize the component codes used by various application programs in the financial field on different business pages. For example, the information filling form, loan business icon, information submission button, etc. used by the bank client on the loan page, and the order information form, order submission button, etc. used by the financial trading platform on the order page. Obtain the component codes of the same type of components applied in different business scenarios as a component code sample of this type of component.
[0032] The component code sample can be logically parsed through a neural network to generate requirement description information that can characterize the component basic information and component application information corresponding to the component code sample.
[0033] For example, the component code sample corresponding to the above-mentioned order submission button can correspond to the following requirement description information: This component is a button component and is applied to the order confirmation pages of various e-commerce and service reservation systems. After the user completes a series of order information filling such as selecting goods, filling in the shipping address, and selecting a payment method, the order can be submitted by clicking this button. Its implemented functions include: Submit order: When the button is clicked, the corresponding order submission logic is triggered, and the order information filled in by the user is sent to the backend server for processing.
[0034] Status display: During the order submission process, the button will display a loading status to prevent the user from clicking repeatedly; after successful or failed submission, there will be corresponding prompt messages.
[0035] Disabled status: When the order information is incomplete or there are errors, the button will be in a disabled state to avoid invalid order submissions.
[0036] During the training process of the original code generation model, the component code sample and the requirement description text corresponding to the component code sample are jointly used as the input data of the model and input into the code generation model together. The code generation model parses the functions that the component needs to set from the requirement description text and learns the code logic for implementing this function in a certain business scenario from the component code sample. For example, it may include the component code encapsulation method, parameter passing method, etc.
[0037] S302, Train the original code generation model according to the code generation result and the component code sample until the code generation model during training shows convergence to obtain the trained code generation model.
[0038] Exemplarily, compare the code generation result with the component code sample, generate a loss function according to the difference between the code generation result and the component code sample, adjust the parameters of the code generation model during training based on this loss function, and then use the component code sample and the requirement description text corresponding to the component code sample to perform a new round of training on the code generation model with adjusted parameters.
[0039] Repeat the above process until the value of the loss function is less than the preset threshold. At this time, it can be confirmed that the code generation model during training has shown convergence, and thus this model can be used as the trained code generation model.
[0040] In this embodiment, component code samples in different business scenarios and the requirement description texts corresponding to the component code samples are used as the model inputs in the model training process, enabling the code generation model during training to continuously learn the mapping relationship between the requirement description texts and the component codes, and learn the code editing logic when the component code samples implement a certain function for a certain business scenario. Thus, the trained code generation model can generate component codes according to the input requirement description texts, generating component codes according to the learned code editing logic, such as generating component codes according to the component code encapsulation method and parameter passing method commonly used in this scenario, so that developers can flexibly apply the component codes without being restricted by fixed encapsulation methods and code editing logics.
[0041] In some examples, the step "input the component code samples of different components in different business scenarios and the requirement description information corresponding to the component code samples into the original code generation model to obtain a code generation result" in the above step S301 can be executed through the following process: Sequentially input the component code samples of the same component in different business scenarios and the requirement description information corresponding to the component code samples into the original code generation model according to the degree of function superposition to obtain a code generation result.
[0042] Exemplarily, first input the component code sample of the basic style and the requirement description information of the component code sample into the original code generation model, and then input the component code sample with new functions superimposed on the component code of the basic style and its requirement description information into the code generation model during training. And so on, input the component code samples and requirement description information into the model according to the degree of function superposition.
[0043] In this way, it is more convenient for the model to focus on and learn the code editing logic of a certain function.
[0044] In some embodiments, as Figure 4 shown, the step "train the original code generation model according to the code generation result and the component code sample until the code generation model during training shows convergence to obtain a trained code generation model" in the above step S302 includes the following steps: S401, respectively calculate the preset loss evaluation metrics of the component code sample and the code generation result.
[0045] Exemplarily, the preset loss evaluation metrics may include metrics for evaluating the functional equivalence of the code generation result and the component code sample. For example, test cases can be written to evaluate whether the functions implemented by the code generation result are the same as those implemented by the component code sample. Or a code static analysis tool can be used to analyze the logical structure, variable usage, etc. of the code, determine the differences between the component code sample and the code generation result, and quantify the degree of difference.
[0046] In addition, the preset loss evaluation metrics may also include metrics for semantic similarity evaluation. For example, convert the code into a natural language description (such as using code annotation or document generation tools), and then calculate the semantic similarity score between the two descriptions.
[0047] In addition, the preset loss evaluation metrics may also include code style specification metrics or code style specification tags. The way of reference and parameter passing when generating component code can be restricted by the code style specification tags. When calculating the metric value, the code can be first parsed into the component reference part and the parameter passing part, and then compare whether the ways of component reference in the component code sample and the code generation result are the same, and compare whether the ways of parameter passing in each place are the same.
[0048] S402. Determine the loss value according to the preset loss evaluation metrics of the component code sample and the preset loss evaluation metrics of the code generation result.
[0049] Exemplarily, the preset loss evaluation metrics of the component code sample can be used as the standard value, and the difference between the preset evaluation metrics of the component code generation result and this standard value is calculated as the loss value.
[0050] S403. Train the original code generation model based on the loss value until the code generation model in the training shows convergence to obtain the trained code generation model.
[0051] Exemplarily, a loss function can be constructed based on the loss values corresponding to each code generation result, and the parameters of the code generation model are adjusted according to the loss function until the code generation model in the training shows convergence, so as to obtain the trained code generation model.
[0052] In this embodiment, the model loss is determined by calculating the preset loss evaluation metrics of the component code sample and the code generation result. This method is more flexible and diverse than directly comparing the component code sample and the code generation result in terms of code. Because different code implementation methods may have the same function, and the function evaluation pays more attention to the final effect achieved by the code, which can identify the same function behind different implementation methods and effectively determine the loss; and it helps to improve the generalization ability of the model. Since the function evaluation does not depend on a specific code form, the model pays more attention to the implementation principle of the function during the learning process and can better handle different inputs and scenarios.
[0053] In some embodiments, the preset loss evaluation metrics include at least one of the following: the evaluation metrics corresponding to the component code encapsulation method and the evaluation metrics corresponding to the component code parameter passing method.
[0054] For example, when training a code generation model applied to a medical scenario, the evaluation metrics corresponding to the component code encapsulation method may include the following: Security-related metrics (e.g., data access control compliance rate). The data access control compliance rate can be understood as ensuring that the access to sensitive medical data (such as patient personal information, case data, etc.) follows strict permission control during the encapsulation of component code. Calculate the ratio of the number of encapsulated code snippets that actually comply with the access control rules to the total number of encapsulated code snippets.
[0055] For example: In a component of a medical information management system, there are 10 pieces of encapsulated code related to patient medical records. Among them, 8 pieces set access permissions strictly in accordance with the principle of least privilege. Then the data access control compliance rate is 80%.
[0056] Functional cohesion, which is used to measure whether the functions of each module or class in the encapsulation of component code are single and closely related. Calculate the functional cohesion score by analyzing the coupling degree of different functions in the code. For example, if a component is mainly responsible for the patient appointment registration function and also contains a large amount of code unrelated to drug management, the cohesion is low.
[0057] In addition, the following description is made for the way of passing parameters in component code: Exemplarily, the way of passing parameters can include passing parameters by property, passing parameters by event, passing parameters by context, passing parameters by slot, and so on.
[0058] For example, for the patient information display component, passing parameters by property is mostly used, and the passed parameters are static information such as the patient's name, age, gender, or information that remains stable within a certain period of time.
[0059] For another example, when multiple component requirements share global data such as hospital departments information and medical policies, the way of passing parameters by context can be used to avoid the cumbersome process of passing properties layer by layer.
[0060] Exemplarily, when training the original code generation model, the evaluation metrics corresponding to the way of passing parameters in component code can be obtained by vectorizing the way of passing parameters involved in the code generation result / component code sample, and quantifying the metric values based on this vector representation.
[0061] In the embodiments of the present application, by setting evaluation indicators corresponding to the component code encapsulation method and / or evaluation indicators corresponding to the component code parameter passing method in the preset loss evaluation indicators, it is possible to constrain the component code encapsulation method and the parameter passing method during the training of the original code generation model, so that the code generation model during training can learn the mapping relationship between the component code encapsulation method and the requirement description information, and the mapping relationship between the parameter passing method and the requirement description information from the requirement description information and the component code samples. As a result, the trained code generation model can determine the component code encapsulation method and the parameter passing method according to the requirement description information input into the model, and generate component code based on the encapsulation method and the parameter passing method, so that the generated component code can meet the personalized requirements in a specific business scenario.
[0062] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0063] In one embodiment, a component code generation device based on artificial intelligence is provided. The component code generation device based on artificial intelligence corresponds one-to-one with the component code generation processing method based on artificial intelligence in the above embodiments. As Figure 5 shown, the component code generation device 500 includes an acquisition module 501 and a code generation module 502. The detailed description of each functional module is as follows: The acquisition module 501 is configured to acquire requirement description information of a component. The requirement description information includes component basic information and component application information, and the component application information is used to characterize the application situation of the component in a business scenario; The code generation module 502 is configured to input the requirement description information into a trained code generation model, so that the trained code generation model generates target component code according to the component basic information and the component application information; The trained code generation model is obtained by training an original code generation model according to component code samples of different components in different business scenarios and requirement description information corresponding to the component code samples.
[0064] In one embodiment, the component code generation device 500 based on artificial intelligence further includes a model training module, and the model training module is configured to train the original code generation model in the following manner: Input component code samples of different components in different business scenarios and requirement description information corresponding to the component code samples into the original code generation model to obtain a code generation result; Train the original code generation model according to the generated result of the code and the component code sample until the code generation model in training shows convergence to obtain the trained code generation model.
[0065] In one embodiment, the model training module is specifically configured to sequentially input the component code samples of the same component in different business scenarios and the requirement description information corresponding to the component code samples into the original code generation model according to the degree of function superposition to obtain the generated result of the code.
[0066] In one embodiment, the model training module is specifically configured to: respectively calculate the preset loss evaluation indexes of the component code sample and the generated result of the code; determine the loss value according to the preset loss evaluation index of the component code sample and the preset loss evaluation index of the generated result of the model; train the original code generation model based on the loss value until the code generation model in training shows convergence to obtain the trained code generation model.
[0067] In one embodiment, the preset loss evaluation index includes at least one of the following: the evaluation index corresponding to the component code encapsulation method and the evaluation index corresponding to the component code parameter passing method.
[0068] In one embodiment, the component basic information includes at least one of the following: component type and component basic attributes.
[0069] In one embodiment, the component application information includes at least one of the following: business scenario data associated with the component, user behavior data, interaction data, and function description.
[0070] In summary, the present invention provides an artificial intelligence-based component code generation device. First, it obtains the requirement description information of the component, and then inputs the requirement description information into the trained code generation model. The trained code generation model generates the target component code according to the component basic information and component application information provided in the requirement description information. In the present invention, the original code generation model is trained in advance according to the component code samples of different components in different business scenarios and the requirement description information corresponding to each component code sample, so that the trained code generation model can learn to generate component codes according to the component basic information and component application information in the requirement description information of any component, and ensure that the generated component codes can adapt to the application situation required by the component application information and the basic characteristics required by the component basic information. Thus, when the user needs to configure component codes for a certain business page, by providing the requirement description information of the component, the target component codes that can adapt to the component basic information and component application information can be obtained, so as to provide the user with various component codes that can achieve a certain application in a certain business scenario, realizing the personalized generation of component codes. This code generation method can flexibly provide the user with various component codes that meet the requirements, can cope with the personalized needs of different business scenarios, and at the same time reduce the development efficiency of component codes.
[0071] For the specific limitations of the artificial intelligence-based component code generation device, reference can be made to the limitations of the artificial intelligence-based component code generation method described above, and details will not be repeated here. Each module in the above component code generation device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor in the computer device in hardware form or be independent of it, or can be stored in the memory in the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0072] In one embodiment, a computer device is provided, as Figure 6 shown. The computer device 600 includes a memory 601, a processor 602, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the artificial intelligence-based component code generation method described in any of the above embodiments.
[0073] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by the processor, it implements the steps of the artificial intelligence-based component code generation method described in any of the above embodiments.
[0074] It should be noted that for the functions or steps that the above computer-readable storage medium or computer device can achieve, reference can be made to the descriptions of the steps of the artificial intelligence-based component code generation method in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0075] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the various embodiments provided in this application can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0076] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above.
[0077] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A component code generation method based on artificial intelligence, characterized in that: The method comprises: Obtaining component requirement description information, wherein the requirement description information includes component basic information and component application information, wherein the component application information is used to characterize the application of the component in a business scenario; Inputting the requirement description information into a trained code generation model, so that the trained code generation model generates target component code according to the component basic information and the component application information; The trained code generation model is obtained by training the original code generation model according to component code samples of different components in different business scenarios and requirement description information corresponding to the component code samples.
2. The method according to claim 1, characterized in that: The original code generation model is trained in the following way: Inputting component code samples of different components in different business scenarios and requirement description information corresponding to the component code samples into the original code generation model to obtain a code generation result; The original code generation model is trained according to the code generation result and the component code sample until the code generation model in training converges to obtain the trained code generation model.
3. The method according to claim 2, characterized in that The step of inputting component code samples of different components in different business scenarios and requirement description information corresponding to the component code samples into the original code generation model to obtain code generation results includes: According to the degree of functional overlap, component code samples of the same component in different business scenarios and requirement description information corresponding to the component code samples are sequentially input into the original code generation model to obtain the code generation result.
4. The method according to claim 2, characterized in that: The step of training the original code generation model according to the code generation result and the component code sample until the code generation model in training converges to obtain the trained code generation model includes: Calculating preset loss evaluation indicators of the component code sample and the code generation result respectively; Determining a loss value according to a preset loss evaluation index of the component code sample and a preset loss evaluation index of the code generation result; The original code generation model is trained based on the loss value until the code generation model in training converges to obtain the trained code generation model.
5. The method according to claim 4, characterized in that The preset loss evaluation index includes at least one of the following: an evaluation index corresponding to a component code encapsulation method and an evaluation index corresponding to a component code parameter transmission method.
6. The method according to any one of claims 1 to 5, characterized in that: The component basic information includes at least one of the following: component type and component basic attributes.
7. The method according to any one of claims 1 to 5, characterized in that: The component application information includes at least one of the following: business scenario data, user behavior data, interaction data and functional description associated with the component.
8. A component code generation device based on artificial intelligence, characterized in that: The device comprises: An acquisition module is used to acquire component requirement description information, wherein the requirement description information includes component basic information and component application information, and the component application information is used to characterize the application of the component in a business scenario; A code generation module, used for inputting the requirement description information into a trained code generation model, so that the trained code generation model generates target component code according to the component basic information and the component application information; The trained code generation model is obtained by training the original code generation model according to component code samples of different components in different business scenarios and requirement description information corresponding to the component code samples.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the component code generation method based on artificial intelligence as claimed in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the component code generation method based on artificial intelligence as claimed in any one of claims 1 to 7 are implemented.