Target embedded code generation method and device, electronic equipment and storage medium

By extracting hardware entities and their interaction relationships from the embedded knowledge graph to generate embedded code, the problem of low accuracy of embedded code in the existing technology is solved, and more accurate code generation is achieved.

CN120704694AActive Publication Date: 2025-09-26LANGCHAO ELECTRONIC INFORMATION IND CO LTD

Patent Information

Application Number
CN202511199556.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-26
Publication Date
2025-09-26
Estimated Expiration
2045-08-26

AI Technical Summary

Technical Problem

The existing embedded code generation technology lacks hardware interaction when generating embedded code, resulting in low accuracy of the generated code.

Method used

By receiving the target code generation request, parsing the request description text and extracting the entity objects and their interaction relationships associated with the target hardware from the embedded knowledge graph, generating target prompt words, and inputting them into the code generation model to generate accurate embedded code.

Benefits of technology

It improves the accuracy of embedded code and can handle complex hardware-related details such as communication protocols, interface types, and signal parameters, ensuring that the generated code meets hardware characteristics and interaction requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120704694A_ABST
    Figure CN120704694A_ABST
Patent Text Reader

Abstract

The invention discloses a target embedded code generation method and device, electronic equipment and a storage medium, and relates to the technical field of code generation. The target embedded code generation method comprises the steps that a target code generation request is received, and a request description text in the target code generation request is analyzed; the entity objects closely related to the target hardware and the interaction relation of the entity objects can be extracted from the embedded knowledge graph. According to the process, natural language description is effectively converted into understanding of hardware characteristics, and therefore prompt words capable of accurately reflecting the hardware characteristics and requirements are generated. Then the generated target cue word is input into a code generation model, an embedded code matched with the target code generation request can be obtained, complex details related to hardware can be processed, the complex details comprise the interaction relation between entities and specific hardware attributes such as a communication protocol, an interface type and signal parameters, and the embedded code can be obtained. Therefore, the accuracy of the generated embedded code can be improved, and the technical problem that the accuracy of the generated embedded code is low is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of code generation, and in particular to a method, device, electronic device, and storage medium for generating target embedded code. Background Art

[0002] In current embedded software development, code generation typically relies on manual coding by software engineers or automated generation based on traditional templates. With the increasing complexity of embedded systems, manual code generation is time-consuming and labor-intensive, especially when it comes to controlling and managing specific hardware. Existing code generation technologies based on natural language processing lack the ability to understand the interactions between hardware components, resulting in low accuracy in the generated embedded code. Summary of the Invention

[0003] The present application provides a method, device, electronic device and storage medium for generating a target embedded code, so as to at least solve the problem of low accuracy in obtaining the generated embedded code in the related art.

[0004] The present application provides a method for generating a target embedded code, comprising: receiving a target code generation request, wherein the target code generation request includes a request description text, and the request description text is used to indicate the target embedded code applied to the target hardware; according to the parsing result of the request description text, determining at least one entity object associated with the target hardware and an interaction relationship between at least one of the entity objects from an embedded knowledge graph, wherein the embedded knowledge graph includes entity nodes for respectively indicating a plurality of entity objects, and the connection relationship between the entity nodes is used to indicate the connection relationship between the corresponding entity objects; obtaining a target prompt word based on the entity description information of at least one of the entity objects and the relationship description information of the interaction relationship; inputting the target prompt word into a code generation model to obtain the target embedded code that matches the target code generation request.

[0005] The present application also provides a device for generating a target embedded code, comprising: a receiving unit for receiving a target code generation request, wherein the target code generation request includes a request description text, and the request description text is used to indicate the target embedded code applied to the target hardware; a determining unit for determining, from an embedded knowledge graph based on the parsing result of the request description text, at least one entity object associated with the target hardware, and an interaction relationship between at least one of the entity objects, wherein the embedded knowledge graph includes entity nodes for respectively indicating a plurality of entity objects, and the connection relationship between the entity nodes is used to indicate the connection relationship between the corresponding entity objects; a combining unit for obtaining a target prompt word based on the entity description information of at least one of the entity objects and the relationship description information of the interaction relationship; and an input unit for inputting the target prompt word into a code generation model to obtain the target embedded code that matches the target code generation request.

[0006] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned methods for generating a target embedded code when executing the computer program.

[0007] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned methods for generating target embedded code are implemented.

[0008] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned target embedded code generation methods when executed by a processor.

[0009] Through this application, by receiving a target code generation request and parsing the request description text therein, it is possible to extract entity objects and their interaction relationships that are closely related to the target hardware from the embedded knowledge graph. This process effectively converts the natural language description into an understanding of the hardware characteristics, thereby generating prompt words that can accurately reflect the hardware characteristics and requirements. The generated target prompt words are then input into the code generation model, and an embedded code that matches the target code generation request can be obtained. This can handle complex hardware-related details, including the interaction relationships between entities and specific hardware properties, such as communication protocols, interface types, and signal parameters, thereby improving the accuracy of the generated embedded code and solving the technical problem of low accuracy of the generated embedded code. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0011] Figure 1 A hardware structure block diagram of a server device for a method for generating a target embedded code provided in an embodiment of the present application;

[0012] Figure 2 This is one of the schematic diagrams of an optional method for generating target embedded code according to an embodiment of the present application;

[0013] Figure 3 This is a second schematic diagram of an optional method for generating target embedded code according to an embodiment of the present application;

[0014] Figure 4 This is a third schematic diagram of an optional method for generating target embedded code according to an embodiment of the present application;

[0015] Figure 5 This is a fourth schematic diagram of an optional method for generating target embedded code according to an embodiment of the present application;

[0016] Figure 6 FIG5 is a fifth schematic diagram of an optional method for generating target embedded code according to an embodiment of the present application;

[0017] Figure 7 Schematic diagram six of an optional method for generating target embedded code according to an embodiment of the present application;

[0018] Figure 8 FIG7 is a seventh schematic diagram of an optional method for generating target embedded code according to an embodiment of the present application;

[0019] Figure 9 This is a structural block diagram of a device for generating target embedded code according to an embodiment of the present application;

[0020] Figure 10 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0021] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative work are within the scope of protection of this application.

[0022] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.

[0023] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0024] The method embodiments provided in the embodiments of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 This is a hardware structure diagram of a computer device for a method of generating a target embedded code according to an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown) a processor 102 (the processor 102 may include but is not limited to a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. The server device may also include a transmission device 106 and an input / output device 108 for communication functions. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.

[0025] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for generating the target embedded code in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implementing the above-mentioned method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0026] Transmission device 106 is used to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by a communication provider of the server device. In one embodiment, transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0027] In this embodiment, a method for generating a target embedded code is provided. Figure 2 is a flow chart of a method for generating a target embedded code according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:

[0028] S202, receiving a target code generation request, wherein the target code generation request includes a request description text, and the request description text is used to indicate a target embedded code to be applied to target hardware;

[0029] Optionally, in this embodiment, the target code generation request refers to an instruction issued by a user to generate specific code, which is the starting point for triggering the code generation process to clarify the requirements and direction of code generation.

[0030] Optionally, in this embodiment, the request description text may refer to, but is not limited to, the specific text content in the target code generation request that specifically describes the code requirements, and is used to elaborate on the relevant information of the code to be generated, such as application scenarios, functional requirements, compatible hardware, etc., to provide a specific basis for code generation.

[0031] It should be noted that when receiving the target code generation request issued by the user, the natural language description, hardware principle design drawing file, chip manual and other materials uploaded by the user along with the target code generation request are also received, and image recognition is performed on the hardware principle design drawing to obtain the recognition result, and the chip manual and the recognition result are combined with the uploaded natural language description to obtain the request description text.

[0032] Optionally, in this embodiment, the target embedded code refers to the embedded program code that is ultimately generated and can run on the target hardware. Its function is to implement specific functions and enable the target hardware to work as expected, such as controlling the operation of the target hardware, processing data, and other behaviors.

[0033] Optionally, in this embodiment, when a target code request for generating specific code is obtained from a user, the request contains a descriptive text to indicate the embedded code to be generated and suitable for the target hardware device. The code requirements are clarified through the request description text to ensure that the generated code can accurately adapt to the target hardware and meet the requirements.

[0034] S204: Determine, from the embedded knowledge graph based on the parsing result of the request description text, at least one entity object associated with the target hardware, and an interaction relationship between at least one entity object, wherein the embedded knowledge graph includes entity nodes for respectively indicating the plurality of entity objects, and the connection relationship between the entity nodes is used to indicate the connection relationship between the corresponding entity objects;

[0035] Optionally, in this embodiment, the parsing result refers to the result obtained after parsing the request description text, which is used to provide a basis for the entity objects and relationships contained in the target embedded code. It can be, but is not limited to, after obtaining the entity objects contained in the text description information, the description information of the entity objects, and the information related to the target embedded code, filling this information into the data element (JavaScript Object Notation, JSON) field, and using the filled data element field as the parsing result.

[0036] Optionally, in this embodiment, the embedded knowledge graph refers to a knowledge graph database established based on the hardware connection relationships and communication links in the server baseboard management controller (BMC) system, wherein the entities in the embedded knowledge graph can be but are not limited to being defined as various functional modules in the BMC system.

[0037] To further illustrate, in an optional embedded knowledge graph, entity objects such as baseboard management system, expansion module, input and output (IO) expansion module, temperature monitoring module, voltage monitoring module, fan module, storage module, etc. may be included. In the established knowledge graph database, the entity contains attribute information, and the attributes of the entity are defined as the specific name of the entity, the chip model of the entity, and the function of the entity. The attributes of the entity may also include the power supply of the entity, the driving current of the entity, the operating system version running on the entity, the kernel version of the entity, the corresponding product model, etc.

