Model reasoning processing method and device, electronic equipment and storage medium

By introducing a two-factor verification mechanism into model encryption technology, using the encryption client identification and decryption and deploying the target model, the security and efficiency compatibility issues in the existing technology are solved, and the safe and effective transmission of the model and the legitimacy of the inference service are achieved.

CN119740209APending Publication Date: 2025-04-01WINNING HEALTH TECHNOLOGY GROUP CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411938535.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

When existing model encryption technologies ensure security, they may affect the efficiency, compatibility or accuracy of the model, making it difficult to transfer and distribute model files safely and effectively, especially while being compatible with the existing open source large language model inference framework.

Method used

Ensure the security of the model and the legitimacy of the inference service by loading the target model file and its initial inference service to the target client, using encrypted client identification for two-factor verification, decrypting and deploying the target model to perform inference operations.

Benefits of technology

Two-factor verification is realized when starting the inference service and processing the request, ensuring the security of the model and the legitimacy of the inference service, and avoiding the conflict between security and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119740209A_ABST
    Figure CN119740209A_ABST
Patent Text Reader

Abstract

The invention provides a model reasoning processing method and device, electronic equipment and a storage medium. The method comprises the following steps: loading a target model file and an initial reasoning service into a target client; in response to a trigger operation of a user on the target client for the initial reasoning service, the initial reasoning service obtains an identifier of the target client, and the trigger operation is used for requesting the target reasoning service to execute a target operation; the initial reasoning service verifies the target client according to the target model file and the identifier of the target client, and determines whether the target client is qualified; and if the target model is qualified, decrypting the weight parameter in the target model by the initial reasoning service, deploying the decrypted target model into the initial reasoning service to obtain a target reasoning service, and executing the target operation by the target reasoning service. Double verification can be carried out when the inference service and the processing request are started, and the safety of the target model is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of model encryption technology, and more specifically, to a model reasoning processing method, device, electronic device and storage medium. Background Art

[0002] With the widespread use of large language models, protecting the intellectual property rights of the models and preventing them from being illegally copied or stolen have become important issues. Existing model encryption technologies often affect the efficiency, compatibility or accuracy of the models while ensuring security. How to safely transmit and distribute model files and make them fully compatible with existing open source large language model reasoning frameworks is a difficult problem.

[0003] Therefore, a method that can transfer models safely and effectively is urgently needed. Summary of the invention

[0004] The purpose of this application is to provide a model reasoning processing method, device, electronic device and storage medium to address the deficiencies in the above-mentioned prior art, so as to improve the security of model reasoning processing.

[0005] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0006] In a first aspect, an embodiment of the present application provides a method for reasoning and processing a model, the method comprising:

[0007] Loading a target model file and an initial inference service into a target client, wherein the target model file includes a target model and an encrypted client identifier, and multiple weight parameters in the target model are encrypted in advance, wherein the encrypted client identifier is used to indicate a client to which the target model is applicable;

[0008] In response to a trigger operation of a user on the target client for the initial reasoning service, the initial reasoning service obtains an identifier of the target client, the trigger operation being used to request the target reasoning service to perform a target operation;

[0009] The initial reasoning service verifies the target client according to the target model file and the identifier of the target client to determine whether the target client is qualified;

[0010] If qualified, the initial reasoning service decrypts the weight parameters in the target model, deploys the decrypted target model to the initial reasoning service, obtains the target reasoning service, and the target reasoning service executes the target operation.

[0011] Optionally, before deploying the target model and the initial reasoning service to the target client, the process further includes:

[0012] Get the unencrypted initial model;

[0013] Encrypting the weight parameters in the initial model to obtain the target model;

[0014] Performing client authority encryption on the identifier of each client to which the target model is applicable to obtain the encrypted client identifier;

[0015] The target model and the encrypted client identifier are added to the target model file.

[0016] Optionally, encrypting the weight parameters in the initial model to obtain the target model includes:

[0017] Obtain at least one weight matrix information of each neural network layer in the initial model;

