WASM code automatic generation method and device based on artificial intelligence

By using large-model-based code generation models and code compilers in artificial intelligence code generation, the problem of insufficient standardization and compatibility of generated code in the prior art is solved, and more efficient and more usable automatic generation of WASM code is achieved.

CN119960745APending Publication Date: 2025-05-09ZHIWEI XINGYI (SHANGHAI) INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510034613.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-09
Publication Date
2025-05-09

AI Technical Summary

Technical Problem

In the prior art, when automatically generating code based on artificial intelligence tools, the generated code is insufficient in standardization and compatibility, resulting in poor usability of automatically generated code.

Method used

By obtaining target task information, a large-scale code generation model based on artificial intelligence is called to find matching code blocks in preset code blocks, and the built code compiler reads the code block content to generate target WASM program code.

Benefits of technology

The generated WASM code is more standardized and has better compatibility, which improves the efficiency and availability of automatically generating WASM code in artificial intelligence.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119960745A_ABST
    Figure CN119960745A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, discloses an automatic code generation method and device based on artificial intelligence, electronic equipment, a computer readable storage medium and a program product, and is used for solving the problem that in the prior art, generated codes are insufficient in normalization and compatibility when codes are automatically generated based on an artificial intelligence tool. And the availability of automatically generated codes is not good. The method comprises the following steps: acquiring target task information of which codes need to be generated; a code generation model is called to search a matched code block in preset code blocks based on the target task information, and the code generation model is constructed based on an artificial intelligence large model algorithm; according to understanding of the code generation model on the matched code blocks and the target task information, code content of the matched code blocks is read based on the constructed code compiler, and target WASM program codes are generated. According to the method, the WASM code which is more standard and better in compatibility can be automatically generated, and the code generation efficiency and availability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an artificial intelligence-based WASM code automatic generation method, device, electronic device, computer storage medium and computer program product. Background Art

[0002] With the rapid development of AIGC (AI Generated Content) technology, automated code generation has become an important trend in the field of software development. Combining AI-generated content technology with WASM (WebAssembly) will bring new possibilities for code generation and subsequent execution.

[0003] In the existing technology, the general code generation scheme is basically based on high-level programming languages, and the code generated in this way has different platform differences. For example, the code style generated by artificial intelligence based on different release versions may be different, and it is difficult for artificial intelligence tools to reverse the code interval that needs to be changed or fine-tuned through the code. When part of the code needs to be adjusted, the entire code is often reconstructed, making manual fine-tuning more difficult. Therefore, there is an urgent need for a method that can automatically generate code, which can make the generated code more standardized and more compatible, and can improve the efficiency and usability of artificial intelligence automatic code generation. Summary of the invention

[0004] The main purpose of the present invention is to solve the technical problem in the prior art that the code generated when automatically generating code based on artificial intelligence tools is not standardized and compatible enough, resulting in poor usability of the automatically generated code.

[0005] The first aspect of the present invention provides a WASM code automatic generation method based on artificial intelligence, comprising:

[0006] Obtain the target task information for which code needs to be generated;

[0007] Calling a code generation model to search for a matching code block in a preset code block based on the target task information, wherein the code generation model is constructed based on an artificial intelligence large model algorithm;

[0008] According to the code generation model's understanding of the matching code block and the target task information, a constructed code compiler reads the code content of the matching code block and generates a target WASM program code.

[0009] Optionally, in a first implementation of the first aspect of the present invention, after the build-based code compiler reads the code content of the matching code block and generates the target WASM program code, it further includes:

[0010] An instruction to adjust the program code is received, and the code generation model is called to modify the program code based on the compiler to obtain a modified target WASM program code.

[0011] Optionally, in a second implementation of the first aspect of the present invention, the build-based code compiler reads the code content of the matching code block and generates the target WASM program code, including:

[0012] Calling the constructed code compiler to read the content of the code block and perform initialization;

[0013] Inject the initialized code block into the custom runtime method;

[0014] Based on the code generation model's understanding of the code block and the task information for which code needs to be generated, the compiler calls the custom runtime method to generate WASM program code that matches the task information.

[0015] Optionally, in a third implementation of the first aspect of the present invention, injecting the initialized code block into the custom runtime method includes:

[0016] Define and add function parameters and return values, and add comments to the parameters and return values;

[0017] Build code blocks that can be used for WASM bytecode calls based on system APIs and user program service APIs;

[0018] Register the function pointer of the code block to the running instance to facilitate the WASM bytecode to call it.

[0019] Optionally, in a fourth implementation of the first aspect of the present invention, the compiler is an interpretive compiler.

[0020] Optionally, in a fifth implementation of the first aspect of the present invention, after the compiler calls the custom runtime method to generate the WASM program code that matches the task information, the method further includes:

[0021] Determine whether the generated WASM program code has been compiled;

[0022] If it has been compiled, try to execute the WASM program code directly;

[0023] If it has not been compiled, the fire method is called to interpret and execute each line of the WASM program code during its execution.

[0024] A second aspect of the present invention provides a WASM code automatic generation device based on artificial intelligence, comprising:

[0025] The acquisition module is used to obtain the target task information for which code generation is required;

[0026] A search module, used for calling a code generation model to search for a matching code block in a preset code block based on the target task information, wherein the code generation model is constructed based on an artificial intelligence large model algorithm;

[0027] A generation module is used to read the code content of the matching code block and the target task information based on the understanding of the code generation model, and generate the target WASM program code based on the constructed code compiler.

[0028] The third aspect of the present invention provides an artificial intelligence-based WASM code automatic generation device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the artificial intelligence-based WASM code automatic generation device performs the steps of the above-mentioned artificial intelligence-based WASM code automatic generation method.

[0029] A fourth aspect of the present invention provides a computer-readable storage medium, which stores instructions that, when executed on a computer, enable the computer to execute the steps of the above-mentioned artificial intelligence-based WASM code automatic generation method.

[0030] A fifth aspect of the present invention provides a computer program product, comprising a computer program / instruction, characterized in that when the computer program / instruction is executed by a processor, the steps of the above-mentioned artificial intelligence-based WASM code automatic generation method are implemented.

[0031] The technical solution provided by the present invention includes obtaining target task information for which code needs to be generated; calling a code generation model to search for a matching code block in a preset code block based on the target task information, wherein the code generation model is constructed based on an artificial intelligence large model algorithm; according to the code generation model's understanding of the matching code block and the target task information, a constructed code compiler reads the code content of the matching code block and generates a target WASM program code.

[0032] The method of the present invention can automatically generate WASM code, can make the generated code more standardized and more compatible, and can improve the efficiency and usability of automatic generation of WASM code by artificial intelligence. A device, electronic device, computer-readable storage medium and computer program product provided by the present invention also solve corresponding technical problems and achieve corresponding technical effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0034] Figure 1 This is a flow chart of a first embodiment of a method for automatically generating WASM code based on artificial intelligence in an embodiment of the present invention;

[0035] Figure 2 This is a schematic diagram of the architecture of a second embodiment of the method for automatic WASM code generation based on artificial intelligence in an embodiment of the present invention;

[0036] Figure 3 This is a flow chart of a second embodiment of the method for automatic WASM code generation based on artificial intelligence in an embodiment of the present invention;

[0037] Figure 4 Schematic diagram of an embodiment of a WASM code automatic generation device based on artificial intelligence in an embodiment of the present invention;

[0038] Figure 5 This is a schematic diagram of an embodiment of a WASM code automatic generation device based on artificial intelligence in an embodiment of the present invention;

[0039] Figure 6 The figure is a schematic diagram of a computer-readable medium in an embodiment of the present invention. DETAILED DESCRIPTION

[0040] Exemplary embodiments of the present invention will now be described more fully with reference to the accompanying drawings. However, exemplary embodiments can be implemented in a variety of forms, and should not be construed as limiting the present invention to the embodiments set forth herein. On the contrary, providing these exemplary embodiments enables the present invention to be more comprehensive and complete, and is more convenient for fully conveying the inventive concept to those skilled in the art. The same reference numerals in the figures represent the same or similar elements, components or parts, and thus their repeated description will be omitted.

[0041] Under the premise of being consistent with the technical concept of the present invention, the features, structures, characteristics or other details described in a specific embodiment do not exclude that they can be combined in one or more other embodiments in a suitable manner.

