A method, device, electronic device and storage medium for generating a model file

By converting multiple operators in the machine learning model into general expressions and generating model files, the problem of expression complexity of multi-frame and multi-algorithm models in the prior art is solved, and the efficiency of model engineering is improved.

CN112069456BActive Publication Date: 2025-02-18BEIJING XUEZHITU NETWORK TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010997489.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-21
Publication Date
2025-02-18
Estimated Expiration
2040-09-21

AI Technical Summary

Technical Problem

The prior art is difficult to effectively express multiple machine learning algorithms in a unified manner, resulting in increased complexity and reduced efficiency of model engineering.

Method used

By obtaining the model function of the target model, each operator is converted into a first general expression, and a model file is generated based on the correlation between the operators, so as to realize the unified expression of multiple algorithms.

Benefits of technology

It improves the efficiency of model engineering, simplifies the expression and management of models, and reduces the complexity of engineering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112069456B_ABST
    Figure CN112069456B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, electronic device and storage medium for generating a model file, wherein the method for generating the model file comprises: obtaining a model function corresponding to a target model; wherein the model function comprises a plurality of operators; converting each operator in the model function into a first general expression; wherein the first general expression comprises a plurality of operator attributes of the operator; determining the association relationship between any two operators in the plurality of operators according to the input information and output information corresponding to each operator; generating a model file corresponding to the target model according to the first general expression corresponding to each operator and the association relationship between any two operators in the plurality of operators. The present application can unify the expression of multiple algorithms in the model and improve the efficiency of model engineering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer information technology, and in particular to a method, device, electronic device and storage medium for generating a model file. Background Art

[0002] At this stage, both traditional machine learning methods and emerging deep learning methods involve a large number of heterogeneous frameworks and algorithms, such as the linear regression algorithm supported by the Sklearn tool, the tree regression algorithm supported by XG boost, and the tree regression algorithm supported by light GBM.

[0003] In practice, each model can include multiple algorithms, and each algorithm in the model can correspond to a different machine learning framework. This multi-framework and multi-algorithm model increases the complexity of model engineering and reduces the efficiency of model engineering. Therefore, unifying the expression of multiple algorithms in the model is a technical problem that needs to be solved urgently. Summary of the invention

[0004] In view of this, the purpose of the embodiments of the present application is to provide a method, device, electronic device and storage medium for generating a model file, which can uniformly express multiple algorithms in the model and improve the efficiency of model engineering.

[0005] In a first aspect, an embodiment of the present application provides a method for generating a model file, the generating method comprising:

[0006] Obtaining a model function corresponding to a target model; wherein the model function includes a plurality of operators;

[0007] Convert each operator in the model function into a first general expression; wherein the first general expression includes multiple operator attributes of the operator;

[0008] Determine, according to the input information and output information corresponding to each operator, an association relationship between any two operators among the multiple operators;

[0009] A model file corresponding to the target model is generated according to the first general expression corresponding to each operator and the association relationship between any two operators among the multiple operators.

[0010] In a possible implementation, converting each operator in the model function into a first general expression includes:

[0011] For each operator in the model function, multiple operator attributes corresponding to the operator are determined according to the category to which the operator belongs, and the operator is converted into a first general expression including the multiple operator attributes.

[0012] In a possible implementation, the category to which each operator belongs is determined in the following manner:

[0013] Find the storage address of each operator in the model function;

[0014] Based on the search result of the storage address, the category matching the search result is determined as the category to which the operator belongs.

[0015] In a possible implementation, generating a model file corresponding to the target model according to the first general expression corresponding to each operator and the association relationship between any two operators among the multiple operators includes:

[0016] Based on a plurality of preset model attributes, generating a second general expression corresponding to the model function and including the plurality of model attributes;

[0017] A model file corresponding to the target model is generated according to a first general expression corresponding to each operator, a second general expression corresponding to the model function, and an association relationship between any two operators among the multiple operators.

[0018] In a possible implementation, the categories to which the operator belongs include: a user-defined operator and a framework semantic operator.

[0019] In a possible implementation, generating a model file corresponding to the target model according to the first general expression corresponding to each operator and the association relationship between any two operators among the multiple operators includes:

[0020] Determining a combination mode corresponding to the multiple operators according to an association relationship between any two operators among the multiple operators;

[0021] A model file corresponding to the target model is generated according to the first general expression corresponding to each operator and the combination mode corresponding to the multiple operators.