[0018] Determine the weight matrix to be encrypted according to each of the weight matrix information;

[0019] The weight parameters in each of the weight matrices to be encrypted are encrypted to obtain the target model.

[0020] Optionally, determining the weight matrix to be encrypted according to each of the weight matrix information includes:

[0021] The length of the weight identifier in the weight matrix information is modulo a preset value to obtain a remainder;

[0022] Determine whether the weight matrix is ​​a weight matrix to be encrypted according to the remainder;

[0023] If the remainder is 1, the weight matrix is ​​determined to be the weight matrix to be encrypted.

[0024] Optionally, encrypting the identifier of each client to which the target model is applicable by client authority to obtain the encrypted client identifier includes:

[0025] Obtaining a unique identifier of each client to which the target model is applicable;

[0026] Generate a secret key corresponding to each of the clients according to the unique identifier;

[0027] The secret key corresponding to each of the clients is used as the encrypted client identifier.

[0028] Optionally, verifying the target client according to the target model file and the identifier of the target client to determine whether the target client is qualified includes:

[0029] Obtaining the encrypted client identifier in the target model file, and decrypting the encrypted client identifier to obtain a decrypted client identifier corresponding to the encrypted client identifier;

[0030] If the decrypted client identifier matches the identifier of the target client, the target client is determined to be qualified.

[0031] Optionally, the initial reasoning service decrypts the weight parameters in the target model, and deploys the decrypted target model to the initial reasoning service to obtain the target reasoning service, including:

[0032] Obtaining, by the initial inference service, an identifier of each weight matrix in each neural network layer in the target model;

[0033] The initial inference service determines the encrypted weight matrix according to the length of the identifier of each weight matrix and a preset value;

[0034] The initial reasoning service decrypts each of the encrypted weight matrices to obtain the decrypted target model, and deploys the decrypted target model to the initial reasoning service to obtain a target reasoning service.

[0035] In a second aspect, an embodiment of the present application further provides a model reasoning processing device, the device comprising:

[0036] A loading module, used to load a target model file and an initial inference service into a target client, wherein the target model file includes a target model and an encrypted client identifier, and a plurality of weight parameters in the target model are encrypted in advance, wherein the encrypted client identifier is used to indicate a client to which the target model is applicable;

[0037] an acquisition module, configured to, in response to a trigger operation of a user on the target client for the initial reasoning service, cause the initial reasoning service to acquire an identifier of the target client, wherein the trigger operation is used to request the target reasoning service to perform a target operation;

[0038] A determination module, configured to verify the target client by the initial reasoning service according to the target model file and the identifier of the target client to determine whether the target client is qualified;

[0039] If qualified, the initial reasoning service decrypts the weight parameters in the target model, deploys the decrypted target model to the initial reasoning service, obtains the target reasoning service, and the target reasoning service executes the target operation.

[0040] Optionally, the encryption module is used to:

[0041] Get the unencrypted initial model;

[0042] Encrypting the weight parameters in the initial model to obtain the target model;

[0043] Performing client authority encryption on the identifier of each client to which the target model is applicable to obtain the encrypted client identifier;

[0044] The target model and the encrypted client identifier are added to the target model file.

[0045] Optionally, the encryption module is used to:

[0046] Obtain at least one weight matrix information of each neural network layer in the initial model;

[0047] Determine the weight matrix to be encrypted according to each of the weight matrix information;

[0048] The weight parameters in each of the weight matrices to be encrypted are encrypted to obtain the target model.

[0049] Optionally, the encryption module is used to:

[0050] The length of the weight identifier in the weight matrix information is modulo a preset value to obtain a remainder;

[0051] Determine whether the weight matrix is ​​a weight matrix to be encrypted according to the remainder;

[0052] If the remainder is 1, the weight matrix is ​​determined to be the weight matrix to be encrypted.

[0053] Optionally, the encryption module is used to:

[0054] Obtaining a unique identifier of each client to which the target model is applicable;