[0038] Alternatively, in one embodiment, Figure 3 As shown in the figure, it is an exemplary embedded knowledge graph. Figure 3In the embedded knowledge graph shown in , baseboard control manager 302 is connected to voltage control module 306 via analog-to-digital converter 304. Baseboard control manager 302 is also connected to fan control module 310 via pulse width modulation 308. Baseboard control manager 302 is connected to voltage control module 314 via general purpose input / output port 312. Furthermore, voltage control module 314 has entity attribute 316. Figure 3 The other functional modules shown in also have corresponding entity attributes, which are not shown in the figure.

[0039] Optionally, in this embodiment, the entity object may refer to, but is not limited to, a specific entity object corresponding to an entity node in an embedded knowledge graph, such as "A model chip" or "I2C protocol", which can serve as the basic component unit of the knowledge graph to record the description and properties of the corresponding functional module.

[0040] Optionally, in this embodiment, the interaction relationship between entity objects refers to the association method between different entity objects, which is used to reflect the hardware connection relationship and communication link relationship between various functional modules in the embedded system, such as "the chip is connected to the sensor through the SPI protocol."

[0041] Optionally, in this embodiment, based on the parsing results of the request description text, at least one entity object associated with the target hardware and at least one interaction relationship between these entity objects are found from the embedded knowledge graph. This process clarifies the process from demand parsing to knowledge graph query. By extracting entities and interaction relationships related to the target hardware, specific hardware association information and collaborative logic basis are provided for embedded code generation, so that the generated code conforms to the actual interaction rules between hardware.

[0042] S206, obtaining a target prompt word based on the entity description information of at least one entity object and the relationship description information of the interaction relationship;

[0043] Optionally, in this embodiment, the entity description information of the entity object refers to the detailed description of each entity object in the embedded knowledge graph, which may include but is limited to the entity's attributes (such as hardware model and parameters), functions (such as sensor measurement type), characteristics (such as the transmission rate of the communication protocol), etc., and is used to provide basic information for constructing prompt words by providing specific characteristics of the entity object.

[0044] Optionally, in this embodiment, the relationship description information of the interaction relationship refers to the specific description of the interaction relationship between entity objects, which is used to clarify the collaboration mode and rules between entities, and supplement the content about the interaction logic in the prompt words, which may include but is not limited to hardware connection relationships and communication link relationships.

[0045] It should be noted that hardware connection relationships refer to the physical or electrical connections between different hardware entities. They are used to define the physical interfaces and connection paths between hardware. They are the foundation of the embedded system's physical architecture, directly influencing hardware layout design and wiring implementation. They also serve as the basis for hardware initialization configuration in the code, for example, "the sensor is connected to the controller via pin A." Communication link relationships refer to the logical connections between hardware entities for data exchange through communication protocols. They define the data exchange rules and paths between hardware, determine the format and rate of data transmission, and enable different hardware entities to correctly interpret and respond to each other's data. For example, "the microcontroller communicates with the humidity sensor via bus A."

[0046] Optionally, in this embodiment, the target prompt word refers to the instruction text formed by integrating entity object description, interaction relationship and other information, which is used to convey the generation requirements of the target embedded code to the code generation model, which may include but is not limited to hardware information such as hardware adaptation, function implementation, and interaction logic.

[0047] Optionally, in this embodiment, detailed description information of at least one entity object obtained from the embedded knowledge graph is integrated with specific description information of the interaction relationship between these entity objects to form prompt words for generating target embedded code, clarifying the conversion process from knowledge graph information to code generation prompt words. By integrating entity features and interaction logic, the prompt words contain both specific hardware information and cover the collaboration rules between entities, so that the embedded code generated based on the prompt words can accurately adapt to the interaction requirements of the target hardware and related entities.

[0048] S208: Input the target prompt word into the code generation model to obtain the target embedded code that matches the target code generation request.

[0049] Optionally, in this embodiment, the code generation model refers to a large language model with code generation capabilities, which is used to receive target prompt words and automatically generate embedded codes that meet the requirements based on its own trained embedded domain knowledge, so as to convert the requirements described in natural language into correct and executable embedded codes.

[0050] Optionally, in this embodiment, the target embedded code refers to an embedded program output by the code generation model that matches the target code generation request.

[0051] Optionally, in this embodiment, the constructed target prompt words are input into the code generation model, and through the processing and generation capabilities of the model, the target embedded code that can meet the initially proposed code generation request is obtained, and the conversion steps from the requirement information to the final embedded code are clarified. The structured prompt words are converted into executable embedded code through the code generation model, and the automatic generation from the requirement description to the actual code is realized, which improves the efficiency of embedded code development and makes the generated code meet the needs of users.

[0052] Through the embodiment of the present application, by receiving the target code generation request and parsing the request description text therein, the entity objects closely related to the target hardware and their interaction relationships can be extracted from the embedded knowledge graph. This process effectively converts the natural language description into an understanding of the hardware characteristics, thereby generating prompt words that can accurately reflect the hardware characteristics and requirements. The generated target prompt words are then input into the code generation model, and an embedded code that matches the target code generation request can be obtained. It can handle complex hardware-related details, including the interaction relationship between entities and specific hardware properties, such as communication protocols, interface types, and signal parameters, thereby improving the accuracy of the generated embedded code.

[0053] As an optional solution, before determining at least one entity object associated with the target hardware and the interaction relationship between at least one entity object from the embedded knowledge graph based on the parsing result of the request description text, the method further includes:

[0054] S1, determining at least one functional module of at least one reference hardware as at least one reference entity object;

[0055] S2, determining a connection relationship between at least one reference entity object from reference entity description information of each of the at least one reference entity object, wherein the reference entity description information is used to indicate a module type and a module function of a functional module;

[0056] S3: Build an embedded knowledge graph based on at least one reference entity object and a connection relationship between at least one reference entity object.

[0057] Optionally, in this embodiment, the reference hardware refers to an example hardware device used to construct the knowledge graph, which is used to provide the source of entity objects and provide actual hardware basis for the construction of the knowledge graph, such as a certain model of single-chip microcomputer, temperature sensor and other hardware devices.

[0058] Optionally, in this embodiment, the functional module refers to a component with independent functions in the reference hardware, which can serve as the basic unit of the knowledge graph entity object and reflect the functional composition of the hardware, such as the general-purpose input / output (GPIO) module of the microcontroller, the data acquisition module of the sensor, etc.

[0059] Optionally, in this embodiment, the reference entity object refers to a basic element of the knowledge graph converted from a functional module of the reference hardware, which is used to represent a specific hardware functional module in the knowledge graph and is a basic node for constructing the graph.

[0060] Optionally, in this embodiment, the reference entity description information refers to the attribute information used to describe the reference entity object to define the characteristics of the reference entity object and provide a basis for determining the relationship between entities. It may include, but is not limited to, module classes such as communication modules, computing modules, and module functions such as data transmission and logical operations.

[0061] It should be noted that the functional modules of the reference hardware are identified as reference entity objects in the knowledge graph. Secondly, the connection relationships between these entity objects are determined based on their descriptive information, such as module type and function. Finally, a complete embedded knowledge graph is constructed based on the entity objects and connection relationships. The construction process of the embedded knowledge graph is clarified. By extracting functional modules and their associations from specific reference hardware, the scattered hardware knowledge is structured and networked to form a reusable domain knowledge resource. This provides stable knowledge support for the generation of embedded code according to requirements and improves the accuracy of the generated embedded code.

[0062] Through the embodiments of the present application, at least one functional module of at least one reference hardware is respectively determined as at least one reference entity object; the connection relationship between at least one reference entity object is determined from the reference entity description information of at least one reference entity object, wherein the reference entity description information is used to indicate the module type and module function of the functional module; based on at least one reference entity object and the connection relationship between at least one reference entity object, an embedded knowledge graph is constructed. By extracting functional modules and their associations from specific reference hardware, the scattered hardware knowledge is structured and networked to form a reusable domain knowledge resource, providing stable knowledge support for generating embedded code according to demand, and improving the accuracy of the generated embedded code.

[0063] As an optional solution, determining the connection relationship between at least one reference entity object from the reference entity description information of each of the at least one reference entity objects includes at least one of the following:

[0064] S1, determining a basic control connection relationship between at least one reference entity object from reference entity description information of each of the at least one reference entity objects, wherein the connection relationship includes the basic control connection relationship;

[0065] S2, determining a data transmission connection relationship between at least one reference entity object from the reference entity description information of each of the at least one reference entity objects, wherein the connection relationship includes a data transmission connection relationship;

[0066] S3, determining a system extension connection relationship between at least one reference entity object from the reference entity description information of each of the at least one reference entity object, wherein the connection relationship includes a system extension connection relationship;

[0067] S4: Determine a debugging interface connection relationship between at least one reference entity object from the reference entity description information of each of the at least one reference entity objects, wherein the connection relationship includes a debugging interface connection relationship.

[0068] Optionally, in this embodiment, the basic control connection relationship refers to the connection method between reference entity objects for realizing control functions, which is used to ensure the transmission of control instructions in the system and realize basic manipulation of hardware, so as to ensure the transmission of control instructions in the system and realize basic manipulation of hardware, which may include but is not limited to GPIO port connection, physical interface (Pin Connection, PIN) pin connection, digital-to-analog converter (DAC) pin connection, etc.

[0069] Optionally, in this embodiment, the data transmission connection relationship refers to a connection method for transferring data between reference entity objects, so that data can be effectively transferred between different functional modules to provide support for data processing and analysis, which may include but is not limited to including.

[0070] Optionally, in this embodiment, the system expansion connection relationship refers to the connection method between reference entity objects for system function expansion, which provides a hardware connection basis for subsequent functional expansion of the system, enhances the flexibility and scalability of the system, and may include but is not limited to serial peripheral interface (Serial Peripheral Interface, SPI) bus connection, low pin count (Low Pin Count, LPC) interface connection, etc.

[0071] Optionally, in this embodiment, the debug interface connection relationship refers to the connection method between reference entity objects for debugging purposes, which facilitates developers to debug, detect and troubleshoot the system and ensure the normal development and operation of the system, and may include but is not limited to Joint Test Action Group (JTAG) interface connection, In-System Programming (ISP) interface connection, etc.