[0042] In the description of specific embodiments, the features, structures, characteristics or other details described in the present invention are intended to enable those skilled in the art to fully understand the embodiments. However, it does not exclude that those skilled in the art can practice the technical solutions of the present invention without one or more of the specific features, structures, characteristics or other details.

[0043] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0044] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0045] The term "and / or" or "and / or" includes all combinations of any one or more of the associated listed items.

[0046] See also Figure 1 , the first embodiment of the WASM code automatic generation method based on artificial intelligence in the embodiment of the present invention includes:

[0047] The commonly used code generation solutions in the current prior art are basically based on high-level programming languages, which are mainly for the purpose of being able to write programs in a way that is easier for humans to understand when editing codes to improve readability. However, if used in a scenario where artificial intelligence automatically writes and generates codes, the generated codes will have certain differences due to the differences in the understanding capabilities of different types or versions of artificial intelligence, which makes it difficult for artificial intelligence to adjust the codes generated based on high-level programming languages. When the existing solutions need to adjust the codes, basically all the codes need to be reconstructed, and the modification effect is not good when there is a need for manual fine-tuning.

[0048] Therefore, this embodiment proposes a WASM (WebAssembly) code automatic generation solution, which can generate WASM code based on user needs; among them, WASM (WebAssembly) as an efficient bytecode format provides cross-platform execution capabilities. Compared with traditional code generation methods, WASM has a huge advantage in the framework affinity of artificial intelligence. Through various existing resources, artificial intelligence frameworks usually have a good understanding of WASM bytecode specifications and WAST text formats.

[0049] S101, obtaining target task information for which code generation is required;

[0050] In this embodiment, the target task information for which code generation is required can be obtained according to the needs of the user. Specifically, the target task information for which code generation is required can be a prompt word in natural language, and the code generation model can obtain the target task information for which code generation is required by the user inputting the prompt word into the operating system.

[0051] S102, calling the code generation model to search for a matching code block in a preset code block based on the target task information;

[0052] The code generation model described in this embodiment is constructed based on an artificial intelligence large model algorithm, which can be a model that can understand and generate natural language content based on a deep learning algorithm architecture. After obtaining the target task information in the aforementioned steps, the target task information can be parsed, and the code blocks that match the task target information can be found based on the understanding of the contents of various preset code blocks.

[0053] For example, when the code generation model is a code generation model built based on the Copilot model, the overall project of the code block can be understood through the editing function of an IDE (Integrated Development Environment).

[0054] The preset code block described in this step is pre-built or split before executing a specific WASM program code generation task. The code block may be a code block of a commonly used tool or a code block pre-built based on the user's demand for WASM program code generation.

[0055] S103: Based on the understanding of the matching code block and the target task information by the code generation model, the constructed code compiler reads the code content of the matching code block and generates the target WASM program code.

[0056] In this embodiment, before executing the specific WASM code generation step, a detailed description document such as the definition and description of each code block at runtime is prepared based on the constructed code compiler. The code generation model can understand the specific content of the code block based on the detailed description document and the specific code content based on the artificial intelligence big model's ability to understand text, and generate the target WASM program code based on the code generation model's understanding of the code content of the matching code block.

[0057] In a specific implementation, the scheme for generating the target WASM program code specifically includes calling a constructed code compiler to read the content of the code block and initialize it; injecting the initialized code block into a custom runtime method; and based on the code generation model's understanding of the code block and the task information for which code needs to be generated, calling the custom runtime method based on the compiler to generate WASM program code that matches the task information.

[0058] In the method provided in this embodiment, the method of automatically generating code based on the constructed compiler and code generation model can make the generated code more standardized and more compatible, and can improve the efficiency and usability of automatic generation of WASM code by artificial intelligence.

[0059] See also Figure 2 as well as Figure 3 , the second embodiment of the WASM code automatic generation method based on artificial intelligence in the embodiment of the present invention includes:

[0060] The WASM code automatic generation scheme proposed in this embodiment can generate WASM code segments in various field scenarios based on user needs. Among them, the code automatic generation scheme described in this embodiment is built based on artificial intelligence generation (AIGC, AI Generated Content) technology. In addition, a compiler and executor are also constructed in this embodiment. The scheme in this embodiment can integrate the API into the compiler and execution environment when implementing the runtime API (Application Programming Interface), and provide an instance of a standard runtime (runtime). This scheme does not rely too much on the code logic of WASM. Complex code implementations and system call suggestions are all placed in the runtime API. In this embodiment, the WASM code generated based on artificial intelligence can integrate them. In a specific implementation, the architectural diagram of a code automatic generation method provided by the scheme in this embodiment is as follows. Figure 2 shown.

[0061] See also Figure 3 The following describes the processing flow of the automatic code generation method in this embodiment step by step.

[0062] Before obtaining task information that requires code generation to execute a specific task, this embodiment also includes constructing a code block that can be called by a WASM program in advance with the help of a system API and a user program service API, wherein the code block can have multiple functions, such as a code block that reads file content, a code block that generates an array, etc.

[0063] S301, obtaining target task information for which code generation is required;

[0064] Specifically, since the code generation model is used for automatic code generation in this embodiment, it is necessary to first obtain the user's needs, that is, obtain the task information for which code generation is required and input it into the code generation model; at the same time, the code generation model obtains the compiler information constructed in this embodiment.

[0065] The code generation model is constructed based on an artificial intelligence large model that can realize the AIGC (AI Generated Content) function, for example, by obtaining the artificial intelligence model framework through Chat GPT or Copilot. The task information that needs to generate code can be a prompt word or prompt phrase in natural language form, and the prompt word or prompt phrase in natural language form is directly input into the code generation model for processing.

[0066] To illustrate with a specific example, the task information may be "generate a WASM program that can read the contents of a target file" or "generate a WASM program that can print the first 20 Fibonacci arrays", etc. These are just two specific embodiments. The specific task information can be determined based on the user's needs, and it does not constitute a limitation on the task information.

[0067] S302, calling the code generation model to search for a matching code block in a preset code block based on the target task information;

[0068] After pre-building the code blocks that can be called by the WASM program, the code generation model is called to understand the compiler information constructed in the embodiment and the task information for which code needs to be generated, and the preset code blocks that match the target task information are searched based on the task information for which code needs to be generated.

[0069] The preset code block described in this step is pre-built or split before executing a specific WASM program code generation task. The code block may be a code block of a commonly used tool or a code block pre-built based on the user's demand for WASM program code generation.

[0070] S303: Based on the understanding of the matching code block and target task information by the code generation model, the constructed code compiler reads the code content of the matching code block and generates the target WASM program code;

[0071] After finding a matching preset code block, preparations are made before execution based on the preset code block, mainly including parsing the binary file of the code block so that it can be used during runtime.

[0072] The following is a specific example to illustrate the specific way to call the built code compiler to read the content of the code block and initialize it. Taking the global variable (global) code block as an example, when initializing, first search for the code block that needs to be initialized in the current task according to the identifier of each code block. After finding the corresponding code block, read the size and binary content in the global variable code block, parse the structure of the global variable segment in the code block, including the number, attributes, type and initialization expression of the global variables, parse and extract the initialization value of the code block, and store the parsed value in the value attribute for use at runtime to complete the initialization. A specific code example of the initialization process is as follows:

[0073]

[0074] After initialization, it also includes injecting the initialized code block into the custom runtime method; based on the code generation model's understanding of the code block and the task information that needs to generate code, the compiler calls the custom runtime method to generate WASM program code that matches the task information. Among them, the injection of the initialized code block into the custom runtime method includes: defining and adding the parameters and return values ​​of the function, and adding annotations to the parameters and return values; building a code block that can be used for WASM bytecode calls based on the system API and user program service API; registering the function pointer of the code block to the running instance to facilitate the WASM bytecode to call; thereby interacting with the WASM (WebAssembly) module by registering the custom runtime.

[0075] Specifically, the aforementioned initialized code block is quickly injected into the custom runtime. In this way, the WASM module can be fully exposed to the custom runtime, so that the compiler runtime method can easily access the resources in the WASM module, including but not limited to stack objects, pointers and other resources; then the function pointer of the code block is registered to the running instance to facilitate the WASM bytecode to call.