[0055] Generate a secret key corresponding to each of the clients according to the unique identifier;

[0056] The secret key corresponding to each of the clients is used as the encrypted client identifier.

[0057] Optionally, the determining module is specifically used to:

[0058] Obtaining the encrypted client identifier in the target model file, and decrypting the encrypted client identifier to obtain a decrypted client identifier corresponding to the encrypted client identifier;

[0059] If the decrypted client identifier matches the identifier of the target client, the target client is determined to be qualified.

[0060] Optionally, the decryption module is used to:

[0061] Obtaining, by the initial inference service, an identifier of each weight matrix in each neural network layer in the target model;

[0062] The initial inference service determines the encrypted weight matrix according to the length of the identifier of each weight matrix and a preset value;

[0063] The initial reasoning service decrypts each of the encrypted weight matrices to obtain the decrypted target model, and deploys the decrypted target model to the initial reasoning service to obtain a target reasoning service.

[0064] In the third aspect, an embodiment of the present application also provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, and when the application is running, the processor communicates with the storage medium through the bus, and the processor executes the program instructions to perform the steps of the inference processing method of the model described in the first aspect above.

[0065] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is read and executes the steps of the model reasoning processing method described in the first aspect above.

[0066] The beneficial effects of this application are:

[0067] The application provides a method, device, electronic device and storage medium for reasoning processing of a model. The target model file and the initial reasoning service are loaded into the target client. The initial reasoning service verifies the target client according to the target model file and the identifier of the target client to determine whether the target client is qualified. If qualified, the initial reasoning service decrypts the weight parameters in the target model, deploys the decrypted target model to the initial reasoning service, obtains the target reasoning service, and the target reasoning service performs the target operation. Double verification can be achieved when starting the reasoning service and processing the request, which ensures the security of the target model and the security of the use of the reasoning service. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] 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.

[0069] Figure 1 A flowchart of a method for reasoning and processing a model provided in an embodiment of the present application;

[0070] Figure 2 A flowchart of another model reasoning processing method provided in an embodiment of the present application;

[0071] Figure 3 A flowchart of a method for obtaining a target model provided in an embodiment of the present application;

[0072] Figure 4 A flowchart of a method for determining a weight matrix to be encrypted provided in an embodiment of the present application;

[0073] Figure 5 A flowchart of a method for obtaining an encrypted client identifier provided in an embodiment of the present application;

[0074] Figure 6 A flowchart of a method for obtaining a target reasoning service provided in an embodiment of the present application;

[0075] Figure 7 A schematic diagram of a device for a model reasoning processing method provided in an embodiment of the present application;

[0076] Figure 8 A structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0077] 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. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.

[0078] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various 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.

[0079] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.

[0080] Optionally, the inference processing method of the model provided in the embodiment of the present application is applied to an electronic device, which may be a terminal device with computing and display capabilities, such as a mobile phone, a tablet computer, a laptop computer, a PDA, a desktop computer, or a server. Specifically, it can be applied to an application in a terminal device, such as an APP (application) of a mobile phone, an application system on a computer, etc.

[0081] The specific implementation process of the reasoning processing of the model provided in the embodiments of the present application is explained in detail below.

[0082] Figure 1 The flowchart of a method for reasoning and processing a model provided in an embodiment of the present application is shown in FIG. 1 , wherein the execution subject of the method is the aforementioned electronic device. Figure 1 As shown, the method includes:

[0083] S101, loading the target model file and the initial reasoning service into the target client.

[0084] Among them, the target model file includes a target model and an encrypted client identifier, wherein multiple weight parameters in the target model are pre-encrypted, the encrypted client identifier is used to indicate the client to which the target model is applicable, and the encrypted client identifier is an encrypted client identifier generated by the initial inference service for the target client, for example, the generated encrypted client identifier is a license key.