[0072] Optionally, in this embodiment, based on the description information of the reference entity objects, the connections between them for implementing the control function are found to clarify the path and method of control instruction transmission in the system, providing a basis for the design of control logic in the embedded code.

[0073] Optionally, in this embodiment, based on the description information of the reference entity objects, the connection between them for data transmission is determined to clarify the data transmission path between different modules and provide a reference for the implementation of data interaction logic in the code.

[0074] Optionally, in this embodiment, a connection for system function expansion is found based on the description information of the reference entity object, providing a hardware connection basis for future function expansion of the system and ensuring that the expanded function can be successfully implemented.

[0075] Optionally, in this embodiment, the connection for debugging is determined based on the description information of the reference entity object to clarify the path of data interaction during the debugging process and provide hardware connection support for developers to perform system debugging.

[0076] It should be noted that, starting from the description information of the reference entity objects, four types of connection relationships between the reference entity objects are determined: basic control, data transmission, system expansion, and debugging interface, and at least one of the above is determined as a connection relationship. By extracting different types of connection relationships from the reference entity description information and clarifying these four types of connection relationships, the association information between entities in the embedded knowledge graph is enriched, allowing the knowledge graph to more comprehensively reflect the connection status of the hardware system. This provides more detailed and comprehensive knowledge support for the subsequent generation of embedded code based on the knowledge graph that meets the actual hardware connection requirements, and improves the accuracy of the generated target embedded code.

[0077] Through the embodiments of the present application, a basic control connection relationship between at least one reference entity object is determined from the reference entity description information of each of at least one reference entity object, wherein the connection relationship includes a basic control connection relationship; a data transmission connection relationship between at least one reference entity object is determined from the reference entity description information of each of at least one reference entity object, wherein the connection relationship includes a data transmission connection relationship; a system extension connection relationship between at least one reference entity object is determined from the reference entity description information of each of at least one reference entity object, wherein the connection relationship includes a system extension connection relationship; a debugging interface connection relationship between at least one reference entity object is determined from the reference entity description information of each of at least one reference entity object, wherein the connection relationship includes a debugging interface connection relationship. By clarifying these four types of connection relationships, the association information between entities in the embedded knowledge graph is enriched, so that the knowledge graph can more comprehensively reflect the connection status of the hardware system, and provide more detailed and comprehensive knowledge support for the subsequent generation of embedded code that meets the actual hardware connection requirements based on the knowledge graph, thereby improving the accuracy of the generated target embedded code.

[0078] As an optional solution, the target prompt word is obtained based on the entity description information of at least one entity object and the relationship description information of the interaction relationship, including:

[0079] S1, obtaining a first code snippet matching the parsing result from a code database, wherein the code database contains code snippets matching at least one entity object respectively;

[0080] S2, determining, from a code database, at least one first reference code segment located before the first code segment, at least one second reference code segment located after the first code segment, and the first code segment;

[0081] S3, determining a target storage path according to code storage paths corresponding to the at least one first reference code segment, the at least one second reference code segment, and the first code segment;

[0082] S4, obtaining a target prompt word according to the entity description information of each of the at least one entity object, the relationship description information of the interaction relationship, and a combination of multiple target storage paths.

[0083] Optionally, in this embodiment, the code database refers to a collection that stores a large number of embedded code snippets. These code snippets correspond to entity objects in the knowledge graph, provide reusable code resources for code generation, and are the basis for obtaining reference codes.

[0084] Optionally, in this embodiment, the first code snippet refers to a code snippet selected from the code database that directly matches the parsed result. It can also be understood as a relevant code snippet that meets the requirements of the code acquisition request, serving as a basic snippet for generating the target code and directly associated with the core functionality of the requirement. In this embodiment, the first code snippet can be one or more first code snippets.

[0085] Optionally, in this embodiment, the first reference code snippet refers to a code snippet located before the first code snippet, and may be code that is pre-dependent or associated with the first code snippet, such as initialization code of the first code snippet.

[0086] Optionally, in this embodiment, the second reference code fragment refers to a code fragment located after the first code fragment, and may be subsequent logic or associated extended code of the first code fragment, such as an execution code after data processing.

[0087] Optionally, in this embodiment, the code storage path refers to the storage location information of the code snippet in the database, which is used to identify the storage location of the code and provide a basis for determining the target storage path.

[0088] Optionally, in this embodiment, the target storage path refers to a comprehensive path determined based on the storage paths of the first code snippet and its preceding and following reference code snippets, which is used to locate the complete code logic chain related to the requirements to improve the relevance and integrity of the code snippets.

[0089] Optionally, in this embodiment, the first code snippet that matches the request parsing result is screened out from a database storing a large number of code snippets. These code snippets correspond to entity objects in the knowledge graph, providing basic snippets for subsequent code generation.

[0090] Next, in the code database, find the preceding reference code before the first code fragment as the first reference code fragment and the following post-reference code as the second reference code fragment, and include the first code fragment itself, which can improve the front-back dependency and relevance of the code.

[0091] Then, based on the storage paths of the first code snippet and its preceding and following reference code snippets, the target storage path is comprehensively determined to integrate related code snippets through path association, clarify the organizational logic and calling relationship of the code, and provide a structural reference for complete code generation.

[0092] Finally, the description information of the entity objects, the description of the interaction relationship between entities, and multiple target storage paths are integrated to form target prompt words for code generation, so as to merge the hardware characteristics, interaction logic and code resource paths into instructions, so that the generated code not only conforms to the hardware characteristics but also has complete logical associations.

[0093] It's important to note that the system first screens core code snippets, then retrieves the surrounding and associated code, determines the code's logical chain through storage paths, and finally generates prompts based on entity information and interaction relationships. This completes the logic from code resource extraction to prompt generation. By associating code snippets and integrating hardware knowledge with code paths, the generated prompts incorporate both hardware characteristics and interaction rules, while also linking to actual, reusable code resources. This provides more specific and actionable guidance for the code generation model, ensuring that the generated code meets requirements, is complete, and is executable.

[0094] Through the embodiment of the present application, a first code snippet that matches the parsing result is obtained from a code database, wherein the code database contains code snippets that match at least one entity object respectively; at least one first reference code snippet located before the first code snippet and at least one second reference code snippet located after the first code snippet and the first code snippet are determined from the code database; a target storage path is determined based on the code storage paths corresponding to the at least one first reference code snippet, the at least one second reference code snippet and the first code snippet; a target prompt word is obtained based on the entity description information of each entity object, the relationship description information of the interaction relationship and the combination of multiple target storage paths. By associating code snippets and integrating hardware knowledge with code paths, the generated prompt word not only contains hardware characteristics and interaction rules, but also associates with actual reusable code resources, providing more specific and more operational guidance for the code generation model, ensuring that the generated code meets the requirements and is complete and executable.

[0095] As an optional solution, the target prompt word is obtained based on the entity description information of at least one entity object, the relationship description information of the interaction relationship, and multiple target storage paths, including:

[0096] S1, combining entity description information of at least one entity object, relationship description information of an interaction relationship, and multiple code storage paths to obtain combined information;

[0097] S2, inputting the combined information into a natural language processing model, wherein the natural language processing model is used to perform natural language processing;

[0098] S3, determining the output result of the natural language processing model as the target prompt word.

[0099] Optionally, in this embodiment, the combined information refers to a comprehensive information set formed by integrating entity description information, relationship description information and code storage path, which is used to gather various types of information required to generate prompt words as the input basis of the natural language processing model.

[0100] Optionally, in this embodiment, the natural language processing model refers to a large language model capable of processing and generating natural language, which is used to process, integrate and optimize the combined information at the language level, and convert scattered information into standardized and coherent natural language text.

[0101] Optionally, in this embodiment, entity object descriptions, descriptions of inter-entity interactions, and multiple code storage paths are integrated to form combined information containing multiple types of key information. This serves to aggregate scattered hardware knowledge, interaction logic, and code resource clues, providing a comprehensive information foundation for subsequent prompt word generation.

[0102] Next, the combined information is input into the natural language processing model. The function of this model is to process natural language, such as integration, optimization, and standardization. With the help of the model's language processing capabilities, the combined information is structured and converted into natural language, solving the problems of scattered information and non-standard expression.

[0103] Finally, the output of the natural language processing model is defined as the target prompt word, which clarifies the instruction text that is ultimately used to guide code generation. This makes the target prompt word highly readable and instructive, and can be accurately understood by the code generation model.

[0104] It's important to note that entity descriptions, interaction relationships, and code storage paths are first integrated to form combined information; this combined information is then fed into a natural language processing model for processing; and finally, the model's output is determined as the target prompt word. Through systematic information integration and natural language processing, multi-source, fragmented information is transformed into standardized prompt words. These prompt words not only fully encompass hardware features, interaction logic, and code resource relationships, but also guide the code generation model in a clear, natural language format, improving the accuracy and applicability of the generated code.

[0105] Through the embodiments of the present application, entity description information of at least one entity object, relationship description information of the interaction relationship, and multiple code storage paths are combined to obtain combined information; the combined information is input into a natural language processing model, wherein the natural language processing model is used to perform natural language processing; and the output of the natural language processing model is determined as the target prompt word. Through systematic information integration and natural language processing, multi-source, scattered information is converted into standardized prompt words, so that the prompt words can fully cover hardware characteristics, interaction logic, and code resource associations, and can also guide the code generation model in a clear natural language form, improving the accuracy and applicability of the generated code.

[0106] As an optional solution, determining the target storage path according to the code storage paths corresponding to the at least one first reference code segment, the at least one second reference code segment, and the first code segment includes:

[0107] S1, determining at least one second code segment that meets a screening condition from a first code segment, at least one first reference code segment, and at least one second reference code segment;

[0108] S2, determining a third reference code segment and a fourth reference code segment corresponding to each of the at least one second code segment, wherein the third reference code segment is a code segment located before the second code segment, and the fourth reference code segment is a code segment located after the second code segment;