[0076] Among them, the compiler described in this step is an interpretive compiler. Compared with the traditional AOT (Ahead of Time Compiler) compiler, the interpretive compiler in this embodiment has an advantage in speed for compiling relatively large WASM files. In addition, in this embodiment, after compilation, the WASM bytecode is also executed. Before execution, it is necessary to determine whether the WASM bytecode has been compiled. If it has been compiled, it is directly executed; if it has not been compiled, the logic of the instruction is interpreted and executed through C++ statements through the fire method, and the jump conditions and function exit conditions are monitored during the execution process, so as to realize the interpretation and execution of each item during the operation of the WASM bytecode.

[0077] S304: Receive an instruction to adjust the program code, call the code generation model to modify the program code based on the compiler, and obtain a modified target WASM program code.

[0078] If the user has other requirements after execution, or needs to modify problems in the WASM bytecode, then after generating the program code, it also includes calling the code generation model to adjust and modify the code; specifically, the user can input program code adjustment instructions into the code generation model based on the requirements, and call the code generation model to adjust the program code according to the adjustment instructions to obtain the automatically generated target WASM program code.

[0079] The automatic code generation solution used in this step adopts the WASM (WebAssembly) format. Compared with traditional code generation methods, the artificial intelligence module has a good understanding of the WASM bytecode specification and text format (WAST). The structured code block segmentation and inclusive external API registration mechanism simplify the artificial intelligence framework's understanding of program capabilities and organization methods, allowing WASM to maintain good consistency in the artificial intelligence generation process, context modification, and intermediate code fragment modification.

[0080] The following is an example of a specific implementation scenario to illustrate the specific execution process. Take the target task information of generating and printing the Fibonacci array as an example, that is, when the task information that needs to generate code is to automatically generate WASM program code that can generate and print the Fibonacci array, the code generation model first searches for the corresponding code block based on the task information. In this embodiment, the specific function can be implemented based on the native code block env.printNumber.

[0081] The specific implementation code of the native code block is:

[0082]

[0083]

[0084] The code generation model generates WASM program code for printing the values ​​in the first 20 Fibonacci arrays based on the native code blocks and the task objectives obtained by AI semantic understanding. The program code can be specifically:

[0085]

[0086]

[0087]

[0088] After generating the specific code, the compiler and runtime of this embodiment verify and run the code generated by the code generation model. For example, one of the verification commands may be as follows:

[0089] wat2wasm. / AI / fib.wat-o. / AI / fib.wasm&&. / build / wasm-interpreter. / AI / fib.wasm

[0090] This command is specifically used to compile the WAT file so that it can be loaded and executed by the WebAssembly runtime or interpreter, and use the WebAssembly interpreter to load and run the generated fib.wasm file to execute its code logic. The fib.wat file refers to the specific code generated in this embodiment, and AI refers to the code generation model.

[0091] In a specific implementation, this embodiment also includes adjusting the program code based on further user needs. For example, the user can input the following prompt words into the code generation model based on the above code: "Print the number of this fibonacci in the Fibonacci array before printing the results." At this time, the code generation model can adjust the program code based on the newly input prompt words, and add instructions to increase the order of the value in the Fibonacci array before printing the results.

[0092] In the method provided in this embodiment, the method that can automatically generate code based on the constructed compiler and code generation model can make the generated code more standardized and more compatible, and can improve the efficiency and usability of automatic generation of WASM code by artificial intelligence; at the same time, the method in this embodiment can enable the code generation model to have a better understanding of WASM code through the constructed compiler, and can more conveniently modify and update the generated WASM code, thereby improving the efficiency of code generation and modification.

[0093] The above describes the WASM code automatic generation method based on artificial intelligence in the embodiment of the present invention. The following describes the WASM code automatic generation device based on artificial intelligence in the embodiment of the present invention. Figure 4 , an embodiment of the WASM code automatic generation device based on artificial intelligence in an embodiment of the present invention includes:

[0094] The acquisition module is used to obtain the target task information for which code generation is required;

[0095] A search module, used for calling a code generation model to search for a matching code block in a preset code block based on the target task information, wherein the code generation model is constructed based on an artificial intelligence large model algorithm;