[0085] Optionally, the initial reasoning service refers to a service without loading the target model file, and the target model file and the initial reasoning service are first uploaded to the target client, specifically, the target model file and the initial reasoning service can be first uploaded to the same directory of the target client. The initial reasoning service is, for example, an application.

[0086] S102: In response to a triggering operation of the user on the target client for the initial reasoning service, the initial reasoning service obtains an identifier of the target client.

[0087] The trigger operation is used to request the target reasoning service to perform a target operation. For example, the trigger operation is to request the target reasoning service to perform a reasoning operation.

[0088] If the target reasoning service has not been generated, it is necessary to generate the target reasoning service first. Specifically, the initial reasoning service can be started first, and the initial reasoning service first obtains the identifier of the target client from the target client, such as obtaining the unique identifier (Universally Unique Identifier, UUID) of the target client.

[0089] S103: The initial reasoning service verifies the target client according to the target model file and the identifier of the target client to determine whether the target client is qualified.

[0090] Optionally, if a preset algorithm is used to verify the target client according to the target model file and the obtained identifier of the target client, it is determined whether the target client is qualified, that is, whether the target client has the right to use the initial reasoning service.

[0091] Optionally, if it is determined that the target client is qualified, that is, it is determined that the target client has the authority to use the initial reasoning service, then execute the following step S104; if it is determined that the target client is unqualified, that is, it is determined that the target client does not have the authority to use the initial reasoning service, then execute the following step S105.

[0092] S104: The initial reasoning service decrypts the weight parameters in the target model, deploys the decrypted target model to the initial reasoning service, obtains the target reasoning service, and the target reasoning service executes the target operation.

[0093] Optionally, after obtaining the target reasoning service, the target reasoning service may execute the target operation indicated by the triggering operation.

[0094] For example, if the target operation input by the user is to request “how to treat influenza A” to the target reasoning service, the target reasoning service can generate a specific answer to the request information.

[0095] Optionally, after the target reasoning service is generated, before the target reasoning service performs the target operation, the target reasoning service needs to further verify the target client. Specifically, before the target reasoning service performs the target operation, the target reasoning service needs to first obtain the target client's identifier, and obtain the decrypted client identifier from the target model file, decrypt the encrypted client identifier, obtain the decrypted client identifier, and match the decrypted client identifier with the target client identifier obtained when the request is received. If they match, it is determined that the target client has the authority to use the target reasoning service, that is, the target reasoning service can be used to perform the target operation on the target client; if they do not match, it is determined that the target client does not have the authority to use the target reasoning service, and the target reasoning service cannot be used to perform the target operation.

[0096] It is worth noting that when the target reasoning service is generated, it means that the target model has been decrypted. At this time, the target reasoning service contains the decrypted target model. When a request instruction is sent to the target reasoning service, the target reasoning service verifies the target client after receiving the request instruction. When the verification is successful, the target reasoning service can execute the operation indicated by the request instruction.

[0097] S105. The initial reasoning service exits directly.

[0098] Optionally, if the initial reasoning service exits directly, the initial reasoning service and the target model file cannot be deployed on the target client.

[0099] In this embodiment, the target model file and the initial reasoning service are loaded into the target client, and the initial reasoning service verifies the target client according to the target model file and the identifier of the target client to determine whether the target client is qualified; if qualified, the initial reasoning service decrypts the weight parameters in the target model, deploys the decrypted target model to the initial reasoning service, obtains the target reasoning service, and the target reasoning service performs the target operation. Double verification can be achieved when starting the reasoning service and processing the request, which ensures the security of the target model and the security of the use of the reasoning service.

[0100] Figure 2 A flowchart of another model reasoning processing method provided in an embodiment of the present application is shown as follows: Figure 2 As shown, before the target model file and the initial reasoning service are loaded into the target client in S101, the following may be included:

[0101] S201: Obtain an unencrypted initial model.

[0102] The unencrypted initial model refers to a model whose weight parameters are not encrypted.

[0103] S202: Encrypt the weight parameters in the initial model to obtain the target model.