[0109] S3: Determine a target storage path according to the code paths of the third reference code segment, the fourth reference code segment, and the second code segment.

[0110] Optionally, in this embodiment, the screening conditions are used to screen out the standards (such as functional matching, hardware adaptability, etc.) for better meeting the requirements from the existing code snippets, and their role is to accurately locate high-quality and highly relevant code resources.

[0111] Optionally, in this embodiment, the second code snippet refers to a code snippet obtained from the first code snippet and its preceding and following reference code snippets after screening by screening conditions, serving as a core code candidate that is closer to the requirements, thereby improving the accuracy of code generation.

[0112] Optionally, in this embodiment, the third reference code snippet refers to a preceding code snippet located before the second code snippet, which is a dependency or preceding logic of the second code snippet to ensure the prerequisites and logical consistency required for the execution of the second code snippet.

[0113] Optionally, in this embodiment, the fourth reference code snippet refers to a post-code snippet located after the second code snippet, which is the subsequent logic or extension of the second code snippet to ensure the integrity and relevance of the subsequent logic of the second code snippet.

[0114] Optionally, in this embodiment, the code path refers to the storage location identifier of the code snippet in the database, which is used to locate the storage location of the code snippet and provide a basis for determining the target storage path.

[0115] Optionally, in this embodiment, the target storage path refers to a path determined by comprehensively analyzing the code paths of the second code fragment and its preceding and following reference code fragments, such as the third reference code fragment and the fourth reference code fragment, identifying a complete code logic chain that is highly matched with the requirements, and providing accurate resource positioning for code generation.

[0116] Optionally, in this embodiment, at least one second code snippet that meets a preset condition is selected from the first code snippet, the preceding first reference code snippet, and the succeeding second reference code snippet. This filtering mechanism is used to extract code snippets that better match the requirements, thereby improving the relevance and quality of code resources.

[0117] Then, for each second code snippet, a third reference code snippet preceding it and a fourth reference code snippet following it are found to obtain the complete logical context of the second code snippet, thereby ensuring the front-to-back dependency and logical coherence of the code snippets.

[0118] Finally, the target storage path is determined based on the storage paths of the second code snippet and its corresponding third and fourth reference code snippets. By integrating the complete logical chain of high-quality code snippets through path association, the code's organizational structure and call relationships are clarified, providing a positioning basis for subsequent generation of complete, connected code.

[0119] It's important to note that the process of selecting the multiple codes that best meet the requirements from existing code snippets, obtaining their complete logical context, and ultimately determining the target storage path involves first selecting a second code snippet that better meets the requirements from the initial code snippet, then finding the reference code that precedes and follows it, and finally determining the target storage path based on the paths of these codes. By screening multiple code snippets and integrating their logical chains, the quality and relevance of code resources are improved, ensuring that the code logical chain pointed to by the target storage path closely matches the requirements. This provides a reliable resource location foundation for the subsequent generation of accurate, complete, and reusable embedded code, further improving the efficiency and accuracy of code generation.

[0120] Through the embodiment of the present application, at least one second code snippet that meets the screening conditions is determined from a first code snippet, at least one first reference code snippet, and at least one second reference code snippet; a third reference code snippet and a fourth reference code snippet corresponding to each of the at least one second code snippet are determined, wherein the third reference code snippet is a code snippet located before the second code snippet, and the fourth reference code snippet is a code snippet located after the second code snippet; and the target storage path is determined based on the code paths of the respective second code snippets according to the third reference code snippet and the fourth reference code snippet. By screening and logically chaining multiple code snippets, the quality and relevance of code resources are improved, ensuring that the code logic chain pointed to by the target storage path is highly matched with the requirements, providing a reliable resource positioning basis for the subsequent generation of accurate, complete, and reusable embedded code, and further improving the efficiency of code generation.

[0121] As an optional solution, in the process of obtaining the target prompt word based on the entity description information of at least one entity object and the relationship description information of the interaction relationship, the method further includes:

[0122] S1, when no reference embedded code related to the target embedded code is found, obtaining a hardware knowledge set according to the parsing result, wherein the hardware knowledge set is used to describe at least one functional module included in the parsing result;

[0123] S2, determining reference hardware information associated with the parsing result from the hardware knowledge set;

[0124] S3, combining the entity description information of each of the at least one entity object, the relationship description information of the interaction relationship, and the reference hardware information to obtain a target prompt word.

[0125] Optionally, in this embodiment, the reference embedded code refers to a reference code that is already in the code database and is related to the target embedded code, and can provide a reference and reuse basis for target code generation.

[0126] Optionally, in this embodiment, the hardware knowledge set is a knowledge set that provides specifications, specific descriptions, etc. about functional modules when there is a lack of reference code, providing a basis for understanding hardware characteristics and generating adaptation code. It can be, but is not limited to, a chip manual, which is an official document containing detailed information such as functional modules, pin definitions, communication protocols, register configurations, etc. of the target hardware.

[0127] Optionally, in this embodiment, reference hardware information refers to hardware details extracted from the hardware knowledge set and related to the parsing results, which is used to provide a reference basis for hardware when there is no reference code to assist in the construction of prompt words, and may include but is not limited to reference information such as characteristics of similar hardware, functional module configuration, etc.

[0128] Optionally, in this embodiment, when it is determined that the target code request does not have a relevant reference code, the corresponding hardware knowledge set is obtained based on the parsing result of the request, such as a chip manual, which details the functional modules involved in the parsing result. The chip manual is used to supplement the hardware details of the functional modules, such as pin functions and operating parameters, to provide a hardware technical basis for subsequent prompt word generation.

[0129] Next, reference hardware information related to the analysis results, such as modules and hardware models corresponding to functional requirements, is filtered out from the chip manual, such as module timing requirements, configuration steps, etc., so as to extract hardware technical details directly related to current needs from the manual to avoid information redundancy.

[0130] Finally, the descriptive information of the entity objects, the description of the interaction relationship between entities, and the reference hardware information extracted from the chip manual are integrated to form the target prompt word. By combining the hardware details of the chip manual with the entity relationship of the knowledge graph, the prompt word contains both the technical parameters of the hardware and the interaction logic, ensuring that the code generation model can generate embedded code that conforms to the physical characteristics of the chip.

[0131] It should be noted that the first step is to obtain the corresponding chip manual based on the parsing results, extract the hardware technical information related to the requirements, and finally form prompt words based on the entity descriptions and interaction relationships. When reference code is lacking, the chip manual serves as the core information source. By extracting hardware details from the manual, the gaps in the code reference are filled, ensuring that the generated prompt words accurately reflect the physical characteristics and technical requirements of the hardware. Ultimately, they guide the generation of embedded code adapted to the target chip, improving the accuracy of embedded code generation.

[0132] According to the embodiments of the present application, if no reference embedded code related to the target embedded code is found, a hardware knowledge set is obtained based on the parsing results, wherein the hardware knowledge set is used to describe at least one functional module included in the parsing results; reference hardware information associated with the parsing results is determined from the hardware knowledge set; and the entity description information of each of the at least one entity object, the relationship description information of the interaction relationship, and the reference hardware information are combined to obtain the target prompt word. By extracting hardware details from the manual, the gaps in the code reference are filled, ensuring that the generated prompt word accurately reflects the physical characteristics and technical requirements of the hardware, and ultimately guiding the generation of embedded code adapted to the target chip, thereby improving the accuracy of embedded code generation.

[0133] As an optional solution, reference hardware information associated with the parsing result is determined from the hardware knowledge set, including:

[0134] S1, determining chapter identification information and page identification information from the hardware knowledge set based on the catalog information of the hardware knowledge set, the parsing result, the entity description information of at least one entity object, and the relationship description information of the interaction relationship;

[0135] S2: Determine reference hardware information from the hardware knowledge set according to the chapter identification information and the page identification information.

[0136] Optionally, in this embodiment, the directory information refers to the directory structure of the hardware knowledge set, recording the subject of each chapter and the corresponding page number, so as to quickly locate the content area related to the requirements in the manual.

[0137] Optionally, in this embodiment, the chapter identification information refers to the number or title of the chapter in the hardware knowledge set, so as to identify a specific content section in the manual and accurately locate the chapter where the relevant hardware information is located.

[0138] Optionally, in this embodiment, the page number identification information refers to the page number corresponding to the content in the hardware knowledge set, so as to further pinpoint the specific page and quickly find the required hardware-related information.

[0139] Optionally, in this embodiment, the chip manual's table of contents, request parsing results, entity object descriptions, and interaction relationship descriptions are combined to find the chapter number and specific page number of the relevant content in the manual. Through multi-dimensional information matching, the location of the content related to the requirement in the manual is accurately located, avoiding blind searches and improving information extraction efficiency.

[0140] Next, based on the found chapters and page numbers, the corresponding hardware technical details are extracted from the chip manual, and hardware information that is highly relevant to the requirements is obtained based on positioning. This ensures that the extracted content is relevant to the code acquisition request issued by the user, providing reliable technical support for the subsequent generation of prompt words.

[0141] It's important to note that we first determine the relevant chapters and pages by combining the catalog, parsing results, entity descriptions, and interactions. We then extract reference hardware information from the manual, establishing a comprehensive process for extracting the required information from the chip. Through catalog navigation and multi-dimensional information matching, we locate and obtain the hardware technical details relevant to the requirements, ensuring the accuracy and relevance of the reference hardware information. This provides a basis for subsequently generating prompts that match the hardware characteristics, improving the accuracy of obtaining the target embedded code.

[0142] Through the embodiments of the present application, based on the directory information of the hardware knowledge set, the parsing results, the entity description information of at least one entity object, and the relationship description information of the interaction relationship, the chapter identification information and page identification information are determined from the hardware knowledge set; and the reference hardware information is determined from the hardware knowledge set based on the chapter identification information and page identification information. Through directory navigation and multi-dimensional information matching, the hardware technical details related to the requirements are located and obtained, ensuring the accuracy and relevance of the reference hardware information, providing a basis for the subsequent generation of prompt words that meet the hardware characteristics, and improving the accuracy of obtaining the target embedded code.

