RNNLMs are widely used in state-of-art speech recognition systems. The high memory consumption and computational costs limit their wider application on resource constrained devices. In order to address this issue for RNNLMs, and deep learning in general, a wide range of deep model compression appproaches including teacher-student based transfer learning[hinton2015distilling] [chebotar2016distilling] [huang2018knowledge], low rank matrix factorization [sainath2013low] [jaderberg2014speeding] [lebedev2014speeding] [tai2015convolutional] [sindhwani2015structured], sparse weight matrices [liu2015sparse] [han2015learning][han2015learning] [wen2016learning] have been proposed. In addition, a highly efficient family of compression techniques based on deep neural network quantization that are capable of producing extremely low bit representation [courbariaux2014training] [courbariaux2015binaryconnect] [courbariaux2016binarized], for example, binarized RNNLMs [liu2018binarized], are gaining increasing research interests.
Earlier forms of deep neural network (DNN) quantization methods compress well-trained full precision models off-line [gong2014compressing] [chen2015compressing]. In [chen2015compressing], a hash function was used to randomly group the connection weight parameters into several shared values. Weights in convolutional layers are quantized in [gong2014compressing]. In order to reduce the inconsistency in error cost function between the full precision model training and subsequent quantization stages, later researches aimed at directly training a low bit neural network from scratch [soudry2014expectation] [courbariaux2016binarized] [liu2018binarized].
The key challenge in these approaches is that gradient descent methods and back-propagation (BP) algorithm can not be directly applied in quantized model training when the weights are restricted to discrete values. To this end, there have been two solutions to this problem in the machine leaning community [soudry2014expectation] [courbariaux2016binarized]. A Bayesian approach was proposed in [soudry2014expectation]
to allow a posterior distribution over discrete weight parameters to be estimated, and the subsequent model quantization used samples drawn from the distribution. In[courbariaux2016binarized], low precision binarized parameters were first used in the forward pass to compute the error loss before full precision parameters are used in the backward pass to propagate the gradients. It was further suggested in [liu2018binarized] for RNNLMs that extra partially quantized linear layers containing binary weight matrices, full precision bias and additional scaling parameters need to be added to mitigate the performance degradation due to model compression. A compression ratio of 11.3 in [liu2018binarized] was reported on PTB and SWBD data without performance loss.
In this paper, by formulating quantized RNNLMs training as an optimization problem, a novel method based on alternating direction methods of multipliers (ADMM) [boyd2011distributed] [leng2018extremely] is proposed. Two sets of parameters: a full precision network, and the optimal quantization table, are considered in a decomposed dual ascent scheme and optimized in an alternating fashion iteratively using an augmented Lagrangian. This algorithm draws strength from both the decomposibility of the dual ascent schemes and the stable convergence of multiplier methods. In order to account for the detailed parameter distributions at a layer or node level within the network, locally shared quantization tables trained using ADMM are also proposed to allow fine-grained and flexible adjustment over the trade-off between model compression rate and performance.
The main contributions of this paper are summarized as below. First, to the best of our knowledge, this paper is the first work to introduce ADMM based RNNLMs quantization for speech recognition tasks. The previous research on low bit quantization [courbariaux2016binarized] of RNNLMs [liu2018binarized] focused on using different parameter precision in the error forwarding and gradient backward propagation stages. The earlier use of alternating methods in off-line quantization of well trained DNNs [xu2018alternating]
also does not allow low bit quantized models to be directly trained from scratch, as considered in this paper. Second, the previous application of ADMM DNN quantization was restricted to computer vision tasks[leng2018extremely]. In addition, a globally tied quantization table was applied to all parameters in the network, thus providing limited flexibility to account for detailed local parameter distributions as considered in this paper. We evaluate the performance of the proposed ADMM RNNLMs quantization method on two tasks targeting primarily on speech recognition applications: Penn Treebank and Switchboard, in comparison against the baseline binarized RNNLMs quantization in terms of the trade-off between model compression factor, perplexity and speech recognition error rate.
The rest of the paper is organized as follows. RNNLMs are reviewed in section 2. A general neural network quantization scheme is described in section 3. Section 4 presents our ADMM based RNNLMs quantization in detail. Experiments and results are shown in section 5. Finally, conclusions and future work are discussed in section 6.
2 Recurrent Neural Network LMs
The recurrent neural network language models (RNNLMs) we considerred in this paper computes the word probability by
where is the hidden state that attempts to encode the history information into a
-dimensional vector representation, whereis the number of hidden nodes.
In RNNLMs, a word is represented by a -dimensional one-hot vector , where is the vocabulary size. To process sparse data, the one-hot vector is first projected into a -dimensional size () continuous space [bengio2003neural] where is considered as he embedding size:
where is a projection matrix to be trained. After the word embedding layer, the hidden state is calculated recursively through a gating function: , which is a vector function that controls the amount of inherited information from in the current “memory” state
. Currently, long short-term memory (LSTM)[hochreiter1997lstm] RNNLMs[sundermeyer2012lstm] definite the state of art performance.
In order to solve the problem of vanishing gradients, LSTM introduces another recursively computed variable , a memory cell, which aims to preserve the historical information over a longer time window. At time four gates are computed – the forget gate , the input gate , the cell gate and the output gate :
where for any . With the four gating outputs, we update
where is the Hadamard product.
3 Neural Network Quantization
The standard n-bit quantization problem for neural network considers for any full precision weight parameter, , finding its closest discrete approximation from the following the quantization table.
Further simplification to the above quantization table of Equation (9) leads to either the binarized [rastegari2016xnor], or tertiary value [li2016ternary] based quantization.
It is assumed in the above quantization that a global quantization table is applied to all weight parameters. In order to account for the detailed local parameter distributional properties, and more importantly flexibly adjust the trade off between model compression ratio and performance degradation, the following more general form of quantization is considered for each parameter within any of the weight cluster, for example, all weight parameters of the same layer,
can be used. The locally shared quantization table is given by
is used to represent the scaling factor of the original discrete quantization. It is shared locally among weight parameters clusters. The tying of quantization tables may be flexibly performed at either node, layer level, or in the extreme case individual parameter level (equivalent to no quantization being applied).
Intuitively, the larger quantization table is used, a smaller compression rate after quantization and reduced performance degradation is expected. A projection from the original full precision parameters to the quantized low precision values needs to be found using Equation (11) during the training phase.
4 RNNLMs Quantization Using ADMM
Alternating direction methods of multipliers (ADMM) is a powerful optimization technique. It decomposes a dual ascent problem into alternating updates of two variables. In the context of the RNNLMs quantization problem considered here, these refer to full precision model weights update and the discrete quantization table estimation. In addition to the standard Lagrangian term taking the form of a dot production between the multiplier variable and the quantization error , it is also useful for alternating direction methods to introduce an additional term to form an augmented Lagrangian [boyd2011distributed] to improve robustness and convergence speed of the algorithm. The overall Lagrange function is formulated as:
where is the crossentropy loss of the neural network, are the network parameters. represents the quantization of the parameters calculated from the projection (11). is the penalty parameter and denotes the Lagrangian multiplier.
The algorithm when being performed at the iteration includes three stages. For simplicity, we assume a globally shared quantization table with a single scaling factor to be learned. The following iterative update can be extended when multiple shared quantization tables and associated scaling factors in Equation (12) are used.
1. Full precision weight update
The following equation is used to update the full precision weight parameters .
where are the quantized weights and error variable at the iteration. The gradient of the loss function in Equation (14) w.r.t is calculated as the following.
It is found in practice that the quadratic term of the augmented Lagrangian of Equation (14) can dominate the loss function computation and lead to a local optimum. One solution to this problem is to perform the gradient calculation one step ahead to improve the convergence. This is referred to as the extra-gradient method [Korpelevi1976An].
here represents the temporary variable to store the intermediate backward parameters, and and are separate learning rates.
2. Quantization variables update
The quantization discrete variables can be solved by minimizing the following:
where is calculated as
The scaling factor is then updated as
and are updated interatively in an alternating way until convergence is reached.
3. Error update
The Lagrange multiplier variable , now encoding the accumulated quantization errors computed at each iteration, is updated as
In all experiments of this paper the scaling factors are initialized to one. The above ADMM quantization algorithm can be executed iteratively until convergence measured in terms of validation data entropy is obtained. Alternatively, a fixed number of iterations, for example, 50, was used throughout this paper. The best performing model was then selected over all the intermediate quantizations obtained as each iteration.
In this section, we evaluate the performance of quantized RNNLMs using the trade-off between the compression ratio and the perplexity (PPL) measure combined with word error rate (WER) obtained in automatic speech recognition (ASR) tasks. All the models are implemented using Python GPU computing library PyTorch[paszke2017automatic]. For all RNNLMs, the recurrent layer is set to be a single LSTM with 200 hidden nodes.
In all models, parameters are updated in mini-batch mode (10 sentences per batch) using the standard stochastic gradient descent (SGD) algorithm with an initial learning rate of 1, optionally within the ADMM based quantization of section4
. In our experiments, all RNNLMs were also further interpolated with 4-gram LMs[emami2007empirical] [park2010improved] [le2012structured]. The weight of the 4-gram LM is determined using the EM algorithm on a validation set.
5.1 Experiments on Penn Treebank Corpus
We first analyze the performance of ADMM based quantization as well as binarized LSTM language model (BLLM [liu2018binarized]), BLLM without linear layer and the standard full precision RNNLM the on the Penn Treebank (PTB) corpus, which consists of vocabulary, words for training, words for development, and words for testing. The PPL results are shown in Table 1.
Performance and compression ratio of quantized LSTM RNNLMs on PTB corpus: full precision baseline with no quantization (STD), binarized model w/o partially quantized linear layers (Binr+Lin or Bin) trained using 50 or 400 epochs with hidden size, and ADMM quantized models with a layer, node or no tying of quantization tables of varying #bits.
The performance of various quantized RNNLMs using binarization and ADMM optimization are presented in table 1. Full precision models are shown in table 1 including the full precision baseline with no quantization (STD), binarized model w/o partially quantized linear layers (Binr+Lin or Bin) trained using 50 or 400 epochs, and ADMM quantized models with a layer, node or no tying of quantization tables of varying #bits.
There are several trends that can be found in table 1. First, the baseline binarization can obtain model compression factor up to approximately time. In order to achievw the best perplexity of (line5 in table 1), it requires both the additional partially quantized linear layers and 400 epochs (s on GPU per epoch) to reach convergence in training. Also, there is a small perplexity increase by against the full precision baseline system. Second, the ADMM based quantization provides a much faster training, requiring 50 epochs ((s on GPU per epoch)) to converge for all ADMM quantized models, which is nearly 4 times faster in convergence over the Bin+lin binarized quantization baseline. Finally, the use of locally shared quantization tables in ADMM systems allow flexible adjustment in the trade-off between the model performance and compression ratio. To achieve the largest compression ratio of , the layer level tied binarized ADMM based quantization system (line 11 in table 1) should be used. On the other hand, the best performance can be obtained using node level tying with quantization table giving a perplexity score of 115.9 (line 10 in table 1).
5.2 Experiments on Conversational Telephone Speech
To further evaluate the performance of proposed ADMM based quantization of RNNLMs for speech recognition, we also used the Switchboard (SWBD) conversational telephone dataset. The SWBD system has 300 hour of conversational telephone speech from Switchboard I for acoustic modeling, 3.6M words of acoustic transcription and 30k words lexicon for language modeling. The acoustic model is a minimum phone error (MPE) trained hybrid DNN, of which the details can be found in[liu2018limited]. The baseline 4-gram language model was used to generate the n-best lists. The Hub5’00 data set with Switchboard (swbd) and CallHome (callhm) subsets were used in evaluation. Perplexity and n-best lists rescoring word error rate performance of various quantized RNNLMs using binarization and ADMM optimization are shown in table 2.
A similar set of experiments as in table 1 were then conducted on the SWBD data. Similar trends can be found. First, the ADMM based quantization convergences 3 times faster than the binarized RNNLM (Bin+lin) (line 5 in table 2). As can be seen from figure 1, our ADMM based quantization system only needs about 50 epochs (23min per epoch) to reach convergence, while the baseline binarized RNNLM (Bin and Bin+Lin) takes about as many as 250 epochs (10min per epoch). Second, the flexibility of ADMM based quantization in adjusting the trade-off between the compression ratio and model performance is clearly shown again in table 2. The largest compression ratio of was obtained using layer level tying and binary quantization set (line 11 in table 2). The lowest word error rate 24.0 on callhm data and a compression ratio of was achieved by the node level tying quantization using as the quantization set (line 10 in table 2).
This paper investigates the use of alternating direction methods of multipliers (ADMM) based optimization method to directly train low-bit quantized RNNLMs from scratch. Experimental results conducted on multiple tasks suggest the proposed technique can achieve faster convergence than the baseline binarized RNNLMs quantization, while producing comparable model compression ratios. Future research will investigate the application of ADMM based quantization techniques to more advanced forms of neural language models and acoustic models for speech recognition.
This research is supported by Hong Kong Research Grants Council General Research Fund No.14200218 and Shun Hing Institute of Advanced Engineering Project No.MMT-p1-19.