[0104] For example, an asymmetric encryption method such as the RSA algorithm may be used to encrypt the weight parameters in the initial model to obtain a target model.

[0105] S203: Encrypt the client authority of the identifier of each client to which the target model is applicable to obtain an encrypted client identifier.

[0106] Exemplarily, if client A has the authority to use the target model, the client authority of client A may be encrypted. Specifically, a license key corresponding to the client may be generated according to the unique identifier of the client.

[0107] S204: Add the target model and the encrypted client identifier to the target model file.

[0108] Specifically, the encrypted initial model and the encrypted client identifier may be added to the target model file.

[0109] Figure 3 A flow chart of a method for obtaining a target model provided in an embodiment of the present application is shown as follows: Figure 3 As shown, in the above S202, encrypting the weight parameters in the initial model to obtain the target model may include:

[0110] S301. Obtain at least one weight matrix information of each neural network layer in the initial model.

[0111] Optionally, the initial model may include multiple neural network layers, each neural network layer may include multiple weight matrix information, and each weight matrix information includes each weight matrix name and weight parameters in each weight matrix.

[0112] For example, for the neural network layer layers.0.self, 7 weight matrices are included, and the identifiers of the weight matrices are, for example, layers.0.self_attn.q_proj.weight; layers.0.self_attn.q_proj.bias; layers.0.self_attn.k_proj.weight; layers.0.self_attn.k_proj.bias; layers.0.self_attn.v_proj.weight; layers.0.self_attn.v_proj.bias; layers.0.self_attn.o_proj.weight. Each weight matrix includes multiple weight parameters.

[0113] S302: Determine the weight matrix to be encrypted according to the information of each weight matrix.

[0114] Specifically, the weight matrix to be encrypted may be determined using a preset method according to each weight matrix identifier in each weight matrix information.

[0115] Exemplarily, the determined weight matrix to be encrypted is, for example, layers.0.self_attn.q_proj.weight; layers.0.self_attn.q_proj.bias.

[0116] S303: Encrypt the weight parameters in each weight matrix to be encrypted to obtain a target model.

[0117] Specifically, the weight parameter can be encrypted using a preset public key. For example, an integer e can be selected as the public key, and for each weight parameter, the formula c=m e modn, where c is the encrypted weight parameter, e is the public key, m is the weight parameter before encryption, and n is the preset value.

[0118] Figure 4 A flow chart of a method for determining a weight matrix to be encrypted provided in an embodiment of the present application is shown as follows: Figure 4 As shown, determining the weight matrix to be encrypted according to each weight matrix information in the above S302 may include:

[0119] S401: Calculate the modulus of the length of the weight identifier in the weight matrix information and a preset value to obtain a remainder.

[0120] Specifically, if the length of the weight identifier can be represented by H, the preset value is, for example, 2, and the remainder=H%2.

[0121] S402: Determine whether the weight matrix is ​​a weight matrix to be encrypted according to a preset.

[0122] Specifically, if the remainder is 1, it is determined that the weight matrix is ​​a weight matrix to be encrypted; if the remainder is 0, it is determined that the weight matrix is ​​not a weight matrix to be encrypted.

[0123] For example, if the length of the identifier of weight matrix 1 is 32, the remainder obtained is 0, then weight matrix 1 is not the weight matrix to be encrypted, that is, the weight parameters in weight matrix 1 do not need to be encrypted; if the length of the identifier of weight matrix 2 is 21, the remainder obtained is 1, then it is determined that weight matrix 2 is the weight matrix to be encrypted, that is, the weight parameters in weight matrix 2 need to be encrypted.

[0124] Figure 5 A flowchart of a method for obtaining an encrypted client identifier provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, in the above S203, the identifiers of each client to which the target model is applicable are encrypted with client permissions to obtain encrypted client identifiers, which may include:

[0125] S501: Obtain a unique identifier of each client to which the target model is applicable.

[0126] For example, if client A, client B, and client C are all applicable to the target model, the unique identifier of each client can be obtained in advance.