[0143] As an optional solution, in the process of determining at least one entity object associated with the target hardware and the interaction relationship between at least one entity object from the embedded knowledge graph based on the parsing result of the request description text, the method further includes:

[0144] According to the parsing result, guide information is determined from the hardware vector knowledge base, wherein the guide information is used to represent specifications corresponding to the target hardware, and the hardware vector knowledge base includes guide information associated with the target hardware.

[0145] Optionally, in this embodiment, the hardware vector knowledge base refers to a vector knowledge base that converts hardware-related documents into vector form for storage and supports semantic retrieval through vectors. It may be, but is not limited to, a vector knowledge base constructed based on Retrieval-Augmented Generation (RAG) technology, which provides a basis for structured storage and fast query for obtaining hardware specification information, thereby improving the accuracy of obtaining hardware specification information.

[0146] Optionally, in this embodiment, the guide information refers to information used to represent the technical specifications, interface requirements, communication rules, etc. corresponding to the target hardware, and may include, but is not limited to, unstructured text data such as adaptation guidance documents, application programming interface (API) documents, protocol documents, chip manuals, etc., providing hardware adaptation standards and operational basis for embedded code generation.

[0147] It should be noted that, based on the parsing results of the code generation request, the specification information corresponding to the target hardware is quickly retrieved as guidance information from the RAG vector knowledge base that stores hardware-related unstructured texts such as manuals and protocol documents, which is used to clarify the technical standards and adaptation requirements of the target hardware, thereby optimizing the generation of target prompt words so that the obtained prompt words can follow the guidance information, further improving the accuracy and efficiency of the obtained embedded code.

[0148] Through the embodiments of the present application, based on the parsing results, guide information is determined from the hardware vector knowledge base, wherein the guide information is used to represent the specifications corresponding to the target hardware, and the hardware vector knowledge base includes guide information associated with the target hardware. Based on the parsing results of the code generation request, the specification information corresponding to the target hardware is quickly retrieved as guide information from the RAG vector knowledge base that stores hardware-related unstructured text, such as manuals and protocol documents, to clarify the technical standards and adaptation requirements of the target hardware, thereby optimizing the generation of target prompt words so that the acquired prompt words can follow the guide information, further improving the accuracy and efficiency of the acquired embedded code.

[0149] As an optional solution, after receiving the target code generation request, the following is further included:

[0150] S1, perform a demand determination operation on the request description text to obtain a demand determination result;

[0151] S2. When the requirement determination result indicates that the request description text meets the target requirement conditions, the request description text is input into the code generation model to obtain the target code that matches the request target code generation request, wherein the target requirement conditions are used to indicate that the request description text is used to generate non-embedded code.

[0152] Optionally, in this embodiment, the requirement determination operation refers to the process of analyzing and judging the request description text, which is used to determine the type of code generation requirement pointed to by the text, so as to screen and classify the requirements for code generation and provide a basis for the selection of subsequent processing methods.

[0153] Optionally, in this embodiment, the requirement determination result: the conclusion obtained after the requirement determination operation is used to clarify whether the request description text meets specific conditions, such as whether it is a non-embedded code generation requirement, to guide the subsequent code generation process.

[0154] Optionally, in this embodiment, the target requirement condition refers to a preset standard for defining the type of request description text, which is used to indicate that the request description text is used to generate non-embedded code and is the basis for determining whether to directly use the code generation model to generate the target code.

[0155] Optionally, in this embodiment, the requirement type of the user's request description text is judged to obtain a requirement judgment result, so as to clarify whether the request belongs to the requirement of generating non-embedded code, provide a decision basis for whether to directly call the code generation model in the future, and avoid using inappropriate processing procedures for embedded code requirements.

[0156] Then, when the requirement determination result shows that the request description text meets the target requirement conditions for generating non-embedded code, the request description text is input into the code generation model to generate target code that matches the user requirements. In order to target the non-embedded code requirements, the code generation model is directly used to quickly generate the corresponding code, simplifying the process and improving the efficiency of non-embedded code generation.

[0157] It's important to note that the request description text is first evaluated for requirements. If the result indicates that the text requires non-embedded code generation, it is directly fed into the code generation model to generate matching target code, clarifying the processing path for non-embedded code generation requirements. This requirement evaluation distinguishes requirement types, and directly calls the model for generation of eligible non-embedded code requirements. This improves the targetedness and efficiency of code generation, ensuring that different types of code generation requirements are appropriately processed.

[0158] Through an embodiment of the present application, a requirement determination operation is performed on a request description text to obtain a requirement determination result. If the requirement determination result indicates that the request description text meets a target requirement condition, the request description text is input into a code generation model to obtain a target code that matches the target code generation request, wherein the target requirement condition is used to indicate that the request description text is used to generate non-embedded code. The requirement determination operation distinguishes requirement types, and for non-embedded code requirements that meet the conditions, a direct call model generation method is used, thereby improving the efficiency of code generation.

[0159] As an optional solution, before determining at least one entity object associated with the target hardware and the interaction relationship between at least one entity object from the embedded knowledge graph based on the parsing result of the request description text, the method further includes:

[0160] S1, if the first validity check result of the parsing result does not meet the verification conditions, a prompt message of verification failure is displayed;

[0161] S2. When the number of rewrites is less than or equal to the target number, rewrite the request description text based on the first legitimacy check result to obtain a rewritten request description text, wherein the number of rewrites is used to indicate the number of times the request description text has been rewritten.

[0162] Optionally, in this embodiment, the first validity check result refers to the conclusion drawn after performing a validity check on the parsing result to determine whether the request description text meets the conditions for further processing, which may be but is not limited to parameter validity checks including regular expression format validity check, numerical range validity check, string spelling validity check, etc.

[0163] Optionally, in this embodiment, the rewrite count refers to the number of times the request description text has been rewritten, limiting the maximum number of rewrites to avoid infinite rewrite loops. The target count refers to the preset maximum number of times the request description text is allowed to be rewritten, controlling the termination condition of the rewrite process and ensuring efficient code generation.

[0164] Optionally, in this embodiment, the rewritten request description text refers to the text obtained by modifying the original request description text based on the first legitimacy check result to correct problems in the original text and make it more likely to pass the legitimacy check.

[0165] Optionally, in this embodiment, when the legitimacy check of the parsing result fails to meet the preset verification conditions, a prompt message indicating that the check failed is displayed to the user, and timely feedback is provided on the problem with the request description text, prompting the user with error information, and automatically making modifications based on the error to ensure that subsequent processing can be based on legal input.

[0166] Then, when the number of rewrites performed does not exceed the maximum target number allowed, the request description text is modified according to the first legitimacy check result to obtain the rewritten text, so that an attempt is made to correct the problems of the original text within the allowed number of times, thereby increasing the probability of the request description text passing the legitimacy check and improving the accuracy of generating the target embedded code.

[0167] It should be noted that a verification failure prompt is first displayed; if the number of rewrites does not exceed the target number, the request description text is rewritten based on the verification result. By establishing an error correction mechanism for the request description text, guiding the user or system to make corrections based on prompt information, and setting a limit on the number of rewrites to prevent invalid rewrites, we ensure that the input request description text ultimately meets legal requirements and provides qualified basic data for subsequent code generation and other processes.

[0168] Through the embodiment of the present application, when the first legitimacy check result of the parsed result does not meet the verification conditions, a prompt message indicating that the verification failed is displayed; when the number of rewrites is less than or equal to the target number, the request description text is rewritten based on the legitimacy check result to obtain a rewritten request description text, wherein the number of rewrites is used to indicate the number of times the request description text has been rewritten. By establishing an error correction mechanism for the request description text, guiding the user or system to make corrections based on prompt information, and setting a number limit to avoid invalid rewrites, it is ensured that the input request description text can ultimately meet the legitimacy requirements and provide qualified basic data for subsequent code generation and other processes.

[0169] As an optional solution, after rewriting the request description text based on the first legitimacy check result to obtain the rewritten request description text, the method further includes:

[0170] S1, performing parameter validity check on the parsed result of the rewritten request description text to obtain a second validity check result;

[0171] S2, if the second legitimacy check result does not meet the check condition and the number of rewrites is greater than the target number, displaying an exception report, wherein the exception report is used to indicate that the target embedded code generation failed and the parameters in the rewritten request description text did not pass the parameter legitimacy check;

[0172] S3: Send the rewritten request description text to a description text review node, wherein the text review node is used to review the rewritten request description text.

[0173] Optionally, in this embodiment, the exception report refers to a report generated when the number of rewrites exceeds the target number and the verification still fails, so as to feedback to the system the result of the failure to generate the target embedded code and the specific parameters that failed the verification, so as to clarify the problem.

[0174] Optionally, in this embodiment, the description text review node may refer to, but is not limited to, a link or system module responsible for reviewing the rewritten request description text, and is used to manually review the text that has been rewritten multiple times and still failed to pass the verification, to determine whether it can be further processed or needs to be resubmitted by the user.

[0175] Optionally, in this embodiment, the parsing result of the rewritten request description text is subjected to parameter validity verification to obtain a second validity verification result. By verifying whether the rewritten text resolves the parameter-level problem, it is determined whether it meets the conditions for subsequent processing, providing a basis for the next step.

[0176] If the second legitimacy check result does not meet the verification conditions and the number of rewrites exceeds the target number, an exception report is displayed. The report indicates that the target embedded code generation failed and the parameters in the rewritten request description text did not pass the parameter legitimacy check. If multiple corrections are ineffective, the automatic rewrite process is terminated. The reason for the failure and the specific problem parameters are clearly informed through the exception report to avoid waste of resources and provide users or auditors with a clear correction direction.

[0177] Finally, the rewritten request description is sent to the description verification node for review. This node is used to conduct further review of text that has failed verification after multiple rewrites. This review may involve manual intervention to determine if there are any special circumstances or if the user needs to rewrite the request.