[0022] In a possible implementation, the combination modes corresponding to the multiple operators include: sequential execution, one-to-many execution, and many-to-many execution.

[0023] In a second aspect, an embodiment of the present application provides a device for generating a model file, the device comprising:

[0024] An acquisition module, used to acquire a model function corresponding to a target model; wherein the model function includes a plurality of operators;

[0025] A conversion module, used for converting each operator in the model function into a first general expression; wherein the first general expression includes multiple operator attributes of the operator;

[0026] A first determination module, used to determine the association relationship between any two operators among the multiple operators according to the input information and output information corresponding to each operator;

[0027] A generation module is used to generate a model file corresponding to the target model according to a first general expression corresponding to each operator and an association relationship between any two operators among the multiple operators.

[0028] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory through the bus, and the processor executes the machine-readable instructions to perform the steps of the method for generating a model file described in any one of the first aspects.

[0029] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for generating a model file described in any one of the first aspects are executed.

[0030] The embodiment of the present application provides a method, device, electronic device and storage medium for generating a model file, obtaining a model function corresponding to a target model; wherein the model function includes multiple operators; converting each operator in the model function into a first general expression; wherein the first general expression includes multiple operator attributes of the operator; determining the association relationship between any two operators in the multiple operators according to the input information and output information corresponding to each operator; generating a model file corresponding to the target model according to the first general expression corresponding to each operator and the association relationship between any two operators in the multiple operators. The embodiment of the present application can uniformly express multiple algorithms in the model and improve the efficiency of model engineering.

[0031] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0033] Figure 1A flow chart showing a method for generating a model file provided in an embodiment of the present application is shown;

[0034] Figure 2 A flowchart showing another method for generating a model file provided in an embodiment of the present application is shown;

[0035] Figure 3 A flowchart showing another method for generating a model file provided in an embodiment of the present application is shown;

[0036] Figure 4 A flowchart showing another method for generating a model file provided in an embodiment of the present application is shown;

[0037] Figure 5 A schematic diagram showing the structure of a device for generating a model file provided in an embodiment of the present application is shown;

[0038] Figure 6 A schematic diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0039] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0040] At this stage, both traditional machine learning methods and emerging deep learning methods involve a large number of heterogeneous frameworks and algorithms, such as the linear regression algorithm supported by the Sklearn tool, the tree regression algorithm supported by XG boost, and the tree regression algorithm supported by light GBM. In practice, each model can include multiple algorithms, and each algorithm in the model can correspond to a different machine learning framework. This multi-framework and multi-algorithm model increases the complexity of model engineering and reduces the efficiency of model engineering. Therefore, unifying the expression of multiple algorithms in the model is a technical problem that needs to be solved urgently.

[0041] Based on the above problems, the embodiments of the present application provide a method, device, electronic device and storage medium for generating a model file, obtaining a model function corresponding to a target model; wherein the model function includes multiple operators; converting each operator in the model function into a first general expression; wherein the first general expression includes multiple operator attributes of the operator; determining the association relationship between any two operators in the multiple operators according to the input information and output information corresponding to each operator; generating a model file corresponding to the target model according to the first general expression corresponding to each operator and the association relationship between any two operators in the multiple operators. The embodiments of the present application can uniformly express multiple algorithms in the model and improve the efficiency of model engineering.

[0042] The defects existing in the above solutions are the results obtained by the inventor after practice and careful research. Therefore, the process of discovering the above problems and the solutions proposed by this application for the above problems below should be the contributions made by the inventor to this application during the application process.

[0043] The technical solutions in the present application will be clearly and completely described below in conjunction with the drawings in the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the present application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0044] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0045] See also Figure 1 As shown, Figure 1 A flowchart of a method for generating a model file provided in an embodiment of the present application, the method comprising the following steps:

[0046] S101. Obtain a model function corresponding to a target model; wherein the model function includes multiple operators.

[0047] In an embodiment of the present application, a target model corresponds to a model function, and the functions of the target model can be implemented based on the model function, such as classifying items, recommending items, etc. The model function includes multiple operators, wherein multiple operators are at least one operator. In practice, an operator is an algorithm, and there are two corresponding categories of operators. The categories to which the operators belong include: custom operators and framework semantic operators, wherein the framework semantic operator is an algorithm corresponding to a machine learning framework, and the custom operator is a user-defined algorithm. The custom operator does not depend on the machine learning framework. Here, each machine learning framework can correspond to multiple operators.