[0127] S502: Generate a secret key corresponding to each client according to the unique identifier.

[0128] Exemplarily, for client A, a secret key corresponding to client A can be generated, for example, licensekeyA corresponding to client A can be obtained; for client B, a secret key corresponding to client B can be generated, for example, licensekeyB corresponding to client B can be obtained; for client C, a secret key corresponding to client C can be generated, for example, licensekeyC corresponding to client C can be obtained.

[0129] S503: Use the secret key corresponding to each client as an encrypted client identifier.

[0130] Exemplarily, the encrypted client identifier of client A is licensekeyA; the encrypted client identifier of client B is licensekeyB; and the encrypted client identifier of client C is licensekeyC.

[0131] Optionally, in S103, verifying the target client according to the target model file and the identifier of the target client to determine whether the target client is qualified may include:

[0132] Specifically, the encrypted client identifier in the target model file may be obtained, and the encrypted client identifier may be decrypted to obtain a decrypted client identifier corresponding to the encrypted client identifier.

[0133] Optionally, if the decrypted client identifier matches the identifier of the target client, the target client is determined to be qualified.

[0134] Exemplarily, if the decrypted client identifier in the decrypted encrypted client identifier is: client A, and the obtained target client identifier is also client A, then the decrypted client identifier matches the obtained target client identifier, and it is determined that the target client is qualified, that is, it is determined that client A has the authority to use the target model. Otherwise, it is determined that the target client is unqualified.

[0135] Figure 6 A flowchart of a method for obtaining a target reasoning service provided in an embodiment of the present application is shown as follows: Figure 6 As shown, in the above S104, the initial reasoning service decrypts the weight parameters in the target model, and deploys the decrypted target model to the initial reasoning service to obtain the target reasoning service, which may include:

[0136] S601. Obtain the identifier of each weight matrix in each neural network layer in the target model through the initial inference service.

[0137] Optionally, since only the weight parameters in the weight matrix are encrypted during the encryption process, and the identifiers of the weight matrices are not encrypted, the identifiers of the weight matrices may be obtained first during decryption.

[0138] S602: The initial inference service determines the encrypted weight matrix according to the length of the weight matrix identifier and a preset value.

[0139] The preset value is the same as the preset value during encryption mentioned above, for example, 2.

[0140] Specifically, the remainder obtained by dividing the length of the identifier of each weight matrix by the preset value determines whether the weight matrix is ​​encrypted. If the remainder obtained is 1, it is determined that the weight matrix is ​​encrypted; if the remainder is 0, it is determined that the weight matrix is ​​not encrypted.

[0141] S603: The initial reasoning service decrypts each encrypted weight matrix to obtain a decrypted target model, and deploys the decrypted target model to the initial reasoning service to obtain a target reasoning service.

[0142] Specifically, the initial inference service may decrypt the weight parameters in each encrypted weight matrix to obtain each decrypted weight matrix, thereby obtaining a decrypted target model.

[0143] Specifically, the private key d can be used to decrypt the weight parameters in each encrypted weight matrix, where (d×e)%φ(n)=1, where φ(n) is a known number that is coprime with the public key e, and the private key d can be obtained. Specifically, the formula m=c d modn obtains the decrypted weight parameter, where c is the encrypted weight parameter in the weight matrix, m is the decrypted weight parameter, d is the private key, and n is the preset value.

[0144] In this embodiment, after the target reasoning service is generated, each time a request message is sent to the target reasoning service, the client where the target reasoning service is located needs to be verified. Only if the verification is passed can the target reasoning service be used, thereby ensuring the security of the target reasoning service.

[0145] Figure 7 A schematic diagram of a device for a model reasoning processing method provided in an embodiment of the present application, such as Figure 7 As shown, the device comprises:

[0146] A loading module 701 is used to load a target model file and an initial inference service into a target client, wherein the target model file includes a target model and an encrypted client identifier, and a plurality of weight parameters in the target model are encrypted in advance, wherein the encrypted client identifier is used to indicate a client to which the target model is applicable;

