Interface management method and device based on industrial internet platform, electronic device and storage medium
By parsing the design text to obtain semantic tags and training a generative model, the problem of logical deviation in interface program generation is solved, and efficient and accurate interface program management and generation are achieved.
Patent Information
- Application Number
- CN202511083835.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-04
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-08-04
AI Technical Summary
During the generation and management of interface programs, differences in the format of interface documents written by different developers and ambiguities in functional design can lead to logical deviations and low accuracy in the functions implemented by the interface programs.
Semantic tags are obtained by parsing the design text of the industrial internet platform, prompt data is constructed and a generative model is trained to generate interface documents and programs, and the complexity is dynamically adjusted to improve accuracy.
It enables end-to-end interface program generation and management, improving the efficiency and accuracy of interface management, reducing functional design deviations, and enhancing the integrity of interface programs and the accuracy of execution logic.
Smart Images

Figure CN120579555B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of interface management technology based on industrial internet platforms, and in particular to an interface management method, device, electronic device and storage medium based on an industrial internet platform. Background Technology
[0002] In the process of developing interface programs, the code used to implement the interface program is usually constructed according to the communication protocol of the interface program. Due to the differences in the format of interface documents written by different developers, and the ambiguity in the requirements for designing the functionality of the interface program based on natural language, this method of interface generation and management can lead to logical deviations in the functionality implemented by the interface program. Summary of the Invention
[0003] In view of the above, it is necessary to propose an interface management method, device, electronic device and storage medium based on an industrial internet platform to solve the technical problem of low accuracy in generating interface programs.
[0004] This application provides an interface management method based on an industrial internet platform, applied to electronic devices. The method includes: parsing the design text of the industrial internet platform to obtain semantic tags of the design text; wherein the semantic tags are used to characterize the functions of interface programs in the industrial internet platform; constructing first prompt data based on the semantic tags and pre-stored first prompt words; wherein the first prompt words are used to indicate the boundary conditions of the interface programs; generating multiple interface documents based on the first prompt data and a pre-trained generative model; parsing any one of the multiple interface documents to obtain the complexity of the interface program corresponding to the arbitrary interface document; determining second prompt data corresponding to the arbitrary interface document based on the arbitrary interface document, the corresponding complexity, and pre-stored second prompt words; and generating the interface program corresponding to the arbitrary interface document based on the second prompt data and a pre-trained generative model.
[0005] In some embodiments, parsing any one of the plurality of interface documents to obtain the complexity of the interface program corresponding to that interface document includes: determining the nesting depth and the number of interface dependencies of the corresponding interface program based on the nested statements in the arbitrary interface document; determining a first complexity of the interface program based on the nesting depth and the number of interface dependencies; the first complexity is used to indicate the structural complexity of the interface program; determining a second complexity of the interface program based on the number of conditional statements and the number of loop statements recorded in the arbitrary interface document; the second complexity is used to indicate the complexity of the execution logic of the interface program; determining a third complexity of the interface program based on the size of the input structure and / or output structure recorded in the arbitrary interface document; the third complexity is used to indicate the complexity of the input data and output data of the interface program; and determining the complexity of the interface program based on the first complexity, the second complexity, and the third complexity.
[0006] In some embodiments, the method further includes training the first generative model, wherein training the first generative model includes: determining a first predicted document corresponding to the first example based on a pre-built first initial model according to a pre-stored first example; determining a first loss value of the first initial model based on the first predicted document and the labeled document corresponding to the first example; updating the first initial model based on a backpropagation algorithm; and stopping updating the first initial model when the first loss value satisfies a preset first condition, thereby obtaining a first generative model trained to a convergent state.
[0007] In some embodiments, determining the first loss value of the first initial model based on the first predicted document and the labeled document corresponding to the first example includes: determining the sentence classification loss of the first initial model based on the cross-entropy between the sentence sequence of the first predicted document and the sentence sequence of the labeled document; determining a first structured field in the first predicted document and a second structured field in the labeled document; determining the matching loss of the first initial model based on the first structured field and the second structured field; determining the semantic similarity between the first predicted document and the labeled document based on the semantics of the first predicted document and the semantics of the labeled document; and determining the first loss value of the first initial model based on the sentence classification loss, the matching loss, and the semantic similarity.
[0008] In some embodiments, the method further includes training the second generative model, wherein training the second generative model includes: determining a prediction program corresponding to the second example based on a pre-built second initial model and a pre-stored second example; determining a second loss value of the second initial model based on the prediction program, the annotation program corresponding to the second example, and the complexity of the pre-acquired annotation program; updating the second initial model based on a backpropagation algorithm; and stopping updating the second initial model when the second loss value satisfies a preset second condition, thereby obtaining a second generative model trained to a convergent state.
[0009] In some embodiments, determining the second loss value of the second initial model includes: determining a corresponding first syntax tree based on the prediction procedure; and determining a corresponding second syntax tree based on the annotation procedure; determining a matching loss of the second initial model based on the similarity between the first syntax tree and the second syntax tree; and updating the matching loss based on the complexity of the annotation procedure to obtain the second loss value.
[0010] In some embodiments, the method includes: inputting second prompt data corresponding to the interface document into the second generative model in order of increasing complexity; and generating an interface program corresponding to the interface document based on the second prompt data and a pre-trained second generative model.
[0011] This application embodiment also provides an interface management device based on an industrial internet platform. The device includes: a parsing module, used to parse the design text of the industrial internet platform to obtain semantic tags of the design text; wherein the semantic tags are used to characterize the functions of interface programs in the industrial internet platform; a construction module, used to construct first prompt data based on the semantic tags and pre-stored first prompt words; wherein the first prompt words are used to indicate the boundary conditions of the interface program; a first generation module, used to generate multiple interface documents based on the first prompt data and a pre-trained first generative model; the parsing module is further used to parse any one of the multiple interface documents to obtain the complexity of the interface program corresponding to the arbitrary interface document; the construction module is further used to determine second prompt data corresponding to the arbitrary interface document based on the arbitrary interface document, the corresponding complexity, and pre-stored second prompt words; and a second generation module, used to generate the interface program corresponding to the arbitrary interface document based on the second prompt data and a pre-trained second generative model.
[0012] This application also provides an electronic device, which includes: a memory for storing at least one instruction; and a processor for executing the instructions stored in the memory to implement the interface management method based on an industrial internet platform.
[0013] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the interface management method based on an industrial internet platform.
[0014] As can be seen from the above technical solutions, the embodiments of this application generate interface documents by parsing design text and generate interface programs based on the interface documents, thereby realizing an end-to-end interface program generation and management process and improving the efficiency of interface management. The semantic tags obtained from parsing the design text directly associate the functions of the interface program, reducing deviations in the functional design of the interface program. Furthermore, boundary conditions of the interface are predefined based on the first and second prompt words, thereby imposing constraints on the process of generating the interface program and improving the completeness of the interface program's functionality. Dynamically adjusting the generation logic based on the complexity of the interface document can improve the accuracy of the execution logic of the generated interface program. Attached Figure Description
[0015] Figure 1 This is an application scenario diagram of an interface management method based on an industrial internet platform provided in one embodiment of this application.
[0016] Figure 2 This is a flowchart of an interface management method based on an industrial internet platform provided in one embodiment of this application.
[0017] Figure 3 This is a functional block diagram of an interface management device based on an industrial internet platform provided in one embodiment of this application.
[0018] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0019] To better understand the purpose, features, and advantages of this application, a detailed description of the application is provided below with reference to the accompanying drawings and specific embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in the embodiments of this application can be combined with each other. Numerous specific details are set forth in the following description to provide a thorough understanding of this application; the described embodiments are only a part of the embodiments of this application, and not all of them.
[0020] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the stated features. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.
[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0022] This application provides an interface management method based on an industrial internet platform, which can be applied to one or more electronic devices. An electronic device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0023] Electronic devices can be any electronic product that allows human-computer interaction with a customer, such as personal computers, tablets, smartphones, personal digital assistants (PDAs), game consoles, interactive network television (IPTV), smart wearable devices, etc.
[0024] Electronic devices may also include network devices and / or client devices. The network devices include, but are not limited to, a single network server, a server group consisting of multiple network servers, or a cloud based on cloud computing consisting of a large number of hosts or network servers.
[0025] The networks in which electronic devices are located include, but are not limited to, the Internet, wide area networks, metropolitan area networks, local area networks, and virtual private networks (VPNs).
[0026] like Figure 1The diagram illustrates an application scenario of an interface management method based on an industrial internet platform, as provided in an embodiment of this application. This method can be applied to an electronic device 100. The electronic device 100 can be any device with data processing capabilities; this application does not limit the specific form of the electronic device 100. The electronic device 100 is communicatively connected to a storage device 200, which stores design text and other related data from the industrial internet platform. The electronic device 100 acquires the design text stored in the storage device 200; parses the design text to obtain semantic tags; the semantic tags characterize the functions of the interface programs in the industrial internet platform. The electronic device 100 also constructs first prompt data based on the semantic tags and pre-stored first prompt words; the first prompt words indicate the boundary conditions of the interface programs; and generates multiple interface documents based on the first prompt data and a pre-trained generative model. The electronic device 100 is also used to parse any one of the plurality of interface documents to obtain the complexity of the interface program corresponding to the arbitrary interface document; based on the arbitrary interface document, the corresponding complexity, and the pre-stored second prompt words, determine the second prompt data corresponding to the arbitrary interface document; and generate the interface program corresponding to the arbitrary interface document based on the second prompt data and a pre-trained second generative model.
[0027] like Figure 2 The diagram shown is a flowchart of an interface management method based on an industrial internet platform according to an embodiment of this application. The order of steps in this flowchart can be changed, and some steps can be omitted, depending on different requirements. The interface management method based on an industrial internet platform provided in this embodiment includes the following steps.
[0028] S20, parse the design text of the industrial internet platform to obtain semantic tags of the design text; wherein, the semantic tags are used to characterize the functions of the interface programs in the industrial internet platform.
[0029] In one embodiment of this application, in order to improve the efficiency of developing, generating and managing program interfaces in an industrial internet platform, the design text of the industrial internet platform can be transformed into machine-understandable semantic tags through natural language processing (NLP) technology, thereby providing a foundation for the automated generation, verification and management of subsequent interface programs.
[0030] In one embodiment of this application, parsing design text to obtain semantic tags includes: preprocessing the design text, performing semantic parsing and tag mapping on the design text, and standardizing and ontology mapping the tags of the design text. Specifically, preprocessing the design text includes: removing redundant characters (e.g., HTML tags, special symbols) from the design text, unifying the text format (e.g., converting full-width characters to half-width characters, normalizing case), thereby cleaning and standardizing the data. The design text is split into natural sentences based on punctuation marks, and each natural sentence is segmented based on a preset dictionary (e.g., an industrial terminology dictionary) to obtain the vocabulary in the design text. The vocabulary in the design text is used to represent the technical terms in the design text (e.g., "PLC control," "data acquisition frequency").
[0031] Specifically, during semantic parsing and tag mapping, the semantic tag of any word can be determined based on its semantic meaning. For example, if the content of any word is data acquisition interface, control command interface, or status reporting interface, the semantic tag of that word is interface type; if the content of any word is temperature sensor data, equipment operating status, or production plan data, the semantic tag of that word is data type; and if the content of any word is real-time requirements, data encryption level, or concurrent access restrictions, the semantic tag of that word is operation attribute.
[0032] Specifically, when performing tag standardization and ontology mapping, the parsing results can be mapped to a predefined semantic tag system to ensure tag consistency and scalability.
[0033] S21, construct first prompt data based on the semantic tag and the pre-stored first prompt word; wherein, the first prompt word is used to indicate the boundary conditions of the interface program.
[0034] In one embodiment of this application, in order to construct input data suitable for generative models, the model can be guided to generate interface programs that meet business requirements and technical specifications through the combination of structured information. Semantic tags can be abstract descriptions of the functions of the industrial internet platform interface programs, including information such as interface type (e.g., data acquisition, command control), data objects (e.g., sensor data, device status), and operational attributes (e.g., real-time performance, concurrency), used to indicate a summary of the interface functions.
[0035] In one embodiment of this application, the first prompt word can be a pre-stored text template used to determine the boundary conditions of the interface program. For example, the first prompt word may include technical constraints (e.g., communication protocol, data format), performance indicators (e.g., response time, throughput), security requirements (e.g., encryption method, access control), etc. For instance, the content of the first prompt word may include "The interface must use the HTTPS protocol, and the response time must not exceed 500ms."
[0036] In one embodiment of this application, since the first prompt data serves as input to the generative model, its quality can affect the accuracy of the model's output. By combining semantic tags with boundary conditions, issues such as missing functionality or non-compliance with technical specifications in the model's generated interface program can be avoided.
[0037] For example, the first prompt can be a combination of variable placeholders and fixed text. For instance, the first prompt could be in the form of "Please generate an interface of [interface type] that processes [data objects] and meets the following conditions:"
[0038] 1. Communication Protocol: [Protocol Type];
[0039] 2. Data format: [Data format];
[0040] 3. Performance Requirements: Response time not exceeding [response time] ms; concurrency support [number of concurrent connections].
[0041] In one embodiment of this application, the specific content of the semantic tag can be filled into the variable placeholder of the prompt word template, and combined with pre-stored boundary condition parameters (e.g., protocol type "HTTP / 2", response time "300ms"), to generate complete first prompt data. For example, the first prompt data could be in the form of: "Please generate a data acquisition interface for processing temperature sensor data, which must meet the following conditions:"
[0042] 1. Communication protocol: HTTP / 2;
[0043] 2. Data format: JSON;
[0044] 3. Performance requirements: Response time not exceeding 300ms, and concurrent connections supported up to 200.
[0045] S22, Based on the first prompt data, generate multiple interface documents using a pre-trained first generative model.
[0046] In one embodiment of this application, the method further includes training the first generative model. Training the first generative model includes: determining a first predicted document corresponding to a pre-stored first example based on a pre-constructed first initial model; determining a first loss value of the first initial model based on the first predicted document and the labeled document corresponding to the first example; updating the first initial model based on a backpropagation algorithm; and stopping the updating of the first initial model when the first loss value satisfies a preset first condition, thereby obtaining a first generative model trained to a convergent state. The preset first condition may be that the first loss value is less than or equal to a preset termination threshold.
[0047] Specifically, a larger first loss value indicates a greater difference between the predicted document output by the first initial model and the labeled document corresponding to the first example, resulting in lower accuracy of the prediction result output by the first initial model. Therefore, the first initial model can continue to be updated. Conversely, a smaller first loss value indicates a smaller difference between the predicted document output by the first initial model and the labeled document corresponding to the first example, resulting in higher accuracy of the prediction result output by the first initial model. Therefore, the first initial model can be stopped from being updated, and the first generative model trained to a convergent state is obtained.
[0048] In one embodiment of this application, determining the first loss value of the first initial model based on the first predicted document and the labeled document corresponding to the first example includes: determining the sentence classification loss of the first initial model based on the cross-entropy between the sentence sequence of the first predicted document and the sentence sequence of the labeled document; determining a first structured field in the first predicted document and a second structured field in the labeled document; determining the matching loss of the first initial model based on the first structured field and the second structured field; determining the semantic similarity between the first predicted document and the labeled document based on the semantics of the first predicted document and the semantics of the labeled document; and determining the first loss value of the first initial model based on the sentence classification loss, the matching loss, and the semantic similarity.
[0049] In one embodiment of this application, the specific method for determining the matching loss of the first initial model satisfies the following relationship:
[0050] ;
[0051] in, M represents the matching loss of the first initial model; j represents the number of the first structured fields; c represents the field type of the first structured field; and C represents the set of any field types. This represents the probability that the j-th first structured field belongs to type c; This represents the probability that the j-th second structured field belongs to type c.
[0052] In one embodiment of this application, a first semantic vector corresponding to the semantics of a first predicted document can be determined based on the encoder in the first initial model, and a second semantic vector corresponding to the semantics of a labeled document can be determined based on the encoder in the first initial model, and the cosine similarity between the first semantic vector and the second semantic vector can be determined.
[0053] In one embodiment of this application, the specific method for determining the first loss value satisfies the following relationship:
[0054] ;
[0055] in, This represents the first loss value of the initial model. Represents classification loss; represents the matching loss; S represents the cosine similarity between the first and second semantic vectors; , and This represents the preset weight parameters, where, , and The sum can be 1.
[0056] S23, parse any one of the multiple interface documents to obtain the complexity of the interface program corresponding to the given interface document.
[0057] In one embodiment of this application, parsing any one of the plurality of interface documents to obtain the complexity of the interface program corresponding to that interface document includes: determining the nesting depth and the number of interface dependencies of the corresponding interface program based on the nested statements in the arbitrary interface document; determining a first complexity of the interface program based on the nesting depth and the number of interface dependencies; the first complexity is used to indicate the structural complexity of the interface program; determining a second complexity of the interface program based on the number of conditional statements and the number of loop statements recorded in the arbitrary interface document; the second complexity is used to indicate the complexity of the execution logic of the interface program; determining a third complexity of the interface program based on the size of the input structure and / or output structure recorded in the arbitrary interface document; the third complexity is used to indicate the complexity of the input data and output data of the interface program; and determining the complexity of the interface program based on the first complexity, the second complexity, and the third complexity.
[0058] In one embodiment of this application, the number of times a nested function is called within a nested statement can be determined, the nesting depth can be determined based on the number of calls to the nested function, and the number of interface dependencies can be determined based on the parameters in the nested function. A higher number of calls to the nested function indicates a greater nesting depth; more types of interface names referenced in the nested function indicate a higher number of interface dependencies. The sum of the number of calls to the nested function and the number of interface names referenced in the nested function can be determined as the first complexity of the interface document.
[0059] In one embodiment of this application, a higher number of conditional statements recorded in the interface document indicates a higher complexity of the execution logic of the corresponding interface program; a higher number of loop statements recorded in the interface document also indicates a higher complexity of the execution logic of the corresponding interface program. The sum of the number of conditional statements and the number of loop statements can be determined as the second complexity of the interface program corresponding to the interface document.
[0060] In one embodiment of this application, the size of the input structure and / or output structure recorded in any interface document can be the amount of input or output data corresponding to the input structure and / or output structure. The amount of input or output data corresponding to the input structure and output structure in any interface document can be normalized to obtain the third complexity of the interface program.
[0061] In one embodiment of this application, the sum of the first complexity, the second complexity, and the third complexity can be determined as the complexity of the interface program corresponding to the interface document.
[0062] S24. Based on any one interface document, the corresponding complexity, and the pre-stored second prompt words, determine the second prompt data corresponding to the any one interface document.
[0063] In one embodiment of this application, during the process of determining the second prompt data, information such as the function description, parameter definition, and call flow in the interface document can be extracted first. The second prompt word corresponding to the interface document is then determined based on the complexity information. The second prompt word is used to indicate the constraints of the interface program corresponding to the interface document.
[0064] For example, when the complexity of the interface document is 3, and the functional description, parameter definition, and process information in the interface document include: "multi-module collaboration logic", "concurrency control", "distributed transactions", "multi-level caching strategy", "QPS greater than 1000" and "response time less than 500 milliseconds", the second prompt word can be in the form of "Generate an interface program containing [multi-module collaboration logic], which needs to implement [concurrency control], [distributed transactions] and [multi-level caching strategy], and meet the requirements of [QPS greater than 1000] and [response time less than 500 milliseconds]; note that the complexity of the interface program is 3".
[0065] S25, Based on the second prompt data and the pre-trained second generative model, generate the interface program corresponding to any one of the interface documents.
[0066] In one embodiment of this application, the method further includes training the second generative model, wherein training the second generative model includes: determining a prediction program corresponding to the second example based on a pre-built second initial model according to a pre-stored second example; determining a second loss value of the second initial model based on the prediction program, the annotation program corresponding to the second example, and the complexity of the pre-acquired annotation program; updating the second initial model based on a backpropagation algorithm; and stopping updating the second initial model when the second loss value satisfies a preset second condition, thereby obtaining a second generative model trained to a convergent state.
[0067] Specifically, a larger second loss value indicates a greater difference between the prediction program output by the second initial model and the annotation program corresponding to the second example, resulting in lower accuracy of the prediction results output by the second initial model. Therefore, the second initial model can continue to be updated. Conversely, a smaller second loss value indicates a smaller difference between the prediction program output by the second initial model and the annotation program corresponding to the second example, resulting in higher accuracy of the prediction results output by the second initial model. Therefore, the second initial model can be stopped from being updated, and the second generative model trained to a convergent state can be obtained.
[0068] In one embodiment of this application, determining the second loss value of the second initial model includes: determining a corresponding first syntax tree based on the prediction program; and determining a corresponding second syntax tree based on the annotation program; determining the matching loss of the second initial model based on the similarity between the first syntax tree and the second syntax tree; and updating the matching loss based on the complexity of the annotation program to obtain the second loss value.
[0069] Specifically, the minimum number of operations required to convert the first syntax tree into the second syntax tree (e.g., operations including insertion, deletion, and modification of nodes) can be calculated. The ratio between the number of structurally identical subtrees in the first and second syntax trees and the number of all subtrees can be calculated. Based on the complexity of the interface program corresponding to the interface document, the minimum number of operations, and the ratio, a second loss value is determined. Specifically, the method for determining the second loss value satisfies the following relationship:
[0070] ;
[0071] Where Loss2 represents the second loss value; N represents the complexity of the interface program corresponding to the interface document; M represents the minimum number of operations required to convert the first syntax tree into the second syntax tree; M represents the ratio between the number of structurally identical subtrees in the first and second syntax trees and the number of all subtrees. and This represents the preset weight parameters, where, and The sum can be 1.
[0072] In one embodiment of this application, the method further includes: inputting second prompt data corresponding to the interface document into the second generative model based on the order of complexity from low to high; and generating an interface program corresponding to the interface document based on the second prompt data and the pre-trained second generative model.
[0073] As can be seen from the above technical solutions, the embodiments of this application generate interface documents by parsing design text and generate interface programs based on the interface documents, thereby realizing an end-to-end interface program generation and management process and improving the efficiency of interface management. The semantic tags obtained from parsing the design text directly associate the functions of the interface program, reducing deviations in the functional design of the interface program. Furthermore, boundary conditions of the interface are predefined based on the first and second prompt words, thereby imposing constraints on the process of generating the interface program and improving the completeness of the interface program's functionality. Dynamically adjusting the generation logic based on the complexity of the interface document can improve the accuracy of the execution logic of the generated interface program.
[0074] Please see Figure 3 , Figure 3This is a functional block diagram of an interface management device based on an industrial internet platform according to an embodiment of this application. The interface management device 31 based on the industrial internet platform includes a parsing module 311, a construction module 312, a first generation module 313, and a second generation module 314. The module / unit referred to in this application refers to a series of computer-readable instruction segments that can be executed by the processor 13 and perform a fixed function, and are stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.
[0075] The parsing module 311 is used to parse the design text of the industrial internet platform to obtain semantic tags of the design text; wherein, the semantic tags are used to characterize the functions of the interface programs in the industrial internet platform.
[0076] The construction module 312 is used to construct first prompt data based on the semantic tag and the pre-stored first prompt word; wherein the first prompt word is used to indicate the boundary conditions of the interface program.
[0077] The first generation module 313 is used to generate multiple interface documents based on the first prompt data and a pre-trained first generative model.
[0078] The parsing module 311 is also used to parse any one of the multiple interface documents to obtain the complexity of the interface program corresponding to the arbitrary interface document.
[0079] The construction module 312 is further configured to determine the second prompt data corresponding to the arbitrary interface document based on the arbitrary interface document, the corresponding complexity, and the pre-stored second prompt words.
[0080] The second generation module 314 is used to generate the interface program corresponding to any one of the interface documents based on the second prompt data and a pre-trained second generative model.
[0081] In some embodiments, the parsing module 311 parses any one of the plurality of interface documents to obtain the complexity of the interface program corresponding to the arbitrary interface document, including: determining the nesting depth and the number of interface dependencies of the corresponding interface program based on the nested statements in the arbitrary interface document; determining a first complexity of the interface program based on the nesting depth and the number of interface dependencies; the first complexity is used to indicate the structural complexity of the interface program; determining a second complexity of the interface program based on the number of conditional statements and the number of loop statements recorded in the arbitrary interface document; the second complexity is used to indicate the complexity of the execution logic of the interface program; determining a third complexity of the interface program based on the size of the input structure and / or output structure recorded in the arbitrary interface document; the third complexity is used to indicate the complexity of the input data and output data of the interface program; and determining the complexity of the interface program based on the first complexity, the second complexity, and the third complexity.
[0082] In some embodiments, the first generation module 313 is further configured to determine a first predicted document corresponding to the first example based on a pre-built first initial model, based on a pre-stored first example; determine a first loss value of the first initial model based on the first predicted document and the labeled document corresponding to the first example; update the first initial model based on a backpropagation algorithm; and stop updating the first initial model when the first loss value meets a preset first condition, thereby obtaining a first generative model trained to a convergent state.
[0083] In some embodiments, the first generation module 313 is further configured to: determine the statement classification loss of the first initial model based on the cross-entropy between the statement sequence of the first predicted document and the statement sequence of the labeled document; determine a first structured field in the first predicted document and a second structured field in the labeled document; determine the matching loss of the first initial model based on the first structured field and the second structured field; determine the semantic similarity between the first predicted document and the labeled document based on the semantics of the first predicted document and the semantics of the labeled document; and determine a first loss value of the first initial model based on the statement classification loss, the matching loss, and the semantic similarity.
[0084] In some embodiments, the second generation module 314 is further configured to determine the prediction program corresponding to the second example based on the pre-stored second example and the pre-built second initial model; determine the second loss value of the second initial model based on the prediction program, the annotation program corresponding to the second example and the complexity of the pre-acquired annotation program; update the second initial model based on the backpropagation algorithm; and stop updating the second initial model when the second loss value meets the preset second condition, thereby obtaining a second generative model trained to a convergent state.
[0085] In some embodiments, the second generation module 314 is further configured to: determine a corresponding first syntax tree based on the prediction program; determine a corresponding second syntax tree based on the annotation program; determine the matching loss of the second initial model based on the similarity between the first syntax tree and the second syntax tree; and update the matching loss based on the complexity of the annotation program to obtain the second loss value.
[0086] In some embodiments, the second generation module 314 is further configured to input second prompt data corresponding to the interface document into the second generative model in order of increasing complexity; and generate the interface program corresponding to the interface document based on the second prompt data and the pre-trained second generative model.
[0087] Please see Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 100 includes a memory 12 and a processor 13. The memory 12 is used to store computer-readable instructions, and the processor 13 executes the computer-readable instructions stored in the memory to implement the interface management method based on an industrial internet platform as described in any of the above embodiments.
[0088] In one embodiment of this application, the electronic device 100 further includes a bus and a computer program stored in the memory 12 and executable on the processor 13, such as an interface management program based on an industrial internet platform.
[0089] Figure 4 Only an electronic device 100 with memory 12 and processor 13 is shown; those skilled in the art will understand that... Figure 4 The structure shown does not constitute a limitation on the electronic device 100, and may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0090] Combination Figure 2The memory 12 in the electronic device 100 stores multiple computer-readable instructions to implement the interface management method based on the industrial internet platform. The processor 13 can execute the multiple instructions to achieve: parsing the design text of the industrial internet platform to obtain semantic tags of the design text; wherein the semantic tags are used to characterize the functions of the interface programs in the industrial internet platform; constructing first prompt data based on the semantic tags and pre-stored first prompt words; wherein the first prompt words are used to indicate the boundary conditions of the interface programs; generating multiple interface documents based on the first prompt data and a pre-trained first generative model; parsing any one of the multiple interface documents to obtain the complexity of the interface program corresponding to the arbitrary interface document; determining second prompt data corresponding to the arbitrary interface document based on the arbitrary interface document, the corresponding complexity, and pre-stored second prompt words; and generating the interface program corresponding to the arbitrary interface document based on the second prompt data and a pre-trained second generative model.
[0091] Specifically, the processor 13's implementation method for the above instructions can be found in [reference needed]. Figure 2 The descriptions of the relevant steps in the corresponding embodiments are not repeated here.
[0092] Those skilled in the art will understand that the schematic diagram is merely an example of the electronic device 100 and does not constitute a limitation on the electronic device 100. The electronic device 100 may be a bus-type structure or a star-type structure. The electronic device 100 may also include more or fewer other hardware or software than shown in the diagram, or different component arrangements. For example, the electronic device 100 may also include input / output devices, network access devices, etc.
[0093] It should be noted that electronic device 100 is only an example. Other existing or future electronic products that are suitable for this application should also be included within the scope of protection of this application and are incorporated herein by reference.
[0094] The memory 12 includes at least one type of readable storage medium, which can be non-volatile or volatile. The readable storage medium includes flash memory, portable hard drives, multimedia cards, card-type memory (e.g., SD or DX memory), magnetic storage, magnetic disks, optical disks, etc. In some embodiments, the memory 12 can be an internal storage unit of the electronic device 100, such as the portable hard drive of the electronic device 100. In other embodiments, the memory 12 can also be an external storage device of the electronic device 100, such as a plug-in portable hard drive, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the electronic device 100. The memory 12 can be used not only to store application software and various types of data installed on the electronic device 100, such as the code of an interface management program based on an industrial internet platform, but also to temporarily store data that has been output or will be output.
[0095] In some embodiments, the processor 13 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 13 is the control unit of the electronic device 100, connecting various components of the electronic device 100 via various interfaces and lines. It executes programs or modules stored in the memory 12 (e.g., executing interface management programs based on an industrial internet platform) and calls data stored in the memory 12 to perform various functions and process data for the electronic device 100.
[0096] The processor 13 executes the operating system of the electronic device 100 and various installed applications. The processor 13 executes these applications to implement the steps in the various embodiments of the interface management method based on the industrial internet platform described above, for example... Figure 3 The steps are shown.
[0097] For example, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete this application. The one or more modules / units may be a series of computer-readable instruction segments capable of performing a specific function, which describe the execution process of the computer program in the electronic device 100. For example, the computer program may be divided into a parsing module 311, a construction module 312, a first generation module 313, and a second generation module 314.
[0098] The integrated unit implemented as a software functional module described above can be stored in a computer-readable storage medium. This software functional module, stored in a storage medium, includes several instructions to cause a computer device (which may be a personal computer, computer equipment, or network device, etc.) or processor to execute a portion of the interface management method based on an industrial internet platform as described in the various embodiments of this application.
[0099] If the modules / units integrated in the electronic device 100 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware devices. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above.
[0100] The computer program includes computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory, and other memory.
[0101] Furthermore, the computer-readable storage medium may primarily include a stored program area and a stored data area, wherein the stored program area may store the operating system, an application program required for at least one function, etc.; and the stored data area may store data created based on the use of blockchain nodes, etc.
[0102] The bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, in... Figure 4 The symbol is represented by only one arrow, but this does not indicate that there is only one bus or one type of bus. The bus is configured to enable communication between the memory 12 and at least one processor 13, etc.
[0103] This application also provides a computer-readable storage medium (not shown), which stores computer-readable instructions. These computer-readable instructions are executed by a processor in an electronic device to implement the interface management method based on an industrial internet platform as described in any of the above embodiments.
[0104] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.
[0105] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0106] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.
[0107] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices described in the specification may also be implemented by a single unit or device through software or hardware. Terms such as "first," "second," etc., are used to indicate names and do not indicate any specific order.
[0108] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application and are not intended to limit it. Although this application has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of this application without departing from the spirit and scope of the technical solutions of this application.
Claims
1. An interface management method based on an industrial internet platform, applied to electronic devices within the industrial internet platform, characterized in that, The method includes: The design text of the industrial internet platform is parsed to obtain semantic tags; wherein, the semantic tags are used to characterize the functions of the interface programs in the industrial internet platform. Based on the semantic tags and the pre-stored first prompt words, first prompt data is constructed; wherein, the first prompt words are used to indicate the boundary conditions of the interface program; Based on the first prompt data, multiple interface documents are generated using a pre-trained first generative model. Training the first generative model includes: determining a first predicted document corresponding to a pre-stored first example and a pre-built first initial model; determining a first loss value for the first initial model based on the first predicted document and the labeled document corresponding to the first example; updating the first initial model using a backpropagation algorithm; stopping the update of the first initial model when the first loss value meets a preset first condition, thus obtaining a first generative model trained to convergence. Determining the first loss value of the first initial model includes: determining a sentence classification loss for the first initial model based on the cross-entropy between the sentence sequence of the first predicted document and the sentence sequence of the labeled document; determining a first structured field in the first predicted document and a second structured field in the labeled document; determining a matching loss for the first initial model based on the first structured field and the second structured field; determining the semantic similarity between the first predicted document and the labeled document based on the semantics of the first predicted document and the semantic similarity of the labeled document; and determining the first loss value for the first initial model based on the sentence classification loss, the matching loss, and the semantic similarity. The matching loss satisfies the following relationship: ;in, M represents the matching loss of the first initial model; j represents the number of the first structured fields; c represents the field type of the first structured field; and C represents the set of any field types. This represents the probability that the j-th first structured field belongs to type c; Let represent the probability that the j-th second structured field belongs to type c; where the first loss value satisfies the following relationship: ;in, This represents the first loss value of the initial model. Represents classification loss; S represents the matching loss; S represents the cosine similarity between the first semantic vector corresponding to the first predicted document and the second semantic vector corresponding to the labeled document, used to indicate the semantic similarity between the first predicted document and the labeled document. , and Represents the preset weight parameters; Parse any one of the multiple interface documents to obtain the complexity of the interface program corresponding to that interface document; Based on any one of the interface documents, the corresponding complexity, and the pre-stored second prompt words, determine the second prompt data corresponding to any one of the interface documents; Based on the second prompt data, and using a pre-trained second generative model, an interface program corresponding to any one of the interface documents is generated.
2. The interface management method based on an industrial internet platform as described in claim 1, characterized in that, The complexity of parsing any one of the multiple interface documents to obtain the corresponding interface program includes: Based on the nested statements in any of the interface documents, determine the nesting depth and the number of interface dependencies of the corresponding interface program; Based on the nesting depth and the number of interface dependencies, a first complexity of the interface program is determined; the first complexity is used to indicate the complexity of the structure of the interface program. The second complexity of the interface program is determined based on the number of conditional statements and loop statements recorded in any of the interface documents; the second complexity is used to indicate the complexity of the execution logic of the interface program. The third complexity of the interface program is determined based on the size of the input structure and / or output structure recorded in any of the interface documents; the third complexity is used to indicate the complexity of the input and output data of the interface program. The complexity of the interface program is determined based on the first complexity, the second complexity, and the third complexity.
3. The interface management method based on an industrial internet platform as described in claim 1, characterized in that, The method further includes training the second generative model, wherein training the second generative model includes: Based on the pre-stored second example, and using the pre-built second initial model, determine the prediction procedure corresponding to the second example; Based on the prediction program, the annotation program corresponding to the second example, and the complexity of the pre-obtained annotation program, the second loss value of the second initial model is determined; The second initial model is updated based on the backpropagation algorithm. When the second loss value meets the preset second condition, the update of the second initial model is stopped, and a second generative model trained to the convergence state is obtained.
4. The interface management method based on an industrial internet platform as described in claim 3, characterized in that, Determining the second loss value of the second initial model includes: Based on the prediction procedure, a corresponding first syntax tree is determined; and based on the annotation procedure, a corresponding second syntax tree is determined. Based on the similarity between the first syntax tree and the second syntax tree, the matching loss of the second initial model is determined; The matching loss is updated based on the complexity of the annotation procedure to obtain the second loss value.
5. The interface management method based on an industrial internet platform as described in claim 1, characterized in that, The method further includes: Based on the order of complexity from low to high, the second prompt data corresponding to the interface document is input into the second generative model; Based on the second prompt data, and using a pre-trained second generative model, the interface program corresponding to the interface document is generated.
6. An interface management device based on an industrial internet platform, characterized in that, The apparatus includes a module for implementing the method as described in any one of claims 1 to 5, the apparatus comprising: The parsing module is used to parse the design text of the industrial internet platform to obtain semantic tags of the design text; wherein, the semantic tags are used to characterize the functions of the interface programs in the industrial internet platform; A construction module is used to construct first prompt data based on the semantic tags and pre-stored first prompt words; wherein, the first prompt words are used to indicate the boundary conditions of the interface program; The first generation module is used to generate multiple interface documents based on the first prompt data and a pre-trained first generative model. The parsing module is also used to parse any one of the multiple interface documents to obtain the complexity of the interface program corresponding to the arbitrary interface document. The construction module is also used to determine the second prompt data corresponding to any one interface document based on any one interface document, the corresponding complexity, and the pre-stored second prompt words; The second generation module is used to generate the interface program corresponding to any one of the interface documents based on the second prompt data and a pre-trained second generative model.
7. An electronic device, characterized in that, The electronic device includes a processor and a storage device, wherein the processor is used to implement the interface management method based on the industrial internet platform as described in any one of claims 1 to 5 when executing a computer program stored in the storage device.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the interface management method based on an industrial internet platform as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Method for generating interface document code based on natural language description
CN116501306A
Industrial big data micro-service API structure optimization method, medium and system
CN119537190A