[0048] For example, the operators included in the target model are: the first operator, the second operator, the third operator, and the fourth operator. The first operator is the preprocessing module preprocessing.scale in the machine learning framework Sklean. Based on the first operator, the original data R1 is converted into a vector T1. The second operator is a custom algorithm A1. In order to adapt to subsequent operations, the second operator processes T1 to obtain T2. ​​The third operator is a PyTorch deep learning model. The third operator fits T2 to obtain the output data S1 of the first layer. The fourth operator is the LGBMClassifier in the machine learning framework lightGBM. The fourth operator processes S1 to obtain the final output U1. The target model performs relevant processing on the original data R1 through multiple algorithms to obtain the final processing result U1.

[0049] S102. Convert each operator in the model function into a first general expression; wherein the first general expression includes multiple operator attributes of the operator.

[0050] In an embodiment of the present application, the operators in the target model may correspond to a machine learning framework or may not rely on a machine learning framework, and different operators may correspond to different machine learning frameworks. In order to uniformly express each operator in the target model, each operator is converted into a first general expression, wherein the first general expression of each operator is composed of multiple operator attributes of the operator, wherein the operator attributes include: algorithm name, algorithm version, algorithm implementation language, implementation language version, algorithm implementation framework, algorithm implementation framework version, the corresponding name of the algorithm in the framework, parameters required by the algorithm during initialization, parameter names that need to be passed in when the algorithm is called, source code corresponding to the language (algorithm implementation language), source file name, etc.

[0051] S103: Determine an association relationship between any two operators among the multiple operators according to input information and output information corresponding to each operator.

[0052] In the embodiment of the present application, each operator corresponds to input information and output information, wherein the input information is the source of the data to be processed by the operator, and the output information is the destination of the data processed by the operator. For each operator, the association relationship between the operator and other operators in the target model except the operator can be determined based on the input information and output information of the operator.

[0053] For example, the target model includes a first operator, a second operator, a third operator, a fourth operator and a fifth operator, wherein, based on the input information and output information of the second operator, it can be determined that the data to be processed by the second operator comes from the first operator, and the data processed by the second operator is sent to the third operator and the fourth operator, and then it can be determined that the first data processed by the first operator is sent to the second operator, and after the second operator processes the first data to obtain the second data, the second data is sent to the third operator and the fourth operator respectively, and the second operator is independent of the fifth operator. Here, the first operator is determined as the upstream operator of the second operator, and the third operator and the fourth operator are respectively determined as the downstream operators of the second operator.

[0054] S104: Generate a model file corresponding to the target model according to the first general expression corresponding to each operator and the association relationship between any two operators among the multiple operators.

[0055] In an embodiment of the present application, the first general expression corresponding to each operator in the target model is determined, and the association relationship between any two operators among the multiple operators included in the target model is determined, and then the first general expression corresponding to each operator is combined based on the above association relationship to obtain a model file corresponding to the target model.

[0056] It should be noted that the model file corresponding to the target model is an S-expression, which is used as both code and data in Lisp. S-expression, also known as S-expression, or sexp, where "S" stands for "symbolic", refers to a convention for expressing semi-structured data in human-readable text form. S-expressions are best known for their use in programming languages ​​of the Lisp family. Other applications are found in Lisp-derived languages ​​such as DSSSL, as markers in communication protocols such as IMAP, and John McCarthy's CBCL. Although the details of the syntax and the data types supported vary from language to language, the most common feature among these languages ​​is the use of S-expressions as bracketed prefix notation (sometimes also called Cambridge Polish notation).

[0057] The model file generation method provided in the embodiment of the present application can uniformly express multiple algorithms in the model, thereby improving the efficiency of model engineering.

[0058] Furthermore, in the method for generating a model file provided in an embodiment of the present application, each operator in the model function is converted into a first general expression, including:

[0059] For each operator in the model function, multiple operator attributes corresponding to the operator are determined according to the category to which the operator belongs, and the operator is converted into a first general expression including the multiple operator attributes.

