Interface document generation method and device, storage medium and program product
By adaptively extracting and mapping the input and output tensor metadata of machine learning models, interface specification documents are generated, solving the problems of low efficiency and error-proneness in API documentation writing in existing technologies, and achieving efficient and accurate documentation generation.
Patent Information
- Application Number
- CN202511466560.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-14
- Publication Date
- 2026-01-16
AI Technical Summary
In the process of service-oriented machine learning models, existing technologies require developers to manually describe API documentation, which leads to low writing efficiency and is prone to errors, especially when the model structure is complex and it is difficult to maintain consistency.
The system adaptively extracts key metadata from the input and output tensors of the target model and generates interface specification documents through mapping and transformation rules, including automatic repair and human-computer interaction to ensure accuracy.
It improved the efficiency of API documentation writing, reduced the error rate, and ensured that the documentation was updated in sync with the model version, thus reducing maintenance costs.
Smart Images

Figure CN121349528A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of machine learning technology, and in particular to interface documentation generation methods, interface documentation generation devices, storage media, and computer program products. Background Technology
[0002] When writing API (Application Programming Interface) documentation for the target model to be deployed during the process of service-oriented output machine learning models, the traditional approach requires developers to describe details such as input and output tensor structures and data types item by item. However, when the model structure is complex, it can easily lead to inconsistencies between the API documentation and the model code.
[0003] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0004] The main purpose of this application is to provide an interface documentation generation method, interface documentation generation device, storage medium, and computer program product, aiming to solve the technical problems of low efficiency and error-proneness in writing and outputting API documentation.
[0005] To achieve the above objectives, this application proposes an interface documentation generation method, which includes: For the target model to be deployed during the service-oriented process of machine learning model, key metadata corresponding to the input and output tensors of the target model is adaptively extracted according to the type of the target model. Based on the pre-established mapping and conversion rules of native data types and service interface standard data types in the model framework, the data types of the key metadata are converted. Based on the key metadata after data conversion, an interface specification document for the target model is generated.
[0006] In one embodiment, the step of adaptively extracting key metadata corresponding to the input-output tensors of the target model based on the type of the target model includes: When the target model is a TensorFlow SavedModel, determine whether the service default signature of the target model exists and is complete; If the service default signature exists and is complete, then the key metadata corresponding to the target model input and output tensors can be obtained by accessing the service default signature; If the default signature of the service does not exist or is incomplete, then fall back to traversing all available signatures of the target model to determine the target signature based on the signature content and / or the number of input and output tensors, and obtain the key metadata corresponding to the input and output tensors of the target model through the target signature.
[0007] In one embodiment, the step of adaptively extracting key metadata corresponding to the input-output tensors of the target model based on the type of the target model includes: When the target model to be deployed is a PyTorch model, the key metadata corresponding to the input and output tensors of the target model is extracted by parsing the computation graph corresponding to the forward propagation of the PyTorch model.
[0008] In one embodiment, the step of adaptively extracting key metadata corresponding to the input-output tensors of the target model based on the type of the target model includes: When the target model to be deployed is an ONNX model, the key metadata corresponding to the input and output tensors of the target model is extracted by loading the ONNX file corresponding to the ONNX model, traversing the input and output nodes of the computation graph corresponding to the ONNX model.
[0009] In one embodiment, the step of adaptively extracting key metadata corresponding to the input-output tensors of the target model based on the type of the target model includes: The key metadata is subjected to integrity verification, which includes whether the input and output tensors corresponding to the key metadata have all basic attributes, whether the data type is a valid data type supported by the model framework, and whether the tensor dimension is a valid dimension format.
[0010] In one embodiment, the step of adaptively extracting key metadata corresponding to the input-output tensors of the target model based on the type of the target model includes: The key metadata is automatically repaired based on the basic attributes, data types, and tensor dimensions of the input and output tensors corresponding to the key metadata. If automatic repair is not possible or the automatic repair results are ambiguous, the key metadata that cannot be automatically repaired or whose automatic repair results are ambiguous will be repaired through human-computer interaction based on the metadata completion configuration file. The metadata completion configuration file obtained after human-computer interaction is used as a patch file in the latest key metadata extraction after the current key metadata extraction.
[0011] In one embodiment, the step of generating the interface specification document for the target model based on the key metadata after data conversion includes: In response to the software development kit (SDK) generation instruction, the interface specification document of the target model is converted into the target SSD, wherein the generation instruction includes the specified interface specification document, the generation language of the target SSD, and the output path.
[0012] Furthermore, to achieve the above objectives, this application also proposes an interface documentation generation apparatus, which includes: The extraction module is used to adaptively extract key metadata corresponding to the input and output tensors of the target model to be deployed during the service-oriented process of machine learning models, based on the type of the target model. The conversion module is used to convert the data types of the key metadata according to the pre-established mapping and conversion rules of the native data types of the model framework and the standard data types of the service interface. The generation module is used to generate the interface specification document of the target model based on the key metadata after data conversion.
[0013] In addition, to achieve the above objectives, this application also proposes an interface documentation generation device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the interface documentation generation method as described above.
[0014] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the interface document generation method described above.
[0015] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the interface document generation method described above.
[0016] One or more technical solutions proposed in this application have at least the following technical effects: In this application, key metadata corresponding to the input and output tensors of the target model is adaptively extracted according to the type of the target model. The data types of the key metadata are converted according to the mapping and conversion rules of the native data types of the model framework and the standard data types of the service interface. Finally, the interface specification document of the target model is generated based on the key metadata after the data types are converted.
[0017] The above describes how the metadata of the target model to be deployed is automatically parsed and its native data types are mapped to the data types of the service interface standard. This further generates the interface specification document of the target model, making the writing and output of API documentation efficient and less prone to errors, thereby significantly reducing maintenance costs and ensuring that the documentation and model versions are updated in sync. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart illustrating the first embodiment of the interface documentation generation method for this application. Figure 2 This is an application diagram provided for the first embodiment of the interface documentation generation method of this application; Figure 3 This is a flowchart illustrating the second embodiment of the interface documentation generation method for this application. Figure 4 This is a schematic diagram of the module structure of the interface documentation generation device according to an embodiment of this application; Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the interface documentation generation method in this application embodiment.
[0021] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0022] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0023] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or interface document generation device capable of performing the above functions. The following description uses an interface document generation device as an example to illustrate this embodiment and the subsequent embodiments.
[0024] Based on this, embodiments of this application provide a method for generating interface documentation, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the interface documentation generation method of this application.
[0025] In this embodiment, the interface document generation method includes steps S10 to S30: Step S10: For the target model to be deployed during the machine learning model service process, the key metadata corresponding to the input and output tensors of the target model is adaptively extracted according to the type of the target model. Step S20: Convert the data type of key metadata according to the pre-established mapping and conversion rules of native data types and service interface standard data types in the model framework; Step S30: Generate the interface specification document for the target model based on the key metadata after data conversion.
[0026] The process of service-oriented machine learning models refers to the process of deploying trained models to a production environment so that they can provide real-time or batch prediction services.
[0027] In the model preparation phase, the trained model is first exported by converting it to a general format (such as ONNX, PMML) or a framework-specific format (TensorFlow SavedModel, PyTorch TorchScript). Then, the preprocessing code, feature engineering logic, and model inference code are packaged to encapsulate dependencies and ensure environment consistency. Finally, techniques such as pruning and quantization are used to compress the model size, achieving lightweight processing and improving inference speed.
[0028] During the service-oriented architecture design phase, the following API interfaces are designed: RESTful API (common tools include Flask, FastAPI, Django, etc.), RPC (suitable for low-latency, high-throughput scenarios), and GraphQL (a more flexible data query interface). The following deployment architectures are selected: monolithic service (suitable for small applications), microservice architecture (deployed via Docker containers, cluster managed by Kubernetes, supporting elastic scaling), and serverless (such as AWS Lambda, which can run on demand and reduce costs).
[0029] During the deployment environment setup phase, dependency isolation is achieved using virtual environments (such as conda, venv, etc.) or containerization technologies (Docker images). Inference optimization is achieved through methods such as GPU acceleration (such as CUDA, TensorRT, etc.), framework optimization (such as TensorFlowServing, TorchServe, etc.), and edge device deployment (such as TensorFlow Lite, Core ML, etc.). Configuration management is performed by managing parameters such as model paths and keys through environment variables or configuration files.
[0030] Subsequent phases may include service release and monitoring, security and compliance auditing, and expansion and maintenance.
[0031] In one embodiment, corresponding to step S10, intelligent parsing of the model computation graph and tensor metadata is achieved by integrating the TensorFlow / PyTorch framework API. Specifically, the service interface signature of the target model to be deployed, such as a TensorFlow model, is parsed, where the `model_path` parameter specifies the model storage path in the `SavedModel` format. The input and output tensor specifications are obtained by accessing the model's service default signature (`serving_default`). For each input and output tensor of the target model to be deployed, the corresponding key metadata is extracted: `name` records the identifier of the tensor in the computation graph, `dtype` describes the data type (e.g., `float32`), and `shape` defines the tensor dimension (dynamic dimensions are marked with "dynamic").
[0032] In another embodiment, corresponding to step S20, the native data types of the model framework are mapped to the standard OpenAPI 3.0 specification, i.e., service interface standard data types, thereby establishing a precise mapping relationship between the native data types of the model framework and the standard data types of the OpenAPI. The core parameter tensor_metadata is used to receive the metadata structure extracted in step S10, and the type_mapping dictionary defines key conversion rules: for example, TensorFlow's float32 is mapped to OpenAPI's number / float type, and int32 is mapped to integer / int32.
[0033] In another embodiment, corresponding to step S30, a complete OpenAPI specification document is created based on the schema generated in step S20. The input parameter `model_name` specifies the API title, and both `input_schema` and `output_schema` are derived from the output of step S20. Key technical features include: automatic registration of POST methods to the `predict` endpoint (standardized prediction entry point), dynamic integration of input tensor structures into the `requestBody`, and mapping of response objects to output tensor schemas.
[0034] Therefore, by integrating machine learning frameworks and API specification standards, cross-domain technology integration is achieved. By dynamically parsing the computation graph or tensor metadata of TensorFlow / PyTorch, it maps it to Swagger Schema objects and generates structured documents, i.e., interface specification documents, based on the OpenAPI 3.0 specification.
[0035] It's worth noting that the Schema object in Swagger, an API design and documentation tool, is used to define the data model used in an API. It's part of the OpenAPI specification and allows describing the structure of input and output data. Specifically, in the OpenAPI (Swagger) specification, the Schema object is a key element in defining the API data structure. It describes the data types (such as objects, arrays, strings, etc.) in requests, responses, or components and provides metadata (such as descriptions, constraints, examples, etc.). The Schema object is based on the JSON Schema standard, but OpenAPI extends and simplifies it.
[0036] In one embodiment, step S30 is followed by: In response to the software development kit (SDK) generation instructions, the interface specification document of the target model is converted into the target SSD. The generation instructions include the specified interface specification document, the generation language of the target SSD, and the output path.
[0037] In one application scenario, refer to Figure 2 Finally, it can also respond to the software development kit (SDK) generation command and automatically output SDK templates in conjunction with code generation tools (such as Swagger Codegen). Specifically, it can convert OpenAPI specification files into production-grade SDK code via the `java -jar` command line. Key parameters in the generation command include: `-i` specifies the input file (swagger.json generated in step S30), `-l` defines the generation language, and `-o` sets the output path. `config.json` provides extended configuration points: for example, setting `packageName=model_client` for the Python SDK and `groupId=com.company.ai` for the Java SDK.
[0038] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to the first embodiment described above can be referred to the above description, and will not be repeated hereafter. On this basis, refer to Figure 3 Step S10 may include steps A11 to A13: Step A11: When the target model is TensorFlow SavedModel, determine whether the service default signature of the target model exists and is complete; Step A12: If the service default signature exists and is complete, then obtain the key metadata corresponding to the input and output tensors of the target model by accessing the service default signature; Step A13: If the service default signature does not exist or is incomplete, fall back to traversing all available signatures of the target model to determine the target signature based on the signature content and / or the number of input and output tensors, and obtain the key metadata corresponding to the input and output tensors of the target model through the target signature.
[0039] TensorFlow SavedModel is the officially recommended standardized model serialization format by TensorFlow, used to completely save and deploy trained machine learning models. It doesn't just save weights, but packages the model's complete computation graph, parameters, weights, dependencies, and metadata into a self-contained directory structure, ensuring consistent model performance across different environments.
[0040] When adaptively extracting key metadata corresponding to the input and output tensors of the target model based on the type of the target model, for TensorFlow SavedModel, it first attempts to parse the serving default signature. If the signature does not exist or is incomplete, it will automatically fallback to traversing all available signatures of the model and select the signature with the most input and output tensors as a candidate based on a preset naming convention (such as a signature containing keywords such as predict or inference) or by selecting the signature with the most input and output tensors. This addresses the challenges brought about by the export of non-standardized models.
[0041] In another feasible implementation, step S10 may include step B: When the target model to be deployed is a PyTorch model, the key metadata corresponding to the input and output tensors of the target model is extracted by parsing the computation graph corresponding to the forward propagation of the PyTorch model.
[0042] When adaptively extracting key metadata corresponding to the input and output tensors of the target model based on the type of the target model, for PyTorch models, the system first checks whether a TorchScript model generated by torch.jit.script or torch.jit.trace exists. If it does, the system directly parses the computation graph corresponding to the forward propagation (forward method) of the PyTorch model to extract key metadata such as the type and shape information of the input and output tensors.
[0043] `torch.jit.script` and `torch.jit.trace` are two main methods in PyTorch for converting Python models to TorchScript (PyTorch's production model format). Both are used to generate models that can run independently of the Python environment. `torch.jit.trace` creates TorchScript by actually executing the model and recording the sequence of operations. Its workflow is as follows: the user provides the model and example input; PyTorch performs forward propagation of the actual model; all executed operations and data flow are recorded; and a static computation graph representation is generated. `torch.jit.script` performs the conversion by directly analyzing the Python source code. Its workflow is as follows: directly parsing the model class definition; converting Python syntax to TorchScript IR (Intermediate Representation, an intermediate representation layer between the Python interface and the underlying execution engine in the PyTorch ecosystem); performing static type inference; and generating a serializable model.
[0044] In another feasible implementation, step S10 may include step C: When the target model to be deployed is an ONNX model, the key metadata corresponding to the input and output tensors of the target model is extracted by loading the ONNX file corresponding to the ONNX model, traversing the input and output nodes of the computation graph corresponding to the ONNX model.
[0045] When adaptively extracting key metadata corresponding to the input and output tensors of the target model based on the type of the target model, for the ONNX (Open Neural Network Exchange) model, the ONNX file can be directly loaded and the input and output nodes of its computation graph can be traversed using the ONNX official library to accurately extract key metadata such as the name, data type (extraction method can be tensor_type.elem_type), and dimension information (extraction method can be tensor_type.shape.dim) of each input and output tensor.
[0046] In this embodiment, an adaptive parsing strategy with multiple parsers is provided to improve the efficiency and accuracy of extracting key metadata corresponding to the input and output tensors of the target model to be deployed, thereby further improving the efficiency and accuracy of writing and outputting the final API documentation.
[0047] Based on the first embodiment of this application, in the third embodiment of this application, the content that is the same as or similar to the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, step D may be included after step S10: Step D involves performing integrity checks on the key metadata. The integrity checks include verifying whether the input and output tensors corresponding to the key metadata have all basic attributes, whether the data type is a valid data type supported by the model framework, and whether the tensor dimensions are in a valid dimension format.
[0048] After adaptively extracting the key metadata corresponding to the input and output tensors of the target model based on the target model type, the key metadata undergoes integrity verification. The corresponding integrity verification rules include: 1. Existence verification: ensuring that each input and output tensor contains and possesses basic attributes such as name, dtype, and shape. 2. Type compliance verification: checking whether the data type dtype is a valid data type supported by the model framework. 3. Dimension format verification: verifying whether the tensor dimension shape is a valid list composed of integers or specific tags (such as None, -1, "dynamic").
[0049] In another feasible implementation, steps E1 to E2 may be included after step S10: Step E1: Automatically repair the key metadata based on the basic attributes, data types, and tensor dimensions of the input and output tensors corresponding to the key metadata. Step E2: If automatic repair is not possible or the automatic repair result is ambiguous, then the key metadata that cannot be automatically repaired or whose automatic repair result is ambiguous is repaired through human-computer interaction based on the metadata completion configuration file. The metadata completion configuration file obtained after human-computer interaction is used as a patch file in the latest key metadata extraction after the current key metadata extraction.
[0050] After adaptively extracting the key metadata corresponding to the input and output tensors of the target model according to the type of the target model, the key metadata is automatically repaired. In the metadata repair and enhancement mechanism proposed in this embodiment, a layered automated and semi-automated repair scheme is provided.
[0051] Corresponding to step E1, based on the basic attributes, data types, and tensor dimensions of the input and output tensors corresponding to the key metadata, a heuristic auto-fix is implemented: a series of heuristic rules based on industry practices are built-in. For example, if the name of an input tensor contains keywords such as image or pic, and its dimension is four-dimensional (e.g., [None, 224, 224, 3]), even if its dtype is missing, it will be inferred to be float32 (normalized image) or uint8 (original image) with a high probability.
[0052] Corresponding to step E2, the interactive assisted-fix: When the above heuristic automatic fix cannot meet the requirements or is ambiguous, a metadata completion configuration file (metadata_patch.yaml) can be generated, prompting the user to interact with the system to manually complete the missing information. The user only needs to fill in the missing information in this file, and the system will load this patch file the next time the interface specification document is generated, merging it with the automatically parsed metadata to form the final complete and accurate interface specification document.
[0053] In this embodiment, the key metadata corresponding to the extracted target model input and output tensors is verified and repaired through integrity verification rules and metadata repair and enhancement mechanisms, ensuring that the subsequent interface document generation method based on key metadata can accurately and efficiently generate interface specification documents.
[0054] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the interface documentation generation method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0055] This application also provides an interface documentation generation device; please refer to [reference needed]. Figure 4 The interface documentation generation device includes: Extraction module 10 is used to adaptively extract key metadata corresponding to the input and output tensors of the target model to be deployed during the service-oriented process of machine learning models, based on the type of the target model. The conversion module 20 is used to convert the data types of key metadata according to the pre-established mapping conversion rules of native data types of the model framework and standard data types of the service interface. The generation module 30 is used to generate the interface specification document of the target model based on the key metadata after data conversion.
[0056] In one embodiment, the extraction module 10 is used to: When the target model is a TensorFlow SavedModel, determine whether the default service signature of the target model exists and is complete. If the service default signature exists and is complete, then the key metadata corresponding to the input and output tensors of the target model can be obtained by accessing the service default signature; If the default signature for the service is missing or incomplete, the process falls back to traversing all available signatures of the target model to determine the target signature based on the signature content and / or the number of input and output tensors, and then obtains the key metadata corresponding to the input and output tensors of the target model through the target signature.
[0057] In one embodiment, the extraction module 10 is used to: When the target model to be deployed is a PyTorch model, the key metadata corresponding to the input and output tensors of the target model is extracted by parsing the computation graph corresponding to the forward propagation of the PyTorch model.
[0058] In one embodiment, the extraction module 10 is used to: When the target model to be deployed is an ONNX model, the key metadata corresponding to the input and output tensors of the target model is extracted by loading the ONNX file corresponding to the ONNX model, traversing the input and output nodes of the computation graph corresponding to the ONNX model.
[0059] In one embodiment, the interface documentation generation device further includes a verification module, used for: After the step of adaptively extracting the key metadata corresponding to the input and output tensors of the target model according to the type of the target model: the key metadata is subjected to integrity verification, wherein the integrity verification includes whether the input and output tensors corresponding to the key metadata have all basic attributes, whether the data type is a valid data type supported by the model framework, and whether the tensor dimension is a valid dimension format.
[0060] In one embodiment, the interface documentation generation device further includes a repair module, used for: After the step of adaptively extracting key metadata corresponding to the input and output tensors of the target model according to the type of the target model: the key metadata is automatically repaired according to the basic attributes, data type and tensor dimension of the input and output tensors corresponding to the key metadata; if it cannot be automatically repaired or the automatic repair result is ambiguous, the key metadata that cannot be automatically repaired or the automatic repair result is ambiguous is repaired through human-computer interaction based on the metadata completion configuration file. The metadata completion configuration file obtained after human-computer interaction is used as a patch file in the latest key metadata extraction after the current key metadata extraction.
[0061] In one embodiment, the interface document generation device further includes a conversion module, used for: After the step of generating the interface specification document of the target model based on the key metadata after data conversion: in response to the software development kit (SDK) generation instructions, the interface specification document of the target model is converted into the target SSD, wherein the generation instructions include the specified interface specification document, the generation language of the target SSD, and the output path.
[0062] The interface documentation generation apparatus provided in this application, employing the interface documentation generation method described in the above embodiments, can solve the technical problems of low efficiency and error-proneness in writing and outputting API documentation. Compared with the prior art, the beneficial effects of the interface documentation generation apparatus provided in this application are the same as those of the interface documentation generation method provided in the above embodiments, and other technical features in the interface documentation generation apparatus are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0063] This application provides an interface documentation generation device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the interface documentation generation method in Embodiment 1 above.
[0064] The following is for reference. Figure 5 The diagram illustrates a structural schematic of an interface documentation generation device suitable for implementing embodiments of this application. The interface documentation generation device in these embodiments may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The interface documentation generation device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0065] like Figure 5As shown, the interface documentation generation device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory 1002 or a program loaded from a storage device 1003 into a random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the interface documentation generation device. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. The communication device 1009 allows the interface documentation generation device to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows interface documentation generation devices with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0066] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0067] The interface documentation generation device provided in this application, employing the interface documentation generation method in the above embodiments, can solve the technical problems of low efficiency and error-proneness in writing and outputting API documentation. Compared with the prior art, the beneficial effects of the interface documentation generation device provided in this application are the same as those of the interface documentation generation method provided in the above embodiments, and other technical features in this interface documentation generation device are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.
[0068] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0069] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0070] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the interface document generation method in the above embodiments.
[0071] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0072] The aforementioned computer-readable storage medium may be included in the interface documentation generation device; or it may exist independently and not be assembled into the interface documentation generation device.
[0073] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by the interface documentation generation device, the interface documentation generation device: for the target model to be deployed during the machine learning model serviceification process, adaptively extracts the key metadata corresponding to the input and output tensors of the target model according to the type of the target model; converts the data type of the key metadata according to the pre-established mapping and conversion rules of the native data type of the model framework and the data type of the serviceification interface standard; and generates the interface specification document of the target model based on the key metadata after the data type conversion.
[0074] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0075] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0076] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0077] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., computer programs) for executing the above-described interface document generation method, thereby solving the technical problems of low efficiency and error-proneness in writing and outputting API documents. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the interface document generation method provided in the above embodiments, and will not be repeated here.
[0078] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the interface documentation generation method described above.
[0079] The computer program product provided in this application can solve the technical problems of low efficiency and error-proneness in writing and outputting API documentation. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the interface documentation generation method provided in the above embodiments, and will not be repeated here.
[0080] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. An interface document generation method characterized by, The interface document generation method comprises: For a target model to be deployed in a machine learning model service process, key metadata corresponding to input and output tensors of the target model is adaptively extracted according to a type of the target model; According to a mapping conversion rule of a pre-established model framework native data type and a service interface standard data type, the data type of the key metadata is converted; According to the key metadata after the data type conversion, an interface specification document of the target model is generated.
2. The interface document generating method of claim 1, wherein, The step of adaptively extracting the key metadata corresponding to the input and output tensors of the target model according to the type of the target model comprises: When the target model is a TensorFlow SavedModel, it is determined whether a service default signature of the target model exists and is complete; If the service default signature exists and is complete, the key metadata corresponding to the input and output tensors of the target model is obtained by accessing the service default signature; If the service default signature does not exist or is not complete, the target signature is determined according to the signature content and / or the number of input and output tensors by falling back to traversing all available signatures of the target model, and the key metadata corresponding to the input and output tensors of the target model is obtained through the target signature.
3. The interface document generating method of claim 1, wherein, The step of adaptively extracting the key metadata corresponding to the input and output tensors of the target model according to the type of the target model comprises: When the target model to be deployed is a PyTorch model, the key metadata corresponding to the input and output tensors of the target model is extracted by parsing a calculation graph corresponding to a forward propagation of the PyTorch model.
4. The interface document generating method of claim 1, wherein, The step of adaptively extracting the key metadata corresponding to the input and output tensors of the target model according to the type of the target model comprises: When the target model to be deployed is an ONNX model, the key metadata corresponding to the input and output tensors of the target model is extracted by loading an ONNX file corresponding to the ONNX model to traverse input nodes and output nodes of a calculation graph corresponding to the ONNX model.
5. The interface document generation method of claim 1, wherein, The step of adaptively extracting the key metadata corresponding to the input and output tensors of the target model according to the type of the target model comprises: The key metadata is subjected to integrity checking, wherein the integrity checking comprises whether the input and output tensors corresponding to the key metadata have all basic attributes, whether the data type is a valid data type supported by the model framework, and whether the tensor dimension is a legal dimension format.
6. The interface document generating method of claim 1, wherein, The step of adaptively extracting the key metadata corresponding to the input and output tensors of the target model according to the type of the target model comprises: The key metadata is subjected to automatic repair according to the basic attributes, the data type and the tensor dimension of the input and output tensors corresponding to the key metadata; If automatic repair is not possible or the automatic repair result is ambiguous, the key metadata that cannot be automatically repaired or has ambiguous automatic repair result is repaired through human-computer interaction based on a metadata completion configuration file, wherein the metadata completion configuration file obtained after the human-computer interaction is used as a patch file for the latest key metadata extraction after the current key metadata extraction.
7. The interface document generating method of claim 1, wherein, The step of generating the interface specification document of the target model according to the converted key metadata comprises: In response to a generation instruction of a software development kit, the interface specification document of the target model is converted into a target software development kit, wherein the generation instruction comprises a specified interface specification document, a generation language of the target software development kit, and an output path.
8. An interface document generating apparatus characterized by comprising: The device comprises a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the interface document generation method according to any one of claims 1 to 7.
9. A storage medium, characterized by The storage medium is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the interface document generation method according to any one of claims 1 to 7.
10. A computer program product, characterised in that, The computer program product comprises a computer program, and the computer program is executed by a processor to implement the steps of the interface document generation method according to any one of claims 1 to 7.