[0178] It should be noted that the input quality is ensured through parameter verification, invalid cycles are avoided through number limits, and problems are clarified with the help of exception reports. The possibility of further processing is provided through audit nodes to ensure that user needs can still be properly handled in complex situations, so as to improve the success rate of generating target embedded code.

[0179] Through the embodiment of the present application, the parameter legitimacy check is performed on the parsing result of the rewritten request description text to obtain a second legitimacy check result; when the second legitimacy check result does not meet the verification condition and the number of rewrites is greater than the target number, an exception report is displayed, wherein the exception report is used to indicate that the target embedded code generation failed and the parameters in the rewritten request description text did not pass the parameter legitimacy check; the rewritten request description text is sent to the description text audit node, wherein the text audit node is used to audit the rewritten request description text. It not only ensures the input quality through parameter verification, but also avoids invalid cycles through number restrictions, and at the same time, clarifies the problem with the help of the exception report, and provides the possibility of further processing through the audit node, so as to ensure that user needs can still be properly handled in complex situations, so as to improve the success rate of the generation of the target embedded code.

[0180] As an optional solution, in order to better understand the process of the above-mentioned target embedded code generation method, the following describes the execution process of the above-mentioned target embedded code generation method in combination with an optional embodiment, but is not used to limit the technical solution of the embodiment of this application.

[0181] It's important to note that, taking the baseboard management controller software development scenario as an example, the development process exhibits a high degree of hardware-software coupling. Physical layer information, such as hardware topology, board connectivity, and interface protocols, must be expressed through unstructured data carriers like hardware schematics and wiring diagrams. Because current multimodal large models haven't achieved breakthroughs in technical areas like image semantic understanding and cross-modal information fusion, relying solely on traditional text prompting makes it difficult to accurately translate complex hardware constraints into executable code requirements.

[0182] To address the above issues, this embodiment proposes an innovative engineering solution. Through a structured input system, key information such as hardware connection topology and interface protocols is formally modeled to ensure accurate expression and effective communication of hardware semantics. Furthermore, a behavior tree control mechanism is introduced. By imposing fine-grained constraints on the execution path of large models, this allows for phased decomposition of development tasks and precise control of execution nodes, allowing the large model to focus on implementing simpler tasks and improving code implementation accuracy.

[0183] Alternatively, as Figure 4 As shown in the figure, the behavior tree process provided in this embodiment is as follows. Figure 4 As shown, the following steps are included:

[0184] S402, execute the root node (sequential node);

[0185] S404, execute the decorator node, and you can initiate a retry (limited number of times);

[0186] S406, agent A performs demand analysis;

[0187] S408, agent B prepares knowledge;

[0188] S410, agent E prepares knowledge;

[0189] S412, agent G generates prompt words;

[0190] S414, agent H generates code.

[0191] Optional, such as Figure 5 As shown, S408 also includes the following steps:

[0192] S408, Agent B prepares knowledge and executes sub-nodes sequentially;

[0193] S502, the decorator node can initiate a retry (limited number of times), and agent C performs parameter extraction;

[0194] S504, performing parameter validity check on the content extracted by agent C;

[0195] S506, performing a regular expression validation on the content extracted by agent C;

[0196] S508, performing a value range validity check on the content extracted by agent C;

[0197] S510, performing string spelling validity check on the content extracted by agent C;

[0198] S512, knowledge base search;

[0199] S514, agent D code library refinement, repeated twice.

[0200] Optional, such as Figure 6 As shown, S410 further includes the following steps:

[0201] S410, agent E prepares knowledge and executes sub-nodes sequentially;

[0202] S602, the decorator node can initiate a retry (limited number of times), and agent C performs parameter extraction;

[0203] S604, performing parameter validity check on the content extracted by agent C;

[0204] S606, performing a regular expression validation on the content extracted by agent C;

[0205] S608, performing a value range validity check on the content extracted by agent C;

[0206] S610, performing a string spelling validity check on the content extracted by agent C;

[0207] S612, knowledge base search;

[0208] S614, extracting the document directory;

[0209] S616, agent F obtains the chapter name;

[0210] S618, extract chapter content;

[0211] S620, agent F performs knowledge condensation.

[0212] The specific steps of the entire behavior tree are as follows:

[0213] In S1, the user enters a natural language description, a hardware schematic design file (e.g., files generated by EDA software such as Altium Designer or Allegro, optional), and a chip manual (optional). The behavior tree enters the root node - the sequence node. The root node will execute all its child nodes in order, starting with the left child node - the decorator node.

[0214] S2, the decorator node is a retry node. Its function is to append an error message to the prompt word after the node's task fails, and then initiate a retry. The execution order of the decorator node is the same as that of the sequence node. After the retry operation is completed, the behavior tree enters the selector node, the left child of the decorator node.

[0215] S3, the selector node is the processing node for Agent A. Agent A will analyze and summarize the problem based on the input prompt words and divide it into three categories of needs:

[0216] 1) Adaptation of existing code to different device models;

[0217] 2) There is no relevant code, and original code needs to be generated according to the manual;

[0218] 3) Other code generation tasks that do not fall into the above two categories of problems.

[0219] When agent A determines that the requirement is S3-1 or S3-2, it executes the left child node and the right child node respectively; when agent A determines that the requirement is S3-3, it directly returns True, then returns to the root node and enters the right child node agent G.

[0220] In step S3-1, when the requirement is judged as 1), the process enters the knowledge preparation node for Agent B. This node is a sequential node that executes all its child nodes sequentially and summarizes the execution results of all child nodes. It then enters the child node Agent C for parameter extraction.

[0221] In S3-1-1, Agent C is responsible for extracting key information from the user's input. An example prompt word is as follows:

[0222] "Keywords are extracted based on user input to fill in JSON fields. Unknown information is left blank (for example, if the user does not mention the processor model, "Processor signal" is blank). If the user mentions "BMC environment", the operating environment is automatically filled in as "BMC". The JSON fields are as follows: {"Task type":"Code adaptation","Device information":{"Processor model":"","Development environment":"","Operation environment":""},"Function requirements":{"Chip name":"","Core function":"","Communication bus":"","Communication address":"","Communication link":"","Other parameters":{}},"Code adaptation":{"Reference code retrieval":{"Keywords":[],"File path":""},"Functions to be retained":[],"Modified parameters":{}}}".

[0223] After extracting key information, the agent proceeds to the left and right child nodes to perform parameter validation. This validation includes, but is not limited to, regular expression format validation, value range validation, and string spelling validation. A successful validation returns True; otherwise, it returns False. Note that parameter validation only verifies parameter validity and does not check for empty parameters. The JSON fields returned by the agent may still contain a significant amount of blank data. For example, when the user provides the prompt "Write code to implement temperature monitoring for the TMP112," the agent may not be able to infer most of the fields in "Functional Requirements" and "Code Adaptation," and may only be able to obtain the "Chip Name" field.

[0224] S3-1-2: After extracting key information, the knowledge base is searched. The knowledge base includes the RAG vector knowledge base and the server BMC hardware knowledge graph. The RAG vector knowledge base contains unstructured text data such as adaptation guidance documents, API documentation, protocol documentation, and chip manuals. The RAG vector knowledge base is constructed using conventional methods and concepts. This embodiment does not specify detailed requirements for the establishment, composition, and retrieval of the RAG knowledge base.

[0225] The server BMC hardware knowledge graph is a knowledge graph database based on the hardware connection relationships and communication links in the server BMC system. The entities are defined as the various functional modules in the BMC system. For example, one definition is:

[0226] Correspondingly, they represent the baseboard management system, expansion module, IO expansion module, temperature monitoring module, voltage monitoring module, fan module, storage module, etc.

[0227] In the established knowledge graph database, entities contain attribute information. The attributes of an entity are defined as the specific name of the entity, the chip model of the entity, and the function of the entity. The attributes of an entity can also include the power supply of the entity (if any), the driving current of the entity (if any), the operating system version running on the entity (if any), the kernel version of the entity (if any), and the corresponding product model.

[0228] In this embodiment, the entity and its corresponding attributes are as follows: when the entity is a baseboard management system, the corresponding attributes are the entity name, chip model, operating system, kernel version, BMC corresponding product model, chip manual name; when the entity is an input output (Input Output, ) expansion module, integrated circuit bus (Inter-IntegratedCircuit, ) When using expansion modules, temperature monitoring modules, voltage monitoring modules, fan modules, and storage modules, the entity implementation can be the entity name, chip model, chip manual name, and module function description. Relationships exist between entities. The definition of a relationship is as follows (used to model communication links in hardware systems): , correspondingly, they represent GPIO port connection, bus connection, expansion module connection, LPC interface connection, IO expansion module connection, SPI bus connection, PIN pin connection, and JTAG interface connection.

[0229] In this embodiment, the relationship includes the attributes of the relationship. In this embodiment, the relationship and its corresponding attributes are, for example, in GPIO port connection, bus connection, expansion module connection, LPC interface connection, IO expansion module connection, SPI bus connection, PIN pin connection, and JTAG interface connection. The attributes can be the name of the relationship, the communication address, the communication direction, the supported communication protocol, the manual document name corresponding to the communication protocol, etc.

[0230] A well-defined knowledge graph of server BMC hardware communication links is as follows: Figure 7As shown, baseboard control manager 702 is connected to chip 706 via integrated circuit bus 704. Baseboard control manager 702 is also connected to fan control module 710 via speed feedback signal 708. Baseboard control manager 702 is also connected to voltage control module 714 via analog-to-digital converter 712. Baseboard control manager 702 is also connected to fan control module 718 via pulse width modulation 716. Baseboard control manager 702 is also connected to voltage control module 722 via general-purpose input / output port 720. Chip 706 is connected to temperature sensor module 726 via general-purpose input / output port 724. Chip 706 is also connected to voltage control module 730 via integrated circuit bus 728. In addition, each entity in the figure has corresponding entity information, which is not shown in the figure.

