Method and device for obtaining model structure
By dynamically selecting the sampling method in the iterative training of the BERT model set and using sampling probability to optimize sub-model training, the problems of insufficient BERT model training efficiency and accuracy are solved, and efficient and low-cost model deployment is achieved.
Patent Information
- Application Number
- CN202210317094.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-29
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2042-03-29
AI Technical Summary
The training efficiency or training accuracy of the BERT model in existing technologies is poor, and the computational overhead in building the model to be deployed is large, resulting in increased computing power costs.
By dynamically selecting the appropriate sampling method during the iterative training of the model set, using the first sampling probability and the second sampling probability to guide the training and search of the sub-model in the model set, optimizing the sampling method to improve training efficiency and accuracy, and selecting the target sub-model according to the computing power resource constraints.
The training efficiency and accuracy of the model set are improved, the computational overhead is reduced, additional sub-model accuracy verification operations are avoided, and the computing resource constraints of electronic devices are met.
Smart Images

Figure CN114707592B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and device for acquiring a model structure, a method and device for determining a model based on hardware computing power constraints, a method and device for semantic recognition, an electronic device, and a machine-readable medium. Background Art
[0002] The Bidirectional Encoder Representation from Transformers (BERT) technology can learn a large amount of data structured information through self-supervised pre-training on a large amount of unlabeled training data. Therefore, it can achieve high accuracy in downstream tasks such as data classification and data matching, and has been widely used.
[0003] At present, to apply the BERT model to a specific deployment environment, it is necessary to sample local structures (sub-models) from the BERT model through a fixed sampling method for training, and extract local structures from the trained BERT model to form a model to be deployed that meets the computing power constraints of the deployment environment. Finally, the model to be deployed can be deployed in the environment for use.
[0004] However, the current solution uses a fixed sampling method to train the BERT model, which results in poor training efficiency or accuracy. In addition, during the construction of the model to be deployed, it is necessary to evaluate the effectiveness of extracting local structures, which will generate more computational overhead and increase computing power costs. Summary of the Invention
[0005] The embodiments of the present application provide a method for acquiring a model structure, a method for determining a model based on hardware computing power constraints, and a method for semantic recognition to solve the problems of poor training efficiency or training accuracy and increased computing power costs in related technologies.
[0006] Correspondingly, the embodiments of the present application also provide a device for acquiring a model structure, a device for determining a model based on hardware computing power constraints, a semantic recognition device, an electronic device, and a storage medium to ensure the implementation and application of the above method.
[0007] In order to solve the above problems, an embodiment of the present application discloses a method for obtaining a model structure, the method comprising:
[0008] During iterative training of a model set including a plurality of sub-models, selecting a target sampling method for a second iterative operation from at least two preset sampling methods based on a first sampling probability of the sub-model after a first iterative operation; the second iterative operation being the next iterative operation of the first iterative operation;
[0009] After performing at least one iterative operation, obtaining a second sampling probability of the sub-model in the model set;
[0010] According to the computing power resource constraint of the target device and the second sampling probability, a target sub-model is selected from the model set, and a target model is obtained according to the target sub-network.
[0011] The present application discloses a method for determining a model based on hardware computing power constraints, the method comprising:
[0012] Obtaining computing power resource constraints of electronic devices;
[0013] During iterative training of a model set including a plurality of sub-models, selecting a target sampling method for a second iterative operation from at least two preset sampling methods based on a first sampling probability of the sub-model after a first iterative operation; the second iterative operation being the next iterative operation of the first iterative operation;
[0014] After performing at least one iterative operation, obtaining a second sampling probability of the sub-model in the model set;
[0015] According to the computing power resource constraint value of the electronic device and the second sampling probability, a target sub-model is selected from the model set to form a target model for use by the electronic device, and the sum of the resource requirements of the target sub-models is less than or equal to the computing power resource constraint value.
[0016] The present application discloses a semantic recognition method, including:
[0017] Obtain the corpus to be recognized;
[0018] Inputting the to-be-recognized corpus into a target model to obtain a semantic recognition result of the to-be-recognized corpus;
[0019] The target model is determined based on the above-mentioned acquisition method of the model structure.
[0020] The present application discloses a device for obtaining a model structure, the device comprising:
[0021] A first selection module is configured to select, during iterative training of a model set including a plurality of sub-models, a target sampling method for a second iterative operation from at least two preset sampling methods based on a first sampling probability of the sub-model after the first iterative operation; the second iterative operation being the next iterative operation after the first iterative operation;
[0022] A first terminating iteration module is configured to obtain a second sampling probability of a sub-model in the model set after performing at least one iterative operation;
[0023] The first construction module is used to select a target sub-model from the model set according to the computing resource constraint of the target device and the second sampling probability, and obtain the target model according to the target sub-network.
[0024] The embodiment of the present application discloses a model determination device based on hardware computing power constraints, comprising:
[0025] A first acquisition module is used to obtain a computing resource constraint value of an electronic device;
[0026] a second selection module configured to select, during iterative training of a model set including a plurality of sub-models, a target sampling method for a second iterative operation from at least two preset sampling methods based on a first sampling probability of the sub-model after the first iterative operation; wherein the second iterative operation is the next iterative operation after the first iterative operation;
[0027] A second terminating iteration module is configured to obtain a second sampling probability of a sub-model in the model set after performing at least one iterative operation;
[0028] The second construction module is used to select a target sub-model from the model set to form a target model for use by the electronic device based on the computing power resource constraint value of the electronic device and the second sampling probability, and the sum of the resource requirements of the target sub-models is less than or equal to the computing power resource constraint value.
[0029] The present application discloses a semantic recognition device, comprising:
[0030] The second acquisition module is used to obtain the corpus to be recognized;
[0031] A recognition module, configured to input the to-be-recognized corpus into a target model to obtain a semantic recognition result of the to-be-recognized corpus;
[0032] The target model is determined by an acquisition device based on the above-mentioned model structure.
[0033] An embodiment of the present application further discloses an electronic device, comprising: a processor; and a memory on which executable code is stored. When the executable code is executed, the processor executes one or more methods described in the embodiments of the present application.
[0034] The embodiments of the present application also disclose one or more machine-readable media on which executable codes are stored. When the executable codes are executed, the processor executes one or more methods described in the embodiments of the present application.
[0035] Compared with the related art, the embodiments of the present application have the following advantages:
[0036] In an embodiment of the present application, the training efficiency and accuracy of the model set can be improved by dynamically selecting a suitable sampling method for each iterative operation during multiple iterative training of the model set, so that the model set and its sub-models are fully trained to a convergence state with high efficiency and high accuracy, thereby solving the problem of poor training efficiency or training accuracy caused by training using a fixed sampling method. In addition, the embodiment of the present application can also quantify the training accuracy of the sub-model through a second sampling probability, and then in the process of model search for the model set, the second sampling probability is directly used as a guiding parameter for selecting the target sub-model, and the target sub-model is selected to form a target model that meets the computing power resource constraints of the target device, so that the model acquisition process does not require additional sub-model accuracy verification operations, thereby reducing computational overhead. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is an architectural diagram of a method for obtaining a model structure according to an embodiment of the present application;
[0038] Figure 2 This is a structural block diagram of a model set in an embodiment of the present application;
[0039] Figure 3 This is a schematic structural diagram of a sub-model according to an embodiment of the present application;
[0040] Figure 4 This is a schematic diagram of an application of a method for obtaining a model structure in an embodiment of the present application in a text processing scenario;
[0041] Figure 5 This is a schematic diagram of an application of a method for obtaining a model structure in an image processing scenario according to an embodiment of the present application;
[0042] Figure 6 This is a schematic diagram of an application of a method for obtaining a model structure in an audio processing scenario according to an embodiment of the present application;
[0043] Figure 7 This is a flowchart of the steps of a method for obtaining a model structure according to an embodiment of the present application;
[0044] Figure 8 This is a flowchart of a method for determining a model based on hardware computing power constraints according to an embodiment of the present application;
[0045] Figure 9 This is a flowchart of a semantic recognition method embodiment of the present application;
[0046] Figure 10 This is a flowchart of another method for obtaining a model structure according to an embodiment of the present application;
[0047] Figure 11 This is a block diagram of a device for obtaining a model structure according to an embodiment of the present application;
[0048] Figure 12 This is a block diagram of a model determination device based on hardware computing power constraints according to an embodiment of the present application;
[0049] Figure 13 is a block diagram of a semantic recognition device according to an embodiment of the present application;
[0050] Figure 14 It is a structural diagram of a device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0051] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0052] To help those skilled in the art better understand this application, the concepts involved in this application are explained below:
[0053] BERT model: It is a pre-trained language representation model. It no longer uses the traditional unidirectional language model for pre-training, or the shallow splicing of two unidirectional language models for pre-training. Instead, it adopts a new masked language model (MLM) to generate deep bidirectional language representations. The BERT model uses a deep bidirectional transformer (Transformer) component to build the entire model, and ultimately generates a deep bidirectional language representation that can integrate left and right context information.
[0054] Sub-model: also known as sub-network, is a local structure in the BERT model. The sub-model can exist independently and can realize data input, calculation and result output.
[0055] SuperNet: A structural assembly consisting of all sub-model structures, which can provide an overall space for subsequent model search, that is, the model collection of this application.
[0056] Model Search: A method that uses Neural Architecture Search (NAS) to automatically search and select suitable model structures through modeling design.
[0057] Search space: The size of the hypernetwork used to implement model search. Specifically, it is a search range built based on size parameters. For example, a search space can be constructed by the number of layers in the model, the number of channels per layer, and the number of attention weights.
[0058] Word Embedding: In text processing scenarios, high-dimensional vectors are used to represent words in natural language. This is used to convert natural language text sequences, that is, one or more sentences consisting of words, into vector sequences for input into neural network models for calculation.
[0059] Sampling method: The training process of the hypernetwork is to select various sub-models from the hypernetwork for training through multiple rounds of iterations. Finally, the hypernetwork is fully trained to a convergent state, and any sampled sub-models are also trained to a convergent state. The sampling method is the way to select which sub-models from the hypernetwork.
[0060] Bernoulli distribution: Also known as the two-point distribution or the 0-1 distribution, a random variable with only two possible outcomes, such as heads or tails on a tossed coin, a defective or non-defective object, or a patient's recovery or failure, is called a Bernoulli random variable.
[0061] Computing resource constraints: Since different electronic devices have different hardware resources, the size of the model deployment space that different hardware can provide is also different. The computing resource constraints reflect this limitation on the size of the model deployment space.
[0062] The embodiments of the present application can be applied to constructing a target model that meets the computing power resource constraints of electronic devices so as to deploy the target model in the scenario of the electronic device. In this scenario, when iteratively training a model set (hypernetwork) with a large search space, the training efficiency and accuracy of the model set with a large search space can be improved by selecting a suitable sampling method, so that the model set and its sub-models are fully trained to a convergence state with high efficiency and high accuracy. Afterwards, the model set can be searched for according to the computing power resource constraints of different electronic devices in the scenario, and the target sub-models therein are selected to form a target model that meets the computing power resource constraints. Finally, the target model can be sent to the electronic device for deployment.
[0063] Specifically, refer to Figure 1 , which shows an architecture diagram of a method for obtaining a model structure provided in an embodiment of the present application, Figure 1 The server shown includes: a search space design module, a training module, and a resource constraint-based model building module.
[0064] The search space design module defines the structure of the BERT model based on parameters. The BERT model offers multiple structural options, primarily in terms of the number of layers (M) and the number of channels (x) per neural network layer. The search space design module constructs a search space based on these parameters, effectively designing the range of options for the relevant dimensions of the BERT model structure. Furthermore, the search space design module can also set the model's input structure. For example, in a text processing environment, the model's input can be set as a sequence of word embedding vectors.
[0065] The training module can complete the parameter convergence of the entire model set and its sub-models through multiple rounds of iterative training, thereby obtaining a trained model set.
[0066] The model building module based on resource constraints can obtain the computing resource constraints of the electronic device for model deployment, and perform a model search operation based on the computing resource constraints and the second sampling probability. Specifically, it selects a target sub-model that meets the accuracy requirements and computing resource constraints from the model set, and obtains the target model based on the target sub-network. Finally, the target model can be sent to the electronic device for deployment. For example, Figure 1 Finally, the structure of sub-model a + sub-model b is searched as the structure of the target model.
[0067] In the examples of this application, refer to Figure 2 , which shows a structural block diagram of a model set provided by an embodiment of the present application. Each row in the model set represents a layer of the model set. The first layer is the input layer of the model set. A node in a layer is used to reflect a neuron. The number of neurons in a layer is the number of channels in the layer. Figure 2 In the example of the model set shown, the model set includes 3 layers, each layer includes 3 neurons, and the connecting lines between neurons in two adjacent layers are used to represent the input-output relationship between neurons. By selecting neurons in the model set to form a local structure, a sub-model can be obtained.
[0068] For example, refer to Figure 3 , which shows a schematic diagram of the structure of a sub-model provided in an embodiment of the present application, based on Figure 2 The model set shown can select neurons a and b in the first layer to form sub-model (1); based on the model set, neurons a and b in the first layer, and neuron d in the second layer are selected to form sub-model (2); based on the model set, neurons a, b and c in the first layer, neurons d and e in the second layer, and neurons g and h in the third layer are selected to form sub-model (3). Figure 3 Only three sub-model structures among all the sub-model structures are shown, and the remaining sub-model structures are not shown one by one.
[0069] The training objectives of the model have two demands: short training time and small computational complexity, and high training accuracy. These two demands are mutually exclusive. Specifically, if a high training accuracy is maintained, a larger search space needs to be set, but a larger search space will lead to increased training time and computational complexity. Therefore, how to avoid excessive training overhead and maintain a sufficiently large search space to obtain sufficiently good training accuracy is an important issue that needs to be solved in the embodiments of this application.
[0070] In practical applications, model accuracy is a key requirement, requiring a large search space. Optimization strategies aim to maintain high model accuracy within this large search space. Compression techniques such as pruning, quantization, and distillation can reduce computational complexity while maintaining model accuracy. However, these processes require extensive manual effort to pre-design the appropriate compression space, which results in a loss of flexibility in the compressed model and consumes significant resources to adjust architectural parameters. This compression effort is tedious and incurs significant costs.
[0071] In an embodiment of the present application, a BERT model search can be performed based on NAS technology. This technology can reduce reliance on manual parameter adjustment, save compression costs, and have a larger search space to ensure model accuracy, as well as adaptively adjust parameters to improve training efficiency. The model search process of the embodiment of the present application includes: process 1, model training based on selecting an appropriate sampling method and joint optimization of model parameters during training; process 2, target model construction based on computing resource constraints.
[0072] For process 1, the training module needs to select a sub-model from the model set for training in each iterative training. This process is called sampling training of the sub-model. The training module of the embodiment of the present application can provide two sampling methods: uniform sampling method (random sampling) and optimized sampling method, and based on the results of the previous iterative training, select the target sampling method from the two sampling methods through the strategy selection function to use the target sampling method as the sampling method adopted in the current iterative training.
[0073] in, Figure 1 The uniform sampling method shown can sample sub-models m with a fixed sampling probability π, so that each sub-model has the same probability of being selected for training. This has a high sampling exploration range for the sub-models. However, this method will lead to a long overall training convergence time when using a large search space. Figure 1 The optimization sampling method shown models the search space as a linear probability distribution function is the probability distribution parameter, m is the sub-model, and the optimized sampling method can give priority to training sub-models with better structures (better training effects). When using this method, it is possible that the sub-model with the global optimal structure has not converged in the early stage of training, resulting in premature focus on the local sub-optimal structure sub-model for repeated sampling and training, and lack of sampling exploration of the remaining sub-models, making it impossible to search for the truly global optimal sub-model structure, thus falling into the local optimum.
[0074] According to the analysis, the problem of local optimality caused by the optimized sampling method is the lack of sampling exploration of the sub-model during the solution process. This problem can be improved by introducing a uniform sampling method. The training module of the embodiment of the present application can quantify a probability distribution parameter θ (first sampling probability) to reflect the training quality of the sub-model after an iterative operation, and determine the sampling effect score of the iterative operation based on the probability distribution parameter θ. The probability distribution parameter θ is specifically the sampling probability for the sub-model in the function constructed by the optimized sampling method. Finally, based on the sampling effect score of the previous iterative training, the target sampling method is selected from the two sampling methods through the strategy selection function, so that the target sampling method is used as the sampling method adopted in the current iterative training. The strategy selection function can achieve the purpose of switching between the optimized sampling method and the uniform sampling method, so that various sub-models can be fully explored during sampling, and those sub-models with more advantages can be trained intensively.
[0075] The embodiment of the present application can make each round of iterative training have its own appropriate sampling method through the above-mentioned method, so as to solve the problem of excessive training time caused by repeated random sampling, and also solve the problem of the network falling into local optimum caused by repeated optimization sampling. In addition, since the embodiment of the present application uses the probability distribution parameter θ as a trainable and optimized model parameter, the joint optimization of the probability distribution parameter θ and the weight parameter of the model set itself during the training process is achieved. After the training module completes the training of the model set, the sub-models in the model set all have their own trained probability distribution parameter θ (second sampling probability). The second sampling probability can be used to reflect the training accuracy of the sub-model, so that the quality of the sub-model has a quantitative performance, which is helpful to carry out subsequent model search operations based on computing resource constraints.
[0076] Among them, in mathematical concepts, the above-mentioned local optimum refers to the solution to a problem being optimal within a certain range or region, or the means of solving the problem or achieving the goal being optimal within a certain range or limitation; and the above-mentioned global optimum refers to a problem / goal under certain conditions / environment, if a decision is optimal compared with all decisions to solve the problem.
[0077] Regarding the target model construction proposed in process 2 above, the relevant technology can use a one-by-one traversal method to perform accuracy testing on each sub-model in the trained model set to obtain the quality score of the sub-model, and then select the target sub-model under the constraints of computing power resources, and obtain the target model based on the target sub-network. However, this method requires the use of a large number of test data sets in the test verification process, resulting in excessive overhead in accuracy testing.
[0078] In an embodiment of the present application, after the model set training is completed, the probability distribution parameters θ (second sampling probability) of the trained sub-models can be used to reflect the training accuracy of the sub-model, so that the quality of the sub-model has a quantitative expression. Therefore, the model building module based on resource constraints can obtain the computing power resource constraints of the electronic device for model deployment, and perform model search operations based on the computing power resource constraints and the second sampling probability of the sub-model. Specifically, the second sampling probability is directly used as the guiding parameter for selecting the target sub-model, and the target sub-model that meets the accuracy requirements and computing power resource constraints is selected from the model set, and the target model is obtained according to the target sub-network. These processes eliminate the overhead of accuracy testing and reduce the amount of calculation. In addition, the parameters of the model itself (weights, etc.) do not need to be retrained in these processes, thereby achieving a sub-model structure that meets the requirements of different resources through one training, further reducing the amount of calculation.
[0079] In one implementation, referring to Figure 4 , which shows a schematic diagram of the application of a model structure acquisition method provided by an embodiment of the present application in a text processing scenario. The embodiment of the present application can select a target sub-model from a unified model set obtained based on text processing training based on the computing power resource constraint value of the electronic device to construct a text processing model that meets the computing power requirements of the electronic device. Assuming that the electronic device includes a mobile terminal, a personal computer, and a computing server, the embodiment of the present application can extract multiple different text processing models from a unified model set based on the different computing power resource constraints of the mobile terminal, the personal computer, and the computing server, and correspond one-to-one to the mobile terminal, the personal computer, and the computing server.
[0080] Specifically, Figure 4The application diagram in the text processing scenario is shown. In this scenario, the BERT model can learn a large amount of natural language structured information through the process of self-supervised pre-training on a large amount of unlabeled language data. After the text processing model 1 is deployed on the mobile terminal, the corpus to be recognized can be converted into a word embedding vector sequence and input into the text processing model 1 to obtain the recognition result of the corpus to be recognized output by the text processing model 1. The recognition result can be further applied to subsequent text classification, text matching and other scenarios to improve the text processing accuracy of these scenarios. The recognition result of the corpus to be recognized is actually a vector sequence with stronger semantic information. The application method of the text processing model in personal computers and computing servers is similar, and will not be repeated in the embodiments of this application.
[0081] In another implementation, referring to Figure 5 , which shows a schematic diagram of the application of a method for obtaining a model structure provided by an embodiment of the present application in an image processing scenario. Assuming that the electronic device includes a mobile terminal, a personal computer, and a computing server, the embodiment of the present application can extract a plurality of different image processing models from the trained model set based on the different computing resource constraints of the mobile terminal, the personal computer, and the computing server, and correspond one-to-one with the mobile terminal, the personal computer, and the computing server. After the image processing model 1 is deployed on the mobile terminal, features of the image to be identified can be extracted, and a sequence of image feature vectors can be constructed and input into the image processing model 1 to obtain the recognition result of the image to be identified output by the image processing model 1. The recognition result can be further applied to subsequent image classification, image matching and other scenarios to improve the image processing accuracy of these scenarios. The application method of the image processing model in the personal computer and the computing server is similar, and will not be elaborated in the embodiment of the present application.
[0082] In another implementation, referring to Figure 6 , which shows a schematic diagram of the application of a method for obtaining a model structure provided by an embodiment of the present application in an audio processing scenario. Assuming that the electronic device includes a mobile terminal, a personal computer, and a computing server, the embodiment of the present application can extract a plurality of different audio processing models from the trained model set based on the different computing resource constraints of the mobile terminal, the personal computer, and the computing server, and correspond one-to-one with the mobile terminal, the personal computer, and the computing server. After the audio processing model 1 is deployed on the mobile terminal, the features of the audio to be identified can be extracted, and an audio feature vector sequence can be constructed and input into the audio processing model 1 to obtain the recognition result of the audio to be identified output by the audio processing model 1. The recognition result can be further applied to subsequent audio classification, audio matching and other scenarios to improve the audio processing accuracy of these scenarios. The application method of the audio processing model in the personal computer and the computing server is similar, and will not be elaborated in the embodiment of the present application.
[0083] It should be noted that in the embodiments of the present application, the process of obtaining the training data (text, images, audio, etc.) used in training the model set, the objects to be identified (text, images, audio, etc.) input during the application of the target model, and other information, signals or data used are all carried out in compliance with the relevant data protection laws and policies of the country where they are located, and with the authorization given by the owner of the corresponding device.
[0084] In an embodiment of the present application, the training efficiency and accuracy of the model set can be improved by dynamically selecting a suitable sampling method for each iterative operation during multiple iterative training of the model set, so that the model set and its sub-models are fully trained to a convergence state with high efficiency and high accuracy, thereby solving the problem of poor training efficiency or training accuracy caused by training using a fixed sampling method. In addition, the embodiment of the present application can also quantify the training accuracy of the sub-model through a second sampling probability, and then in the process of model search for the model set, the second sampling probability is directly used as a guiding parameter for selecting the target sub-model, and the target sub-model is selected to form a target model that meets the computing resource constraint conditions, so that the model acquisition process does not require additional sub-model accuracy verification operations, thereby reducing computational overhead.
[0085] Reference Figure 7 , which shows a flowchart of the steps of a method for obtaining a model structure provided by an embodiment of the present application, including:
[0086] Step 101: During iterative training of a model set including multiple sub-models, a target sampling method for a second iterative operation is selected from at least two preset sampling methods based on the first sampling probability of the sub-model after the first iterative operation; the second iterative operation is the next iterative operation of the first iterative operation.
[0087] In the embodiment of the present application, a probability distribution parameter θ (first sampling probability) can be quantified to reflect the training quality of the sub-model after one iterative operation, and the probability distribution parameter θ is used as a guiding parameter for selecting the sampling method corresponding to the iterative operation. The probability distribution parameter θ is specifically the sampling probability for the sub-model in the function constructed by the optimized sampling method. The optimized sampling method can model the search space as a linear probability distribution function The optimized sampling method can give priority to training sub-models with better structures (better training effects). That is, after each iteration, each sub-model in the model set will obtain a probability distribution parameter θ. The larger the probability distribution parameter θ, the higher the training accuracy of the sub-model, that is, the greater the probability of the sub-model being selected by the optimized sampling method. Among them, the probability distribution parameters θ of all sub-models can be used to obtain a sampling effect score using the cumulative value of the information entropy (the sampling effect score can also be calculated using the accuracy of the sub-network and fixed empirical parameters). The sampling effect score is used to reflect the uncertainty of the probability distribution parameter θ. The smaller the sampling effect score, the smaller the uncertainty of the probability distribution parameter θ, which makes it less likely that the next iteration will use the optimized sampling method (the smaller the uncertainty of the probability distribution parameter θ after the previous iteration, the more likely it is that the average sampling method will be used in subsequent iterations to increase the sampling exploration range of the sub-model and avoid falling into local optimality); the larger the sampling effect score, the greater the uncertainty, which makes it more likely that the next iteration will use the optimized sampling method (the greater the uncertainty of the probability distribution parameter θ after the previous iteration, the more likely it is that the optimized sampling method will be used in subsequent iterations to improve the training accuracy of the sub-model, thereby reducing the uncertainty of the probability distribution parameter θ).
[0088] From the above discussion, it can be seen that the first sampling probability of the sub-model after the first iterative operation is completed can guide the sampling method selected for the second iterative operation. Therefore, the embodiment of the present application can achieve the purpose of dynamic switching of sampling methods by selecting the target sampling method adopted by the second iterative operation from at least two preset sampling methods, so that various sub-models can be fully explored during sampling, and those sub-models with more advantages can be trained intensively, so that each round of iterative training has its own sampling method. This can solve the problem of long training time caused by repeated random sampling, and can also solve the problem of the network falling into local optimality caused by repeated optimization sampling.
[0089] Step 102: After performing at least one iteration operation, obtain a second sampling probability of the sub-model in the model set.
[0090] In an embodiment of the present application, after executing at least one iterative operation to complete the training of the model set, the probability distribution parameter θ of the sub-model in the model set can be used as the second sampling probability of the sub-model to reflect the training accuracy of the sub-model. The larger the second sampling probability, the higher the training accuracy of the sub-model, so that the quality of the sub-model has a quantitative expression, which is helpful to carry out subsequent model search operations based on computing power resource constraints.
[0091] It should be noted that at the end of each iteration, the sampling probability of each sub-model can be constructed into a probability distribution, referring to Figure 1, after executing at least one iterative operation to complete the training of the model set, the second sampling probability of each sub-model can be constructed to obtain a linear distribution.
[0092] Step 103: Select a target sub-model from the model set according to the computing resource constraint of the target device and the second sampling probability, and obtain a target model according to the target sub-network.
[0093] Given the varying hardware resources of different electronic devices, model deployment must also meet the computing resource constraints of each device. Therefore, it is necessary to refine target models of varying magnitudes based on the model set to meet these constraints. For example, a high-computing-power, heavyweight target model can be established for computing servers with strong computing power, while a low-computing, lightweight target model can be established for mobile terminals with weaker computing power. Target devices can include smart devices, mobile terminals, servers, or server clusters.
[0094] In an embodiment of the present application, the computing power resource constraints of the electronic device for model deployment can be obtained, and a model search operation can be performed based on the computing power resource constraints and the second sampling probability. Specifically, a target sub-model that meets the accuracy requirements and computing power resource constraints is selected from the model set, and the target model is obtained based on the target sub-network. Finally, the target model can be sent to the electronic device for deployment.
[0095] After the model set training is completed, the second sampling probability of each sub-model trained can be directly used as a guiding parameter for selecting the target sub-model. The target sub-model that meets the accuracy requirements and computing power resource constraints is selected from the model set, and the target model is obtained based on the target sub-network. These processes save the overhead of accuracy verification and reduce the amount of calculation.
[0096] To sum up, in the embodiment of the present application, in the process of multiple iterative training of the model set, the training efficiency and accuracy of the model set can be improved by dynamically selecting a suitable sampling method for each iterative operation, so that the model set and the sub-models therein are fully trained to a convergence state with high efficiency and high accuracy, thereby solving the problem of poor training efficiency or training accuracy caused by training using a fixed sampling method. In addition, the embodiment of the present application can also quantify the training accuracy of the sub-model through a second sampling probability, and then in the process of model search for the model set, the second sampling probability is directly used as a guiding parameter for selecting the target sub-model, and the target sub-model is selected to form a target model that meets the computing resource constraint conditions, so that the model acquisition process does not require additional sub-model accuracy verification operations, thereby reducing computational overhead.
[0097] Reference Figure 8, shows a flowchart of the steps of an embodiment of the model determination method based on hardware computing power constraints of the present application. It includes:
[0098] Step 201: Obtain the computing resource constraint value of the electronic device.
[0099] Step 202: During the iterative training of a model set including multiple sub-models, a target sampling method for a second iterative operation is selected from at least two preset sampling methods based on the first sampling probability of the sub-model after the first iterative operation; the second iterative operation is the next iterative operation of the first iterative operation.
[0100] Step 203: After performing at least one iteration operation, obtain a second sampling probability of the sub-model in the model set.
[0101] Step 204: Based on the computing power resource constraint value of the electronic device and the second sampling probability, select a target sub-model from the model set to form a target model for use by the electronic device, and the sum of the resource requirements of the target sub-models is less than or equal to the computing power resource constraint value.
[0102] The embodiments of the present application can be applied to constructing a target model that meets the computing power resource constraints of electronic devices so as to deploy the target model in the scenario of the electronic device. In this scenario, when iteratively training a model set (hypernetwork) with a large search space, the training efficiency and accuracy of the model set with a large search space can be improved by selecting a suitable sampling method, so that the model set and its sub-models are fully trained to a convergence state with high efficiency and high accuracy. Afterwards, the model set can be searched for according to the computing power resource constraints of different electronic devices in the scenario, and the target sub-models therein are selected to form a target model that meets the computing power resource constraints. Finally, the target model can be sent to the electronic device for deployment.
[0103] To sum up, in the embodiment of the present application, in the process of multiple iterative training of the model set, the training efficiency and accuracy of the model set can be improved by dynamically selecting a suitable sampling method for each iterative operation, so that the model set and the sub-models therein are fully trained to a convergence state with high efficiency and high accuracy, thereby solving the problem of poor training efficiency or training accuracy caused by training using a fixed sampling method. In addition, the embodiment of the present application can also quantify the training accuracy of the sub-model through a second sampling probability, and then in the process of model search for the model set, the second sampling probability is directly used as a guiding parameter for selecting the target sub-model, and the target sub-model is selected to form a target model that meets the computing resource constraint conditions, so that the model acquisition process does not require additional sub-model accuracy verification operations, thereby reducing computational overhead.
[0104] Reference Figure 9 , shows a flowchart of the steps of an embodiment of a semantic recognition method of the present application. It includes:
[0105] Step 301: Obtain corpus to be recognized.
[0106] Step 302: Input the corpus to be recognized into the target model to obtain a semantic recognition result of the corpus to be recognized.
[0107] The target model is determined based on the above-mentioned acquisition method of the model structure.
[0108] In the examples of this application, refer to Figure 4 In the text processing scenario shown, after the electronic device deploys the target model based on text processing, it can convert the corpus to be recognized into a sequence of word embedding vectors and input it into the target model to obtain the semantic recognition results of the corpus to be recognized output by the target model. The semantic recognition results can be further applied to subsequent text classification, text matching and other scenarios to improve the text processing accuracy of these scenarios. In addition, the embodiments of the present application can also be applied to other scenarios, such as Figure 5 The image processing scenario shown and Figure 6 The audio processing scenario shown is not described in detail in this embodiment of the application.
[0109] To sum up, in the embodiment of the present application, in the process of multiple iterative training of the model set, the training efficiency and accuracy of the model set can be improved by dynamically selecting a suitable sampling method for each iterative operation, so that the model set and the sub-models therein are fully trained to a convergence state with high efficiency and high accuracy, thereby solving the problem of poor training efficiency or training accuracy caused by training using a fixed sampling method. In addition, the embodiment of the present application can also quantify the training accuracy of the sub-model through a second sampling probability, and then in the process of model search for the model set, the second sampling probability is directly used as a guiding parameter for selecting the target sub-model, and the target sub-model is selected to form a target model that meets the computing resource constraint conditions, so that the model acquisition process does not require additional sub-model accuracy verification operations, thereby reducing computational overhead.
[0110] Reference Figure 10 , shows a flowchart of another embodiment of a method for obtaining a model structure of the present application. It includes:
[0111] Step 401: Obtain a selection range of network structure parameters.
[0112] Step 402: Establish a model set including multiple sub-models according to the selection range of the network structure parameters.
[0113] Optionally, the network structure parameters include: one or more of the total number of network layers, the number of channels in each network layer, and the number of attention weights; and the multiple optional values in the selection range are distributed in a step-by-step increasing manner.
[0114] Regarding steps 401-402, before performing a structural search on the model, the network structure of the model set can be defined based on parameters. There are multiple network structure options, with the main selection dimensions being the number of layers M and the number of channels x per neural network layer. Constructing a search space based on these parameters is crucial for designing the range of options for the relevant dimensions of the model set's network structure. Furthermore, the model's input structure can be set. For example, in a text processing environment, the model input can be set as a sequence of word embedding vectors.
[0115] Specifically, the network structure parameters include: the total number of network layers, the number of channels in each layer, and the number of attention weights, for example, Figure 2 The structure of the model set shown is: the model set includes 3 layers, each layer includes 3 neurons, and the connecting lines between neurons in two adjacent layers are used to represent the input-output relationship between neurons. By selecting neurons in the model set to form a local structure, a sub-model can be obtained.
[0116] In addition, the model training process is similar to the human learning process, which is a process from simple to complex. By analogy with this learning method, the training of the model set can also adopt the method of first learning the easier sub-model and then learning the more difficult sub-model. This training method helps to reduce the probability of overfitting and underfitting during the training process.
[0117] Therefore, the optional values included in the selection range in the embodiment of the present application can be distributed in a step-by-step manner, thereby constructing multiple sub-models arranged from simple to complex, so that the training process matches the human learning process and improves the subsequent training efficiency.
[0118] For example, assuming the total number of network layers and the number of channels per layer are set as two parameters to determine the size of the search space, with the number of layers ranging from any integer in the range [1, 12] and the number of channels per layer from {128, 256, 512}, then these two parameters combined provide 12 × 3 = 36 possible seed network structures, and the values within these two ranges are distributed in a step-wise manner from simple to complex, resulting in multiple sub-models with varying structures. In practical applications, to ensure a larger search space, a wide range of parameters can be provided for multiple dimensions, resulting in a maximum of 10 to the power of 10 or more possible seed network structures.
[0119] Step 403: During iterative training of a model set including multiple sub-models, a sampling effect score corresponding to the first iterative operation is calculated based on the first sampling probability. The smaller the sampling effect score, the better the sampling effect of the first iterative operation.
[0120] In an embodiment of the present application, a probability distribution parameter θ (sampling probability) can be quantified to reflect the training quality of the sub-model after one iterative operation, and the sampling effect score of the iterative operation can be determined based on the probability distribution parameter θ.
[0121] Specifically, Figure 1 The optimization sampling method shown models the search space as a linear probability distribution function is the probability distribution parameter, m is the sub-model, if w is used to represent the parameters of the model itself (such as weights and other parameters), the acquisition process of the model structure can be modeled as follows:
[0122]
[0123] in, It refers to the loss function value of the sub-model N(w,m) on the training data set, m is the network structure of the sub-model, ω is its network weight, so the expected value of the loss function is The loss value can be minimized by optimizing the probability distribution parameter θ and the hypernetwork weight W, and the solution process can be achieved through stochastic natural gradients (SNG).
[0124] Furthermore, the embodiment of the present application specifically determines the sampling method to be preferably adopted for the iterative operation to be executed currently based on the sampling training effect of the last iterative operation. Therefore, the embodiment of the present application needs to calculate a sampling effect score ρ based on the probability distribution parameter θ of all sub-models after the last iterative operation. The sampling effect score ρ is used to reflect the uncertainty of the probability distribution parameter θ. The smaller the sampling effect score ρ, the greater the probability that the iterative operation to be executed currently will prioritize the average sampling method, which means that the uncertainty of the probability distribution parameter θ after the previous iteration is small, and subsequent iterations are more likely to adopt the average sampling method to increase the sampling exploration range of the sub-model and avoid falling into local optimality; the larger the sampling effect score ρ, the greater the probability that the iterative operation to be executed currently will prioritize the optimized sampling method, which means that the uncertainty of the probability distribution parameter θ after the previous iteration is large, and subsequent iterations are more likely to adopt the optimized sampling method to improve the training accuracy of the sub-model, thereby reducing the uncertainty of the probability distribution parameter θ.
[0125] Step 404 : Select a function and the sampling effect score according to a preset method, and select a target sampling method used in the second iterative operation from at least two preset sampling methods.
[0126] Optionally, step 404 may specifically include:
[0127] Sub-step 4041, according to the Bernoulli distribution function, the preset number of sampling times and the sampling effect score, selects the target sampling method from the preset uniform sampling method and the optimized sampling method, so that the second iterative operation selects the sub-model to be trained from the model set according to the target sampling method for training.
[0128] Among them, the uniform sampling method is used to select the sub-model according to a fixed selection probability; the optimized sampling method has a higher selection probability for the sub-model with better training effect.
[0129] In the embodiment of the present application, the Bernoulli distribution function can be introduced To realize the judgment of whether to select uniform sampling or optimized sampling in the iterative operation, the function H is defined to have a probability of K to select the current optimized sampling method and a probability of NK to select the current average sampling method. N is the number of sampling times (a fixed known value), K is the probability of currently using the optimized sampling method, ρ is the sampling effect score of the previous iterative operation, and ρ is the sampling effect score of the previous iterative operation. max It is the normalized result of the sampling effect score.
[0130] Optionally, sub-step 4041 may specifically include:
[0131] Sub-step 40411, calculating the normalized processing result of the sampling effect score.
[0132] Sub-step 40412: Determine the ratio of the sampling effect score to the normalized processing result as the target probability for selecting the optimized sampling method in the Bernoulli distribution function; the sampling effect score is in positive proportion to the target probability.
[0133] Sub-step 40413, selecting a target sampling method from the uniform sampling method and the optimized sampling method according to the Bernoulli distribution function, the sampling number and the target probability.
[0134] It can be seen from sub-steps 40411-40412 that the larger ρ in the Bernoulli distribution function, the larger K; the smaller ρ, the smaller K, that is, the first sampling probability of the sub-model after the first iterative operation can guide the sampling method selected for the second iterative operation. Therefore, the embodiment of the present application can achieve the purpose of dynamic switching of sampling methods by selecting the target sampling method adopted by the second iterative operation from at least two preset sampling methods, so that various sub-models can be fully explored during sampling, and those sub-models with more advantages can be trained in a focused manner, so that each round of iterative training has its own sampling method. This can solve the problem of excessive training time caused by repeated random sampling, and can also solve the problem of the network falling into local optimality caused by repeated optimization sampling.
[0135] Optionally, step 403 may specifically include:
[0136] Sub-step 4031: taking the accumulated value of the logarithm of the first sampling probability of the sub-model as the sampling effect score corresponding to the first iterative operation.
[0137] In one implementation of an embodiment of the present application, the probability distribution parameters θ of all sub-models can be used to obtain a sampling effect score using the accumulated value of the information entropy therein. Specifically, the accumulated value of the logarithm of the first sampling probability of all sub-models is used as the sampling effect score corresponding to the first iterative operation.
[0138] In addition, the accuracy of the sub-network and fixed empirical parameters can also be used to calculate the sampling effect score, which is not limited in the embodiment of the present application.
[0139] Step 405: Sort the sub-models according to the second sampling probability to obtain a target sequence.
[0140] Step 406 , starting from the sub-model with the second largest sampling probability in the target sequence, select a target sub-model that meets the computing resource constraint condition, and obtain a target model based on the target sub-network.
[0141] For steps 405-406, after the model set training is completed, the second sampling probability of each sub-model trained can be directly used as a guiding parameter for selecting the target sub-model, and the target sub-model that meets the accuracy requirements and computing power resource constraints is selected from the model set, and the target model is obtained based on the target sub-network. These processes save the overhead of accuracy testing and reduce the amount of calculation.
[0142] Specifically, we can start from the sub-model with the second largest sampling probability in the target sequence and select the target sub-model that meets the computing resource constraints, so as to maximize the accuracy of the target model that can be constructed.
[0143] Optionally, step 406 may specifically include:
[0144] Sub-step 4061: Obtain resource requirements of the sub-models in the model set.
[0145] Sub-step 4062: Starting from the starting point of the target sequence, one or more target sub-models are selected, and the model accuracy of the target sub-model selected for each selection operation is determined, and the sum of the resource requirements of the target sub-model selected each time is less than or equal to the resource upper limit value corresponding to the computing power resource constraint condition.
[0146] Sub-step 4063: The target sub-model selected by the selection operation with the maximum model accuracy is used to form the target model.
[0147] Optionally, the resource upper limit includes at least one of: a model parameter upper limit, a model single calculation upper limit, and a model memory usage upper limit.
[0148] In an embodiment of the present application, the computing power resource constraint of the target device can be quantified as a judgment process of whether it exceeds the resource upper limit value, that is, if the sum of the resource requirements of the constructed target model is less than or equal to the resource upper limit value, it can be considered that the target model meets the computing power resource constraint condition.
[0149] For example, assuming that the computing power resource constraint of a target device is that the number of parameters of the deployed target model does not exceed 50 megabytes, and the trained target model has three sub-models: sub-model a (second sampling probability 0.8, parameter amount 30 megabytes), sub-model b (second sampling probability 0.7, parameter amount 10 megabytes), and sub-model c (second sampling probability 0.6, parameter amount 20 megabytes), then you can first sort them according to the size of the second sampling probability (assuming sorting from large to small) to obtain the target sequence: {sub-model a, sub-model b, sub-model c}. In addition, since the total number of parameters of the target model needs to not exceed the upper limit of 50 megabytes, two target models can be constructed: target model 1 includes sub-model a, and target model 2 includes sub-model a and sub-model b. Finally, the accuracy values of target model 1 and target model 2 can be verified through the verification set, and the target model with a larger accuracy value can be selected and sent to the target device for deployment.
[0150] Since the entire target model acquisition process directly uses the second sampling probability trained by each sub-model as the guiding parameter for selecting the target sub-model, the cost of accuracy testing is saved and the efficiency of determining the target sub-model is improved.
[0151] It should be noted that the embodiment of the present application can also introduce a reward function to further optimize the probability distribution function under the constraints of computing power resources. The reward function is as follows:
[0152]
[0153] Among them, m is the network structure of a sub-model, and ACC(m) refers to the accuracy of the sub-model on the target data set. is the resource consumption calculation function, and They refer to the resource consumption of the sub-network and super-network respectively, and Ω is the resource limit threshold. In the process of selecting the target sub-model based on the reward function, the weight W of the super-network remains unchanged and does not need to be retrained. Therefore, a sub-model structure that meets the requirements of different resources can be obtained through a single training, further reducing the amount of computation.
[0154] To sum up, in the embodiment of the present application, in the process of multiple iterative training of the model set, the training efficiency and accuracy of the model set can be improved by dynamically selecting a suitable sampling method for each iterative operation, so that the model set and the sub-models therein are fully trained to a convergence state with high efficiency and high accuracy, thereby solving the problem of poor training efficiency or training accuracy caused by training using a fixed sampling method. In addition, the embodiment of the present application can also quantify the training accuracy of the sub-model through a second sampling probability, and then in the process of model search for the model set, the second sampling probability is directly used as a guiding parameter for selecting the target sub-model, and the target sub-model is selected to form a target model that meets the computing resource constraint conditions, so that the model acquisition process does not require additional sub-model accuracy verification operations, thereby reducing computational overhead.
[0155] Reference Figure 11 , which shows a block diagram of a device for obtaining a model structure provided by an embodiment of the present application, including:
[0156] A first selection module 501 is configured to select, during iterative training of a model set including multiple sub-models, a target sampling method for a second iterative operation from at least two preset sampling methods based on a first sampling probability of the sub-model after the first iterative operation; the second iterative operation is the next iterative operation after the first iterative operation;
[0157] A first terminating iteration module 502 is configured to obtain a second sampling probability of a sub-model in the model set after performing at least one iteration operation;
[0158] The first construction module 503 is used to select a target sub-model from the model set according to the computing resource constraint of the target device and the second sampling probability, and obtain a target model according to the target sub-network.
[0159] Optionally, the first selection module 501 includes:
[0160] a first calculation submodule, configured to calculate a sampling effect score corresponding to the first iterative operation according to the first sampling probability, wherein the smaller the sampling effect score, the better the sampling effect of the first iterative operation;
[0161] The selection submodule is used to select a function and the sampling effect score according to a preset method, and select a target sampling method used in the second iterative operation from at least two preset sampling methods.
[0162] Optionally, the selection submodule includes:
[0163] A Bernoulli unit is configured to select a target sampling method from a preset uniform sampling method and an optimized sampling method according to a Bernoulli distribution function, a preset number of sampling times, and the sampling effect score, so that a second iterative operation selects a sub-model to be trained from the model set for training according to the target sampling method;
[0164] Among them, the uniform sampling method is used to select the sub-model according to a fixed selection probability; the optimized sampling method has a higher selection probability for the sub-model with better training effect.
[0165] Optionally, the first calculation submodule includes:
[0166] an accumulating unit, configured to use the accumulated value of the logarithm of the first sampling probability of the sub-model as a sampling effect score corresponding to the first iterative operation;
[0167] The Bernoulli unit comprises:
[0168] A normalization subunit, used to calculate the normalization processing result of the sampling effect score;
[0169] an accumulation subunit, configured to determine a ratio of the sampling effect score to the normalization processing result as a target probability for selecting the optimized sampling method in the Bernoulli distribution function; the sampling effect score and the target probability are in direct proportion;
[0170] A selection subunit is used to select a target sampling method from the uniform sampling method and the optimized sampling method according to the Bernoulli distribution function, the sampling number and the target probability.
[0171] Optionally, the first building module 503 includes:
[0172] a sorting submodule, configured to sort the submodels according to the second sampling probability to obtain a target sequence;
[0173] The screening submodule is used to select the target submodel that meets the computing resource constraint conditions starting from the submodel with the second largest sampling probability in the target sequence, and obtain the target model according to the target subnetwork.
[0174] Optionally, the screening submodule includes:
[0175] an acquiring unit, configured to acquire resource requirements of sub-models in the model set;
[0176] a comparing unit, configured to select one or more target sub-models from the starting point of the target sequence, and determine the model accuracy of the target sub-model selected in each selection operation, wherein the sum of the resource requirements of the target sub-models selected in each selection operation is less than or equal to the resource upper limit value corresponding to the computing power resource constraint condition;
[0177] The selection unit is used to form the target model from the target sub-model selected by the selection operation with the highest model accuracy.
[0178] Optionally, the resource upper limit value includes at least one of: a model parameter upper limit value, a model single calculation upper limit value, and a model memory usage upper limit value.
[0179] Optionally, also include:
[0180] The third acquisition module is used to obtain the selection range of network structure parameters;
[0181] The search space design module is used to establish a model set including multiple sub-models according to the selection range of the network structure parameters.
[0182] Optionally, the network structure parameters include: one or more of the total number of network layers, the number of channels in each network layer, and the number of attention weights;
[0183] The multiple optional values in the selection range are distributed in a step-by-step increasing manner.
[0184] In summary, in the embodiments of the present application, in the process of multiple iterative training of the model set, the training efficiency and accuracy of the model set can be improved by dynamically selecting a suitable sampling method for each iterative operation, so that the model set and the sub-models therein are fully trained to a convergence state with high efficiency and high accuracy, thereby solving the problem of poor training efficiency or training accuracy caused by training with a fixed sampling method. In addition, the embodiments of the present application can also quantify the training accuracy of the sub-model through the second sampling probability, and then in the process of model search for the model set, the second sampling probability is directly used as a guiding parameter for selecting the target sub-model, and the target sub-model is selected to form a target model that meets the computing power resource constraint conditions, so that the model acquisition process does not require additional sub-model accuracy verification operations, thereby reducing computational overhead.
[0185] Reference Figure 12 , which shows a block diagram of a model determination device based on hardware computing power constraints provided by an embodiment of the present application, including:
[0186] A first acquisition module 601 is configured to acquire a computing resource constraint value of an electronic device;
[0187] A second selection module 602 is configured to select, during iterative training of a model set including multiple sub-models, a target sampling method for a second iterative operation from at least two preset sampling methods based on the first sampling probability of the sub-model after the first iterative operation; the second iterative operation is the next iterative operation after the first iterative operation;
[0188] A second terminating iteration module 603 is configured to obtain a second sampling probability of a sub-model in the model set after performing at least one iteration operation;
[0189] The second construction module 604 is used to select a target sub-model from the model set to form a target model for use by the electronic device based on the computing power resource constraint value of the electronic device and the second sampling probability, and the sum of the resource requirements of the target sub-models is less than or equal to the computing power resource constraint value.
[0190] In summary, in the embodiments of the present application, in the process of multiple iterative training of the model set, the training efficiency and accuracy of the model set can be improved by dynamically selecting a suitable sampling method for each iterative operation, so that the model set and the sub-models therein are fully trained to a convergence state with high efficiency and high accuracy, thereby solving the problem of poor training efficiency or training accuracy caused by training with a fixed sampling method. In addition, the embodiments of the present application can also quantify the training accuracy of the sub-model through the second sampling probability, and then in the process of model search for the model set, the second sampling probability is directly used as a guiding parameter for selecting the target sub-model, and the target sub-model is selected to form a target model that meets the computing power resource constraint conditions, so that the model acquisition process does not require additional sub-model accuracy verification operations, thereby reducing computational overhead.
[0191] Reference Figure 13 , which shows a block diagram of a semantic recognition device provided by an embodiment of the present application, including:
[0192] The second acquisition module 701 is used to acquire the corpus to be recognized;
[0193] The recognition module 702 is used to input the corpus to be recognized into the target model to obtain a semantic recognition result of the corpus to be recognized;
[0194] The target model is determined by an acquisition device based on the model structure.
[0195] In summary, in the embodiments of the present application, in the process of multiple iterative training of the model set, the training efficiency and accuracy of the model set can be improved by dynamically selecting a suitable sampling method for each iterative operation, so that the model set and the sub-models therein are fully trained to a convergence state with high efficiency and high accuracy, thereby solving the problem of poor training efficiency or training accuracy caused by training with a fixed sampling method. In addition, the embodiments of the present application can also quantify the training accuracy of the sub-model through the second sampling probability, and then in the process of model search for the model set, the second sampling probability is directly used as a guiding parameter for selecting the target sub-model, and the target sub-model is selected to form a target model that meets the computing power resource constraint conditions, so that the model acquisition process does not require additional sub-model accuracy verification operations, thereby reducing computational overhead.
[0196] An embodiment of the present application further provides a non-volatile readable storage medium, which stores one or more modules (programs). When the one or more modules are applied to a device, the device can execute instructions (instructions) of each method step in the embodiment of the present application.
[0197] The present application provides one or more machine-readable media having instructions stored thereon, which, when executed by one or more processors, cause an electronic device to perform one or more of the methods described in the above embodiments. In the present application, the electronic device includes various types of devices such as terminal devices and server (cluster).
[0198] The embodiments of the present disclosure may be implemented as a device configured as desired using any appropriate hardware, firmware, software, or any combination thereof, and the device may include electronic devices such as terminal devices and server (clusters). Figure 14 An exemplary apparatus 1000 that can be used to implement various embodiments described in the embodiments of this application is schematically shown.
[0199] For one embodiment, Figure 14 An exemplary apparatus 1000 is shown having one or more processors 1002, a control module (chip set) 1004 coupled to at least one of the processor(s) 1002, a memory 1006 coupled to the control module 1004, a non-volatile memory (NVM) / storage device 1008 coupled to the control module 1004, one or more input / output devices 1010 coupled to the control module 1004, and a network interface 1012 coupled to the control module 1004.
[0200] The processor 1002 may include one or more single-core or multi-core processors, and the processor 1002 may include any combination of general-purpose processors or dedicated processors (e.g., graphics processors, application processors, baseband processors, etc.). In some embodiments, the apparatus 1000 can serve as a terminal device, a server (cluster), or other device described in the embodiments of the present application.
[0201] In some embodiments, the apparatus 1000 may include one or more computer-readable media (e.g., memory 1006 or NVM / storage 1008) having instructions 1014 and one or more processors 1002 configured in conjunction with the one or more computer-readable media to execute the instructions 1014 to implement a module to perform the actions described in the present disclosure.
[0202] For one embodiment, the control module 1004 may include any suitable interface controller to provide any suitable interface to at least one of the processor(s) 1002 and / or any suitable device or component in communication with the control module 1004 .
[0203] The control module 1004 may include a memory controller module to provide an interface to the memory 1006. The memory controller module may be a hardware module, a software module, and / or a firmware module.
[0204] The memory 1006 can be used, for example, to load and store data and / or instructions 1014 for the device 1000. For one embodiment, the memory 1006 can include any suitable volatile memory, such as a suitable DRAM. In some embodiments, the memory 1006 can include double data rate type four synchronous dynamic random access memory (DDR4 SDRAM).
[0205] For one embodiment, the control module 1004 may include one or more input / output controllers to provide an interface to the NVM / storage device 1008 and the input / output device(s) 1010 .
[0206] For example, NVM / storage 1008 may be used to store data and / or instructions 1014. NVM / storage 1008 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable non-volatile storage device(s) (e.g., one or more hard disk drives (HDDs), one or more compact disk (CD) drives, and / or one or more digital versatile disk (DVD) drives).
[0207] NVM / storage device 1008 may include storage resources that are physically part of the device on which apparatus 1000 is installed, or it may be accessible to the device without being part of the device. For example, NVM / storage device 1008 may be accessible over a network via input / output device(s) 1010.
[0208] (One or more) input / output devices 1010 may provide an interface for apparatus 1000 to communicate with any other appropriate device. Input / output devices 1010 may include communication components, audio components, sensor components, etc. Network interface 1012 may provide an interface for apparatus 1000 to communicate via one or more networks. Apparatus 1000 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, for example, accessing a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G, etc., or a combination thereof for wireless communication.
[0209] For one embodiment, at least one of the processor(s) 1002 may be packaged together with the logic of one or more controllers (e.g., a memory controller module) of the control module 1004. For one embodiment, at least one of the processor(s) 1002 may be packaged together with the logic of one or more controllers of the control module 1004 to form a system-in-package (SiP). For one embodiment, at least one of the processor(s) 1002 may be integrated on the same die with the logic of one or more controllers of the control module 1004. For one embodiment, at least one of the processor(s) 1002 may be integrated on the same die with the logic of one or more controllers of the control module 1004 to form a system-on-chip (SoC).
[0210] In various embodiments, the apparatus 1000 may be, but is not limited to, a terminal device such as a server, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.). In various embodiments, the apparatus 1000 may have more or fewer components and / or a different architecture. For example, in some embodiments, the apparatus 1000 includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit (ASIC), and a speaker.
[0211] Among them, the main control chip can be used as a processor or control module in the detection device, sensor data, location information, etc. are stored in the memory or NVM / storage device, the sensor group can be used as an input / output device, and the communication interface may include a network interface.
[0212] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0213] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0214] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0215] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0216] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0217] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the underlying inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as changes and modifications that fall within the scope of the embodiments of the present invention.
[0218] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0219] The above is a detailed introduction to a method and device for obtaining a model structure, a method and device for determining a model based on hardware computing power constraints, a semantic recognition method and device, an electronic device, and a machine-readable medium provided by this application. This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method of this application and its core idea; at the same time, for general technical personnel in this field, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on this application.
Claims
1. A method for obtaining a model structure, characterized in that: include: During iterative training of a model set including a plurality of sub-models, selecting a target sampling method for a second iterative operation from at least two preset sampling methods based on a first sampling probability of the sub-model after a first iterative operation; the second iterative operation being the next iterative operation of the first iterative operation; After performing at least one iterative operation, obtaining a second sampling probability of the sub-model in the model set; According to the computing power resource constraint of the target device and the second sampling probability, a target sub-model is selected from the model set, and a target model is obtained based on the target sub-model.
2. The method according to claim 1, characterized in that The step of selecting a target sampling method for the second iterative operation from at least two preset sampling methods based on the first sampling probability of the sub-model after the first iterative operation includes: Calculating a sampling effect score corresponding to the first iterative operation according to the first sampling probability, wherein a smaller the sampling effect score is, a better sampling effect of the first iterative operation is; A function and the sampling effect score are selected according to a preset method, and a target sampling method used in the second iterative operation is selected from at least two preset sampling methods.
3. The method according to claim 2, characterized in that The step of selecting the function and the sampling effect score according to a preset method, and selecting a target sampling method for the second iterative operation from at least two preset sampling methods, includes: Selecting a target sampling method from a preset uniform sampling method and an optimized sampling method according to a Bernoulli distribution function, a preset number of sampling times, and the sampling effect score, so that a second iterative operation selects a sub-model to be trained from the model set for training according to the target sampling method; Among them, the uniform sampling method is used to select the sub-model according to a fixed selection probability; the optimized sampling method has a higher selection probability for the sub-model with better training effect.
4. The method according to claim 3, characterized in that Calculating a sampling effect score corresponding to the first iterative operation according to the first sampling probability includes: Taking the accumulated value of the logarithm of the first sampling probability of the sub-model as the sampling effect score corresponding to the first iterative operation; The target sampling method is selected from a preset uniform sampling method and an optimized sampling method according to the Bernoulli distribution function, the preset number of sampling times and the sampling effect score, including: Calculating a normalized processing result of the sampling effect score; Determining the ratio of the sampling effect score to the normalized processing result as the target probability for selecting the optimized sampling method in the Bernoulli distribution function; the sampling effect score and the target probability are in direct proportion; A target sampling method is selected from the uniform sampling method and the optimized sampling method according to the Bernoulli distribution function, the sampling number and the target probability.
5. The method according to claim 1, wherein The selecting a target sub-model from the model set according to the computing resource constraint of the target device and the second sampling probability, and obtaining a target model according to the target sub-model, includes: Sort the sub-models according to the second sampling probability to obtain a target sequence; Starting from the sub-model with the second largest sampling probability in the target sequence, a target sub-model that meets the computing resource constraint condition is selected, and a target model is obtained based on the target sub-model.
6. The method according to claim 5, characterized in that Starting from the starting point of the target sequence, selecting a target sub-model that meets the computing resource constraint condition to form a target model includes: Obtaining resource requirements of sub-models in the model set; Starting from the starting point of the target sequence, one or more target sub-models are selected, and the model accuracy of the target sub-model selected in each selection operation is determined, and the sum of the resource requirements of the target sub-models selected in each selection operation is less than or equal to the resource upper limit value corresponding to the computing power resource constraint condition; The target sub-model selected by the selection operation with the maximum model accuracy constitutes the target model.
7. The method according to claim 6, characterized in that The resource upper limit value includes: at least one of the upper limit value of model parameter quantity, the upper limit value of model single calculation quantity, and the upper limit value of model memory usage.
8. A model determination method based on hardware computing power constraints, characterized in that: include: Obtaining computing power resource constraints of electronic devices; During iterative training of a model set including a plurality of sub-models, selecting a target sampling method for a second iterative operation from at least two preset sampling methods based on a first sampling probability of the sub-model after a first iterative operation; the second iterative operation being the next iterative operation of the first iterative operation; After performing at least one iterative operation, obtaining a second sampling probability of the sub-model in the model set; According to the computing power resource constraint value of the electronic device and the second sampling probability, a target sub-model is selected from the model set to form a target model for use by the electronic device, and the sum of the resource requirements of the target sub-models is less than or equal to the computing power resource constraint value.
9. A semantic recognition method, characterized in that: include: Obtain the corpus to be recognized; Inputting the to-be-recognized corpus into a target model to obtain a semantic recognition result of the to-be-recognized corpus; Wherein, the target model is determined based on the method for obtaining the model structure according to any one of claims 1 to 7.
10. A device for acquiring a model structure, characterized in that: include: A first selection module is configured to select, during iterative training of a model set including a plurality of sub-models, a target sampling method for a second iterative operation from at least two preset sampling methods based on a first sampling probability of the sub-model after the first iterative operation; the second iterative operation being the next iterative operation after the first iterative operation; A first terminating iteration module is configured to obtain a second sampling probability of a sub-model in the model set after performing at least one iterative operation; The first construction module is used to select a target sub-model from the model set according to the computing resource constraint of the target device and the second sampling probability, and obtain a target model according to the target sub-model.
11. A model determination device based on hardware computing power constraints, characterized in that: include: A first acquisition module is used to obtain a computing resource constraint value of an electronic device; a second selection module configured to select, during iterative training of a model set including a plurality of sub-models, a target sampling method for a second iterative operation from at least two preset sampling methods based on a first sampling probability of the sub-model after the first iterative operation; wherein the second iterative operation is the next iterative operation after the first iterative operation; A second terminating iteration module is configured to obtain a second sampling probability of a sub-model in the model set after performing at least one iterative operation; The second construction module is used to select a target sub-model from the model set to form a target model for use by the electronic device based on the computing power resource constraint value of the electronic device and the second sampling probability, and the sum of the resource requirements of the target sub-models is less than or equal to the computing power resource constraint value.
12. A semantic recognition device, characterized in that: include: The second acquisition module is used to obtain the corpus to be recognized; A recognition module, configured to input the to-be-recognized corpus into a target model to obtain a semantic recognition result of the to-be-recognized corpus; Wherein, the target model is determined by the acquisition device based on the model structure of claim 10 above.
13. An electronic device, characterized in that: include: processor; and A memory having executable codes stored thereon, which, when executed, causes the processor to perform the method according to any one of claims 1 to 7.
14. One or more machine-readable media having executable codes stored thereon, which, when executed, cause a processor to perform the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Super network training method and device, electronic equipment and storage medium
CN112784961A