[0060] In the embodiment of the present application, operators of different categories correspond to different operator attributes. The categories to which the operators belong include: custom operators and framework semantic operators. Specifically, the operator attributes corresponding to the framework semantic operators include: algorithm name (name), algorithm version (version), algorithm implementation language (language), implementation language version (language-version), algorithm implementation framework (framework), algorithm implementation framework version (framework-version), the name corresponding to the algorithm in the framework (operator-inner-name), parameters required by the algorithm during initialization (parameters), and parameter names (args) that need to be passed in when the algorithm is called; the operator attributes corresponding to the custom operator include: algorithm name (name), algorithm version (version), algorithm implementation language (language), implementation language version (language-version), parameter names (args) that need to be passed in when the algorithm is called, source code corresponding to the language (code), and source file name (source-file-name).

[0061] The algorithm version defaults to v1; the algorithm implementation language defaults to Python, and can also include options such as java, c, and c++ to facilitate access to different algorithm frameworks; the algorithm implementation frameworks include machine learning frameworks such as sklearn, tensorflow, and pytorch; the parameter names that need to be passed in when the algorithm is called are expressed as lists, corresponding to the list output generated by the upstream operator. For example, the first operator is the upstream operator of the second operator, and the data processed by the first operator is the data to be processed by the second operator; the source code corresponding to language is processed by language itself. Compiled languages ​​need to be compiled first, and interpreted languages ​​can be directly interpreted and run; source file name, if it is a custom algorithm and this item is not nil, put the content corresponding to code into the file name corresponding to source-file-name for compilation. Some compiled languages ​​have special requirements for file names.

[0062] Specifically, when the computer server determines the first general expression corresponding to each operator, the corresponding processing flow is: read the model function corresponding to the target model, read the next operation in the model function, determine the category of the operator corresponding to the step operation, if the operator is a custom operator, then based on the multiple operator attributes corresponding to the custom operator, generate the first general expression and write it into the result set; if the operator is a framework semantic operator, then based on the multiple operator attributes corresponding to the framework semantic operator, generate the first general expression and write it into the result set, until all the step operations in the model function are read in, and the first general expression corresponding to each operator in the target model is obtained.

[0063] The method for generating a model file provided in an embodiment of the present application is based on a first general expression, and uses a self-describing manner to represent framework semantic operators of heterogeneous frameworks. Custom operators are directly described using their own codes. With the help of the "data is code" feature of the first general expression, algorithms of various frameworks can be represented, custom algorithms can be supported, multiple traditional machine learning frameworks and deep learning frameworks, as well as their different versions, and hybrid frameworks can be supported. The first general expression is a plain text representation and can be directly viewed and modified without special software, thereby improving the efficiency of target model engineering.

[0064] For further information, see Figure 2 As shown, in the method for generating a model file provided in the embodiment of the present application, the category to which each operator belongs is determined in the following manner:

[0065] S201. Find the storage address of each operator in the model function.

[0066] In an embodiment of the present application, since the location for storing custom operators is different from the location for storing framework semantic operators, the categories of operators can be distinguished based on the storage address corresponding to each operator. Specifically, framework semantic operators have corresponding storage addresses, and custom operators are only stored in memory. Therefore, the storage address corresponding to the custom operator is empty.

[0067] S202: Based on the search result of the storage address, determine the category that matches the search result as the category to which the operator belongs.

[0068] In an embodiment of the present application, the search results of the storage address include two cases: "there is a storage address" and "the storage address is empty", where "there is a storage address" matches the framework semantic operator, and "the storage address is empty" matches the custom operator. For each operator, if the search result of the operator is "there is a storage address", the operator is determined to be a framework semantic operator; if the search result of the operator is "the storage address is empty", the operator is determined to be a custom operator.

[0069] For further information, see Figure 3As shown, in the method for generating a model file provided in an embodiment of the present application, the model file corresponding to the target model is generated according to the first general expression corresponding to each operator and the association relationship between any two operators among the multiple operators, including:

[0070] S301. Based on a plurality of preset model attributes, generate a second general expression corresponding to the model function and including the plurality of model attributes.

[0071] In the embodiment of the present application, generally speaking, the model file is a structure consisting of a model name (name0), a model version (version0), an author (author0), a brief description of the model (describe), the input parameter style of the model (inputs), the output parameter style of the model (outputs), and the first general expression (operator) corresponding to each operator.

[0072] Among them, the model version, the default version is v1; the model input parameter style, because there may be multiple input parameters, here is expressed in the form of a list; the model output style, also, because there may be multiple output parameters, here is expressed in the form of a list; the operator can be a single algorithm or a combination of multiple operators, that is, the target model can include one operator or two or more operators.