[0147] An acquisition module 702, configured to obtain, by the initial reasoning service, an identifier of the target client in response to a trigger operation of the user on the target client for the initial reasoning service, wherein the trigger operation is used to request the target reasoning service to perform a target operation;

[0148] The determination module 703 is configured to verify the target client by the initial reasoning service according to the target model file and the identifier of the target client to determine whether the target client is qualified;

[0149] If qualified, the initial reasoning service decrypts the weight parameters in the target model, deploys the decrypted target model to the initial reasoning service, obtains the target reasoning service, and the target reasoning service executes the target operation.

[0150] Optionally, an encryption module is used at 704:

[0151] Get the unencrypted initial model;

[0152] Encrypting the weight parameters in the initial model to obtain the target model;

[0153] Performing client authority encryption on the identifier of each client to which the target model is applicable to obtain the encrypted client identifier;

[0154] The target model and the encrypted client identifier are added to the target model file.

[0155] Optionally, the encryption module 704 is used to:

[0156] Obtain at least one weight matrix information of each neural network layer in the initial model;

[0157] Determine the weight matrix to be encrypted according to each of the weight matrix information;

[0158] The weight parameters in each of the weight matrices to be encrypted are encrypted to obtain the target model.

[0159] Optionally, the encryption module 704 is used to:

[0160] The length of the weight identifier in the weight matrix information is modulo a preset value to obtain a remainder;

[0161] Determine whether the weight matrix is ​​a weight matrix to be encrypted according to the remainder;

[0162] If the remainder is 1, the weight matrix is ​​determined to be the weight matrix to be encrypted.

[0163] Optionally, the encryption module 704 is used to:

[0164] Obtaining a unique identifier of each client to which the target model is applicable;

[0165] Generate a secret key corresponding to each of the clients according to the unique identifier;

[0166] The secret key corresponding to each of the clients is used as the encrypted client identifier.

[0167] Optionally, the determining module 703 is specifically configured to:

[0168] Obtaining the encrypted client identifier in the target model file, and decrypting the encrypted client identifier to obtain a decrypted client identifier corresponding to the encrypted client identifier;

[0169] If the decrypted client identifier matches the identifier of the target client, the target client is determined to be qualified.

[0170] Optionally, the decryption module 704 is used to:

[0171] Obtaining, by the initial inference service, an identifier of each weight matrix in each neural network layer in the target model;

[0172] The initial inference service determines the encrypted weight matrix according to the length of the identifier of each weight matrix and a preset value;

[0173] The initial reasoning service decrypts each of the encrypted weight matrices to obtain the decrypted target model, and deploys the decrypted target model to the initial reasoning service to obtain a target reasoning service.

[0174] Figure 8 8 is a structural block diagram of an electronic device 800 provided in an embodiment of the present application. The electronic device may be, for example, a model inference processor as described in the foregoing embodiment. Figure 8 As shown, the electronic device may include: a processor 801 and a memory 802 .

[0175] Optionally, a bus 803 may also be included, wherein the memory 802 is used to store machine-readable instructions executable by the processor 801. When the electronic device 800 is running, the processor 801 communicates with the memory 802 through the bus 803. When the machine-readable instructions are executed by the processor 801, the method steps in the above method embodiment are performed.

[0176] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method steps of the above-mentioned model reasoning processing method embodiment are executed.

[0177] 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 method embodiment, and will not be repeated in this application. In the several embodiments provided in this 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.

[0178] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable 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: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), disk or optical disk and other media that can store program code.

[0179] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.

Claims

