Artificial intelligence model adaptation method and apparatus, electronic device, and storage medium
By determining the accuracy differences and relative entropy sets of artificial intelligence models in different hardware environments, and adjusting the target model parameters, the problem of misalignment of model accuracy was solved, achieving efficient hardware adaptation and generalization performance improvement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- KUNLUNXIN TECHNOLOGY (BEIJING) CO LTD
- Filing Date
- 2023-03-29
- Publication Date
- 2026-05-15
AI Technical Summary
Artificial intelligence models cannot achieve the same level of accuracy in different hardware environments. Existing adjustment methods are ineffective and costly, causing inconvenience to customers.
By determining the accuracy differences and relative entropy sets of artificial intelligence models in different hardware environments, the parameters of the target model are adjusted to achieve adaptation, including using regression models and neural network models to determine target weights, and combining training data for multiple transfers and processing.
It effectively reduced model adaptation time, improved generalization performance under different hardware environments, and maintained model accuracy.
Smart Images

Figure CN116341680B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, particularly to the fields of deep learning and big data, and specifically to an artificial intelligence model adaptation method, apparatus, electronic device, and storage medium. Background Technology
[0002] With the development of artificial intelligence (AI) technology, AI models have permeated all aspects of life. AI models generally rely on hardware environments to function. Therefore, integrating AI models with hardware environments is particularly important. Summary of the Invention
[0003] This disclosure provides an artificial intelligence model adaptation method, apparatus, electronic device, and storage medium.
[0004] According to one aspect of this disclosure, an artificial intelligence model adaptation method is provided, comprising: in response to determining that a first processing precision of the artificial intelligence model in a first hardware environment is greater than a second processing precision of the artificial intelligence model in a second hardware environment, determining a precision difference based on the first processing precision and the second processing precision, wherein the artificial intelligence model is trained in the first hardware environment; determining a relative entropy set of the model parameter set based on a first vector set obtained in the first hardware environment based on a model parameter set of the artificial intelligence model and a second vector set obtained in the second hardware environment based on the model parameter set; determining target model parameters based on the precision difference and the relative entropy set; and adapting the artificial intelligence model to the second hardware environment by processing the target model parameters.
[0005] According to another aspect of this disclosure, an artificial intelligence model apparatus is provided, comprising: a first determining module, configured to determine a precision difference based on the first processing precision and the second processing precision in response to determining that a first processing precision of the artificial intelligence model in a first hardware environment is greater than a second processing precision of the artificial intelligence model in a second hardware environment, wherein the artificial intelligence model is trained in the first hardware environment; a second determining module, configured to determine a relative entropy set of the model parameter set based on a first vector set obtained in the first hardware environment based on a model parameter set of the artificial intelligence model and a second vector set obtained in the second hardware environment based on the model parameter set; a third determining module, configured to determine target model parameters based on the precision difference and the relative entropy set; and a processing module, configured to adapt the artificial intelligence model to the second hardware environment by processing the target model parameters.
[0006] According to another aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the artificial intelligence model adaptation method of this disclosure.
[0007] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to execute the artificial intelligence model adaptation method of this disclosure.
[0008] According to another aspect of this disclosure, a computer program product is provided, including a computer program stored on at least one of a readable storage medium and an electronic device, wherein the computer program implements the artificial intelligence model adaptation method of this disclosure when executed by a processor.
[0009] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0010] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0011] Figure 1 This illustration schematically shows an exemplary system architecture to which artificial intelligence model adaptation methods and apparatus can be applied according to embodiments of the present disclosure;
[0012] Figure 2 A flowchart illustrating an artificial intelligence model adaptation method according to an embodiment of the present disclosure is shown schematically.
[0013] Figure 3 The flowchart illustrates an adaptation method for migrating an artificial intelligence model trained in a GPU environment to an XPU environment according to an embodiment of the present disclosure.
[0014] Figure 4 A block diagram of an artificial intelligence model adaptation device according to an embodiment of the present disclosure is schematically shown; and
[0015] Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement embodiments of the present disclosure is shown. Detailed Implementation
[0016] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0017] In the technical solution disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure, and application of user personal information comply with the provisions of relevant laws and regulations, necessary confidentiality measures have been taken, and there is no violation of public order and good morals.
[0018] In the technical solution disclosed herein, the user's authorization or consent is obtained before acquiring or collecting the user's personal information.
[0019] When adapting AI (Artificial Intelligence) models to different hardware environments, misalignment of model accuracy may occur. Model accuracy is a measure of its actual performance, so misalignment can cause significant problems for users. In such cases, the accuracy can be aligned manually by adjusting model parameters.
[0020] In the process of realizing the present invention, the inventors discovered that the adjustment effect of the above method cannot be guaranteed, and there is a possibility that alignment may still not be achieved after adjusting multiple sets of different parameters. In addition, the time and computational resource costs of this method are also relatively large.
[0021] Figure 1 The illustration schematically depicts an exemplary system architecture to which artificial intelligence model adaptation methods and apparatus can be applied according to embodiments of the present disclosure.
[0022] It is important to note that Figure 1 The examples shown are merely examples of system architectures applicable to embodiments of this disclosure, intended to help those skilled in the art understand the technical content of this disclosure. They do not imply that embodiments of this disclosure cannot be used in other devices, systems, environments, or scenarios. For instance, in another embodiment, an exemplary system architecture for applying the artificial intelligence model adaptation method and apparatus may include a terminal device. However, the terminal device can implement the artificial intelligence model adaptation method and apparatus provided in the embodiments of this disclosure without interacting with a server.
[0023] like Figure 1As shown, the system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0024] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as knowledge reading applications, web browser applications, search applications, instant messaging tools, email clients, and / or social platform software, etc. (for example only).
[0025] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0026] Server 105 can be a server providing various services, such as a backend management server (for example only) that supports the content browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The backend management server can analyze and process received user requests and other data, and feed back the processing results (such as web pages, information, or data obtained or generated based on user requests) to the terminal devices. The server can be a cloud server, also known as a cloud computing server or cloud host, a host product in the cloud computing service system, which solves the shortcomings of traditional physical hosts and VPS services ("Virtual Private Server", or simply "VPS") in terms of high management difficulty and weak business scalability. The server can also be a server for a distributed system or a server integrated with blockchain.
[0027] It should be noted that the artificial intelligence model adaptation method provided in this embodiment can generally be executed by the first terminal device 101, the second terminal device 102, or the third terminal device 103. Accordingly, the artificial intelligence model adaptation device provided in this embodiment can also be disposed in the first terminal device 101, the second terminal device 102, or the third terminal device 103.
[0028] Alternatively, the artificial intelligence model adaptation method provided in this embodiment can also generally be executed by server 105. Correspondingly, the artificial intelligence model adaptation device provided in this embodiment can generally be located in server 105. The artificial intelligence model adaptation method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the artificial intelligence model adaptation device provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105.
[0029] For example, when it is necessary to adapt an artificial intelligence model to a second hardware environment, the first terminal device 101, the second terminal device 102, and the third terminal device 103 can obtain information such that the first processing accuracy of the artificial intelligence model in the first hardware environment is greater than the second processing accuracy of the artificial intelligence model in the second hardware environment, as well as a first vector set obtained based on the model parameter set of the artificial intelligence model in the first hardware environment and a second vector set obtained based on the model parameter set in the second hardware environment. The artificial intelligence model is trained in the first hardware environment. Then, the obtained first processing accuracy, second processing accuracy, first vector set, and second vector set are sent to the server 105. The server 105 responds by determining that the first processing accuracy is greater than the second processing accuracy, determining the accuracy difference based on the first and second processing accuracy, determining the relative entropy set of the model parameter set based on the first and second vector sets, determining the target model parameters based on the accuracy difference and relative entropy, and adapting the artificial intelligence model to the second hardware environment by processing the target model parameters. Alternatively, a server or server cluster capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105 can analyze the first processing precision, the second processing precision, the first vector set, and the second vector set, and adapt the artificial intelligence model to the second hardware environment.
[0030] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0031] Figure 2 A flowchart illustrating an artificial intelligence model adaptation method according to an embodiment of the present disclosure is shown.
[0032] like Figure 2 As shown, the method includes operations S210 to S240.
[0033] In operation S210, in response to determining that the first processing accuracy of the artificial intelligence model in the first hardware environment is greater than the second processing accuracy of the artificial intelligence model in the second hardware environment, the accuracy difference is determined based on the first processing accuracy and the second processing accuracy, and the artificial intelligence model is trained in the first hardware environment.
[0034] In operation S220, the relative entropy set of the model parameter set is determined based on the first vector set obtained from the model parameter set of the artificial intelligence model in the first hardware environment and the second vector set obtained from the model parameter set in the second hardware environment.
[0035] In operation S230, the target model parameters are determined based on the accuracy difference and the relative entropy set.
[0036] In operation S240, the artificial intelligence model is adapted to the second hardware environment by processing the target model parameters.
[0037] According to embodiments of this disclosure, the artificial intelligence model may include any one of the following: a pre-trained model, a model trained for various scenarios, etc., and is not limited to these. The processing accuracy of the artificial intelligence model may be expressed by at least one of the following: recall rate, false detection rate, etc. For an artificial intelligence model, the processing accuracy of the model can be calculated by combining a preset accuracy calculation formula.
[0038] According to embodiments of this disclosure, the first hardware environment and the second hardware environment may use different types of processors, or they may use processors of the same type but with different configurations. For example, the first hardware environment and the second hardware environment may each include at least one of the following: processor processing speed, processor memory capacity, and processor transmission speed. The processor may include at least one of the following: GPU (Graphics Processing Unit), TPU (Tensor Processing Unit), NPU (Neural Network Processing Unit), XPU (an FPGA intelligent cloud acceleration processor), etc., and is not limited to these.
[0039] According to embodiments of this disclosure, since at least one of the following information—processing speed, memory capacity, transmission speed, etc.—may differ in different hardware environments, the artificial intelligence model can exhibit different processing accuracies in different hardware environments. Based on the differences between the first hardware environment and the second hardware environment, the artificial intelligence model can exhibit a first processing accuracy in the first hardware environment and a second processing accuracy in the second hardware environment.
[0040] According to embodiments of this disclosure, an artificial intelligence model may have one or more model parameters. These one or more model parameters may constitute a model parameter set for the artificial intelligence model. The model parameter set may include, for example, at least one of the following: an Add operator, a Multipul operator, a Softmax operator, etc., and is not limited to these. The calculation result of the model parameters may be represented in vector form. In a first hardware environment, a first vector can be obtained based on each model parameter of the artificial intelligence model. The first vector set may include one or more first vectors obtained based on one or more model parameters of the artificial intelligence model in the first hardware environment. In a second hardware environment, a second vector can be obtained based on each model parameter of the artificial intelligence model. The second vector set may include one or more second vectors obtained based on one or more model parameters of the artificial intelligence model in the second hardware environment.
[0041] It should be noted that the first and second vector sets may include the output vectors of all model parameters in the artificial intelligence model, or they may only include the output vectors of some model parameters; this is not limited here. Some model parameters can be defined and determined manually.
[0042] According to embodiments of this disclosure, each vector can be viewed as a specific distribution, and the difference between two distributions can be measured by the relative entropy between the two distributions. A method for calculating relative entropy may include: first, for a first vector and a second vector obtained based on the same model parameters, determining a first probability distribution for the first vector and a second probability distribution for the second vector. Then, the relative entropy of the model parameters can be calculated using the relative entropy calculation formula, based on the first and second probability distributions. By applying this method to each model parameter in the model parameter set, a set of relative entropies can be obtained. The relative entropies in the relative entropy set correspond one-to-one with the model parameters in the model parameter set.
[0043] According to embodiments of this disclosure, target model parameters can characterize model parameters that significantly impact the accuracy of the artificial intelligence model running in a second hardware environment. In this embodiment, for example, target model parameters that significantly impact the accuracy of the artificial intelligence model can be determined by controlling variables and considering changes in accuracy difference. Control variables can, for example, involve keeping the values of certain model parameters in the model parameter set constant while changing the values of other model parameters.
[0044] It should be noted that the above method for determining the target model parameters is only an exemplary embodiment, but is not limited thereto. Other methods known in the art may also be included, as long as the target model parameters that have a significant impact on the accuracy of the artificial intelligence model can be determined from the model parameter set.
[0045] According to embodiments of this disclosure, after determining the target model parameters, the artificial intelligence model trained in the first hardware environment can be adapted to the second hardware environment while maintaining similar accuracy by adjusting or otherwise processing the target model parameters.
[0046] For example, if an AI model with a first processing accuracy is trained in a first hardware environment, and the business needs to migrate this AI model to a second hardware environment, the second processing accuracy of the AI model in the second hardware environment can be determined first. Then, if it is determined that the second processing accuracy is less than the first processing accuracy, the above method can be combined to adapt the AI model to the second hardware environment by processing the target model parameters.
[0047] It should be noted that if the second processing accuracy is greater than or equal to the first processing accuracy, the artificial intelligence model can be migrated to the second hardware environment without performing any processing on the model parameters.
[0048] Through the above embodiments of this disclosure, by determining the target model parameters and processing the target model parameters, the artificial intelligence model can be adapted to different hardware environments, which can effectively reduce the adaptation time and increase the generalization performance of the model for different hardware environments.
[0049] The following describes specific embodiments. Figure 2 The method shown will be further explained.
[0050] According to embodiments of this disclosure, the above-described artificial intelligence model adaptation method may further include: before performing the above-described operation S220, acquiring training data used by the artificial intelligence model; when training the artificial intelligence model using the training data in a first hardware environment, the output accuracy of the artificial intelligence model is a first processing accuracy. The artificial intelligence model, which has been migrated to a second hardware environment, is trained multiple times using the training data to obtain multiple second vector sets. At least two of the multiple training sessions have different training rounds.
[0051] According to embodiments of this disclosure, the training data used by an AI model trained in a first hardware environment to achieve a first processing accuracy can be used to train an AI model that has been transferred to a second hardware environment. By performing multiple training iterations and controlling the number of training epochs to be different, different second vectors can be obtained based on the same model parameters. The resulting multiple sets of second vectors can have richer numerical representations. Based on this richer numerical representation, it is convenient to subsequently determine the parameters of the target model.
[0052] It should be noted that the different number of training rounds mentioned above refers to the different number of training rounds when training the AI model multiple times in the same hardware environment. When training the AI model in different hardware environments, the same number of training rounds should be maintained.
[0053] According to embodiments of this disclosure, the above operation S220 may include: for each model parameter in the model parameter set, determining a first probability distribution of the model parameter output first vector, and determining a second probability distribution of the model parameter output second vector. The first vector is obtained from model parameters based on an artificial intelligence model in a first hardware environment. The second vector is obtained from model parameters based on an artificial intelligence model in a second hardware environment. The relative entropy of the model parameters is determined based on the first and second probability distributions. A relative entropy set is determined based on the relative entropy of at least one model parameter in the model parameter set.
[0054] According to embodiments of this disclosure, the relative entropy can be calculated using the KL divergence calculation formula. The KL divergence calculation formula can be, for example, as shown in formula (1), but is not limited thereto.
[0055]
[0056] In formula (1), N can represent the number of training rounds in one training session. Based on formula (1), after one training session, N first vectors can be obtained based on each model parameter. It can be represented as the first vector calculated in the i-th round based on a certain model parameter of an artificial intelligence model in the first hardware environment. It can represent the output of model parameters. The first probability distribution. It can be represented as the second vector calculated in the i-th round based on the same model parameters as those mentioned above in the artificial intelligence model in the second hardware environment. It can represent the output of model parameters. The second probability distribution. P can be a representation of the first probability distribution, and Q can be a representation of the second probability distribution. D KL It can represent the KL divergence between N first vectors and N second vectors obtained based on the same model parameters in different hardware environments. It can also characterize the similarity between N first probability distributions and N second probability distributions; the more similar the two probability distributions, the higher the KL divergence. KL The closer the value is to 0, the more likely it is to be determined. Based on the KL divergence calculated by formula (1), the relative entropy of the vector output by a model parameter in an artificial intelligence model in different hardware environments can be determined.
[0057] By performing the operation as shown in formula (1) on each model parameter in the model parameter set of the artificial intelligence model, a relative entropy set can be obtained.
[0058] It should be noted that the calculation of relative entropy based on the KL divergence calculation formula shown in formula (1) is only an exemplary embodiment, but is not limited to it. Other KL divergence calculation methods known in the art can also be included, as long as the relative entropy can be obtained from the first vector and the second vector.
[0059] According to embodiments of this disclosure, when multiple second vector sets are obtained based on multiple training iterations, the artificial intelligence model in the first hardware environment can be trained multiple times using the same pattern using training data to obtain multiple first vector sets. The multiple first vector sets and multiple second vector sets can correspond one-to-one. For example, first vector sets and second vector sets obtained based on the same number of training rounds and the same model parameters can correspond to each other. Then, for each corresponding first vector set and second vector set, the aforementioned operation of determining the relative entropy set can be performed to obtain multiple relative entropy sets. Multiple relative entropy sets can have richer numerical representations.
[0060] According to embodiments of this disclosure, when multiple relative entropy sets are obtained, the relative entropy in each relative entropy set can correspond one-to-one with the model parameters in the model parameter set.
[0061] According to embodiments of this disclosure, given that AI models trained in different hardware environments have many model parameters at different epochs (representing the smallest unit of training), and considering that model accuracy matching is a goal to be achieved in model adaptation scenarios, regression or neural network training methods can be considered to combine the differences in model parameters and model accuracy, and train an adjusted model to determine the model parameters that need to be adjusted.
[0062] According to embodiments of this disclosure, based on this concept, the above operation S230 may include: determining an adjustment model based on the precision difference and the relative entropy set. The precision difference is the true label of the adjustment model, and the relative entropy in the relative entropy set is the feature value of the adjustment model, with the relative entropy having an initial weight. A target weight for the relative entropy is determined based on multiple relative entropy sets and the adjustment model. Target model parameters are determined based on the target weight.
[0063] According to embodiments of this disclosure, the adjustment model may include a regression model or a neural network model, but is not limited to these. The relative entropy of the vectors output by the same model parameters under different hardware environments can be used as the feature value of the adjustment model, and the absolute value of the accuracy difference of the same model under different hardware environments can be used as the label of the adjustment model, thereby constructing the adjustment model.
[0064] According to embodiments of this disclosure, based on determining the adjustment model according to the accuracy difference and relative entropy set, combining multiple relative entropy sets allows for a faster and more accurate determination of the weights that best match each relative entropy in the relative entropy set, thus determining the aforementioned target weights. This facilitates the determination of the target model parameters based on the target weights.
[0065] Through the above embodiments of this disclosure, by adjusting the model and combining the rich numerical representations of multiple relative entropy sets, the efficiency of determining the parameters of the target model can be improved.
[0066] According to embodiments of this disclosure, the plurality of relative entropy sets may include at least a first relative entropy set and a second relative entropy set, and are not limited thereto. When the adjustment model is a regression model, determining the target weight of the relative entropy based on the plurality of relative entropy sets and the adjustment model may include: determining a first regression equation based on the first relative entropy set and the adjustment model; determining a second regression equation based on the second relative entropy set and the adjustment model; and determining the target weight based on the first regression equation and the second regression equation.
[0067] According to embodiments of this disclosure, the regression model may be expressed as a regression equation as shown in formula (2), and is not limited thereto.
[0068]
[0069] In formula (2), Y can represent the accuracy difference. M can represent the total number of model parameters in the model parameter set. j can represent the positional or label representation of a model parameter in the model parameter set, which can be used to locate a specific model parameter. X j W represents the relative entropy of the vector output by the j-th model parameter in different hardware environments. j It can represent the regression coefficient corresponding to the j-th model parameter.
[0070] According to embodiments of this disclosure, X in formula (2) can be replaced by a first relative entropy set based on the form shown in formula (2). j Combining the precision value as Y, we obtain the first regression equation. The second relative entropy set can be used to replace X in formula (2). j This can be combined with the precision value as Y to obtain the second regression equation. By combining the first and second regression equations, W can be solved. j This allows us to obtain the target weights of the model parameters.
[0071] It should be noted that the above is only an exemplary embodiment, and the relative entropy set can include more. When there are more relative entropy sets, multiple regression equations can be obtained in the same way as described above, and W can be obtained by solving multiple regression equations. j The target weight is obtained.
[0072] Through the above embodiments of this disclosure, the efficiency of determining the target model parameters can be improved by combining multiple relative entropy sets to calculate the target weight based on the regression model.
[0073] According to embodiments of this disclosure, when the adjusted model is a neural network model, determining the target weights of the relative entropy based on multiple relative entropy sets and the adjusted model may include: if the neural network model has not converged, inputting the relative entropy sets into the neural network model to obtain the target accuracy; adjusting the initial weights based on the target accuracy and the true labels until the neural network model converges; and determining the target weights based on the weights in the converged neural network model.
[0074] According to embodiments of this disclosure, the neural network model may be, for example, a network model including at least one fully connected (FC) layer and one softmax layer, and is not limited thereto. Each FC layer may have an initial weight, for example, 1. The input to the neural network model may be the relative entropy in the relative entropy set, and the output may be the target accuracy. The initial weights of the FC layers may be adjusted in reverse based on the loss value determined according to the target accuracy and the true label, until the iterative neural network model converges. In the case of a converged neural network model, the target weights may be determined based on the weights in the converged neural network model.
[0075] Through the above embodiments of this disclosure, based on the neural network model and combined with the model training method, the initial weights in the model are adjusted based on multiple relative entropy sets to determine the target weights, which can effectively improve the efficiency of determining the target model parameters.
[0076] According to embodiments of this disclosure, after determining the target weights corresponding to the model parameters in the model parameter set, target model parameters can be determined based on the target weights. This process may include: in response to determining that the target weights are greater than a preset threshold, determining the target relative entropy corresponding to the target weights; and determining the model parameters corresponding to the target relative entropy based on the target relative entropy, which are then used as the target model parameters.
[0077] According to embodiments of this disclosure, the importance of model parameters to model accuracy can be determined based on target weights. For example, if the target weight is greater than a preset threshold, it can be determined that the model parameter corresponding to the target relative entropy is relatively important for adjusting the model accuracy, and thus this model parameter can be identified as the target model parameter to be processed.
[0078] Through the above embodiments of this disclosure, by determining the target weights, the target model parameters can be determined more intuitively, effectively improving the efficiency of determining the target model parameters during the model adaptation process.
[0079] According to embodiments of this disclosure, after determining the target model parameters, various processing methods can be performed on the target model parameters.
[0080] In one processing method, the above operation S240 may include: obtaining the model accuracy of the trained model when the target model parameters are transferred to the central processing unit. In response to determining that the model accuracy meets a preset condition, when the artificial intelligence model is transferred to a second hardware environment, the target model parameters are recorded in a blacklist. The blacklist is used to record parameters calculated based on the central processing unit.
[0081] According to embodiments of this disclosure, by transferring the target model parameters to the CPU for basic calculations, the model accuracy can be effectively maintained. Furthermore, during the migration of the AI model to a second hardware environment, the target model parameters can be added to a blacklist of operators running in the second hardware environment. Based on this method, the target model parameters cannot run in the second hardware environment but are instead transferred to the CPU associated with that environment. Since the target model parameters significantly impact model accuracy, and running them on the CPU does not reduce the accuracy of the AI model, migrating the target model parameters to the central processing unit associated with the second hardware environment effectively reduces the accuracy loss caused by the target model parameters during model migration, ensuring that the model accuracy remains unchanged.
[0082] In another processing method, the above operation S240 may further include: training the artificial intelligence model that has been transferred to the second hardware environment multiple times using training data to obtain multiple first output values of the target model parameters. In response to determining that there is a target output value among the multiple first output values that does not satisfy a Gaussian-like distribution, the target output value is replaced with a first target value, which satisfies a Gaussian-like distribution. The target model parameters are then adjusted based on the first target value.
[0083] According to embodiments of this disclosure, in the aforementioned multiple training iterations, each training iteration may include multiple training rounds, and the number of training rounds may differ between different training iterations. After each training iteration of the artificial intelligence model in the second hardware environment, a first output value can be obtained based on each target model parameter. Multiple first output values can be obtained after the aforementioned multiple training iterations.
[0084] According to embodiments of this disclosure, after obtaining multiple first output values, the mean E1 and variance D1 of the multiple first output values can be calculated. Based on the mean E1 and variance D1, the Gaussian-like distribution interval of the multiple first output values can be determined as [E1-3D1, E1+3D1]. If a first output value is within this interval, it can be determined that the first output value satisfies a Gaussian-like distribution. If a first output value is outside this interval, it can be determined that the first output value does not satisfy a Gaussian-like distribution. The first output value that does not satisfy a Gaussian-like distribution, i.e., the target output value, can be determined as an extreme value. When an extreme value is determined to be the output of the model parameters, a replacement operation can be performed on the extreme value based on the first target value.
[0085] According to embodiments of this disclosure, the first target value can be determined based on a Gaussian-like distribution interval. For example, for a target output value that does not satisfy a Gaussian-like distribution, the target output value can be replaced with any value within the Gaussian-like distribution interval, without limitation. For example, for a target output value smaller than the minimum value located within the Gaussian-like distribution interval, an edge value E1-3D1 can be used for replacement. For a target output value larger than the maximum value located within the Gaussian-like distribution interval, an edge value E1+3D1 can be used for replacement.
[0086] In this approach, a first target value for adjusting the target model parameters can be determined based on a Gaussian-like distribution interval. Since the first target value satisfies a Gaussian-like distribution, adjusting the target model parameters in the artificial intelligence model based on the first target value can improve the stability of the artificial intelligence model in a new hardware environment.
[0087] In another processing method, the above operation S240 may further include: training the target model parameters, which have been migrated to the central processing unit associated with the second hardware environment, multiple times using training data to obtain multiple second output values of the target model parameters; determining a second target value based on the multiple first output values and the multiple second output values; and adjusting the target model parameters based on the second target value.
[0088] According to embodiments of this disclosure, a process of training the parameters of a target model migrated to a central processing unit associated with the second hardware environment multiple times using training data can be performed based on the same training mode as training an artificial intelligence model migrated to a second hardware environment multiple times using training data. The same training mode can manifest as at least one of the following: the same number of training iterations, the same number of training rounds, etc., and is not limited to these.
[0089] According to embodiments of this disclosure, for example, the value of the target model parameters obtained by running the training data on a CPU is d. CPUThe mean of the multiple second output values obtained by running multiple training runs on the CPU with respect to the target model parameters is E. CpU The variance is D CPU The second target value d′ used to adjust the target model parameters can be determined by combining formula (3).
[0090] d′=((d CpU -E1+3×D1) / D1)×D CPU +(E CPU -3×D CPU ) Formula (3)
[0091] It should be noted that formula (3) is only an exemplary embodiment, but is not limited thereto, and may also include other d-based methods known in the art. CPU The method to determine the second target value dd′ is simply to achieve the second output value of the target model parameters obtained based on the CPU environment.
[0092] In this approach, a second target value for adjusting the target model parameters can be determined by combining the second output value based on the target model parameters in the CPU environment. Since CPU data processing can effectively maintain the accuracy of the model, adjusting the target model parameters in the artificial intelligence model based on the second target value can help maintain the high accuracy of the artificial intelligence model.
[0093] Figure 3 The flowchart illustrates an adaptation method for migrating an artificial intelligence model trained in a GPU environment to an XPU environment according to an embodiment of the present disclosure.
[0094] like Figure 3 As shown, the method includes operations S310 to S370.
[0095] When operating S310, the first vector obtained based on the model parameters of the artificial intelligence model is acquired when training the artificial intelligence model in the GPU environment. The model accuracy is the first processing accuracy.
[0096] When operating S320, the second vector obtained based on the model parameters of the artificial intelligence model is acquired when training the artificial intelligence model in the XPU environment. The model accuracy is the second processing accuracy.
[0097] In operation S330, KL divergence is calculated on the first and second vectors to obtain the relative entropy of the model parameters.
[0098] In operation S340, the difference between the first processing precision and the second processing precision is calculated to obtain the precision difference.
[0099] When operating the S350, an adjustment model is constructed based on using relative entropy as a feature value and precision difference as a label.
[0100] When operating S360, the target model parameters to be processed are determined based on the adjusted model.
[0101] In operation S370, the target model parameters are processed.
[0102] According to embodiments of this disclosure, operation S370 may include any one of operation S371 and operation S372, and may not be limited thereto.
[0103] When operating S371, the target model parameters are recorded in the blacklist of XPU running operators, so that the target model parameters are calculated based on the CPU.
[0104] In operation S372, the parameters of the target model are adjusted.
[0105] According to embodiments of this disclosure, the training data used to train the artificial intelligence model is the same in operations S310 and S320.
[0106] Through the above embodiments of this disclosure, the adaptation time of artificial intelligence models in different hardware environments can be effectively shortened in artificial intelligence model adaptation scenarios, and the generalization performance of artificial intelligence models for different hardware can be increased.
[0107] Figure 4 A block diagram of an artificial intelligence model adaptation device according to an embodiment of the present disclosure is shown schematically.
[0108] like Figure 4 As shown, the artificial intelligence model device 400 includes a first determining module 410, a second determining module 420, a third determining module 430, and a processing module 440.
[0109] The first determining module 410 is configured to determine the accuracy difference based on the first processing accuracy and the second processing accuracy of the artificial intelligence model in the first hardware environment in response to determining that the first processing accuracy of the artificial intelligence model in the first hardware environment is greater than the second processing accuracy of the artificial intelligence model in the second hardware environment, wherein the artificial intelligence model is trained in the first hardware environment.
[0110] The second determining module 420 is used to determine the relative entropy set of the model parameter set based on the first vector set obtained from the model parameter set of the artificial intelligence model in the first hardware environment and the second vector set obtained from the model parameter set in the second hardware environment.
[0111] The third determining module 430 is used to determine the target model parameters based on the accuracy difference and the relative entropy set.
[0112] The processing module 440 is used to adapt the artificial intelligence model to the second hardware environment by processing the target model parameters.
[0113] According to embodiments of this disclosure, there are multiple relative entropy sets, and the relative entropies in the relative entropy sets correspond one-to-one with the model parameters in the model parameter set. The third determining module includes a first determining unit, a second determining unit, and a third determining unit.
[0114] The first determining unit is used to determine the adjustment model based on the precision difference and the relative entropy set. The precision difference is the true label of the adjustment model, and the relative entropy in the relative entropy set is the feature value of the adjustment model. The relative entropy has an initial weight.
[0115] The second determining unit is used to determine the target weight of the relative entropy based on multiple relative entropy sets and the adjustment model.
[0116] The third determining unit is used to determine the target model parameters based on the target weights.
[0117] According to embodiments of this disclosure, the adjusted model is a regression model, and the multiple relative entropy sets include at least a first relative entropy set and a second relative entropy set. The second determining unit includes a first determining subunit, a second determining subunit, and a third determining subunit.
[0118] The first determining subunit is used to determine the first regression equation based on the first relative entropy set and the adjusted model.
[0119] The second determining subunit is used to determine the second regression equation based on the second relative entropy set and the adjusted model.
[0120] The third determining subunit is used to determine the target weights based on the first and second regression equations.
[0121] According to embodiments of this disclosure, the adjusted model is a neural network model. The second determining unit includes an obtaining subunit, an adjusting subunit, and a fourth determining subunit.
[0122] The sub-unit is obtained to input the relative entropy set into the neural network model to obtain the target accuracy when the neural network model has not converged.
[0123] The adjustment subunit is used to adjust the initial weights based on the target accuracy and the true label until the neural network model converges.
[0124] The fourth determination subunit is used to determine the target weights based on the weights in the converged neural network model.
[0125] According to embodiments of this disclosure, the third determining unit includes a fifth determining subunit and a sixth determining subunit.
[0126] The fifth determining subunit is used to determine the target relative entropy corresponding to the target weight in response to the determination that the target weight is greater than a preset threshold.
[0127] The sixth determining sub-unit is used to determine the model parameters corresponding to the target relative entropy based on the target relative entropy, and use them as target model parameters.
[0128] According to embodiments of this disclosure, the processing module includes an acquisition unit and a recording unit.
[0129] The acquisition unit is used to acquire the model accuracy of the trained model when the target model parameters are transferred to the central processing unit.
[0130] The recording unit is used to record the target model parameters into a blacklist in response to determining that the model accuracy meets the preset conditions, when the artificial intelligence model is migrated to a second hardware environment. The blacklist is used to record parameters calculated based on the central processing unit.
[0131] According to embodiments of this disclosure, the processing module includes a first obtaining unit, a replacement unit, and a first adjusting unit.
[0132] The first acquisition unit is used to train the artificial intelligence model that has been transferred to the second hardware environment multiple times using training data to obtain multiple first output values of the target model parameters.
[0133] The replacement unit is used to replace the target output value with a first target value that satisfies a Gaussian distribution in response to determining that there is a target output value among a plurality of first output values that does not satisfy a Gaussian distribution.
[0134] The first adjustment unit is used to adjust the target model parameters according to the first target value.
[0135] According to embodiments of this disclosure, the processing module further includes a second obtaining unit, a fourth determining unit, and a second adjusting unit.
[0136] The second acquisition unit is used to train the target model parameters, which have been transferred to the central processing unit associated with the second hardware environment, multiple times using training data to obtain multiple second output values of the target model parameters.
[0137] The fourth determining unit is used to determine the second target value based on multiple first output values and multiple second output values.
[0138] The second adjustment unit is used to adjust the target model parameters according to the second target value.
[0139] According to embodiments of this disclosure, the artificial intelligence model adaptation device further includes, prior to the second determining module: an acquisition module and an obtaining module.
[0140] The acquisition module is used to acquire the training data used by the artificial intelligence model. When the artificial intelligence model is trained using the training data in the first hardware environment, the output accuracy of the artificial intelligence model is the first processing accuracy.
[0141] The module is used to train the artificial intelligence model that has been transferred to the second hardware environment multiple times using training data to obtain multiple second vector sets. At least two of the training rounds are different.
[0142] According to embodiments of this disclosure, the second determining module includes a fifth determining unit, a sixth determining unit, a seventh determining unit, and an eighth determining unit.
[0143] The fifth determining unit is used to determine the first probability distribution of the first vector of the model parameter output for each model parameter in the model parameter set. The first vector is obtained from the model parameters based on the artificial intelligence model in the first hardware environment.
[0144] The sixth determining unit is used to determine the second probability distribution of the model parameter output second vector, which is obtained from the model parameters based on the artificial intelligence model in the second hardware environment.
[0145] The seventh determining unit is used to determine the relative entropy of the model parameters based on the first probability distribution and the second probability distribution.
[0146] The eighth determining unit is used to determine the relative entropy set based on the relative entropy of at least one model parameter in the model parameter set.
[0147] According to embodiments of this disclosure, the first hardware environment and the second hardware environment each include at least one of the following: processor processing speed, processor memory capacity, and processor transmission speed. The processor includes at least one of the following: graphics processor, tensor processor, and neural network processor.
[0148] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0149] According to an embodiment of the present disclosure, an electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the artificial intelligence model adaptation method of the present disclosure.
[0150] According to embodiments of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to execute the artificial intelligence model adaptation method of the present disclosure.
[0151] According to an embodiment of the present disclosure, a computer program product includes a computer program stored on at least one of a readable storage medium and an electronic device, wherein the computer program implements the artificial intelligence model adaptation method of the present disclosure when executed by a processor.
[0152] Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0153] like Figure 5 As shown, device 500 includes a computing unit 501, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 502 or a computer program loaded from storage unit 508 into random access memory (RAM) 503. RAM 503 may also store various programs and data required for the operation of device 500. The computing unit 501, ROM 502, and RAM 503 are interconnected via bus 504. Input / output (I / O) interface 505 is also connected to bus 504.
[0154] Multiple components in device 500 are connected to input / output (I / O) interface 505, including: input unit 506, such as keyboard, mouse, etc.; output unit 507, such as various types of monitors, speakers, etc.; storage unit 508, such as disk, optical disk, etc.; and communication unit 509, such as network card, modem, wireless transceiver, etc. Communication unit 509 allows device 500 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0155] The computing unit 501 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 501 performs the various methods and processes described above, such as the artificial intelligence model adaptation method. For example, in some embodiments, the artificial intelligence model adaptation method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on device 500 via ROM 502 and / or communication unit 509. When the computer program is loaded into RAM 503 and executed by the computing unit 501, one or more steps of the artificial intelligence model adaptation method described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the artificial intelligence model adaptation method by any other suitable means (e.g., by means of firmware).
[0156] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0157] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0158] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0159] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0160] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0161] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, distributed system servers, or servers incorporating blockchain technology.
[0162] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0163] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. An artificial intelligence model adaptation method, comprising: In response to determining that a first processing accuracy of the artificial intelligence model in a first hardware environment is greater than a second processing accuracy of the artificial intelligence model in a second hardware environment, an accuracy difference is determined based on the first processing accuracy and the second processing accuracy, wherein the artificial intelligence model is trained in the first hardware environment; Based on a first vector set obtained in the first hardware environment based on the model parameter set of the artificial intelligence model and a second vector set obtained in the second hardware environment based on the model parameter set, a relative entropy set of the model parameter set is determined. The number of relative entropy sets is multiple, and the relative entropy in the relative entropy set corresponds one-to-one with the model parameter in the model parameter set. Based on the precision difference and the relative entropy set, an adjustment model is determined, wherein the precision difference is the true label of the adjustment model, and the relative entropy in the relative entropy set is the feature value of the adjustment model, and the relative entropy has an initial weight. The target weight of the relative entropy is determined based on multiple sets of relative entropy and the adjustment model. Based on the target weights, determine the target model parameters; and By processing the parameters of the target model, the artificial intelligence model is adapted to the second hardware environment.
2. The method according to claim 1, wherein, The adjustment model is a regression model, and the multiple relative entropy sets include at least a first relative entropy set and a second relative entropy set; determining the target weight of the relative entropy based on the multiple relative entropy sets and the adjustment model includes: Based on the first relative entropy set and the adjustment model, determine the first regression equation; Based on the second relative entropy set and the adjusted model, determine the second regression equation; and The target weights are determined based on the first regression equation and the second regression equation.
3. The method according to claim 1, wherein, The adjustment model is a neural network model; determining the target weight of the relative entropy based on multiple relative entropy sets and the adjustment model includes: If the neural network model fails to converge, the relative entropy set is input into the neural network model to obtain the target accuracy. Based on the target accuracy and the true labels, the initial weights are adjusted until the neural network model converges; and The target weights are determined based on the weights in the converged neural network model.
4. The method according to any one of claims 1-3, wherein, The step of determining the target model parameters based on the target weights includes: In response to determining that the target weight is greater than a preset threshold, a target relative entropy corresponding to the target weight is determined; and Based on the target relative entropy, determine the model parameters corresponding to the target relative entropy, and use them as the target model parameters.
5. The method according to any one of claims 1-3, wherein, The step of adapting the artificial intelligence model to the second hardware environment by processing the target model parameters includes: By transferring the target model parameters to the central processing unit, the model accuracy of the trained model is obtained; and In response to determining that the model accuracy meets the preset conditions, when the artificial intelligence model is migrated to the second hardware environment, the target model parameters are recorded in a blacklist, which is used to record parameters calculated based on the central processing unit.
6. The method according to any one of claims 1-3, wherein, The step of adapting the artificial intelligence model to the second hardware environment by processing the target model parameters includes: The artificial intelligence model, which has been migrated to the second hardware environment, is trained multiple times using training data to obtain multiple first output values of the target model parameters; In response to determining that there is a target output value among the plurality of first output values that does not satisfy a Gaussian-like distribution, the target output value is replaced with a first target value, the first target value satisfying the Gaussian-like distribution; and The target model parameters are adjusted based on the first target value.
7. The method according to claim 6, wherein, The step of processing the target model parameters to adapt the artificial intelligence model to the second hardware environment further includes: The target model parameters, which have been migrated to the central processing unit associated with the second hardware environment, are trained multiple times using training data to obtain multiple second output values of the target model parameters; Based on the plurality of first output values and the plurality of second output values, a second target value is determined; and The target model parameters are adjusted based on the second target value.
8. The method according to any one of claims 1-3, further comprising, before determining the relative entropy set of the model parameter set: When the training data used by the artificial intelligence model is obtained, and the artificial intelligence model is trained using the training data in the first hardware environment, the output accuracy of the artificial intelligence model is the first processing accuracy; and The artificial intelligence model that has been migrated to the second hardware environment is trained multiple times using the training data to obtain multiple second vector sets, wherein at least two of the training rounds have different numbers.
9. The method according to any one of claims 1-3, wherein, The determination of the relative entropy set of the model parameter set includes: For each model parameter in the model parameter set, a first probability distribution of the model parameter output first vector is determined, wherein the first vector is obtained based on the model parameters of the artificial intelligence model in the first hardware environment; Determine the second probability distribution of the model parameter output second vector, wherein the second vector is obtained based on the model parameters of the artificial intelligence model in the second hardware environment; Based on the first probability distribution and the second probability distribution, determine the relative entropy of the model parameters; and The relative entropy set is determined based on the relative entropy of at least one model parameter in the model parameter set.
10. The method according to any one of claims 1-3, wherein, The first hardware environment and the second hardware environment each include at least one of the following: Processor processing speed, processor memory capacity, processor data transfer speed; The processor includes at least one of the following: a graphics processor, a tensor processor, and a neural network processor.
11. An artificial intelligence model adaptation device, comprising: A first determining module is configured to, in response to determining that a first processing accuracy of an artificial intelligence model in a first hardware environment is greater than a second processing accuracy of the artificial intelligence model in a second hardware environment, determine an accuracy difference based on the first processing accuracy and the second processing accuracy, wherein the artificial intelligence model is trained in the first hardware environment; The second determining module is used to determine the relative entropy set of the model parameter set based on the first vector set obtained in the first hardware environment based on the model parameter set of the artificial intelligence model and the second vector set obtained in the second hardware environment based on the model parameter set. The number of relative entropy sets is multiple, and the relative entropy in the relative entropy sets corresponds one-to-one with the model parameters in the model parameter set. The first determining unit is used to determine the adjustment model based on the precision difference and the relative entropy set, wherein the precision difference is the true label of the adjustment model, the relative entropy in the relative entropy set is the feature value of the adjustment model, and the relative entropy has an initial weight. The second determining unit is used to determine the target weight of the relative entropy based on multiple relative entropy sets and the adjustment model; The third determining unit is used to determine the target model parameters based on the target weights; and The processing module is used to adapt the artificial intelligence model to the second hardware environment by processing the parameters of the target model.
12. The apparatus according to claim 11, wherein, The adjustment model is a regression model, and the multiple relative entropy sets include at least a first relative entropy set and a second relative entropy set; The second determining unit includes: The first determining subunit is used to determine the first regression equation based on the first relative entropy set and the adjustment model; The second determining subunit is used to determine the second regression equation based on the second relative entropy set and the adjustment model; and The third determining subunit is used to determine the target weights based on the first regression equation and the second regression equation.
13. The apparatus according to claim 11, wherein, The adjustment model is a neural network model; the second determining unit includes: Obtain sub-units to input the relative entropy set into the neural network model to obtain the target accuracy when the neural network model has not converged; An adjustment subunit is used to adjust the initial weights based on the target accuracy and the true label until the neural network model converges; and The fourth determining subunit is used to determine the target weights based on the weights in the converged neural network model.
14. The apparatus according to any one of claims 11-13, wherein, The third determining unit includes: The fifth determining subunit is configured to, in response to determining that the target weight is greater than a preset threshold, determine the target relative entropy corresponding to the target weight; and The sixth determining subunit is used to determine the model parameters corresponding to the target relative entropy based on the target relative entropy, and use them as the target model parameters.
15. The apparatus according to any one of claims 11-13, wherein, The processing module includes: The acquisition unit is configured to acquire the model accuracy of the trained model after transferring the target model parameters to the central processing unit; and A recording unit is configured to, in response to determining that the model accuracy meets a preset condition, record the target model parameters in a blacklist when the artificial intelligence model is migrated to the second hardware environment. The blacklist is used to record parameters calculated based on the central processing unit.
16. The apparatus according to any one of claims 11-13, wherein, The processing module includes: The first obtaining unit is used to train the artificial intelligence model that has been migrated to the second hardware environment multiple times using training data to obtain multiple first output values of the target model parameters. A replacement unit is configured to, in response to determining that among the plurality of first output values there is a target output value that does not satisfy a Gaussian-like distribution, replace the target output value with a first target value, wherein the first target value satisfies the Gaussian-like distribution; and The first adjustment unit is used to adjust the target model parameters according to the first target value.
17. The apparatus according to claim 16, wherein, The processing module further includes: The second obtaining unit is used to train the target model parameters, which have been migrated to the central processing unit associated with the second hardware environment, multiple times using training data to obtain multiple second output values of the target model parameters. The fourth determining unit is configured to determine a second target value based on the plurality of first output values and the plurality of second output values; and The second adjustment unit is used to adjust the target model parameters according to the second target value.
18. The apparatus according to any one of claims 11-13, further comprising, prior to the second determining module: The acquisition module is configured to acquire the training data used by the artificial intelligence model, wherein, when the artificial intelligence model is trained using the training data in the first hardware environment, the output accuracy of the artificial intelligence model is the first processing accuracy; and The module is used to train the artificial intelligence model that has been migrated to the second hardware environment multiple times using the training data to obtain multiple second vector sets, wherein at least two of the multiple training sessions have different training rounds.
19. The apparatus according to any one of claims 11-13, wherein, The second determining module includes: The fifth determining unit is used to determine a first probability distribution of the model parameter output first vector for each model parameter in the model parameter set, wherein the first vector is obtained based on the model parameters of the artificial intelligence model in the first hardware environment; The sixth determining unit is used to determine the second probability distribution of the model parameter output second vector, wherein the second vector is obtained based on the model parameters of the artificial intelligence model in the second hardware environment; The seventh determining unit is configured to determine the relative entropy of the model parameters based on the first probability distribution and the second probability distribution; and The eighth determining unit is used to determine the relative entropy set based on the relative entropy of at least one model parameter in the model parameter set.
20. The apparatus according to any one of claims 11-13, wherein, The first hardware environment and the second hardware environment each include at least one of the following: Processor processing speed, processor memory capacity, processor data transfer speed; The processor includes at least one of the following: a graphics processor, a tensor processor, and a neural network processor.
21. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the method of any one of claims 1-10.
22. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-10.
23. A computer program product comprising a computer program stored on at least one of a readable storage medium and an electronic device, wherein the computer program, when executed by a processor, implements the method according to any one of claims 1-10.