[0073] Here, the model attributes of the target model include: model name (name0), model version (version0), author (author0), a brief description of the model (describe), the input parameter style of the model (inputs), and the output parameter style of the model (outputs). Based on the above multiple model attributes, a second general expression including multiple model attributes corresponding to the model function is generated.

[0074] S302: Generate a model file corresponding to the target model according to a first general expression corresponding to each operator, a second general expression corresponding to the model function, and an association relationship between any two operators among the multiple operators.

[0075] In an embodiment of the present application, a first general expression corresponding to each operator in the target model, a second general expression corresponding to the model function, and an association relationship between any two operators among the multiple operators included in the target model are determined respectively, and a model file corresponding to the target model is obtained based on the second general expression, the association relationship between the operators, and the first general expression corresponding to each operator.

[0076] For further information, see Figure 4As shown, in the method for generating a model file provided in an embodiment of the present application, the model file corresponding to the target model is generated according to the first general expression corresponding to each operator and the association relationship between any two operators among the multiple operators, including:

[0077] S401. Determine a combination method corresponding to the multiple operators according to an association relationship between any two operators among the multiple operators.

[0078] In an embodiment of the present application, the combination methods corresponding to multiple operators include: sequential execution, one-to-many execution, and many-to-many execution. Among them, in sequential execution, each operator in the target model corresponds to a unique upstream operator and a unique downstream operator, and each operator is executed in sequence according to the order of the operators; one-to-many execution, that is, the result of the first operator will be copied to all subsequent operators; many-to-many execution, that is, the result of each operator from the second operator to the last operator is uniformly input to the first operator.

[0079] According to the association relationship between any two operators among multiple operators, the upstream operators and downstream operators corresponding to each operator can be known. If an operator corresponds to multiple upstream operators, or the operator corresponds to multiple downstream operators, the combination mode corresponding to the multiple operators is determined to be "sequential execution"; if there is an operator whose downstream operators are all operators in the target model except the operator, the combination mode corresponding to the multiple operators is determined to be "one-to-many execution"; if there is an operator whose upstream operators are all operators in the target model except the operator, the combination mode corresponding to the multiple operators is determined to be "many-to-many execution".

[0080] S402: Generate a model file corresponding to the target model according to the first general expression corresponding to each operator and the combination method corresponding to the multiple operators.

[0081] In an embodiment of the present application, based on the combination method corresponding to multiple operators in the target model, the first general expression corresponding to each operator in the target model is combined to obtain a model file corresponding to the target model.

[0082] Corresponding to the target model exemplified in step 101, the model file corresponding to the target model is:

[0083] (make-s-model:name'p1

[0084] :author'xiaoming

[0085] :vertion'v1

[0086] :inputs(list “[-1,15]”)

[0087] :outputs(list“[1]”)

[0088] :operator(pipeline

[0089] (make-operator:name’preprocessing

[0090] :language’python

[0091] :framework’sklearn

[0092] :framework-vertion“0.22”

[0093] :operator-inner-name’preproccessing.scale

[0094] :args(R1))

[0095] (make-operator:name’A1

[0096] :code“x+3”)

[0097] (make-operator:framework’pytorch

[0098] :framework-vertion“1.3.1”

[0099] :operator-inner-name’nn.Linear

[0100] :parameters(list 3 4))

[0101] (make-operator:framework’lightgbm

[0102] :framework-vertion“2.3.0”

[0103] :operator-inner-name’LGBMClassifier)))

[0104] Among them, the combination method corresponding to multiple operators in the target model is "pipeline", that is, sequential execution. The first general expression corresponding to the first operator in the target model is the content after make-operator:name'preprocessing (including this content) and before make-operator:name'A1 (excluding this content), the first general expression corresponding to the second operator is the content after make-operator:name'A1 and before make-operator:framework'pytorch, the first general expression corresponding to the third operator is the content after make-operator:framework'pytorch and before make-operator:framework'lightgbm, and the first general expression corresponding to the fourth operator is the content after make-operator:framework'lightgbm.

[0105] The generation method of the model file provided in the embodiment of the present application supports the free combination of multiple custom operators and framework semantic operators. After determining the combination method corresponding to multiple operators, the first general expression corresponding to each operator can be combined into a new general expression, which is a recursive process. With the help of the operator combination method, the functions of "combination" and "recursion" in the programming language can be given to the target model, so that a target model with high complexity and high flexibility can be created.

