Robustness Aware Norm Decay for Quantization Aware Training and Generalization
A method includes obtaining a plurality of training samples, determining a minimum integer fixed-bit width representing a maximum quantization of an automatic speech recognition (ASR) model, and training the ASR model on the plurality of training samples using a quantity of random noise. The ASR model includes a plurality of weights that each include a respective float value. The quantity of random noise is based on the minimum integer fixed-bit value. After training the ASR model, the method also includes selecting a target integer fixed-bit width greater than or equal to the minimum integer fixed-bit width, and for each respective weight of the plurality of weights, quantizing the respective weight from the respective float value to a respective integer associated with a value of the selected target integer fixed-bit width. The operations also include providing the quantized trained ASR model to a user device.
Latest Google Patents:
This U.S. patent application claims priority under 35 U.S.C. § 119(e) to U.S. Provisional Application 63/495,310, filed on Apr. 11, 2023. The disclosure of this prior application is considered part of the disclosure of this application and is hereby incorporated by reference in its entirety.
TECHNICAL FIELDThis disclosure relates to robustness aware norm decay for quantization aware training and generalization.
BACKGROUNDModern automated speech recognition (ASR) systems focus on providing not only high quality (e.g., a low word error rate (WER)), but also low latency (e.g., a short delay between the user speaking and a transcription appearing). Moreover, when using an ASR system today there is a demand that the ASR system decode utterances in a streaming fashion that corresponds to real-time or even faster than real-time. To illustrate, when an ASR system is deployed on a mobile phone that experiences direct user interactivity, an application on the mobile phone using the ASR system may require the speech recognition to be streaming such that words appear on the screen as soon as they are spoken. Here, it is also likely that the user of the mobile phone has a low tolerance for latency. Due to this low tolerance, the speech recognition strives to run on the mobile device in a manner that minimizes an impact from latency and inaccuracy that may detrimentally affect the user's experience. However, mobile phones often have limited resources, which limit the size of the ASR model.
SUMMARYOne aspect of the disclosure provides a computer-implemented method that when executed on data processing hardware causes the data processing hardware to perform operations that include obtaining a plurality of training samples, determining a minimum integer fixed-bit width representing a maximum quantization of an automatic speech recognition (ASR) model, and training the ASR model on the plurality of training samples using a quantity of random noise. Each respective training sample of the plurality of training samples includes a respective speech utterance and a respective textual utterance representing a transcription of the respective speech utterance. The ASR model includes a plurality of weights, wherein each respective weight of the plurality of weights includes a respective float value. The quantity of random noise used for training the ASR model is based on the minimum integer fixed-bit value. After training the ASR model, the operations also include selecting a target integer fixed-bit width greater than or equal to the minimum integer fixed-bit width, and for each respective weight of the plurality of weights, quantizing the respective weight from the respective float value to a respective integer with the selected target integer fixed-bit width. The operations also include providing the quantized trained ASR model to a user device.
Implementations of the disclosure may include one or more of the following optional features. In some implementations, training the ASR model using the quantity of random noise includes, for each respective channel of each respective tensor of the ASR model, determining a respective maximum value for the respective channel of the respective tensor, and adding, to the respective channel of the respective tensor, a uniform distribution of noise based on the respective maximum value and the minimum integer fixed-bit width. In these implementations, the uniform distribution of noise may represent the entire range of noise the ASR model receives due to quantization up to the minimum integer fixed-bit width. Additionally, adding the uniform distribution of noise may include scaling the uniform distribution of noise based on the respective maximum value, while scaling the uniform distribution of noise may be further based on a sensitivity of the respective channel to scaling.
In some examples, the maximum quantization level includes a 4-bit quantization. In other examples, the maximum quantization level includes a 2-bit quantization. The random noise may be drawn from a uniform distribution of noise.
In some additional implementations, training the ASR model using the quantity of random noise includes adding, during forward propagation of the ASR model, the quantity of random noise. The ASR model may further include a plurality of activations each associated with a respective float value such that for each respective action of the plurality of activations, the operations further include quantizing the respective activation from the respective float value to the respective integer with the selected target fixed-bit width.
Another aspect of the disclosure provides a system that includes data processing hardware and memory hardware storing instructions that when executed on the data processing hardware causes the data processing hardware to perform operations that include obtaining a plurality of training samples, determining a minimum integer fixed-bit width representing a maximum quantization of an automatic speech recognition (ASR) model, and training the ASR model on the plurality of training samples using a quantity of random noise. Each respective training sample of the plurality of training samples includes a respective speech utterance and a respective textual utterance representing a transcription of the respective speech utterance. The ASR model includes a plurality of weights, wherein each respective weight of the plurality of weights includes a respective float value. The quantity of random noise used for training the ASR model is based on the minimum integer fixed-bit value. After training the ASR model, the operations also include selecting a target integer fixed-bit width greater than or equal to the minimum integer fixed-bit width, and for each respective weight of the plurality of weights, quantizing the respective weight from the respective float value to a respective integer with the selected target integer fixed-bit width. The operations also include providing the quantized trained ASR model to a user device
This aspect of the disclosure may include one or more of the following optional features. In some implementations, training the ASR model using the quantity of random noise includes, for each respective channel of each respective tensor of the ASR model, determining a respective maximum value for the respective channel of the respective tensor, and adding, to the respective channel of the respective tensor, a uniform distribution of noise based on the respective maximum value and the minimum integer fixed-bit width. In these implementations, the uniform distribution of noise may represent the entire range of noise the ASR model receives due to quantization up to the minimum integer fixed-bit width. Additionally, adding the uniform distribution of noise may include scaling the uniform distribution of noise based on the respective maximum value, while scaling the uniform distribution of noise may be further based on a sensitivity of the respective channel to scaling.
In some examples, the maximum quantization level includes a 4-bit quantization. In other examples, the maximum quantization level includes a 2-bit quantization. The random noise may be drawn from a uniform distribution of noise.
In some additional implementations, training the ASR model using the quantity of random noise includes adding, during forward propagation of the ASR model, the quantity of random noise. The ASR model may further include a plurality of activations each associated with a respective float value such that for each respective action of the plurality of activations, the operations further include quantizing the respective activation from the respective float value to the respective integer with the selected target fixed-bit width
Another aspect of the present disclosure provides a computer-implemented method that when executed on data processing hardware causes the data processing hardware to perform operations that include obtaining a plurality of training samples, determining a minimum integer fixed-bit width representing a maximum quantization of a model, and training the model on the plurality of training samples using a quantity of random noise. The model includes a plurality of weights, wherein each respective weight of the plurality of weights includes a respective float value. The quantity of random noise used for training the model is based on the minimum integer fixed-bit value. After training the model, the operations also include selecting a target integer fixed-bit width greater than or equal to the minimum integer fixed-bit width, and for each respective weight of the plurality of weights, quantizing the respective weight from the respective float value to a respective integer with the selected target integer fixed-bit width. The operations also include providing the quantized trained ASR model to a user device.
This aspect of the disclosure may include one or more of the following optional features. In some implementations, the model includes an automated speech recognition (ASR) model. In other implementations, the model includes a large language model. In yet other implementations, the model includes an image processing model.
The details of one or more implementations of the disclosure are set forth in the accompanying drawings and the description below. Other aspects, features, and advantages will be apparent from the description and drawings, and from the claims.
Like reference symbols in the various drawings indicate like elements.
DETAILED DESCRIPTIONWith the fast growth of voice search and speech-interactive features, automatic speech recognition (ASR) has become an essential component for user-interactive services and devices (e.g., search by voice functions in search engines and smartphones). Modern ASR applications are often developed based on an end-to-end model, which has been shown to achieve significant recognition performance improvements compared to conventional hybrid systems with a much smaller model size. Improving latency and model size without compromising recognition quality has been an active pursuit to benefit live ASR applications with both server-side and on-device models.
Quantization is a technique to reduce the computational and memory costs of ASR models by representing the weights and/or activations with lower precision data types (e.g., an 8-bit integer) instead of a conventional 32-bit floating point value. Among modern model quantization methods, post training quantization (PTQ) with 8-bit integers (int8) is a popular and easy to use technique that has been successfully applied in many applications. However, one of the drawbacks of such a technique is the potential performance degradation due to the loss of precision. Moreover, PTQ, during training, generally does not expose the model to noise the model experiences after training, which causes accuracy to further suffer.
Quantization aware training (QAT) is an alternative technique to PTQ that emulates quantization during the forward pass in training, which allows the network to learn from the quantization. That is, the quantization emulation introduces error to the model which the model attempts to compensate for by adjusting parameters (i.e., weights). Thus, QAT tends to reduce loss versus conventional PTQ methods. However, conventional QAT relies on the user committing to the amount of quantization during training. That is, conventional QAT requires the user to select what weights and/or activations will be quantized and to what extent (e.g., 8-bit, 4-bit, etc.) during training. The resulting trained model will generally lose accuracy whenever quantized in a manner different from what was emulated during training. For example, a model trained using QAT for 8-bit quantization will be less accurate at 4-bit quantization than a model trained using 4-bit quantization. The reverse is also true in that a model trained using QAT for 4-bit quantization will be less accurate at 8-bit quantization than a model trained using 8-bit quantization. Put another way, the model tends to be tuned to the particular use case dictated during training. This requires training separate models for each potential quantization use case. Because very large and complex models (such as large language models (LLMs)) take considerable resources to train and store, the training of models individually is not ideal.
Implementations herein are directed toward a model trainer that trains an ASR model (or a large language model (LLM) or image processing model) using robustness aware norm decay for QAT. The model trainer trains the ASR model to be robust to quantization with a per channel scale by adding an expected noise distribution during training. For example, the model trainer determines a worst-case amount of noise the ASR model is subject to from quantization. The model trainer adds a uniform distribution of noise to the ASR model during training based on the worst-case amount of noise. The model trainer improves the robustness of learned weights to deployment time perturbation by pushing the converged set of weights toward a flat minimum, which lowers the loss increase after rounding. The model trainer also makes the converged set of weights closer to the quantization centroid to decrease rounding noise. Additionally, the model trainer trains the ASR model to be both robust at lower precisions and higher precisions compared to conventional models. In some implementations, the model trainer lowers the quantization scale parameter (i.e., the matrix norm of the weight matrix) in order to ensure the rounding noise is less scaled. While specific examples depict the training and quantization of an ASR model, the techniques disclosed herein are equally applicable to training and quantizing other types of models, such as, without limitation, large language models (LLMs) and image processing models.
The user device 10 may correspond to any computing device associated with a user 104 and capable of receiving audio data. Some examples of user devices 10 include, but are not limited to, mobile devices (e.g., mobile phones, tablets, laptops, etc.), computers, wearable devices (e.g., smart watches), smart appliances, internet of things (IoT) devices, vehicle infotainment systems, smart displays, smart speakers, etc. The user device 10 includes data processing hardware 12 and memory hardware 14 in communication with the data processing hardware 12 and stores instructions, that when executed by the data processing hardware 12, cause the data processing hardware 12 to perform one or more operations. The user device 10 further includes an audio system 16 with an audio capture device (e.g., microphone) 16, 16a for capturing and converting spoken utterances 106 within the speech environment 101 into electrical signals and a speech output device (e.g., a speaker) 16, 16b for communicating an audible audio signal (e.g., as output audio data from the device 10). While the user device 10 implements a single audio capture device 16a in the example shown, the user device 10 may implement an array of audio capture devices 16a without departing from the scope of the present disclosure, whereby one or more capture devices 16a in the array may not physically reside on the user device 10, but be in communication with the audio system 16.
In the speech environment 101, an automated speech recognition (ASR) system 118 includes a model 200 (such as a recurrent neural network-transducer (RNN-T) model or other conformer transducer model/multi-pass model) that resides on the user device 10 of the user 104 and/or on a remote computing device 60 (e.g., one or more remote servers of a distributed system executing in a cloud-computing environment) in communication with the user device 10 via a network 40. The remote computing device is equipped with data processing hardware 62 and memory hardware 64. The user device 10 and/or the remote computing device 60 also includes an audio subsystem 108 configured to receive the utterance 106 spoken by the user 104 and captured by the audio capture device 16a, and convert the utterance 106 into a corresponding digital format associated with input acoustic frames 110 capable of being processed by the ASR system 118. In the example shown, the user speaks a respective utterance 106 and the audio subsystem 108 converts the utterance 106 into corresponding audio data (e.g., acoustic frames) 110 for input to the ASR system 118. Thereafter, the model 200 receives, as input, the audio frames 110 (i.e., audio data) corresponding to the utterance 106, and generates/predicts, as output, a corresponding transcription 120 (e.g., speech recognition result/hypothesis) of the utterance 106.
The user device 10 and/or the remote computing device 60 also executes a user interface generator 107 configured to present a representation of the transcription 120 of the utterance 106 to the user 104 of the user device 10. As described in greater detail below, the user interface generator 107 may display the speech recognition results 120 in a streaming fashion. In some configurations, the transcription 120 output from the ASR system 118 is processed, e.g., by a natural language understanding (NLU) module executing on the user device 10 or the remote computing device 60, to execute a user command/query specified by the utterance 106. Additionally or alternatively, a text-to-speech system (not shown) (e.g., executing on any combination of the user device 10 or the remote computing device 60) may convert the transcription into synthesized speech for audible output by the user device 10 and/or another device.
In the example shown, the user 104 interacts with a program or application 50 (e.g., the digital assistant application 50) of the user device 10 that uses the ASR system 118. For instance,
Referring now to
The model trainer 150 trains the ASR model 200 on the plurality of training samples 152. The ASR model 200 includes weights 202 and activations 204. In some examples, the weights 202 and/or activations 204 are 32-bit float values. In other examples, the weights 202 and/or activations 204 are other float values. As discussed in more detail below, the model trainer 150 uses quantization aware training to adjust the weights 202 and/or activations 204 of the ASR model 200 by adding a quantity of random noise 162 to the weights 202 and/or the activations 204 during training.
After training the ASR model 200, a model quantizer 170 selects a target integer fixed-bit width 172 for the ASR model 200. The target integer fixed-bit width 172 may be any value greater than or equal to the minimum integer fixed-bit width 160. For example, when the minimum integer fixed-bit width 160 is 4-bit, the target integer fixed-bit width 172 may be 4-bit, 8-bit, 16-bit, 32-bit, etc. The target integer fixed-bit width 172 may be pre-determined for the use case of the ASR model 200 or based on the user device 10 (or whatever computing the device the ASR model 200 is to execute on). For example, the target integer fixed-bit width 172 may be 4-bit when the computing device (e.g., the user device 10) has minimal computing resources. In another example, the target integer fixed-bit width 172 may be 8-bit when the computing device has more significant computing resources. In some examples, the target integer fixed-bit width 172 is configurable (e.g., by the user 104). The model quantizer 170, for some or all of the weights 202 of the ASR model 200, quantizes the respective weight 202 from the respective float value (e.g., 32-bit float value) to a respective integer with a value of the selected target integer fixed-bit width 172. For example, when the selected target integer fixed-bit width 172 is 4-bit, the model quantizer 170 quantizes the float values of the weights 202 and/or the activations 204 to 4-bit integer values. In some implementations, the remote computing device 60 provides the quantized model 200, 200Q with the quantized weights 202, 202Q and/or the quantized activations 204, 204Q to the user device 10.
Neural networks generally involve tensors that include matrix multiplications. The matrix multiplication of the tensors may be modeled as y=Wx where x is an input column vector, W is a weight matrix, and y is an output column vector. Accordingly, each row may be modeled by yi=Wix where i is the row. Each row may be referred to as a channel of the respective tensor. Conventionally, the values of the weight matrix (i.e., W) are 32-bit float values. During quantization, these float values are converted to a corresponding integer value (i.e., a 4-bit integer, an 8-bit integer, etc.). This necessarily involves a loss of precision via rounding. This rounding introduces noise to the weights, and this noise may introduce loss of accuracy during inference. Quantization aware training attempts to make the network aware of this noise by introducing noise comparable to the noise introduced during quantization. For example, during conventional QAT, a model that is to be quantized to 8-bit integers has noise introduced that emulates the noise generated by rounding the float values to 8-bit integers. However, this noise is specific to the specific quantization the model is trained for, making the model sub-optimal for other quantization values.
In contrast, the model trainer 150 introduces the ASR model 200 to noise that allows the model 200 to adapt to noise present for different quantization values simultaneously. In some implementations, the model trainer 150, while training the ASR model 200, randomly draws the noise 162 from a uniform distribution of noise. In some of these implementations, the model trainer 150 determines a respective maximum value for each channel of each tensor of the ASR model 200. For example, the maximum value represents the absolute value of the maximum weight value for the channel. The model trainer 150 adds noise to each respective channel of each respective tensor of the ASR model 200 (e.g., during forward propagation) separately and independently based on the maximum value for the respective channel and the minimum integer fixed-bit width 160. In some implementations, the uniform distribution of noise represents the entire range of noise the ASR model 200 may receive due to quantization up to the minimum integer fixed-bit width 160. Generally speaking, the greater the quantization (i.e., the smaller the integer width the weights 202 and/or activations 204 are rounded to), the greater the noise introduced to the ASR model 200. The uniform distribution of noise may include up to the maximum amount of noise the ASR model 200 may be introduced to based on the minimum integer fixed-bit width 160. For example, when the minimum integer fixed-bit width 160 is 4-bit, the uniform distribution includes noise up to the maximum the ASR model 200 may experience when quantized to 4-bit integers. In some implementations, the model trainer 150 adds noise per the following equation, where y is the output, W is the weight, bit is the minimum integer fixed-bit width 160 (i.e., four for 4-bit quantization, eight for 8-bit quantization, etc.), and N is the added noise.
where every entry of Ni is drawn from Unif(−0.5,0.5) (1)
By sampling the added noise from such a uniform distribution, the model trainer 150 exposes the ASR model 200 to noise that emulates a range of quantization from the maximum quantization represented by the minimum integer fixed-bit width 160 to no quantization. This allows the ASR model 200 to learn to adapt to each of these different noise scenarios. The model trainer 150 adds this noise on a per channel basis because adding the noise globally (e.g., at the tensor level) would introduce incorrect per noise power, which would degrade performance of the ASR model 200.
In some implementations, the model trainer 150 scales the added noise to attenuate outliers (i.e., general robustness aware norm decay). That is, the model trainer 150 may make the ASR model 200 “scale-aware” so that information from the noise gradient is not discarded during training. For example, the model trainer may instead model max(|Wi|) from the above equation as maybe_stop_grad(|Wi|) to simultaneously induce robustness to noise and provide a gradient to selectively attenuate outliers. That is, in some implementations, the model trainer 150 back propagates to the norm term ∥Wi∥, which allows the network to learn to lower the scale in a principled way. For example, channels that are more sensitive to scaling may be attenuated more than channels that are relatively less sensitive to scaling. The sensitivity of the channel to scaling represents an amount that scaling affects the output of the channel.
Thus, the model trainer 150 trains the ASR model 200 to be robust to quantization with a per channel scale by adding the expected noise distribution during training. Because the model trainer 150 adds uniform noise, the weights 202 converge to a point where the average loss of the hyper-rectangle around it is minimized. The length of each side of the rectangle depends on the scale for the respective weight 202. The exposure to noise causes the weights 202 to converge toward a flatter minima, while the norm (scale) decay gradients make the hyperrectangle smaller in a principled way. That is, when the network loss value is plotted against the values of the network weights, minimizing average loss over a hyper rectangle causes the weights to converge to a region with a flat loss surface. Because the scale parameter used to scale the noise is based on the worst case noise that the ASR model 200 is designed for (e.g., 4-bit quantization), the noise also covers the ranges of noise encountered for higher precision, allowing the ASR model 200 to operate effectively at both lower precision and higher precision.
The model trainer 150 may apply the techniques described herein to some or all of the weights 202 of the ASR model 200, some or all of the activations 204 of the ASR model 200, or any combination thereof. The model trainer 150 enables training of a single ASR model 200 that can be effectively quantized to a number of different precisions, which greatly improves efficiency of research and evaluation. While examples herein describe an ASR model 200, the model trainer 150 may train any other type of model, such as a large language model (LLM), a vision model, etc.
Additionally, techniques herein may be applied to improve generalization of the ASR model 200. That is, ∥Wi∥ is a general norm, and during quantization, the model trainer 150 uses an infinity norm. This may be changed to an L1 or an L2 norm to allow the ASR mode 1200 to learn to reduce the L1 or L2 norm of the matrix depending on how that set of weights are affected by perturbations. This is an improvement over conventional L1 or L2 regularization, where instead every weight is shifted down depending on magnitude only. Because the norm of the weight matrix is related to how much amplification any input or weight noise will encounter, the model trainer 150 may be used to improve generalization of extremely large neural network models. The model trainer 150 may decay the matrix norm depending on how sensitive the norm is to noise perturbations as opposed to robustness unaware technique such as L2 regularization.
Referring now to
Similarly, the prediction network 300 may also be an LSTM network, which, like a language model (LM), processes the sequence of non-blank symbols output by a final Softmax layer 240 so far, y0, . . . , yui-1, into a dense representation put. Finally, with the RNN-T model architecture, the representations produced by the encoder and prediction/decoder networks 210, 300 are combined by the joint network 230. The prediction network 300 may be replaced by an embedding look-up table to improve latency by outputting looked-up sparse embeddings in lieu of processing dense representations. The joint network then predicts P(yi|xt
The Softmax layer 240 may employ any technique to select the output label/symbol with the highest probability in the distribution as the next output symbol predicted by the RNN-T model 200 at the corresponding output step. In this manner, the RNN-T model 200 does not make a conditional independence assumption, rather the prediction of each symbol is conditioned not only on the acoustics but also on the sequence of labels output so far. The RNN-T model 200 does assume an output symbol is independent of future acoustic frames 110, which allows the RNN-T model to be employed in a streaming fashion.
In some examples, the encoder network (i.e., audio encoder) 210 of the RNN-T model 200 includes a stack of multi-head attention layers or self-attention layers/blocks, such as one or more conformer blocks/layers or one or more transformer blocks/layers. Optionally, the encoder 210 (i.e., the audio encoder) includes a first pass causal encoder and a second pass non-causal encoder for a multi-pass architecture. This multi-pass model unifies the streaming and non-streaming ASRs, where the causal encoder uses only left context and produces partial results with minimal latency, and the non-causal encoder can provide more accurate hypothesis by using both left and right context. In this example, each conformer block includes a series of multi-headed self attention, depth wise convolution, and feed-forward layers. The prediction network 300 may have two 2,048-dimensional LSTM layers, each of which is also followed by 640-dimensional projection layer. Alternatively, the prediction network 300 may include a stack of transformer or conformer blocks, or an embedding look-up table in lieu of LSTM layers. Finally, the joint network 230 may also have 640 hidden units. The Softmax layer 240 may be composed of a unified word piece or grapheme set that is generated using all unique word pieces or graphemes in a plurality of training data sets.
Referring to the first head 302A of the multi-headed attention mechanism 302, the head 302A generates, using the shared embedding matrix 304, a corresponding embedding 306, 306a-n (e.g., X∈N×d
While the corresponding embedding generated by shared embedding matrix 304 for each for each non-blank symbol 301 among the sequence of non-blank symbols 301a-n, yui-n, . . . , yui-1, is the same at all of the heads 302A-H of the multi-headed attention mechanism 302, each head 302A-H defines a different set/row of position vectors 308. For instance, the first head 302A defines the row of position vectors PVAa-An 308Aa-An, the second head 302B defines a different row of position vectors PVBa-Bn 308Ba-Bn, . . . , and the Hth head 302 H defines another different row of position vectors PVHa-Hn308Ha-Hn.
For each non-blank symbol in the sequence of non-blank symbols 301a-n received, the first head 302A also weights, via a weight layer 310, the corresponding embedding 306 proportional to a similarity between the corresponding embedding and the respective position vector PV 308 assigned thereto. In some examples, the similarity may include a cosine similarity (e.g., cosine distance). In the example shown, the weight layer 310 outputs a sequence of weighted embeddings 312, 312Aa-An each associated the corresponding embedding 306 weighted proportional to the respective position vector PV 308 assigned thereto. Stated differently, the weighted embeddings 312 output by the weight layer 310 for each embedding 306 may correspond to a dot product between the embedding 306 and the respective position vector PV 308. The weighted embeddings 312 may be interpreted as attending over the embeddings in proportion to how similar they are to the positioned associated with their respective position vectors PV 308. To increase computational speed, the prediction network 300 includes non-recurrent layers, and therefore, the sequence of weighted embeddings 312Aa-An are not concatenated, but instead, averaged by a weighted average module 316 to generate, as output from the first head 302A, a weighted average 318A of the weighted embeddings 312Aa-An represented by:
In the above equation, h represents the index of the heads 302, n represents position in context, and e represents the embedding dimension. Additionally, H, N, and de include the sizes of the corresponding dimensions. The position vector PV 308 does not have to be trainable and may include random values. Notably, even though the weighted embeddings 312 are averaged, the position vectors PV 308 can potentially save position history information, alleviating the need to provide recurrent connections at each layer of the prediction network 300.
The operations described above with respect to the first head 302A are similarly performed by each other head 302B-H of the multi-headed attention mechanism 302. Due to the different set of positioned vectors PV 308 defined by each head 302, the weight layer 310 outputs a sequence of weighted embeddings 312Ba-Bn, 312Ha-Hn at each other head 302B-H that is different than the sequence of weighted embeddings 312Aa-Aa at the first head 302A. Thereafter, the weighted average module 316 generates, as output from each other corresponding head 302B-H, a respective weighted average 318B-H of the corresponding weighted embeddings 312 of the sequence of non-blank symbols.
In the example shown, the prediction network 300 includes a head average module 322 that averages the weighted averages 318A-H output from the corresponding heads 302A-H. A projection layer 326 with SWISH may receive, as input, an output 324 from the head average module 322 that corresponds to the average of the weighted averages 318A-H, and generate, as output, a projected output 328. A final layer normalization 330 may normalize the projected output 328 to provide the single embedding vector Pui 350 at the corresponding time step from the plurality of time steps. The prediction network 300 generates only a single embedding vector Pui 350 at each of the plurality of time steps subsequent to an initial time step.
In some configurations, the prediction network 300 does not implement the multi-headed attention mechanism 302 and only performs the operations described above with respect to the first head 302A. In these configurations, the weighted average 318A of the weighted embeddings 312Aa-An is simply passed through the projection layer 326 and layer normalization 330 to provide the single embedding vector Pui 350.
In some implementations, to further reduce the size of the RNN-T decoder, i.e., the prediction network 300 and the joint network 230, parameter tying between the prediction network 300 and the joint network 230 is applied. Specifically, for a vocabulary size |V| and an embedding dimension de, the shared embedding matrix 304 at the prediction network is E∈|V|×d
The computing device 500 includes a processor 510, memory 520, a storage device 530, a high-speed interface/controller 540 connecting to the memory 520 and high-speed expansion ports 550, and a low speed interface/controller 560 connecting to a low speed bus 570 and a storage device 530. Each of the components 510, 520, 530, 540, 550, and 560, are interconnected using various busses, and may be mounted on a common motherboard or in other manners as appropriate. The processor 510 (i.e., data processing hardware 62 of the computing device 60 of
The memory 520 stores information non-transitorily within the computing device 500. The memory 520 may be a computer-readable medium, a volatile memory unit(s), or non-volatile memory unit(s). The non-transitory memory 520 may be physical devices used to store programs (e.g., sequences of instructions) or data (e.g., program state information) on a temporary or permanent basis for use by the computing device 500. Examples of non-volatile memory include, but are not limited to, flash memory and read-only memory (ROM)/programmable read-only memory (PROM)/erasable programmable read-only memory (EPROM)/electronically erasable programmable read-only memory (EEPROM) (e.g., typically used for firmware, such as boot programs). Examples of volatile memory include, but are not limited to, random access memory (RAM), dynamic random access memory (DRAM), static random access memory (SRAM), phase change memory (PCM) as well as disks or tapes.
The storage device 530 is capable of providing mass storage for the computing device 500. In some implementations, the storage device 530 is a computer-readable medium. In various different implementations, the storage device 530 may be a floppy disk device, a hard disk device, an optical disk device, or a tape device, a flash memory or other similar solid state memory device, or an array of devices, including devices in a storage area network or other configurations. In additional implementations, a computer program product is tangibly embodied in an information carrier. The computer program product contains instructions that, when executed, perform one or more methods, such as those described above. The information carrier is a computer- or machine-readable medium, such as the memory 520, the storage device 530, or memory on processor 510.
The high speed controller 540 manages bandwidth-intensive operations for the computing device 500, while the low speed controller 560 manages lower bandwidth-intensive operations. Such allocation of duties is exemplary only. In some implementations, the high-speed controller 540 is coupled to the memory 520, the display 580 (e.g., through a graphics processor or accelerator), and to the high-speed expansion ports 550, which may accept various expansion cards (not shown). In some implementations, the low-speed controller 560 is coupled to the storage device 530 and a low-speed expansion port 590. The low-speed expansion port 590, which may include various communication ports (e.g., USB, Bluetooth, Ethernet, wireless Ethernet), may be coupled to one or more input/output devices, such as a keyboard, a pointing device, a scanner, or a networking device such as a switch or router, e.g., through a network adapter.
The computing device 500 may be implemented in a number of different forms, as shown in the figure. For example, it may be implemented as a standard server 500a or multiple times in a group of such servers 500a, as a laptop computer 500b, or as part of a rack server system 500c.
Various implementations of the systems and techniques described herein can be realized in digital electronic and/or optical circuitry, integrated circuitry, specially designed ASICs (application specific integrated circuits), computer hardware, firmware, software, and/or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A software application (i.e., a software resource) may refer to computer software that causes a computing device to perform a task. In some examples, a software application may be referred to as an “application,” an “app,” or a “program.” Example applications include, but are not limited to, system diagnostic applications, system management applications, system maintenance applications, word processing applications, spreadsheet applications, messaging applications, media streaming applications, social networking applications, and gaming applications.
These computer programs (also known as programs, software, software applications or code) include machine instructions for a programmable processor, and can be implemented in a high-level procedural and/or object-oriented programming language, and/or in assembly/machine language. As used herein, the terms “machine-readable medium” and “computer-readable medium” refer to any computer program product, non-transitory computer readable medium, apparatus and/or device (e.g., magnetic discs, optical disks, memory, Programmable Logic Devices (PLDs)) used to provide machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term “machine-readable signal” refers to any signal used to provide machine instructions and/or data to a programmable processor.
The processes and logic flows described in this specification can be performed by one or more programmable processors, also referred to as data processing hardware, executing one or more computer programs to perform functions by operating on input data and generating output. The processes and logic flows can also be performed by special purpose logic circuitry, e.g., an FPGA (field programmable gate array) or an ASIC (application specific integrated circuit). Processors suitable for the execution of a computer program include, by way of example, both general and special purpose microprocessors, and any one or more processors of any kind of digital computer. Generally, a processor will receive instructions and data from a read only memory or a random access memory or both. The essential elements of a computer are a processor for performing instructions and one or more memory devices for storing instructions and data. Generally, a computer will also include, or be operatively coupled to receive data from or transfer data to, or both, one or more mass storage devices for storing data, e.g., magnetic, magneto optical disks, or optical disks. However, a computer need not have such devices. Computer readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media and memory devices, including by way of example semiconductor memory devices, e.g., EPROM, EEPROM, and flash memory devices; magnetic disks, e.g., internal hard disks or removable disks; magneto optical disks; and CD ROM and DVD-ROM disks. The processor and the memory can be supplemented by, or incorporated in, special purpose logic circuitry.
To provide for interaction with a user, one or more aspects of the disclosure can be implemented on a computer having a display device, e.g., a CRT (cathode ray tube), LCD (liquid crystal display) monitor, or touch screen for displaying information to the user and optionally a keyboard and a pointing device, e.g., a mouse or a trackball, by which the user can provide input to the computer. Other kinds of devices can be used to provide interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback, e.g., visual feedback, auditory feedback, or tactile feedback; and input from the user can be received in any form, including acoustic, speech, or tactile input. In addition, a computer can interact with a user by sending documents to and receiving documents from a device that is used by the user; for example, by sending web pages to a web browser on a user's client device in response to requests received from the web browser.
A number of implementations have been described. Nevertheless, it will be understood that various modifications may be made without departing from the spirit and scope of the disclosure. Accordingly, other implementations are within the scope of the following claims.
Claims
1. A computer-implemented method when executed on data processing hardware causes the data processing hardware to perform operations comprising:
- obtaining a plurality of training samples, each respective training sample of the plurality of training samples comprising: a respective speech utterance; and a respective textual utterance representing a transcription of the respective speech utterance;
- determining a minimum integer fixed-bit width representing a maximum quantization of an automatic speech recognition (ASR) model, the ASR model comprising a plurality of weights, each respective weight of the plurality of weights comprising a respective float value;
- training the ASR model on the plurality of training samples using a quantity of random noise, the quantity of random noise based on the minimum integer fixed-bit width;
- after training the ASR model, selecting a target integer fixed-bit width greater than or equal to the minimum integer fixed-bit width;
- for each respective weight of the plurality of weights, quantizing the respective weight from the respective float value to a respective integer associated with a value of the selected target integer fixed-bit width; and
- providing the quantized trained ASR model to a user device.
2. The method of claim 1, wherein the maximum quantization level comprises 4-bit quantization.
3. The method of claim 1, wherein the maximum quantization level comprises 2-bit quantization.
4. The method of claim 1, wherein the random noise is drawn from a uniform distribution of noise.
5. The method of claim 1, wherein training the ASR model using the quantity of random noise comprises, for each respective channel of each respective tensor of the ASR model:
- determining a respective maximum value for the respective channel of the respective tensor; and
- adding, to the respective channel of the respective tensor, a uniform distribution of noise based on the respective maximum value and the minimum integer fixed-bit width.
6. The method of claim 5, wherein the uniform distribution of noise represents the entire range of noise the ASR model receives due to quantization up to the minimum integer fixed-bit width.
7. The method of claim 5, wherein adding the uniform distribution of noise comprises scaling the uniform distribution of noise based on the respective maximum value.
8. The method of claim 7, wherein scaling the uniform distribution of noise is further based on a sensitivity of the respective channel to scaling.
9. The method of claim 1, wherein training the ASR model using the quantity of random noise comprises adding, during forward propagation of the ASR model, the quantity of random noise.
10. The method of claim 1, wherein:
- the ASR model further comprises a plurality of activations, each activation of the plurality of activations comprising a respective float value; and
- for each respective activation of the plurality of activations, the operations further comprise quantizing the respective activation from the respective float value to the respective integer with the value of the selected target fixed-bit width.
11. A system comprising:
- data processing hardware; and
- memory hardware in communication with the data processing hardware, the memory hardware storing instructions that when executed on the data processing hardware cause the data processing hardware to perform operations comprising: obtaining a plurality of training samples, each respective training sample of the plurality of training samples comprising: a respective speech utterance; and a respective textual utterance representing a transcription of the respective speech utterance; determining a minimum integer fixed-bit width representing a maximum quantization of an automatic speech recognition (ASR) model, the ASR model comprising a plurality of weights, each respective weight of the plurality of weights comprising a respective float value; training the ASR model on the plurality of training samples using a quantity of random noise, the quantity of random noise based on the minimum integer fixed-bit width; after training the ASR model, selecting a target integer fixed-bit width greater than or equal to the minimum integer fixed-bit width; for each respective weight of the plurality of weights, quantizing the respective weight from the respective float value to a respective integer associated with a value of the selected target integer fixed-bit width; and providing the quantized trained ASR model to a user device.
12. The system of claim 11, wherein the maximum quantization level comprises 4-bit quantization.
13. The system of claim 11, wherein the maximum quantization level comprises 2-bit quantization.
14. The system of claim 11, wherein the random noise is drawn from a uniform distribution of noise.
15. The system of claim 11, wherein training the ASR model using the quantity of random noise comprises, for each respective channel of each respective tensor of the ASR model:
- determining a respective maximum value for the respective channel of the respective tensor; and
- adding, to the respective channel of the respective tensor, a uniform distribution of noise based on the respective maximum value and the minimum integer fixed-bit width.
16. The system of claim 15, wherein the uniform distribution of noise represents the entire range of noise the ASR model receives due to quantization up to the minimum integer fixed-bit width.
17. The system of claim 15, wherein adding the uniform distribution of noise comprises scaling the uniform distribution of noise based on the respective maximum value.
18. The system of claim 17, wherein scaling the uniform distribution of noise is further based on a sensitivity of the respective channel to scaling.
19. The system of claim 11, wherein training the ASR model using the quantity of random noise comprises adding, during forward propagation of the ASR model, the quantity of random noise.
20. The system of claim 11, wherein:
- the ASR model further comprises a plurality of activations, each activation of the plurality of activations comprising a respective float value; and
- for each respective activation of the plurality of activations, the operations further comprise quantizing the respective activation from the respective float value to the respective integer associated with the value of the selected target fixed-bit width.
21. A computer-implemented method when executed on data processing hardware causes the data processing hardware to perform operations comprising:
- obtaining a plurality of training samples;
- determining a minimum integer fixed-bit width representing a maximum quantization of a model, the model comprising a plurality of weights, each respective weight of the plurality of weights comprising a respective float value;
- training the model on the plurality of training samples using a quantity of random noise, the quantity of random noise based on the minimum integer fixed-bit width;
- after training the model, selecting a target integer fixed-bit width greater than or equal to the minimum integer fixed-bit width;
- for each respective weight of the plurality of weights, quantizing the respective weight from the respective float value to a respective integer associated with a value of the selected target integer fixed-bit width; and
- providing the quantized trained model to a user device.
22. The method of claim 21, wherein the model comprises an automated speech recognition model.
23. The method of claim 21, wherein the model comprises a large language model.
24. The method of claim 21, wherein the model comprises an image processing model.
Type: Application
Filed: Apr 10, 2024
Publication Date: Oct 17, 2024
Applicant: Google LLC (Mountain View, CA)
Inventors: David Qiu (Fremont, CA), David Rim (Mountain View, CA), Shaojin Ding (Mountain View, CA), Yanzhang He (Mountain View, CA)
Application Number: 18/632,237