[0096] A generation module is used to read the code content of the matching code block and the target task information based on the understanding of the code generation model, and generate the target WASM program code based on the constructed code compiler.

[0097] The method of the present invention can automatically generate WASM code, can make the generated code more standardized and more compatible, and can improve the efficiency and usability of automatic generation of WASM code by artificial intelligence.

[0098] In another embodiment of the present application, the artificial intelligence-based WASM code automatic generation device also includes a modification module, which is specifically used to: receive adjustment instructions for the program code, call the code generation model to modify the program code based on the compiler, and obtain a modified target WASM program code.

[0099] In another embodiment of the present application, the generation module is specifically used to: call the constructed code compiler to read the content of the code block and initialize it; inject the initialized code block into the custom runtime method; based on the code generation model's understanding of the code block and the task information for which code needs to be generated, call the custom runtime method based on the compiler to generate WASM program code that matches the task information.

[0100] In another embodiment of the present application, injecting the initialized code block into the custom runtime method includes:

[0101] Define and add function parameters and return values, and add comments to the parameters and return values;

[0102] Build code blocks that can be used for WASM bytecode calls based on system APIs and user program service APIs;

[0103] Register the function pointer of the code block to the running instance to facilitate the WASM bytecode to call it.

[0104] In another embodiment of the present application, the compiler is an interpretive compiler.

[0105] In another embodiment of the present application, the generation module is further used to: determine whether the generated WASM program code has been compiled; if it has been compiled, directly try to execute the WASM program code; if it has not been compiled, call the fire method to interpret and execute each item during the running of the WASM program code.

[0106] In addition, the details of the method that can be executed by the WASM code automatic generation device based on artificial intelligence described in the embodiments of the present application can refer to the contents in the aforementioned WASM code automatic generation method embodiment based on artificial intelligence, and the details will not be repeated here.

[0107] In the method provided in this embodiment, the method that can automatically generate code based on the constructed compiler and code generation model can make the generated code more standardized and more compatible, and can improve the efficiency and usability of automatic generation of WASM code by artificial intelligence; at the same time, the method in this embodiment can enable the code generation model to have a better understanding of WASM code through the constructed compiler, and can more conveniently modify and update the generated WASM code, thereby improving the efficiency of code generation and modification.

[0108] Based on the same inventive concept, an embodiment of this specification also provides an electronic device for automatic generation of WASM code based on artificial intelligence. The electronic device for automatic generation of WASM code based on artificial intelligence in an embodiment of the present invention is described in detail below from the perspective of hardware processing.

[0109] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this specification. Figure 5 The electronic device 500 according to this embodiment of the present invention is described. Figure 5 The electronic device 500 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0110] like Figure 5 As shown, the electronic device 500 is in the form of a general computing device. The components of the electronic device 500 may include, but are not limited to: at least one processing unit 510, at least one storage unit 520, a bus 530 connecting different system components (including the storage unit 520 and the processing unit 510), a display unit 540, etc.

[0111] The storage unit stores program codes, which can be executed by the processing unit 510, so that the processing unit 510 performs the steps according to various exemplary embodiments of the present invention described in the above processing method section of this specification. For example, the processing unit 510 can perform the following steps: Figure 1 or Figure 3 Steps shown.

[0112] The storage unit 520 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 5201 and / or a cache memory unit 5202 , and may further include a read-only memory unit (ROM) 5203 .

[0113] The storage unit 520 may also include a program / utility 5204 having a set (at least one) of program modules 5205, such program modules 5205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include the implementation of a network environment.

[0114] Bus 530 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0115] The electronic device 500 may also communicate with one or more external devices 100 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device 500, and / or any device that enables the electronic device 500 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 550. Furthermore, the electronic device 500 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 560. The network adapter 560 may communicate with other modules of the electronic device 500 through the bus 530. It should be understood that although Figure 5 Not shown, other hardware and / or software modules may be used in conjunction with electronic device 500, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0116] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the exemplary embodiments described in the present invention can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation method of the present invention can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.) or on a network, including a number of instructions to enable a computing device (which can be a personal computer, server, or network device, etc.) to execute the above method according to the present invention. When the computer program is executed by a data processing device, the computer-readable medium can implement the above method of the present invention, that is: Figure 1 or Figure 3 The method shown.