[0106] Based on the same inventive concept, the embodiment of the present application also provides a device for generating a model file corresponding to the method for generating a model file. Since the principle of solving the problem by the device in the embodiment of the present application is similar to the method for generating a model file in the embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0107] See also Figure 5 As shown, Figure 5 A schematic diagram of a structure of a device for generating a model file provided in an embodiment of the present application, the device comprising:

[0108] The acquisition module 501 is used to acquire a model function corresponding to the target model; wherein the model function includes multiple operators;

[0109] A conversion module 502, configured to convert each operator in the model function into a first general expression; wherein the first general expression includes a plurality of operator attributes of the operator;

[0110] A first determination module 503, configured to determine an association relationship between any two operators among the plurality of operators according to input information and output information corresponding to each operator;

[0111] The generating module 504 is used to generate a model file corresponding to the target model according to the first general expression corresponding to each operator and the association relationship between any two operators among the multiple operators.

[0112] In a possible implementation, the conversion module 502, when converting each operator in the model function into the first general expression, includes:

[0113] For each operator in the model function, multiple operator attributes corresponding to the operator are determined according to the category to which the operator belongs, and the operator is converted into a first general expression including the multiple operator attributes.

[0114] In a possible implementation manner, the device for generating the model file further includes:

[0115] A search module, used to search for the storage address of each operator in the model function;

[0116] The second determination module is used to determine, based on the search result of the storage address, a category that matches the search result as the category to which the operator belongs.

[0117] In a possible implementation, the generating module 504, when generating the model file corresponding to the target model according to the first general expression corresponding to each operator and the association relationship between any two operators among the multiple operators, includes:

[0118] Based on a plurality of preset model attributes, generating a second general expression corresponding to the model function and including the plurality of model attributes;

[0119] A model file corresponding to the target model is generated according to a first general expression corresponding to each operator, a second general expression corresponding to the model function, and an association relationship between any two operators among the multiple operators.

[0120] In a possible implementation, the categories to which the operator belongs include: a user-defined operator and a framework semantic operator.

[0121] In a possible implementation, the generating module 504, when generating the model file corresponding to the target model according to the first general expression corresponding to each operator and the association relationship between any two operators among the multiple operators, further includes:

[0122] Determining a combination mode corresponding to the multiple operators according to an association relationship between any two operators among the multiple operators;

[0123] A model file corresponding to the target model is generated according to the first general expression corresponding to each operator and the combination mode corresponding to the multiple operators.

[0124] In a possible implementation, the combination modes corresponding to the multiple operators include: sequential execution, one-to-many execution, and many-to-many execution.

[0125] The model file generation device provided in the embodiment of the present application can uniformly express multiple algorithms in the model, thereby improving the efficiency of model engineering.

[0126] See also Figure 6 As shown, Figure 6 An electronic device 600 is provided for an embodiment of the present application, and the electronic device 600 includes: a processor 601, a memory 602 and a bus, wherein the memory 602 stores machine-readable instructions executable by the processor 601. When the electronic device is running, the processor 601 communicates with the memory 602 via the bus, and the processor 601 executes the machine-readable instructions to perform the steps of the method for generating a model file as described above.

[0127] Specifically, the above-mentioned memory 602 and processor 601 can be general-purpose memories and processors, which are not specifically limited here. When the processor 601 runs the computer program stored in the memory 602, the above-mentioned model file generation method can be executed.

[0128] Corresponding to the above-mentioned method for generating a model file, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned method for generating a model file are executed.

[0129] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.

[0130] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0131] In addition, each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.

[0132] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that can be executed by a processor. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0133] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A method for generating a model file, characterized in that: The generation method comprises: Obtaining a model function corresponding to a target model; wherein the model function includes a plurality of operators; Convert each operator in the model function into a first general expression; wherein the first general expression includes multiple operator attributes of the operator, and the multiple operator attributes include: algorithm name, algorithm version, algorithm implementation language, implementation language version, algorithm implementation framework, algorithm implementation framework version, algorithm corresponding name in the framework, parameters required for algorithm initialization, parameter names required to be passed in when the algorithm is called, source code corresponding to the algorithm implementation language, and source file name; Determine, according to the input information and output information corresponding to each operator, an association relationship between any two operators among the multiple operators; Generate a model file corresponding to the target model according to the first general expression corresponding to each operator and the association relationship between any two operators among the multiple operators; The converting each operator in the model function into a first general expression comprises: for each operator in the model function, according to the category to which the operator belongs, determining a plurality of operator attributes corresponding to the operator, and converting the operator into a first general expression including the plurality of operator attributes; The categories to which the operators belong include: custom operators and framework semantic operators. Framework semantic operators are algorithms corresponding to machine learning frameworks, and custom operators are user-defined algorithms.

