Voice model quantitative training method and system, electronic equipment and storage medium
By performing structural splitting and quantitative training on the speech model, the problem that the GRU structure occupies a large amount of parameters is solved, and the compression rate and acceleration effect of the speech model are improved to meet the real-time deployment needs.
Patent Information
- Application Number
- CN202410912228.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-11-01
AI Technical Summary
The GRU structure in the existing speech model occupies a large amount of parameters and operations, but the Pytorch training framework does not support GRU quantitative training, resulting in limited compression rate and acceleration effects of the speech model.
By equivalently splitting the structure of the speech model, converting it into a fully connected layer, and adding pseudo-quantitative nodes to the split model, quantization training is performed to obtain multiple sets of quantization parameters, so as to realize the speech model under the Pytorch framework Quantitative training.
The volume reduction and acceleration effect of the voice model are achieved, which meets the needs of real-time deployment and solves the problem of not being able to perform quantitative training under the Pytorch framework.
Smart Images

Figure CN118887946A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of household appliance technology, and in particular to a method and system for quantizing and training a speech model, an electronic device, and a storage medium. Background Art
[0002] In related technologies, the GRU (Gate Recurrent Unit) structure often occupies the main part of the parameters and computational complexity in the speech model. However, the Pytorch (an open source programming language machine learning library) training framework does not support quantized training of GRU, so the compression rate and acceleration effect of the speech model are limited. Summary of the invention
[0003] The present invention aims to solve at least one of the technical problems existing in the prior art or related art.
[0004] To this end, the first aspect of the present invention proposes a method for quantizing and training a speech model.
[0005] The second aspect of the present invention proposes a system for quantization training of speech models.
[0006] A third aspect of the present invention provides an electronic device.
[0007] A fourth aspect of the present invention provides a storage medium.
[0008] A fifth aspect of the present invention provides a computer program product.
[0009] In view of this, according to the first aspect of the present invention, a method for quantization training of a speech model is proposed, comprising: obtaining a first speech model, wherein the first speech model includes a gated recurrent unit; splitting the structure of the first speech model to obtain a second speech model, wherein the second speech model includes at least one fully connected layer; quantizing the second speech model to obtain a third speech model, wherein the third speech model includes multiple pseudo-quantization nodes; obtaining a speech training data set; training the third speech model according to the speech training data set to obtain multiple sets of quantization parameters; determining a target speech model according to the quantization parameters.
[0010] The method for speech model quantization training provided by the present invention mainly includes: first obtaining a first speech model, wherein the first speech model may include a GRU (Gate Recurrent Unit, gated recurrent unit) structure. Then analyzing the structure of the first speech model, determining the calculation relationship inside the first speech model through the structure of the first speech model, and then being able to perform equivalent splitting of the structure of the first speech model through the calculation relationship, that is, equivalently splitting the structure of the first speech model into multiple fully connected layers, thereby obtaining a second speech model, wherein the second speech model contains at least one fully connected layer. After obtaining the second speech model, the second speech model is subjected to model quantization processing, and model quantization refers to converting the floating-point algorithm of the neural network into a fixed-point algorithm. Model quantization can reduce the resource overhead occupied by the model, improve the reasoning speed of the model, and better meet the needs of real-time deployment. In other words, the floating-point algorithm in the second speech model is converted into a fixed-point algorithm. Among them, the second speech model can be quantized by manually adding a pseudo-quantization node to obtain a third speech model, wherein the third speech model will contain multiple pseudo-quantization nodes. Pseudo-quantization nodes are a technology used to count the maximum and minimum values of specific operations during training. Therefore, after obtaining the third speech model, it is necessary to obtain a speech training data set, wherein the speech training data in the speech training data set are all data determined in advance, and then the third speech model is trained according to the speech training data set. During the training process, multiple sets of quantization parameters are determined through multiple pseudo-quantization nodes in the third speech model. The quantization parameters can simulate the precision loss after quantization during quantization perception training, and serve the downstream to generate the final static quantization fixed-point model, that is, finally determine the target speech model according to multiple sets of quantization parameters. The present invention first performs equivalent decomposition of the structure of the speech model, and then quantizes and trains the decomposed speech model to obtain multiple sets of quantization parameters, and then obtains the target speech model according to the quantization parameters. The present invention decomposes the structure of the speech model and performs quantization training on the decomposed speech model, so that the speech model that cannot be quantized and trained under the Pytorch (an open source programming language machine learning library) training framework can be quantized and trained, thereby reducing the volume of the speech model and improving the compression rate and acceleration effect of the speech model.
[0011] The method for quantizing and training the speech model according to the present invention may also have the following technical features:
[0012] In some technical schemes, optionally, the step of splitting the structure of the first speech model to obtain the second speech model includes: determining the forward reasoning formula of the first speech model based on the first speech model; determining multiple first weight matrices in the forward reasoning formula; splitting the first speech model according to the multiple first weight matrices to obtain multiple fully connected layers; and determining the second speech model based on the multiple fully connected layers.
[0013] In this technical solution, the structure of the first speech model is split to obtain the second speech model, including: first, determining the forward reasoning formula of the first speech model according to the first speech model, and the forward reasoning formula can express the information transmission process from the input layer to the output layer of the first speech model. Then determine multiple first weight matrices in the forward reasoning formula, analyze the forward reasoning formula and the determined multiple first weight matrices, and then split the first speech model according to the multiple first weight matrices to obtain multiple fully connected layers, in which all nodes of the previous layer are connected to each node of the next layer, so that the fully connected layer can learn and extract input features more deeply. Finally, determine the second speech model based on the obtained multiple fully connected layers. By determining the forward reasoning formula of the first speech model and splitting the first speech model according to the multiple first weight matrices in the forward reasoning formula, the equivalent splitting of the structure of the first speech model is achieved.
[0014] In some technical schemes, optionally, the first speech model is split according to multiple first weight matrices to obtain multiple fully connected layers, including: determining the operational relationship between the multiple first weight matrices according to the multiple first weight matrices; merging the multiple first weight matrices according to the operational relationship between the multiple first weight matrices to obtain multiple second weight matrices; and obtaining multiple fully connected layers according to the multiple second weight matrices.
[0015] In this technical solution, the first speech model is split according to multiple first weight matrices to obtain multiple fully connected layers, including: first, determining the operational relationship between multiple first weight matrices according to multiple first weight matrices and forward reasoning formulas, and then merging them according to the operational relationship between the first weight matrices to obtain multiple second weight matrices, wherein the number of second weight matrices is less than the number of first weight matrices. Since the forward reasoning formula contains multiple equations, and the multiple equations are formed by the operational relationship between multiple first weight matrices, the multiple equations, i.e., the operational relationship between multiple first weight matrices, can be merged to obtain multiple operational relationships about the second weight matrices. Finally, multiple fully connected layers are obtained according to the multiple second weight matrices, wherein the number of fully connected layers is the same as the number of second weight matrices, that is, the formula formed by the operational relationship of a second weight matrix is taken as a fully connected layer.
[0016] In some technical solutions, optionally, the step of quantizing the second speech model to obtain the third speech model includes: determining the operation structure of the second speech model; adding multiple pseudo-quantization nodes to the operation structure to obtain the third speech model.
[0017] In this technical solution, the step of quantizing the second speech model to obtain the third speech model includes: determining the operation structure of the second speech model, that is, determining the operation relationship between the fully connected layers, and then manually adding multiple pseudo-quantization nodes in the operation structure to obtain the third speech model. The pseudo-quantization node is a data structure. By adding pseudo-quantization nodes to recognizable operations, statistical information of data flowing through these nodes can be collected, which helps to reduce precision loss in subsequent quantization operations.
[0018] In some technical schemes, optionally, multiple pseudo-quantization nodes are added to the operation structure to obtain the step of obtaining the third speech model, including: determining multiple operation operations and calculation positions corresponding to the operation operations according to the operation structure; adding pseudo-quantization nodes to the calculation positions corresponding to the operation operations based on the absence of a weight matrix during the operation; adding pseudo-quantization nodes to the calculation positions corresponding to the operation operations based on the presence of a weight matrix during the operation, and adding pseudo-quantization nodes to the weight matrix.
[0019] In the technical solution, a plurality of pseudo-quantization nodes are added to the operation structure to obtain the step of the third speech model, including: firstly, according to the operation structure, a plurality of operation operations and the calculation positions corresponding to the operation operations are determined, and the operation operations may include: addition operation, subtraction operation, multiplication operation, division operation and convolution operation, etc., and the calculation position is the position of the operation operation in the second speech model. Then, the operation operation process is analyzed to determine whether the weight matrix is involved in the operation operation process. When there is no weight matrix in the operation operation process, that is, the weight matrix does not participate in this operation operation, then only the pseudo-quantization node is added to the calculation position corresponding to the operation operation, that is, only the output activation quantization is performed on the operation operation. When there is a weight matrix in the operation operation process, that is, the weight matrix participates in this operation operation, then the pseudo-quantization node is added to the calculation position corresponding to the operation operation, and the pseudo-quantization node needs to be added to the weight matrix at the same time, that is, the operation operation with the weight matrix needs not only to add pseudo-quantization nodes to the weight matrix to complete the quantization, but also to quantize the activation output of the operation operation. By adding pseudo-quantization nodes to the calculation position of the operation operation, the quantization of the speech model is realized.
[0020] In some technical solutions, optionally, after adding multiple pseudo-quantization nodes in the operation structure, it also includes: obtaining a mapping relationship between a floating-point operator and a quantization operator; determining a first floating-point operator in the second speech model; and replacing the operator of the second speech model according to the first floating-point operator and the mapping relationship to obtain a third speech model.
[0021] In this technical solution, after adding multiple pseudo-quantization nodes to the operation structure, it also includes: obtaining the mapping relationship between the floating-point operator and the quantization operator, then determining the first floating-point operator in the second speech model, and then replacing the operator of the second speech model according to the first floating-point operator and the mapping relationship, thereby obtaining a third speech model. However, when the speech model is GRU, through the mapping relationship between the floating-point operator and the quantization operator, the nn.GRU (a module in PyTorch used to implement the gated recurrent unit) module can be manually mapped to the manually split quantizable GRU module for operator replacement. After the replacement is completed, the quantizable GRU is built and can perform quantization-aware training to simulate the quantization loss to guide the update of the model weights and quantization parameters.
[0022] In some technical schemes, optionally, the step of training a third speech model according to a speech training data set to obtain multiple sets of quantization parameters includes: obtaining the maximum and minimum values of the operator in the process of training the third speech model according to the speech training data set according to the pseudo-quantization nodes in the third speech model; determining the scaling factor and the corresponding zero reference point according to the maximum and minimum values of the operator; and using the scaling factor and the corresponding zero reference point as a set of quantization parameters.
[0023] In the technical solution, the third speech model is trained according to the speech training data set to obtain multiple sets of quantization parameters, including: first, since the pseudo-quantization node can count the maximum and minimum values of a specific operation, the maximum and minimum values of the operator of the third speech model in the training process are obtained according to the pseudo-quantization node in the third speech model during the training process of the third speech model according to the speech training data set, and then the scaling factor and the corresponding zero reference point are determined according to the maximum and minimum values of the operator, wherein the formula for calculating the scaling factor is: Among them, Scale represents the scaling factor, f max represents the maximum value of the operator, f min It represents the minimum value of the operator. The formula for calculating the zero reference point is Among them, Z 0 represents the zero reference point, f max It represents the maximum value of the operator, Scale represents the scaling factor, and Z maxThe maximum value of the floating point number represented by round() means that the number will be rounded to the nearest integer. The mainstream floating point numbers will be compressed to the range of 0 to 255 (asymmetric) or -128 to 127 (symmetric), that is, Z max It can be 255 or 127. When symmetric quantization is performed, the zero reference point of quantization is equal to 0. Then the scaling factor and the corresponding zero reference point are used as a set of quantization parameters, which can simulate the accuracy loss after quantization during quantization-aware training and serve the downstream to generate the final static quantization fixed-point model.
[0024] According to a second aspect of the present invention, a system for speech model quantization training is proposed, comprising: a first acquisition module, the first acquisition module is used to acquire a first speech model, wherein the first speech model includes a gated recurrent unit; a splitting module, the splitting module is used to split the structure of the first speech model to obtain a second speech model, wherein the second speech model includes at least one fully connected layer; a quantization module, the quantization module is used to quantize the second speech model to obtain a third speech model, wherein the third speech model includes multiple pseudo-quantization nodes; a second acquisition module, the second acquisition module is used to acquire a speech training data set; a training module, the training module is used to train the third speech model according to the speech training data set to obtain multiple sets of quantization parameters; a first determination module, the first determination module is used to determine the target speech model according to the quantization parameters.
[0025] The system for speech model quantization training provided by the present invention mainly includes: a first acquisition module, a splitting module, a quantization module, a second acquisition module, a training module and a first determination module. Among them, the first acquisition module first acquires the first speech model, and the first speech model may include a GRU structure. Then the structure of the first speech model is analyzed, and the calculation relationship inside the first speech model is determined by the structure of the first speech model, and then the splitting module can perform equivalent splitting of the structure of the first speech model through the calculation relationship, that is, the structure of the first speech model is equivalently split into multiple fully connected layers, so as to obtain a second speech model, wherein the second speech model contains at least one fully connected layer. After obtaining the second speech model, the quantization module performs model quantization processing on the second speech model, and model quantization refers to converting the floating-point algorithm of the neural network into a fixed-point algorithm. Model quantization can reduce the resource overhead occupied by the model, improve the reasoning speed of the model, and better meet the needs of real-time deployment. That is to say, the floating-point algorithm in the second speech model is converted into a fixed-point algorithm. Among them, the second speech model can be quantized by manually adding a pseudo-quantization node to obtain a third speech model, wherein the third speech model will contain multiple pseudo-quantization nodes. Pseudo-quantization node is a technology used to count the maximum and minimum values of a specific operation during training. Therefore, after obtaining the third speech model, the second acquisition module obtains a speech training data set, wherein the speech training data in the speech training data set are all data determined in advance, and then the training module trains the third speech model according to the speech training data set. During the training process, multiple sets of quantization parameters are determined by multiple pseudo-quantization nodes in the third speech model. The quantization parameters can simulate the precision loss after quantization during quantization perception training, and serve the downstream to generate the final static quantization fixed-point model, that is, the first determination module finally determines the target speech model according to multiple sets of quantization parameters. The present invention first performs equivalent splitting of the structure of the speech model, and then quantizes and trains the split speech model to obtain multiple sets of quantization parameters, and then obtains the target speech model according to the quantization parameters. The present invention splits the structure of the speech model and performs quantization training on the split speech model, so that the speech model that cannot be quantized and trained under the Pytorch training framework can be quantized and trained, thereby reducing the volume of the speech model and improving the compression rate and acceleration effect of the speech model.
[0026] According to a third aspect of the present invention, an electronic device is proposed, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method for quantizing and training a speech model as described above are implemented.
[0027] The electronic device provided by the present invention, in which the processor implements the steps of the above-mentioned method for quantizing and training the speech model when executing a computer program, can achieve the technical effects of any of the above-mentioned technical solutions and will not be repeated here.
[0028] According to a fourth aspect of the present invention, a storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for quantizing and training a speech model as described above are implemented.
[0029] The storage medium provided by the present invention, when the computer program is executed by the processor, implements the steps of the above-mentioned method for quantization training of the speech model, which can achieve the technical effects of any of the above-mentioned technical solutions and will not be repeated here.
[0030] According to a fifth aspect of the present invention, a computer program product is proposed, comprising a computer program, which, when executed by a processor, implements the steps of the method for quantizing and training a speech model as in any of the above-mentioned technical solutions.
[0031] The computer program product provided by this technical solution implements the steps of the method for quantizing speech models as in any technical solution of the present invention, and thus has all the beneficial effects of the method for quantizing speech models as in any technical solution of the present invention, which will not be repeated here.
[0032] Additional aspects and advantages of the present invention will become apparent from the following description or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0034] Figure 1 A schematic diagram showing a flow chart of a method for quantizing and training a speech model according to an embodiment of the present invention;
[0035] Figure 2 A schematic flow chart showing the steps of splitting the structure of a first speech model to obtain a second speech model in a method for speech model quantization training according to an embodiment of the present invention;
[0036] Figure 3 A schematic flow chart showing the steps of splitting a first speech model according to a plurality of first weight matrices to obtain a plurality of fully connected layers in a method for quantizing and training a speech model according to an embodiment of the present invention;
[0037] Figure 4 A schematic flow chart showing the steps of quantizing the second speech model to obtain the third speech model in the speech model quantization training method according to an embodiment of the present invention;
[0038] Figure 5 A schematic flow chart showing the steps of adding multiple pseudo-quantization nodes to a computing structure to obtain a third speech model in a method for speech model quantization training according to an embodiment of the present invention;
[0039] Figure 6 A schematic diagram of a flow chart after adding multiple pseudo-quantization nodes in a calculation structure in a method for quantization training of a speech model according to an embodiment of the present invention is shown;
[0040] Figure 7 A flow chart showing the steps of training a third speech model according to a speech training data set to obtain multiple groups of quantization parameters in a speech model quantization training method according to an embodiment of the present invention;
[0041] Figure 8 One of the principle diagrams of speech model quantization training according to an embodiment of the present invention is shown;
[0042] Fig. 9 A second schematic diagram of the speech model quantization training according to an embodiment of the present invention is shown;
[0043] Fig.10 A schematic block diagram of a system for speech model quantization training according to an embodiment of the present invention is shown;
[0044] Fig.11 A schematic block diagram of an electronic device according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0045] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.
[0046] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0047] Figure 1 A flow chart of a method for quantizing and training a speech model according to an embodiment of the present invention is shown. The method comprises:
[0048] Step 102: Acquire a first speech model, wherein the first speech model includes a gated recurrent unit;
[0049] Step 104: splitting the structure of the first speech model to obtain a second speech model, wherein the second speech model includes at least one fully connected layer;
[0050] Step 106: quantizing the second speech model to obtain a third speech model, wherein the third speech model includes a plurality of pseudo-quantization nodes;
[0051] Step 108: Acquire a speech training data set;
[0052] Step 110: training the third speech model according to the speech training data set to obtain multiple groups of quantization parameters;
[0053] Step 110: Determine a target speech model according to the quantization parameters.
[0054] The method for speech model quantization training provided by the present invention mainly includes: first obtaining a first speech model, wherein the first speech model can be a GRU (Gate Recurrent Unit, gated recurrent unit) structure. Then analyze the structure of the first speech model, determine the calculation relationship inside the first speech model through the structure of the first speech model, and then be able to perform equivalent splitting of the structure of the first speech model through the calculation relationship, that is, the structure of the first speech model is equivalently split into multiple fully connected layers, thereby obtaining a second speech model, wherein the second speech model contains at least one fully connected layer. After obtaining the second speech model, the second speech model is subjected to model quantization processing, and model quantization refers to converting the floating-point algorithm of the neural network into a fixed-point algorithm. Model quantization can reduce the resource overhead occupied by the model, improve the reasoning speed of the model, and better meet the needs of real-time deployment. In other words, the floating-point algorithm in the second speech model is converted into a fixed-point algorithm. Among them, the second speech model can be quantized by manually adding a pseudo-quantization node to obtain a third speech model, wherein the third speech model will contain multiple pseudo-quantization nodes. Pseudo-quantization nodes are a technology used to count the maximum and minimum values of specific operations during training. Therefore, after obtaining the third speech model, it is necessary to obtain a speech training data set, wherein the speech training data in the speech training data set are all data determined in advance, and then the third speech model is trained according to the speech training data set. During the training process, multiple sets of quantization parameters are determined by multiple pseudo-quantization nodes added in the third speech model. The quantization parameters can simulate the precision loss after quantization during quantization perception training, and serve the downstream to generate the final static quantization fixed-point model, that is, finally determine the target speech model according to multiple sets of quantization parameters. The present invention first performs equivalent decomposition of the structure of the speech model, and then quantizes and trains the decomposed speech model to obtain multiple sets of quantization parameters, and then obtains the target speech model according to the quantization parameters. The present invention decomposes the structure of the speech model and performs quantization training on the decomposed speech model, so that the speech model that cannot be quantized and trained under the Pytorch (an open source programming language machine learning library) training framework can be quantized and trained, thereby reducing the volume of the speech model and improving the compression rate and acceleration effect of the speech model.
[0055] Figure 2 A flow chart showing the steps of splitting the structure of a first speech model to obtain a second speech model in a method for speech model quantization training according to an embodiment of the present invention is shown; wherein the steps of splitting the structure of the first speech model to obtain the second speech model include:
[0056] Step 202: determining a forward reasoning formula of the first speech model according to the first speech model;
[0057] Step 204: Determine a plurality of first weight matrices in the forward reasoning formula;
[0058] Step 206: splitting the first speech model according to the multiple first weight matrices to obtain multiple fully connected layers;
[0059] Step 208: Determine a second speech model based on multiple fully connected layers.
[0060] In this embodiment, the structure of the first speech model is split to obtain the step of the second speech model, including: first, determining the forward reasoning formula of the first speech model according to the first speech model, and the forward reasoning formula can express the information transmission process from the input layer to the output layer of the first speech model. Then determine multiple first weight matrices in the forward reasoning formula, analyze the forward reasoning formula and the determined multiple first weight matrices, and then split the first speech model according to the multiple first weight matrices to obtain multiple fully connected layers, in which all nodes of the previous layer are connected to each node of the next layer, so that the fully connected layer can learn and extract input features more deeply. Finally, determine the second speech model based on the obtained multiple fully connected layers. By determining the forward reasoning formula of the first speech model and splitting the first speech model according to the multiple first weight matrices in the forward reasoning formula, the equivalent splitting of the structure of the first speech model is achieved.
[0061] Figure 3 A flow chart showing the steps of splitting the first speech model according to multiple first weight matrices to obtain multiple fully connected layers in a method for quantizing speech model training according to an embodiment of the present invention is shown; wherein the steps of splitting the first speech model according to multiple first weight matrices to obtain multiple fully connected layers include:
[0062] Step 302: determining a computational relationship between a plurality of first weight matrices according to a plurality of first weight matrices;
[0063] Step 304: merging the plurality of first weight matrices according to the operational relationship between the plurality of first weight matrices to obtain a plurality of second weight matrices;
[0064] Step 306: Obtain multiple fully connected layers according to the multiple second weight matrices.
[0065] In this embodiment, the first speech model is split according to multiple first weight matrices to obtain multiple fully connected layers, including: first, determining the operational relationship between multiple first weight matrices according to multiple first weight matrices and forward reasoning formulas, and then merging them according to the operational relationship between the first weight matrices to obtain multiple second weight matrices, wherein the number of second weight matrices is less than the number of first weight matrices. Since the forward reasoning formula contains multiple equations, and the multiple equations are formed by the operational relationship between multiple first weight matrices, the multiple equations, i.e., the operational relationship between multiple first weight matrices, can be merged to obtain multiple operational relationships about the second weight matrices. Finally, multiple fully connected layers are obtained according to the multiple second weight matrices, wherein the number of fully connected layers is the same as the number of second weight matrices, that is, the formula formed by the operational relationship of a second weight matrix is used as a fully connected layer.
[0066] Figure 4 A flow chart showing the steps of quantizing the second speech model to obtain the third speech model in the method for speech model quantization training according to an embodiment of the present invention is shown; wherein the steps of quantizing the second speech model to obtain the third speech model include:
[0067] Step 402: Determine the operation structure of the second speech model;
[0068] Step 404: Add multiple pseudo-quantization nodes to the operation structure to obtain a third speech model.
[0069] In this embodiment, the step of quantizing the second speech model to obtain the third speech model includes: determining the operation structure of the second speech model, that is, determining the operation relationship between the fully connected layers, and then manually adding multiple pseudo-quantization nodes in the operation structure to obtain the third speech model. The pseudo-quantization node is a data structure. By adding pseudo-quantization nodes to recognizable operations, statistical information of data flowing through these nodes can be collected, which helps to reduce precision loss in subsequent quantization operations.
[0070] Figure 5 A flow chart showing the steps of adding multiple pseudo-quantization nodes in a computing structure to obtain a third speech model in a method for quantization training of a speech model according to an embodiment of the present invention is shown; wherein the steps of adding multiple pseudo-quantization nodes in a computing structure to obtain a third speech model include:
[0071] Step 502: determining a plurality of operation operations and calculation positions corresponding to the operation operations according to the operation structure;
[0072] Step 504: adding a pseudo quantization node at a calculation position corresponding to the operation based on the absence of a weight matrix during the operation;
[0073] Step 506: Based on the existence of a weight matrix during the operation, a pseudo quantization node is added at a calculation position corresponding to the operation, and a pseudo quantization node is added to the weight matrix.
[0074] In this embodiment, the step of adding multiple pseudo-quantization nodes to the operation structure to obtain the third speech model includes: first, determining multiple operation operations and calculation positions corresponding to the operation operations according to the operation structure, the operation operations may include: addition operation, subtraction operation, multiplication operation, division operation and convolution operation, etc., and the calculation position is the position of the operation operation in the second speech model. Then, the operation operation process is analyzed to determine whether the weight matrix is involved in the operation operation process. When there is no weight matrix in the operation operation process, that is, the weight matrix does not participate in this operation operation, then only the pseudo-quantization node is added to the calculation position corresponding to the operation operation, that is, only the output activation quantization is performed on the operation operation. When there is a weight matrix in the operation operation process, that is, the weight matrix participates in this operation operation, then the pseudo-quantization node is added to the calculation position corresponding to the operation operation, and the pseudo-quantization node needs to be added to the weight matrix at the same time, that is, the operation operation with the weight matrix not only needs to add pseudo-quantization nodes to the weight matrix to complete the quantization, but also needs to quantize the activation output of the operation operation. By adding pseudo-quantization nodes to the calculation position of the operation operation, the quantization of the speech model is realized.
[0075] Figure 6 A flow chart of a method for quantizing a speech model according to an embodiment of the present invention is shown after a step of adding multiple pseudo-quantization nodes in a computing structure; wherein, after a step of adding multiple pseudo-quantization nodes in a computing structure, the method includes:
[0076] Step 602: Obtain a mapping relationship between a floating-point operator and a quantization operator;
[0077] Step 604: Determine a first floating-point operator in the second speech model;
[0078] Step 606: Perform operator replacement on the second speech model according to the first floating-point operator and the mapping relationship to obtain a third speech model.
[0079] In this embodiment, after adding multiple pseudo-quantization nodes to the operation structure, it also includes: obtaining the mapping relationship between the floating-point operator and the quantization operator, then determining the first floating-point operator in the second speech model, and then replacing the operator of the second speech model according to the first floating-point operator and the mapping relationship, thereby obtaining a third speech model. However, when the speech model is GRU, through the mapping relationship between the floating-point operator and the quantization operator, the nn.GRU (a module in PyTorch used to implement the gated recurrent unit) module can be manually mapped to the manually split quantizable GRU module for operator replacement. After the replacement is completed, the quantizable GRU is built and can perform quantization-aware training to simulate the quantization loss to guide the update of the model weights and quantization parameters.
[0080] Figure 7 A flow chart showing the steps of training a third speech model according to a speech training data set to obtain multiple groups of quantization parameters in a speech model quantization training method according to an embodiment of the present invention is shown; wherein the steps of training the third speech model according to the speech training data set to obtain multiple groups of quantization parameters include:
[0081] Step 702: according to the pseudo-quantization node in the third speech model, obtaining the maximum value and the minimum value of the operator in the process of training the third speech model according to the speech training data set;
[0082] Step 704: Determine the scaling factor and the corresponding zero reference point according to the maximum and minimum values of the operator;
[0083] Step 706: Use the scaling factor and the corresponding zero reference point as a set of quantization parameters.
[0084] In this embodiment, the step of training the third speech model according to the speech training data set to obtain multiple groups of quantization parameters includes: first, since the pseudo-quantization node can count the maximum and minimum values of a specific operation, the maximum and minimum values of the operator of the third speech model during the training process are obtained according to the pseudo-quantization node in the third speech model during the training process of the third speech model according to the speech training data set, and then the scaling factor and the corresponding zero reference point are determined according to the maximum and minimum values of the operator, wherein the formula for calculating the scaling factor is: Among them, Scale represents the scaling factor, f max represents the maximum value of the operator, f min It represents the minimum value of the operator. The formula for calculating the zero reference point is Among them, Z 0 represents the zero reference point, f max It represents the maximum value of the operator, Scale represents the scaling factor, and Z maxThe maximum value of the floating point number represented by round() means that the number will be rounded to the nearest integer. The mainstream floating point numbers will be compressed to the range of 0 to 255 (asymmetric) or -128 to 127 (symmetric), that is, Z max It can be 255 or 127. When symmetric quantization is performed, the zero reference point of quantization is equal to 0. Then the scaling factor and the corresponding zero reference point are used as a set of quantization parameters, which can simulate the accuracy loss after quantization during quantization-aware training and serve the downstream to generate the final static quantization fixed-point model.
[0085] Exemplarily, when the first speech model is GRU, the forward reasoning formula of GRU is first determined, where the forward reasoning formula is:
[0086] r t =σ(W ir x t +b ir +W hr h (t-1) +b hr );
[0087] z t =σ(W iz x t +b iz +W hz h (t-1) +b hz );
[0088] n t =tanh(W in x t +b in +r t ×(W hn h (t-1) +b hn ));
[0089] h t =(1-z t )×n t +z t ×h (t-1) .
[0090] Among them, x t It represents the input of the current time step, h (t-1) is the hidden state of the previous step, W ir and W hr is the weight matrix associated with the reset gate, b ir is the bias term of the reset gate in the normal state, σ() represents the activation function, r t represents the reset gate, b hrrepresents the reset gate bias term in the hidden state; z t represents the update gate, W iz and W hz is the weight matrix associated with the update gate, b iz represents the bias term of the update gate in the normal state, b hz It represents the bias term of the update gate in the hidden state, n t represents the candidate hidden state, W in and W hn is the weight matrix associated with the candidate hidden state, tanh() represents the hyperbolic tangent activation function, b in represents the bias term of the candidate hidden state under normal conditions, b hn The bias term of the candidate hidden state under the hidden state represented by h t It represents the hidden state at the current time step.
[0091] From the forward reasoning formula of GRU, we can see that the complete GRU is a composite structure composed of several basic operators, which is composed of 6 weight matrices interspersed with several activation functions and multiplication and addition mathematical operations. Therefore, in order to fully quantize the GRU structure, it is necessary to manually insert pseudo-quantization nodes for targeted optimization so that GRU can also perform quantization-aware training.
[0092] Figure 8 FIG. 1 shows one of the principle diagrams of speech model quantization training according to an embodiment of the present invention; Figure 8 As shown, Figure 8 After splitting the forward reasoning formula, r t =σ(W ir x t +b ir +W hr h (t-1) +b hr ) is used to insert the pseudo-quantization node. Figure 8 In the example, fq represents a pseudo-quantization node, Qadd represents the addition of two quantization results, Sig represents the activation function, and W 11 It means W ir , W 21 It means W hr .because Figure 8 It can be seen that the way to insert pseudo-quantization nodes is to insert them at the input of each operation, for example, in h (t-1) With W 21 When performing multiplication, h (t-1) Input is inserted, and when Sig operation is to be performed, it is inserted before the Sig operation. At the same time, it can also be inserted in the weight matrix W11 and W 21 , it is inserted not only during the operation but also inside the weight matrix.
[0093] Fig. 9 FIG. 2 shows a second schematic diagram of the speech model quantization training of an embodiment of the present invention; Fig. 9 As shown, Fig. 9 Is to split the complete GRU equivalently into W r , W h Schematic diagram after two fully connected layers. The op (operation) with weights not only needs to add pseudo-quantization nodes to the weight matrix to complete quantization, but also needs to quantize the activation output of the op. Other ops only quantize the output activation. According to the forward reasoning formula of GRU, r t , n t , z t The three rows, a total of six matrix multiplication operations, can be combined into two fully connected layers, one for receiving the complete input x for non-streaming training. t , and another one for receiving the state quantity h updated frame by frame (t-1) The calculation of rt and nt can be done in parallel, and the first fully connected layer can complete the calculation of x at once instead of intercepting it and recalculating it at time t in each frame. Fig. 9 In the figure, the weights of each of the two fully connected layers are 192×64 and the bias is 192. First, the two fully connected layers are split (Split), wherein the dimension (axis) is 1 during data splitting, and then the data after data splitting are added (Add), and the obtained sum is classified (Logistic). After the classification operation is completed, the first classification of the first fully connected layer is subtracted (Sub), wherein the subtrahend is 1 (A=1), and the second classification is multiplied (Mul) with other inputs. After the second fully connected layer performs classification operation, it is multiplied (Mul) with the data after data splitting of the first connection layer to obtain first data, the first data is added (Add) with the data after data splitting of the second connection layer to obtain second data, the second data is subjected to a hyperbolic tangent activation function (Tanh) operation to obtain third data, the third data is multiplied (Mul) with the data after subtraction (Sub) of the first classification of the first fully connected layer to obtain fourth data, and the fourth data is added (Add) with the data of the second classification multiplied (Mul) with other inputs to obtain the final output.
[0094] Fig.10A schematic block diagram of a system for quantizing and training a speech model according to an embodiment of the present invention is shown; wherein the system 100 for quantizing and training a speech model comprises:
[0095] A first acquisition module 1002 is used to acquire a first speech model, wherein the first speech model includes a gated recurrent unit;
[0096] A splitting module 1004 is used to split the structure of the first speech model to obtain a second speech model, wherein the second speech model includes at least one fully connected layer;
[0097] A quantization module 1006, configured to quantize the second speech model to obtain a third speech model, wherein the third speech model includes a plurality of pseudo quantization nodes;
[0098] A second acquisition module 1008 is used to acquire a speech training data set;
[0099] A training module 1010 is used to train the third speech model according to the speech training data set to obtain multiple groups of quantization parameters;
[0100] The first determination module 1012 is used to determine the target speech model according to the quantization parameter.
[0101] The system 100 for speech model quantization training provided by the present invention mainly includes: a first acquisition module 1002, a splitting module 1004, a quantization module 1006, a second acquisition module 1008, a training module 1010 and a first determination module 1012. Among them, the first acquisition module 1002 first acquires the first speech model, and the first speech model can be a GRU (Gate Recurrent Unit, gated recurrent unit) structure. Then the structure of the first speech model is analyzed, and the calculation relationship inside the first speech model is determined by the structure of the first speech model, and then the splitting module 1004 can perform equivalent splitting of the structure of the first speech model through the calculation relationship, that is, the structure of the first speech model is equivalently split into multiple fully connected layers, so as to obtain a second speech model, wherein the second speech model contains at least one fully connected layer. After obtaining the second speech model, the quantization module 1006 performs model quantization processing on the second speech model. Model quantization refers to converting the floating-point algorithm of the neural network into a fixed-point algorithm. Model quantization can reduce the resource overhead occupied by the model, improve the reasoning speed of the model, and better meet the needs of real-time deployment. That is to say, the floating-point algorithm in the second speech model is converted into a fixed-point algorithm. Among them, the second speech model can be quantized by manually adding a pseudo-quantization node to obtain a third speech model, wherein the third speech model includes multiple pseudo-quantization nodes. Pseudo-quantization nodes are a technology used to count the maximum and minimum values of specific operations during training. Therefore, after obtaining the third speech model, the second acquisition module 1008 obtains a speech training data set, wherein the speech training data in the speech training data set are all data determined in advance, and then the training module 1010 trains the third speech model according to the needs of the speech training data set, and determines multiple groups of quantization parameters through multiple pseudo-quantization nodes in the third speech model during the training process. The quantization parameters can simulate the precision loss after quantization during quantization perception training, and serve the downstream to generate the final static quantization fixed-point model, that is, the first determination module 1012 determines the target speech model according to multiple groups of quantization parameters. The present invention first performs equivalent splitting of the structure of the speech model, and then quantizes and trains the split speech model to obtain multiple groups of quantization parameters, and then obtains the target speech model according to the quantization parameters. The present invention splits the structure of the speech model and performs quantization training on the split speech model, so that the speech model that cannot be quantized under the Pytorch (an open source programming language machine learning library) training framework can be quantized, thereby reducing the volume of the speech model and improving the compression rate and acceleration effect of the speech model.
[0102] In some embodiments, optionally, the splitting module 1004 is used to determine a forward reasoning formula of the first speech model based on the first speech model; determine multiple first weight matrices in the forward reasoning formula; split the first speech model according to the multiple first weight matrices to obtain multiple fully connected layers; and determine the second speech model based on the multiple fully connected layers.
[0103] In this embodiment, the splitting module 1004 first determines the forward reasoning formula of the first speech model according to the first speech model, and the forward reasoning formula can represent the information transmission process from the input layer to the output layer of the first speech model. Then, multiple first weight matrices in the forward reasoning formula are determined, and the forward reasoning formula and the determined multiple first weight matrices are analyzed. Then, the first speech model is split according to the multiple first weight matrices to obtain multiple fully connected layers, in which all nodes of the previous layer are connected to each node of the next layer, so that the fully connected layer can learn and extract input features more deeply. Finally, the second speech model is determined based on the multiple fully connected layers. By determining the forward reasoning formula of the first speech model and splitting the first speech model according to the multiple first weight matrices in the forward reasoning formula, the equivalent splitting of the first speech model structure is achieved.
[0104] In some embodiments, optionally, the splitting module 1004 is also used to determine the operational relationship between multiple first weight matrices based on multiple first weight matrices; merge the multiple first weight matrices according to the operational relationship between the multiple first weight matrices to obtain multiple second weight matrices; and obtain multiple fully connected layers based on the multiple second weight matrices.
[0105] In this embodiment, the splitting module 1004 first determines the operational relationship between multiple first weight matrices based on multiple first weight matrices and forward reasoning formulas, and then merges them based on the operational relationship between the first weight matrices to obtain multiple second weight matrices, wherein the number of second weight matrices is less than the number of first weight matrices. Since the forward reasoning formula contains multiple equations, and the multiple equations are formed by the operational relationship between multiple first weight matrices, the multiple equations, i.e., the operational relationship between multiple first weight matrices, can be merged to obtain multiple operational relationships about the second weight matrices. Finally, multiple fully connected layers are obtained based on the multiple second weight matrices, wherein the number of fully connected layers is the same as the number of second weight matrices, i.e., the formula formed by the operational relationship of a second weight matrix is used as a fully connected layer.
[0106] In some embodiments, optionally, the quantization module 1006 is used to determine an operation structure of the second speech model; and add a plurality of pseudo-quantization nodes to the operation structure to obtain a third speech model.
[0107] In this embodiment, the quantization module 1006 is used to determine the operation structure of the second speech model, that is, to determine the operation relationship between the fully connected layers, and then manually add multiple pseudo-quantization nodes in the operation structure to obtain the third speech model. The pseudo-quantization node is a data structure. By adding pseudo-quantization nodes to recognizable operations, statistical information of the data flowing through these nodes can be collected, which helps to reduce the loss of precision in subsequent quantization operations.
[0108] In some embodiments, optionally, the quantization module 1006 is specifically used to determine multiple operation operations and calculation positions corresponding to the operation operations according to the operation structure; based on the absence of a weight matrix during the operation operation, a pseudo quantization node is added to the calculation position corresponding to the operation operation; based on the presence of a weight matrix during the operation operation, a pseudo quantization node is added to the calculation position corresponding to the operation, and a pseudo quantization node is added to the weight matrix.
[0109] In this embodiment, the quantization module 1006 is specifically used to first determine multiple operation operations and calculation positions corresponding to the operation operations according to the operation structure. The operation operations may include: addition operation, subtraction operation, multiplication operation, division operation and convolution operation, etc. The calculation position is the position of the operation operation in the second speech model. Then the operation operation process is analyzed to determine whether the weight matrix is involved in the operation operation process. When there is no weight matrix in the operation operation process, that is, the weight matrix does not participate in this operation operation, then only add pseudo quantization nodes at the calculation position corresponding to the operation operation, that is, only perform output activation quantization on the operation operation. When there is a weight matrix in the operation operation process, that is, the weight matrix participates in this operation operation, then add pseudo quantization nodes at the calculation position corresponding to the operation operation, and also need to add pseudo quantization nodes in the weight matrix, that is, the operation operation with the weight matrix not only needs to add pseudo quantization nodes to the weight matrix to complete quantization, but also needs to quantize the activation output of the operation operation. By adding pseudo quantization nodes at the calculation position of the operation operation, the quantization of the speech model is realized.
[0110] In some embodiments, the quantization module 1006 is also specifically used to obtain a mapping relationship between a floating-point operator and a quantization operator; determine a first floating-point operator in a second speech model; and replace the operator of the second speech model according to the first floating-point operator and the mapping relationship to obtain a third speech model.
[0111] In this embodiment, the quantization module 1006 is also specifically used to obtain the mapping relationship between the floating-point operator and the quantization operator, and then determine the first floating-point operator in the second speech model, and then replace the operator of the second speech model according to the first floating-point operator and the mapping relationship, so as to obtain the third speech model. However, when the speech model is GRU, through the mapping relationship between the floating-point operator and the quantization operator, the nn.GRU (a module in PyTorch used to implement the gated recurrent unit) module can be manually mapped to the manually split quantizable GRU module for operator replacement. After the replacement is completed, the quantizable GRU is built and can perform quantization-aware training to simulate the quantization loss to guide the update of the model weights and quantization parameters.
[0112] In some embodiments, optionally, the training module 1010 is used to obtain the maximum and minimum values of the operator in the process of training the third speech model according to the speech training data set based on the pseudo-quantization nodes in the third speech model; determine the scaling factor and the corresponding zero reference point according to the maximum and minimum values of the operator; and use the scaling factor and the corresponding zero reference point as a set of quantization parameters.
[0113] In this embodiment, the training module 1010 is used to obtain the maximum and minimum values of the operator of the third speech model during the training process according to the pseudo-quantization nodes in the third speech model, and then determine the scaling factor and the corresponding zero reference point according to the maximum and minimum values of the operator, wherein the formula for calculating the scaling factor is: Among them, Scale represents the scaling factor, f max represents the maximum value of the operator, f min It represents the minimum value of the operator. The formula for calculating the zero reference point is Among them, Z 0 represents the zero reference point, f max It represents the maximum value of the operator, Scale represents the scaling factor, and Z max The maximum value of the floating point number represented by round() means that the number will be rounded to the nearest integer. The mainstream floating point numbers will be compressed to the range of 0 to 255 (asymmetric) or -128 to 127 (symmetric), that is, Z max It can be 255 or 127. When symmetric quantization is performed, the zero reference point of quantization is equal to 0. Then the scaling factor and the corresponding zero reference point are used as a set of quantization parameters, which can simulate the accuracy loss after quantization during quantization-aware training and serve the downstream to generate the final static quantization fixed-point model.
[0114] Fig.11A schematic block diagram of an electronic device of an embodiment of the present invention is shown; wherein the electronic device 1100 includes a memory 1102, a processor 1104, and a computer program stored in the memory 1102 and executable on the processor 1104, and when the processor 1104 executes the computer program, the steps of the method for quantizing the speech model as described above are implemented.
[0115] The electronic device 1100 provided by the present invention, in which the processor 1104 implements the steps of the above-mentioned method for quantizing and training the speech model when executing a computer program, can achieve the technical effect of any of the above-mentioned embodiments and will not be repeated here.
[0116] An embodiment of the present invention provides a storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method for quantizing and training a speech model as described above are implemented.
[0117] The storage medium provided by the present invention, when the computer program is executed by a processor, implements the steps of the above-mentioned method for quantization training of the speech model, which can achieve the technical effect of any of the above-mentioned embodiments and will not be repeated here.
[0118] The storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device. The storage medium may be an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the above devices, but is not limited thereto. A non-exhaustive list of more specific examples of storage media includes: a portable computer floppy disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory card, a floppy disk, a coding mechanical device (such as a punch card or a groove with a raised structure with instructions recorded thereon), and any suitable combination of the above devices. The storage medium used herein should not be understood as a transmission signal itself, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media, or electrical signals transmitted through wires.
[0119] One embodiment of the present invention provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the method for speech model quantization training in any of the above embodiments.
[0120] The computer program product provided in this embodiment implements the steps of the method for quantizing speech models as in any embodiment of the present invention, and thus has all the beneficial effects of the method for quantizing speech models as in any embodiment of the present invention, which will not be described in detail here.
[0121] In the description of this specification, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance unless otherwise clearly specified and limited; the terms "connection", "installation", "fixation" and the like should be understood in a broad sense, for example, "connection" can be a fixed connection, a detachable connection, or an integral connection; it can be directly connected or indirectly connected through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0122] In the description of this specification, the description of the terms "one embodiment", "some embodiments", "specific embodiments", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0123] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for quantizing and training a speech model. It is characterized in that include: Acquire a first speech model, wherein the first speech model includes a gated recurrent unit; Splitting the structure of the first speech model to obtain a second speech model, wherein the second speech model includes at least one fully connected layer; quantizing the second speech model to obtain a third speech model, wherein the third speech model includes a plurality of pseudo quantization nodes; Obtain a speech training data set; Training the third speech model according to the speech training data set to obtain multiple groups of quantization parameters; A target speech model is determined according to the quantization parameters.
2. The method for quantizing and training a speech model according to claim 1, It is characterized in that The step of splitting the structure of the first speech model to obtain the second speech model includes: Determining a forward reasoning formula of the first speech model according to the first speech model; Determining a plurality of first weight matrices in the forward reasoning formula; Splitting the first speech model according to the plurality of the first weight matrices to obtain a plurality of the fully connected layers; The second speech model is determined according to a plurality of fully connected layers.
3. The method for quantizing and training a speech model according to claim 2, It is characterized in that The step of splitting the first speech model according to the plurality of the first weight matrices to obtain the plurality of the fully connected layers comprises: Determine an operation relationship between a plurality of the first weight matrices according to the plurality of the first weight matrices; Merging the plurality of first weight matrices according to the operational relationship between the plurality of first weight matrices to obtain a plurality of second weight matrices; A plurality of the fully connected layers are obtained according to the plurality of the second weight matrices.
4. The method for quantizing and training a speech model according to claim 1, It is characterized in that The step of quantizing the second speech model to obtain a third speech model includes: Determining an operation structure of the second speech model; A plurality of the pseudo-quantization nodes are added to the operation structure to obtain the third speech model.
5. The method for quantizing and training a speech model according to claim 4, It is characterized in that The step of adding a plurality of pseudo-quantization nodes in the operation structure to obtain the third speech model comprises: Determine a plurality of computing operations and calculation positions corresponding to the computing operations according to the computing structure; Based on the absence of a weight matrix during the operation, adding the pseudo quantization node at the calculation position corresponding to the operation; Based on the presence of the weight matrix during the operation, the pseudo quantization node is added to the calculation position corresponding to the operation, and the pseudo quantization node is added to the weight matrix.
6. The method for quantizing and training a speech model according to claim 5, It is characterized in that After the step of adding a plurality of pseudo quantization nodes to the operation structure, the method further includes: Get the mapping relationship between floating-point operators and quantization operators; Determining a first floating-point operator in the second speech model; The operator of the second speech model is replaced according to the first floating-point operator and the mapping relationship to obtain the third speech model.
7. The method for quantizing and training a speech model according to any one of claims 1 to 6, It is characterized in that The step of training the third speech model according to the speech training data set to obtain multiple groups of quantization parameters includes: According to the pseudo-quantization node in the third speech model, obtaining the maximum value and the minimum value of the operator in the process of training the third speech model according to the speech training data set; Determine a scaling factor and a corresponding zero reference point according to a maximum value and a minimum value of the operator; The scaling factor and the corresponding zero reference point are taken as a set of quantization parameters.
8. A system for quantizing and training speech models. It is characterized in that include: A first acquisition module, the first acquisition module is used to acquire a first speech model, wherein the first speech model includes a gated recurrent unit; A splitting module, wherein the splitting module is used to split the structure of the first speech model to obtain a second speech model, wherein the second speech model includes at least one fully connected layer; A quantization module, the quantization module is used to quantize the second speech model to obtain a third speech model, wherein the third speech model includes a plurality of pseudo quantization nodes; A second acquisition module, the second acquisition module is used to acquire a speech training data set; A training module, wherein the training module is used to train the third speech model according to the speech training data set to obtain multiple groups of quantization parameters; A first determination module is used to determine a target speech model according to the quantization parameter.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the steps of the method for quantization training of a speech model as described in any one of claims 1 to 7 are implemented.
10. A storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method for quantization training of a speech model as described in any one of claims 1 to 7 are implemented.
11. A computer program product comprising computer instructions, It is characterized in that When the computer instructions are executed by a processor, the steps of the method for quantization training of a speech model as described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Model optimization method, service processing method, server and terminal equipment
CN119272822A