[0117] Figure 6 A schematic diagram of a computer-readable medium provided for an embodiment of this specification.

[0118] accomplish Figure 1 or Figure 3 The computer program of the method shown can be stored on one or more computer readable media. The computer readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0119] The computer readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by an instruction execution system, an apparatus, or a device or used in combination with it. The program code contained on the readable storage medium may be transmitted with any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.

[0120] In addition, the present invention also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the artificial intelligence-based WASM code automatic generation method as described in any of the above embodiments.

[0121] In summary, the present invention can be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that general data processing devices such as microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0122] The specific embodiments described above further describe the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the present invention is not inherently related to any specific computer, virtual device or electronic device, and various general devices can also implement the present invention. The above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

[0123] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

[0124] If the technical solution of this application involves personal information, the product using the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using the technical solution of this application has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to the collection of his or her personal information; or on the device that processes personal information, the personal information processing rules are notified by obvious signs / information, and the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; among them, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.

[0125] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A WASM code automatic generation method based on artificial intelligence, characterized in that: include: Obtain the target task information for which code needs to be generated; Calling a code generation model to search for a matching code block in a preset code block based on the target task information, wherein the code generation model is constructed based on an artificial intelligence large model algorithm; According to the code generation model's understanding of the matching code block and the target task information, a constructed code compiler reads the code content of the matching code block and generates a target WASM program code.

2. The method for automatic WASM code generation based on artificial intelligence according to claim 1 is characterized in that: After the build-based code compiler reads the code content of the matching code block and generates the target WASM program code, it also includes: An instruction to adjust the program code is received, and the code generation model is called to modify the program code based on the compiler to obtain a modified target WASM program code.

3. The method for automatic WASM code generation based on artificial intelligence according to claim 2 is characterized in that: The build-based code compiler reads the code content of the matching code block and generates the target WASM program code, including: Calling the constructed code compiler to read the content of the code block and perform initialization; Inject the initialized code block into the custom runtime method; Based on the code generation model's understanding of the code block and the task information for which code needs to be generated, the compiler calls the custom runtime method to generate WASM program code that matches the task information.

4. The method for automatic WASM code generation based on artificial intelligence according to claim 3 is characterized in that: The injecting of the initialized code block into the custom runtime method includes: Define and add function parameters and return values, and add comments to the parameters and return values; Build code blocks that can be used for WASM bytecode calls based on system APIs and user program service APIs; Register the function pointer of the code block to the running instance to facilitate the WASM bytecode to call it.

5. The method for automatic WASM code generation based on artificial intelligence according to claim 4 is characterized in that: The compiler is an interpretive compiler.

6. The method for automatic WASM code generation based on artificial intelligence according to claim 5 is characterized in that: After the compiler calls the custom runtime method to generate the WASM program code that matches the task information, the method further includes: Determine whether the generated WASM program code has been compiled; If it has been compiled, try to execute the WASM program code directly; If it has not been compiled, the fire method is called to interpret and execute each line of the WASM program code during its execution.

7. A WASM code automatic generation device based on artificial intelligence, characterized in that: The artificial intelligence-based WASM code automatic generation device includes: The acquisition module is used to obtain the target task information for which code generation is required; A search module, used for calling a code generation model to search for a matching code block in a preset code block based on the target task information, wherein the code generation model is constructed based on an artificial intelligence large model algorithm; A generation module is used to read the code content of the matching code block and the target task information based on the understanding of the code generation model, and generate the target WASM program code based on the constructed code compiler.

8. A WASM code automatic generation device based on artificial intelligence, characterized in that: The artificial intelligence-based WASM code automatic generation device includes: a memory and at least one processor, wherein the memory stores instructions; The at least one processor calls the instructions in the memory so that the artificial intelligence-based WASM code automatic generation device performs the steps of the artificial intelligence-based WASM code automatic generation method as described in any one of claims 1-6.

9. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the program / instructions are executed by the processor, the steps of the method for automatic WASM code generation based on artificial intelligence as described in any one of claims 1 to 6 are implemented.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the artificial intelligence-based WASM code automatic generation method as described in any one of claims 1 to 6 are implemented.