1. A method for reasoning a model, characterized in that: The method comprises: Loading a target model file and an initial inference service into a target client, wherein the target model file includes a target model and an encrypted client identifier, and multiple weight parameters in the target model are encrypted in advance, wherein the encrypted client identifier is used to indicate a client to which the target model is applicable; In response to a trigger operation of a user on the target client for the initial reasoning service, the initial reasoning service obtains an identifier of the target client, the trigger operation being used to request the target reasoning service to perform a target operation; The initial reasoning service verifies the target client according to the target model file and the identifier of the target client to determine whether the target client is qualified; If qualified, the initial reasoning service decrypts the weight parameters in the target model, deploys the decrypted target model to the initial reasoning service, obtains the target reasoning service, and the target reasoning service executes the target operation.

2. The inference processing method of the model according to claim 1, characterized in that: Before deploying the target model and the initial reasoning service to the target client, the method further includes: Get the unencrypted initial model; Encrypting the weight parameters in the initial model to obtain the target model; Performing client authority encryption on the identifier of each client to which the target model is applicable to obtain the encrypted client identifier; The target model and the encrypted client identifier are added to the target model file.

3. The inference processing method of the model according to claim 2, characterized in that: Encrypting the weight parameters in the initial model to obtain the target model includes: Obtain at least one weight matrix information of each neural network layer in the initial model; Determine the weight matrix to be encrypted according to each of the weight matrix information; The weight parameters in each of the weight matrices to be encrypted are encrypted to obtain the target model.

4. The inference processing method of the model according to claim 3 is characterized in that: The step of determining the weight matrix to be encrypted according to each of the weight matrix information comprises: The length of the weight identifier in the weight matrix information is modulo a preset value to obtain a remainder; Determine whether the weight matrix is ​​a weight matrix to be encrypted according to the remainder; If the remainder is 1, the weight matrix is ​​determined to be the weight matrix to be encrypted.

5. The inference processing method of the model according to claim 2, characterized in that: The step of encrypting the identifiers of each client to which the target model is applicable by client authority to obtain the encrypted client identifier comprises: Obtaining a unique identifier of each client to which the target model is applicable; Generate a secret key corresponding to each of the clients according to the unique identifier; The secret key corresponding to each of the clients is used as the encrypted client identifier.

6. The inference processing method of the model according to claim 1, characterized in that: The verifying the target client according to the target model file and the identifier of the target client to determine whether the target client is qualified includes: Obtaining the encrypted client identifier in the target model file, and decrypting the encrypted client identifier to obtain a decrypted client identifier corresponding to the encrypted client identifier; If the decrypted client identifier matches the identifier of the target client, the target client is determined to be qualified.

7. The inference processing method of the model according to claim 1, characterized in that: The initial reasoning service decrypts the weight parameters in the target model, and deploys the decrypted target model to the initial reasoning service to obtain the target reasoning service, including: Obtaining, by the initial inference service, an identifier of each weight matrix in each neural network layer in the target model; The initial inference service determines the encrypted weight matrix according to the length of the identifier of each weight matrix and a preset value; The initial reasoning service decrypts each of the encrypted weight matrices to obtain the decrypted target model, and deploys the decrypted target model to the initial reasoning service to obtain a target reasoning service.

8. A model inference processing device, characterized in that: include: A loading module, used to load a target model file and an initial inference service into a target client, wherein the target model file includes a target model and an encrypted client identifier, and a plurality of weight parameters in the target model are encrypted in advance, wherein the encrypted client identifier is used to indicate a client to which the target model is applicable; an acquisition module, configured to, in response to a trigger operation of a user on the target client for the initial reasoning service, cause the initial reasoning service to acquire an identifier of the target client, wherein the trigger operation is used to request the target reasoning service to perform a target operation; A determination module, configured to verify the target client by the initial reasoning service according to the target model file and the identifier of the target client to determine whether the target client is qualified; If qualified, the initial reasoning service decrypts the weight parameters in the target model, deploys the decrypted target model to the initial reasoning service, obtains the target reasoning service, and the target reasoning service executes the target operation.

9. An electronic device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program executable by the processor, and when the processor executes the computer program, the steps of the inference processing method of the model described in any one of claims 1 to 7 are implemented.

10. 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 inference processing method of the model as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Model deployment method

    CN121300870A