[0231] Based on the key information in the JSON field obtained in S3-1-1, such as the "Chip Name" field, the server BMC hardware communication link knowledge graph is retrieved to obtain the communication link, communication address, and communication protocol from the BMC to the specified chip. The information obtained is all structured JSON text information. For example, to query the communication link from the BMC to Inlet Temp0, you can use the following query statement: MATCH path=(bmc:BMC{name:"BMC"})-[r*]->(temp:temperature{name:"InletTemp0"})RETURN path, and you will get the following: Figure 8 Shown based on Figure 7 The communication link to be queried and its corresponding description information (JSON format), such as: the substrate control manager 702 is connected to the chip 706 through the integrated circuit bus 704, and the chip 706 is connected to the temperature sensor module 726 through the general input and output port 724.

[0232] In summary, the knowledge base search is completed to obtain the structured text information of the hardware connection data. In this embodiment, neo4j is used to build a graph database.

[0233] In step S3-1-3, after completing the knowledge base search, the behavior tree enters the Agent D node. This node is executed repeatedly, twice. The first input is the key information provided by Agent C. Agent D extracts the keywords of the reference code from this information and initiates a query request to the code library management software, retrieving relevant code snippets and contextual information. Agent D then analyzes these relevant code snippets and contextual information to locate the top K code snippets most relevant to the requirement. The second search then begins, searching a wider range of context based on these top K code snippets to obtain the most relevant code file paths.

[0234] S3-1-4, based on all the retrieved contents from S3-1-1 to S3-1-4 above, input into agent G for natural language processing, and agent G organizes the structured text information into natural language prompt words so that agent H can subsequently generate code.

[0235] S3-1-5, finally enters the code generation node of agent H, agent H generates code based on the natural language prompt words organized by agent G, and then calls the tool to write the generated code into a file.

[0236] In step S3-2, if the requirement is determined to be 2), the process enters the knowledge preparation node for agent E. This node is a sequential node that executes all its child nodes sequentially and summarizes the execution results of all child nodes. The process then enters the child node, agent C, for parameter extraction.

[0237] S3-2-1 This step is exactly the same as S3-1-1, that is, agent C is responsible for extracting key information from the user's input, filling it according to the same JSON template, and verifying the validity of the parameters.

[0238] S3-2-2 This step is exactly the same as S3-1-2, that is, after completing the key information extraction, start searching the knowledge base containing the RAG vector knowledge base and the server BMC hardware knowledge graph.

[0239] S3-2-3, since there is no relevant code for this task, it is necessary to generate the original code according to the manual. Therefore, firstly, based on the JSON field obtained from the key information, the directory of the chip manual file is extracted.

[0240] In step S3-2-4, the directory extracted in the previous step, the prompt word entered by the user, the key information extracted by agent C, and the relevant information retrieved from the knowledge base in step S3-2-2 are input into agent F. Agent F determines the manual chapter names and page numbers in the directory where relevant information may exist, as well as the key content that requires attention (such as the register address and communication protocol content that need to be read).

[0241] S3-2-5, extract the corresponding chapter content according to the chapter name and page number determined by agent F.

[0242] S3-2-6, input the extracted chapter content into agent F, which summarizes and condenses the required content.

[0243] S3-2-7, input the contents of S3-2-1 to S3-2-6 into agent G for knowledge aggregation, and agent G organizes the structured text information into natural language prompt words.

[0244] S3-2-8, finally enters the code generation node of agent H, agent H generates code based on the natural language prompt words organized by agent G, and then calls the tool to write the generated code into a file.

[0245] It should be noted that embedded code generation faces four core challenges: the ambiguity of natural language makes it difficult to accurately and comprehensively express requirements with string type prompts; chip manuals are complex and contain a large amount of text, far exceeding the context processing capabilities of current large models; circuit schematic data structures are complex and cannot be directly input into large models; in reference code application scenarios, the adaptation of old code requires precise retrieval of massive code libraries, and the development of new devices relies on chip manual information processing.

[0246] This example proposes an innovative approach that leverages a behavior tree model to break down the code generation task into simple subtasks, such as structured querying and text content summarization. By formally modeling multimodal data as structured text data and combining it with a behavior tree model with clear input, output, and logical switching, this example embeds a large model into the "code generation pipeline," effectively reducing task complexity and significantly improving the success rate of code generation.

[0247] Through the embodiments of this application, innovative applications of the behavior tree model are demonstrated: extending behavior trees from traditional control logic (such as game AI and robot collaboration) to code generation process management, reducing the processing complexity of large models through structured task splitting. Formal modeling of multimodal data: converting unstructured data such as chip manuals and schematics into structured text, especially combining knowledge graphs to enable accurate retrieval of hardware link information. A pipeline generation mechanism: achieving automated and robust code generation through logical switching of behavior tree nodes (such as retry nodes and selection nodes), significantly improving the success rate.

[0248] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.

[0249] Based on this understanding, the technical solution of this application, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, or optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of this application.

[0250] In the present embodiment, a device for generating a target embedded code is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments, and will not be repeated herein. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and contemplated.

[0251] Figure 9 is a structural block diagram of a device for generating target embedded code according to an embodiment of the present application; Figure 9 Shown, including:

[0252] A receiving unit 902 is configured to receive a target code generation request, wherein the target code generation request includes a request description text, and the request description text is used to indicate a target embedded code to be applied to the target hardware;

[0253] A determining unit 904 is configured to determine, based on the parsing result of the request description text, at least one entity object associated with the target hardware and an interaction relationship between at least one entity object from the embedded knowledge graph, wherein the embedded knowledge graph includes entity nodes for respectively indicating the plurality of entity objects, and the connection relationship between the entity nodes is used to indicate the connection relationship between the corresponding entity objects;

[0254] A combining unit 906 is configured to obtain a target prompt word based on the entity description information of at least one entity object and the relationship description information of the interaction relationship;

[0255] The input unit 908 is used to input the target prompt word into the code generation model to obtain the target embedded code that matches the target code generation request.

[0256] As an optional solution, the determination unit 904 includes: a first determination module, used to determine at least one functional module of at least one reference hardware as at least one reference entity object before determining at least one entity object associated with the target hardware and the interaction relationship between at least one entity object from the embedded knowledge graph based on the parsing result of the request description text; a second determination module, used to determine the connection relationship between at least one reference entity object from the reference entity description information of at least one reference entity object, wherein the reference entity description information is used to indicate the module type and module function of the functional module; and a construction module, used to construct the embedded knowledge graph based on at least one reference entity object and the connection relationship between at least one reference entity object.

[0257] As an optional solution, the construction module includes: a first determination submodule, used to determine the basic control connection relationship between at least one reference entity object from the reference entity description information of each of at least one reference entity object, wherein the connection relationship includes the basic control connection relationship; a second determination submodule, used to determine the data transmission connection relationship between at least one reference entity object from the reference entity description information of each of at least one reference entity object, wherein the connection relationship includes the data transmission connection relationship; a third determination submodule, used to determine the system extension connection relationship between at least one reference entity object from the reference entity description information of each of at least one reference entity object, wherein the connection relationship includes the system extension connection relationship; a fourth determination submodule, used to determine the debugging interface connection relationship between at least one reference entity object from the reference entity description information of each of at least one reference entity object, wherein the connection relationship includes the debugging interface connection relationship.

[0258] As an optional solution, the combination unit 906 includes: a first acquisition module, used to obtain a first code fragment matching the parsing result from a code database, wherein the code database contains code fragments matching at least one entity object respectively; a third determination module, used to determine at least one first reference code fragment located before the first code fragment and at least one second reference code fragment located after the first code fragment and the first code fragment from the code database; a fourth determination module, used to determine a target storage path based on the code storage paths corresponding to the at least one first reference code fragment, the at least one second reference code fragment and the first code fragment respectively; a first combination module, used to obtain a target prompt word based on the entity description information of each entity object, the relationship description information of the interaction relationship and the combination of multiple target storage paths.

[0259] As an optional solution, the first combination module includes: a combination sub-module, which is used to combine the entity description information of at least one entity object, the relationship description information of the interaction relationship, and multiple code storage paths to obtain combination information; an input sub-module, which is used to input the combination information into a natural language processing model, wherein the natural language processing model is used to perform natural language processing; and a fifth determination sub-module, which is used to determine the output result of the natural language processing model as the target prompt word.

[0260] As an optional solution, the fourth determination module includes: a sixth determination sub-module, used to determine at least one second code fragment that meets the screening conditions from the first code fragment, at least one first reference code fragment and at least one second reference code fragment; a seventh determination sub-module, used to determine the third reference code fragment and the fourth code fragment corresponding to each of the at least one second code fragment, wherein the third reference code fragment is a code fragment located before the second code fragment, and the fourth reference code fragment is a code fragment located after the second code fragment; an eighth determination sub-module, used to determine the target storage path based on the third reference code fragment, the fourth code fragment, and the code paths of the second code fragments.

[0261] As an optional solution, the combination unit 906 includes: a second acquisition module, used to obtain a hardware knowledge set based on the parsing result when no reference embedded code related to the target embedded code is found, wherein the hardware knowledge set is used to describe at least one functional module included in the parsing result; a fifth determination module, used to determine the reference hardware information associated with the parsing result from the hardware knowledge set; a second combination module, used to combine the entity description information of at least one entity object, the relationship description information of the interaction relationship, and the reference hardware information to obtain the target prompt word.

[0262] As an optional solution, the fifth determination module includes: a ninth determination sub-module, which is used to determine chapter identification information and page number identification information from the hardware knowledge set based on the directory information of the hardware knowledge set, the parsing results, the entity description information of at least one entity object, and the relationship description information of the interaction relationship; and a tenth determination sub-module, which is used to determine reference hardware information from the hardware knowledge set based on the chapter identification information and the page number identification information.

[0263] As an optional solution, the determination unit 904 includes: a sixth determination module, which is used to determine the guide information from the hardware vector knowledge base based on the analysis results, wherein the guide information is used to represent the specifications corresponding to the target hardware, and the hardware vector knowledge base includes guide information that is associated with the target hardware.