2. The method for generating a model file according to claim 1, characterized in that: The category to which each operator belongs is determined as follows: Find the storage address of each operator in the model function; Based on the search result of the storage address, the category matching the search result is determined as the category to which the operator belongs.

3. The method for generating a model file according to claim 1, characterized in that: The step of generating a model file corresponding to the target model according to the first general expression corresponding to each operator and the association relationship between any two operators among the plurality of operators includes: Determining a combination mode corresponding to the multiple operators according to an association relationship between any two operators among the multiple operators; A model file corresponding to the target model is generated according to the first general expression corresponding to each operator and the combination mode corresponding to the multiple operators.

4. The method for generating a model file according to claim 3, characterized in that: The combination modes corresponding to the multiple operators include: sequential execution, one-to-many execution, and many-to-many execution.

5. A method for generating a model file, characterized in that: The generation method comprises: Obtaining a model function corresponding to a target model; wherein the model function includes a plurality of operators; Convert each operator in the model function into a first general expression; wherein the first general expression includes multiple operator attributes of the operator, and the multiple operator attributes include: algorithm name, algorithm version, algorithm implementation language, implementation language version, algorithm implementation framework, algorithm implementation framework version, algorithm corresponding name in the framework, parameters required for algorithm initialization, parameter names required to be passed in when the algorithm is called, source code corresponding to the algorithm implementation language, and source file name; Determine, according to the input information and output information corresponding to each operator, an association relationship between any two operators among the multiple operators; Based on a plurality of preset model attributes, generating a second general expression corresponding to the model function and including the plurality of model attributes; Generate a model file corresponding to the target model according to a first general expression corresponding to each operator, a second general expression corresponding to the model function, and an association relationship between any two operators among the multiple operators; The converting each operator in the model function into a first general expression comprises: for each operator in the model function, according to the category to which the operator belongs, determining a plurality of operator attributes corresponding to the operator, and converting the operator into a first general expression including the plurality of operator attributes; The categories to which the operators belong include: custom operators and framework semantic operators. Framework semantic operators are algorithms corresponding to machine learning frameworks, and custom operators are user-defined algorithms.

6. A device for generating a model file, characterized in that: The generating device comprises: An acquisition module, used to acquire a model function corresponding to a target model; wherein the model function includes a plurality of operators; A conversion module, used to convert each operator in the model function into a first general expression; wherein the first general expression includes multiple operator attributes of the operator, and the multiple operator attributes include: algorithm name, algorithm version, algorithm implementation language, implementation language version, algorithm implementation framework, algorithm implementation framework version, algorithm corresponding name in the framework, algorithm required parameters when initializing, algorithm parameter name that needs to be passed in when calling, source code corresponding to the algorithm implementation language, and source file name; A first determination module, used to determine the association relationship between any two operators among the multiple operators according to the input information and output information corresponding to each operator; A generating module, configured to generate a model file corresponding to the target model according to a first general expression corresponding to each operator and an association relationship between any two operators among the plurality of operators; The conversion module is further configured to determine, for each operator in the model function, a plurality of operator attributes corresponding to the operator according to the category to which the operator belongs, and convert the operator into a first general expression including the plurality of operator attributes. The categories to which the operators belong include: custom operators and framework semantic operators. Framework semantic operators are algorithms corresponding to machine learning frameworks, and custom operators are user-defined algorithms.

7. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of the method for generating a model file as described in any one of claims 1 to 4 or the steps of the method for generating a model file as described in claim 5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the method for generating a model file according to any one of claims 1 to 4 or the steps of the method for generating a model file according to claim 5.

Citation Information

Patent Citations

  • Power grid model file for supporting fast model splicing, generation method and system thereof

    CN102521451A

  • Method and device for performing software integration on multiple model codes

    CN108279885A