[0264] As an optional solution, the receiving unit 902 includes: a determination module, which is used to perform a requirement determination operation on the request description text to obtain a requirement determination result; an input module, which is used to input the request description text into the code generation model when the requirement determination result indicates that the request description text meets the target requirement conditions, to obtain a target code that matches the request target code generation request, wherein the target requirement conditions are used to indicate that the request description text is used to generate non-embedded code.

[0265] As an optional solution, the determination unit 904 includes: a display module for displaying a verification failure prompt message when the legitimacy verification result of the parsing result does not meet the verification conditions before determining at least one entity object associated with the target hardware and the interaction relationship between at least one entity object from the embedded knowledge graph based on the parsing result of the request description text; a rewriting module for rewriting the request description text based on the legitimacy verification result when the number of rewrites is less than or equal to the target number of times, to obtain a rewritten request description text, wherein the number of rewrites is used to indicate the number of times the request description text has been rewritten.

[0266] As an optional solution, the determining unit 904 includes: an execution module, configured to perform parameter validity verification on the parsing result of the rewritten request description text to obtain a second validity verification result;

[0267] A display module is configured to display an exception report when the second legitimacy check result does not meet the check condition and the number of rewrites is greater than the target number, wherein the exception report is used to indicate that the target embedded code fails to be generated and the parameters in the rewritten request description text fail to pass the parameter legitimacy check;

[0268] The sending module is used to send the rewritten request description text to a description text review node, wherein the text review node is used to review the rewritten request description text.

[0269] For the description of the features in the embodiment corresponding to the target embedded code generation device, please refer to the relevant description of the embodiment corresponding to the target embedded code generation method, which will not be repeated here.

[0270] An embodiment of the present application further provides an electronic device, Figure 10 is a schematic diagram of an electronic device according to an embodiment of the present application, such as Figure 10 As shown, the electronic device includes a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the above-mentioned target embedded code generation method embodiments.

[0271] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0272] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail here.

[0273] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned target embedded code generation method embodiments when running.

[0274] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0275] An embodiment of the present application further provides a computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the method in each embodiment of the present application; the computer program product further comprises a non-volatile computer-readable storage medium, which stores the computer program, which, when executed by a processor, implements the steps of the method for generating target embedded code in each embodiment of the present application.

[0276] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0277] The above is a detailed introduction to a method for generating a target embedded code provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.

Claims

1. A method for generating a target embedded code, characterized in that: include: Receive a target code generation request, wherein the target code generation request includes a request description text, and the request description text is used to indicate a target embedded code applied to target hardware; Determining, from an embedded knowledge graph based on the parsing result of the request description text, at least one entity object associated with the target hardware, and an interaction relationship between at least one of the entity objects, wherein the embedded knowledge graph includes entity nodes for respectively indicating a plurality of entity objects, and the connection relationship between the entity nodes is used to indicate the connection relationship between the corresponding entity objects; Obtaining a target prompt word based on the entity description information of at least one of the entity objects and the relationship description information of the interaction relationship; The target prompt word is input into a code generation model to obtain the target embedded code that matches the target code generation request.

2. The method according to claim 1, characterized in that Before determining at least one entity object associated with the target hardware and an interaction relationship between at least one entity object from the embedded knowledge graph based on the parsing result of the request description text, the method further includes: determining at least one functional module of at least one reference hardware as at least one reference entity object; Determining the connection relationship between at least one of the reference entity objects from reference entity description information of each of the at least one reference entity objects, wherein the reference entity description information is used to indicate a module type and a module function of the functional module; The embedded knowledge graph is constructed based on at least one of the reference entity objects and the connection relationship between at least one of the reference entity objects.

3. The method according to claim 2, characterized in that Determining the connection relationship between at least one of the reference entity objects from the reference entity description information of each of the at least one reference entity objects includes at least one of the following: Determining a basic control connection relationship between at least one of the reference entity objects from the reference entity description information of each of the at least one reference entity objects, wherein the connection relationship includes the basic control connection relationship; determining a data transmission connection relationship between at least one of the reference entity objects from the reference entity description information of each of the at least one reference entity objects, wherein the connection relationship includes the data transmission connection relationship; determining a system extension connection relationship between at least one of the reference entity objects from the reference entity description information of each of the at least one reference entity objects, wherein the connection relationship includes the system extension connection relationship; A debugging interface connection relationship between at least one of the reference entity objects is determined from the reference entity description information of each of the at least one reference entity objects, wherein the connection relationship includes the debugging interface connection relationship.

4. The method according to claim 1, wherein The step of obtaining a target prompt word based on the entity description information of at least one of the entity objects and the relationship description information of the interaction relationship includes: Acquire a first code snippet matching the parsing result from a code database, wherein the code database contains code snippets matching at least one of the entity objects; Determining, from the code database, at least one first reference code segment located before the first code segment, at least one second reference code segment located after the first code segment, and the first code segment; Determine a target storage path according to code storage paths corresponding to at least one first reference code segment, at least one second reference code segment, and the first code segment; A target prompt word is obtained according to the entity description information of at least one of the entity objects, the relationship description information of the interaction relationship, and a combination of the plurality of target storage paths.

5. The method according to claim 4, characterized in that The obtaining of the target prompt word according to the entity description information of at least one of the entity objects, the relationship description information of the interaction relationship, and the combination of the plurality of target storage paths includes: combining entity description information of at least one entity object, relationship description information of the interaction relationship, and a plurality of code storage paths to obtain combination information; inputting the combined information into a natural language processing model, wherein the natural language processing model is configured to perform natural language processing; The output result of the natural language processing model is determined as the target prompt word.

6. The method according to claim 4, characterized in that The determining the target storage path according to the code storage paths corresponding to at least one first reference code fragment, at least one second reference code fragment, and the first code fragment includes: Determining at least one second code segment that meets a screening condition from the first code segment, at least one first reference code segment, and at least one second reference code segment; Determining a third reference code fragment and a fourth reference code fragment corresponding to at least one of the second code fragments, wherein the third reference code fragment is a code fragment located before the second code fragment, and the fourth reference code fragment is a code fragment located after the second code fragment; According to the third reference code segment and the fourth reference code segment, the code paths of the second code segments respectively determine the target storage path.

7. The method according to claim 1, characterized in that In the process of obtaining the target prompt word based on the entity description information of at least one of the entity objects and the relationship description information of the interaction relationship, the method further includes: If no reference embedded code related to the target embedded code is found, obtaining a hardware knowledge set according to the parsing result, wherein the hardware knowledge set is used to describe at least one functional module included in the parsing result; Determining reference hardware information associated with the parsing result from the hardware knowledge set; The target prompt word is obtained by combining the entity description information of at least one of the entity objects, the relationship description information combination of the interaction relationship, and the reference hardware information.

8. The method according to claim 7, characterized in that The determining, from the hardware knowledge set, reference hardware information associated with the parsing result includes: Determining chapter identification information and page identification information from the hardware knowledge set based on the catalog information of the hardware knowledge set, the parsing result, the entity description information of each of the at least one entity object, and the relationship description information of the interaction relationship; The reference hardware information is determined from the hardware knowledge set according to the chapter identification information and the page identification information.

9. The method according to any one of claims 1 to 8, characterized in that In the process of determining at least one entity object associated with the target hardware and an interaction relationship between at least one of the entity objects from the embedded knowledge graph based on the parsing result of the request description text, the method further includes: According to the analysis result, guide information is determined from a hardware vector knowledge base, wherein the guide information is used to represent specifications corresponding to the target hardware, and the hardware vector knowledge base includes guide information associated with the target hardware.

10. The method according to any one of claims 1 to 8, characterized in that After receiving the target code generation request, it also includes: Performing a demand determination operation on the request description text to obtain a demand determination result; When the requirement determination result indicates that the request description text meets the target requirement conditions, the request description text is input into the code generation model to obtain the target code that matches the request target code generation request, wherein the target requirement conditions are used to indicate that the request description text is used to generate non-embedded code.

11. The method according to any one of claims 1 to 8, characterized in that Before determining at least one entity object associated with the target hardware and an interaction relationship between at least one entity object from the embedded knowledge graph according to the parsing result of the request description text, the method further includes: If the first validity check result of the parsing result does not meet the verification condition, a prompt message of verification failure is displayed; When the number of rewrites is less than or equal to the target number, the request description text is rewritten based on the first legitimacy check result to obtain a rewritten request description text, wherein the number of rewrites is used to indicate the number of times the request description text has been rewritten.

12. The method according to claim 11, characterized in that After rewriting the request description text based on the first legitimacy check result to obtain a rewritten request description text, the method further includes: Performing a parameter validity check on the parsing result of the rewritten request description text to obtain a second validity check result; If the second legitimacy check result does not meet the check condition and the number of rewrites is greater than the target number, displaying an exception report, wherein the exception report is used to indicate that the target embedded code failed to be generated and the parameters in the rewritten request description text did not pass the parameter legitimacy check; The rewritten request description text is sent to a description text review node, wherein the text review node is used to review the rewritten request description text.

13. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the method for generating a target embedded code according to any one of claims 1 to 11 when executing the computer program.

14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the method for generating a target embedded code according to any one of claims 1 to 11 are implemented.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method for generating target embedded code according to any one of claims 1 to 11 are implemented.

Citation Information

Patent Citations

  • Request processing method and device, equipment and storage medium

    CN118170360A

  • Automatic hardware code generation method and device, electronic equipment and storage medium

    CN118466960A

  • Method and device for automatically generating program code from design drawing, medium and product

    CN119045821A

  • Application program generation method and device and electronic equipment

    CN119088355A

  • Training code generation method and device, terminal and computer readable storage medium

    CN119249156A

Cited By

  • Sensor manual automatic analysis and ROS2 drive generation system and method

    CN122261660A

  • Sensor manual automatic parsing and ros2 driving generation system and method

    CN122261660B