On Training Bi-directional Neural Network Language Model with Noise Contrastive Estimation

02/19/2016 ∙ by Tianxing He, et al. ∙ MIT Shanghai Jiao Tong University Microsoft 0

We propose to train bi-directional neural network language model(NNLM) with noise contrastive estimation(NCE). Experiments are conducted on a rescore task on the PTB data set. It is shown that NCE-trained bi-directional NNLM outperformed the one trained by conventional maximum likelihood training. But still(regretfully), it did not out-perform the baseline uni-directional NNLM.

READ FULL TEXT VIEW PDF
POST COMMENT

Comments

There are no comments yet.

Authors

page 1

page 2

page 3

page 4

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Recent years have witnessed exciting performance improvements in the field of language modeling, largely due to introduction of a series of neural network language models(NNLM). Although the conventional back-off n-gram language model has been widely used in the automatic speech recognition (ASR) or machine translation(MT) community for its simplicity and effectiveness, it has long suffered from the

curse-of-dimensionality problem caused by huge number of possible word combinations in real-world text. Various smoothing techniques[1] are proposed to address this issue but the improvements have been limited. Recently, neural network based language models have attracted great interest due to its effective encoding of word context history [2, 3, 4, 5]

.In neural network based language models, the word context is projected into a continuous space and the projection, represented by the transformation matrices in the neural network, are learned during training. The projected continuous word vectors are also referred to as

word embeddings

. With the continuous context representation, feed-forward neural network language models (FNNLM)

[2, 3, 4, 5, 6], have achieved both better perplexity(PPL) and better word error rate (WER) when embedded into a real-world system.

Despite the benefits of effective context representation brought by word embeddings, FNNLM is still a short-span language model and not capable of utilizing long-term (e.g. context that is 5 or 6 words away) word history for the target word prediction. To address this issue, recurrent neural network language model (RNNLM), which introduces a recurrent connection in the hidden layer, is proposed to preserve long-term context. It has achieved significant performance gain on perplexity and word error rate (WER) performance on various data sets

[7, 8, 9, 10, 11, 12], out-performing traditional back-off n-gram models and FNNLMs.

However, RNN training generally suffered from the “vanishing gradient” problem

[13]:the gradient flow will decay sharply through a non-linear operation. The LSTM[14] structure alleviates this problem by introducing a “memory cell” structure which allows the gradient to travel without being squashed by a non-linear operation. Also, it has a set of gates which enable the model to decide whether to memorize, forget, or output information. By introducing the LSTM strucutre into RNNLM[9], LSTMLM is able to remember longer context information and gains more performance gain. It has also been shown that the dropout [15]

can be used to regularize the LSTMLM. Inspired by its success, several variants of LSTM have been proposed, recently the gated recurrent unit(GRU)

[16] is gaining increasing popularity becuase it has matching performance with LSTM but has simpler structure. More recently, [17] has proposed to introduce the concept of memory into NNLM. By fetching memories from previous time, the model is able to “explicitly” utilizing long-term dependency without recurrence structure.

While these research efforts have been focusing on better utilization of history information, it would be desirable if the model can utilize context information from both sides. In literature, very few attempts have been made to train a proper bi-directional neural network language model, even though bi-drectional NN has already been successfully applied to other fields[18]. This is because the bi-directional model won’t be by itself normalized because of the generative nature of language model, which makes the conventional maximum likelihood training framework improper for its training.

In this work, attempts have been made to train a bi-directional neural network language model with noise contrastive estimation, an alternative to maximum likelihood training which does not have the constrain that the model to be trained is inherently normalized. The rest of the paper is organized as follows: in section 2, the motivation of this work is discussed, in section 3 the formulation of the model are elaborated in detail, implementation is covered in section 4, finally experiment results are shown in section 5 and related works are discussed in section 6.

2 Motivation

Statistical language models assign a probability

to a given sentence , which can be decomposed into a product of word-level probabilities using the rule of conditional probability:

(1)

Language models by this formulation predict the probability distribution of the next word given its former words(history). Since the prediction only depends on history information, in this work, this kind of model is denoted as uni-directional language model. All types of language model mentioned in section

1

fall into this category, but note that shot-span models like N-gram makes the ”Markov Chain” assumption

to alleviate the data-sparsity problem.

For uni-directional language models, as long as each word-level probability is properly normalized, normalization is also guaranteed on sentence level:

(2)

This is the key reason why the ”maximum likelihood estimation” training framework, which requires the model to be inherently probabilistic, has been successfully applied to the parameter estimation(training) of uni-directional language models. And recent years of research effort in the field of neural network language model has been focused on getting a better representation of history context using sophisticated recurrent neural network structures like LSTM[9].

Unfortunately, while recently bi-directional neural network like BI-RNN or BI-LSTM has been successfully applied to many tasks, it is not trivial to apply this powerful model to language modeling, the main challenge is that the bi-directional information will break the sentence-level normalization111If some bi-directional model like is used as the word-level LM, equation 1, and hence equation 2 won’t hold any more., making the model no longer valid for the MLE training framework(please refer to section 3 for more details ).

In this work, noise contrastive estimation(NCE)[19] is used to train a bi-directional neural network based LM, one big advantage of NCE over MLE is that it doesn’t require the model to be self-normalized. This enables the utilization of bi-directional information for word-level scoring. Formulations of this work will be elaborated in the next section.

3 Formulation

3.1 Model Formulation

In this work, is the product of word-level scores(similar to uni-directional LM) and a learned normalization scalar , required by the NCE framework to ensure normalization:

(3)

where the scoring given by a bi-directional neural network on each word index. And the ”NCE” superscript for is for indicating the normalization is induced by NCE training.

In this work, the same bi-directional neural network structure that has been used in [18, 20] is applied, and is shown in figure 1 and formulated below(we are aware that other variants of BI-RNN exist[21], but they are not fundamentally different with regard to this work):

(4)

where and

are the transformation matrices and bias vector parameters in the neural network, and

is the one-hot representation of . Finally, is obtained after a normalizing operation over the vocabulary(denoted as ) on :

(5)

Note that the word-level normalization is not needed in this work( can be used directly as ), but experiments show that reserving the word-level normalization will give better results.

Figure 1: Illustration of the network structure

In this work, gated recurrent unit is used as the recurrent structure because it is faster, causes less memory and has matching performance with the LSTM structure[16]. So our NN model is denoted BI-GRULM and the formulation is put below:

(6)

where

is the sigmoid function

and is element-wise multiplication, and note that a different set of parameter is used for forward and backward connections in the bi-directional neural network.

Finally, we also write down the formulations of a one-layer uni-directional GRULM(UNI-GRULM) here since it will be used as baseline model:

(7)

Note that other than being uni-directional, the only other difference between these two models is the normalization scalar . And in this work, the dropout operation is applied on for both models.

3.2 Training of bi-directional NNLM

As stressed in section 2, the MLE framework is not suitable for training bi-directional NNLM, still, in this work MLE training is tried as a baseline experiment. Denoting the the data distribution as , the MLE objective function is formulated as below:

(8)

Note that here the normalization scalar does not exist in the model.

In this work, noise contrastive estimation[19] is applied to train the bi-directional NNLM. NCE introduces a noise distribution into training and a ”to-be-learned” normalization scalar into the model, and its basic idea is that instead of maximizing the likelihood of the data samples, the model is asked to discriminative samples from the data distribution against samples from the noise distribution:

(9)

assuming a noise ratio of .

And the gradients are:

(10)

For NCE to get good performance, a noise distribution that is close to the real data distribution is preferred, so in our case it is natural to use a good uni-directional LM as the noise distribution. In this work, N-gram LM is used as the noise distribution since it is efficient to sample from. Details about implementation and training process will be covered in section 4.

4 Training and Implementation details

Figure 2: Illustration of the parallel training implementation

Mini-batch based stochastic gradient descent(SGD) is used to train bi-directional NNLM in this work. The training process is very similar to

[12], but several changes need to be made for the sentence-level bi-directional NNLM training. Since NN training in this work is sentence-level, data(consisted of real data samples and noise model samples) are processed in chunks, illustrated in figure 2. Moreover, a batch of data streams is processed together to utilize the computing power of GPU. It is relatively easy to realize this training process of BI-RNN with the help of neural network training tool-kits like CNTK[22]. In this work, the chunk size is set to 90(which is larger than the longest sentence in the ptb data-set) and the batch size is set to 64.

An validation-based learning strategy is used, the learning rate is fixed to a large value at first, and start halving at a rate of 0.6 when no significant improvement on the validation data is observed. And the training is stopped when that happens again. Further, a L2 regularization with coefficient 1e-5 is used.

Finally, the SRILM[23] Toolkit is used for N-gram LM training in this work. In our training the N-GRAM noise is generated on-the-fly so noise samples won’t be the same between iterations.

5 Experiments

5.1 Datasets

In this section, results of experiments designed to test the performance of the proposed bi-directional NNLM trained by NCE. Since the training process is very time-costly when the noise ratio is large(in our training framework, it will cost at least times the time for training the baseline UNI-GRULM model), we confined our experiments to the Penn Treebank portion(PTB) of the WSJ corpus, which is publicly available and has been used extensively in LM community. There are 930k tokens, 74k tokens, 82k tokens for training, validation and testing, respectively, and the vocabulary size is 10k.

Further, since there is no guarantee that the trained model will be properly normalized, the evaluation of perplexity(PPL), which is the most conventional evaluation for LM, can no longer be applied. Instead, we need to resort to some discriminative task in which the LM is asked to tell ”good” sentence from ”bad” sentences, like its application in decoding or rescoring in systems like speech recognition or machine translation. But still, we want the training corpus and vocabulary size to be small enough, which will enable us to try a large noise ratio , since sentence-level sampling is considered in this work, it is expected that needs to be large enough for the training to work.

In light of the above concerns, a rescoring task is created directly on the PTB dataset, denoted as ptb-rescore222This test set and the scripts for reproducing the N-gram baseline are available at https://bitbucket.org/cloudygoose/ptb_rescore. In this test, random small errors are introduced to each sentence of the original test corpus of the PTB dataset, and the LM is then asked to recognize the original sentence from the tampered ones by assigning it the highest score. In this work, three types of error, namely substitution, deletion and insertion, are generated. For each error type, 9 decoys(one decoy only has one error) are generated for each test sentence, constituting three test sets. So a uniform guess will have an accuracy of . Further, a mixed set where each decoy can be of any of the three types of error is also added, denoted as test sdi. Some examples are shown in table 1

. Note that in this test set all random number(for the position or new word index) are drawn from a uniform distribution, and the

s-test set is similar to the MSR sentence completion task [24].

original no it was n’t black monday
s-error no it was n’t black revoke
d-error no it was n’t monday
i-error no it cracks was n’t black monday
Table 1: Examples of decoys in the ptb-resocre test set

5.2 Pseudo-PPL Test

Although perplexity can not be used to evaluate bi-directional NNLM, it is still interesting what PPL the trained model will assign to the test sentences. Besides the original test set for the PTB data, two additional text are generated, one is sentences sampled from the 4-GRAM baseline model(denoted as 4gram-text), the other one is sentences sampled from a completely uniform distribution(denoted as uniform-text). All three sets have around 4,000 sentences. A well-behaved LM is expected to assign lowest PPL to the first set, relatively low PPL to the second, and very high(bad) PPL to the last one. The results are shown in table 2.

Model Pseudo-PPL
test-ptb 4gram-text uniform-text
UNI-GRULM 103.7 431.0 91935.7
BI-GRULM(MLE) 1.12 1.16 3.358
BI-GRULM(NCE with noise ratio ) 15.5 3846.4 99565.4
Table 2: Pseudo-PPL result of different trained LMs on three test sets.

It is shown that the BI-GRULM(detailed configuration will be discussed in section 5.3) trained with NCE has similiar behavior to the baseline uni-directional model, meaning that NCE is helping the model with sentence-level normalization. On the contrary, BI-GRULM trained with MLE is assigning extremely low PPL to every test set, indicating that the model is not properly normalized. But surprisingly, the relative order of PPL from MLE-trained BI-GRULM is correct.

5.3 Evaluation on the ptb-rescore task

In this section accuracy results on the ptb-rescore

task is presented. Three models are trained to be baseline models: 4-GRAM, UNI-GRULM, and BI-GRULM trained by MLE. Note that unless otherwise mentioned, all GRULMs trianed in the work has 300 neurons on hidden layer and only one layer(in the BI-GRULM case, one layer means one forward layer and one backward layer) is used. This setting is chosen for the reason that adding more neurons or more layers give no significant on the test PPL for the baseline UNI-GRULM model. Through training, a dropout rate of

is applied for the UNI-GRULM, but no dropout is applied for the reported experiments for the BI-GRULM because it is found that dropout won’t give performance gain in that case.

The baseline results are shown in the upper part of table 3. Overally, the UNI-GRULM model gives the best performance, as expected. An interesting observation is that all model have extremely poor performance on the test-d set. This behavior, however, is not so surprising since the LM score of a sentence is afterall a product of word-level probabilities, so decoys with one less word will have big advantage. It is found that this problem can be alleviated by a length-norm trick:

(11)

assuming sentence is of length (including the sentence-end token). Note that this trick is equivalent to ranking the sentences using PPL instead of sentence-level log likelihood and it will do harm to the performance on the test-i set, although not large.

Model noise Accuracy(%)/Accuracy after length-norm(%)
ratio test-s test-d test-i test-sdi
4-GRAM - 75.4/n75.4 3.2/n12.7 100/n98.2 13.4/n40.8
UNI-GRULM - 80.6/n80.6 3.9/n21.8 99.9/n96.9 20.2/n60.9
BI-GRULM(MLE) - 50.0/n50.0 0.31/n21.9 95.3/n31.5 6.8/n27.1
1 31.9/n31.9 3.9/n12.8 67.4/n53.0 10.9/n17.8
BI-GRULM 10 39.9/n39.9 8.8/n19.4 61.8/n48.8 20.5/n26.2
(NCE) 20 39.2/n39.2 11.0/n21.6 59.1/n45.3 21.0/n26.3
50 48.4/n48.4 6.8/n19.8 74.2/n54.9 18.1/n29.0
100 55.7/n55.7 0.5/n13.4 98.6/n80.4 10.3/n34.5
Table 3: Accuracy result of BI-GRULM models trained by NCE.

Results of BI-GRULM trained by NCE are shown in in the lower part of table 3, it is observed that the length-norm trick can also help in this case, and the overall performance is improving with larger and larger noise ratio, however, it became unaffordable for us to run experiments with ratio larger than 100. One strange observation is that performance on the test-d set degrades with larger noise ratio, and this causes performance on the test-sdi to become worse. Also, comparing with the BI-GRULM(MLE) result, BI-GRULMs trained by NCE with a large noise ratio have overally better performance, indicating that NCE has the potential to utilize to power of BI-GRULM structure more properly.

Unfortunately, the proposed model failed to out-perform the best UNI-GRULM baseline model on every test set. Results on the test-s set show that improvement can only be obtained by growing the noise ratio exponentially, this matches our concern in section 5.1, the sentence-level sampling space may be too sparse for our sampling to properly cover.

6 Related work

In [20], bi-directional LSTMLM is trained with MLE and tested by LM rescoring in an ASR task. However, no improvement is observed over the uni-directional baseline model. On the other hand, NCE has been used in uni-directional LM training both for FNNLM[25] and RNNLM[26], the main goal was to speed-up the training and evaluation of these two models because under NCE training the final softmax operation on the output layer is no longer necessary. Note that different from these two work, NCE is applied on the sentence level in this work.

7 Conclusion

In this work noise contrastive estimation is used to train a bi-directional neural network language model. Experiments are conducted on a rescore task on the PTB data set. It is shown that NCE-trained bi-directional NNLM outperformed the one trained by conventional maximum likelihood training. But still, it did not out-perform the baseline uni-directional NNLM. The key reason maybe that the sentence-level sampling space is too sparse for our sampling to cover.

8 Acknowledgements

The authors want to thank Abdelrahman Mohamed, Kaisheng Yao, Geoffrey Zewig, Dong Yu, Mike Seltzer, and Da Zheng for valuable discussions.

References

  • [1] Stanley F. Chen and Joshua Goodman, “An empirical study of smoothing techniques for language modeling,” in Proc. ACL. 1996, pp. 310–318, Association for Computational Linguistics.
  • [2] Yoshua Bengio, Rejean Ducharme, Pascal Vincent, and Christian Jauvin, “A neural probabilistic language model,”

    Journal OF Machine Learning Research

    , vol. 3, pp. 1137–1155, 2003.
  • [3] Holger Schwenk, “Continuous space language models,” Computer Speech Language, vol. 21, no. 3, pp. 492–518, 2007.
  • [4] Frederic Morin and Yoshua Bengio, “Hierarchical probabilistic neural network language model,” in AISTATS, 2005, pp. 246–252.
  • [5] J. Park, X. Liu, M. J. F. Gales, and P. C. Woodland, “Improved neural network based language modelling andadaptation,” in Proc. InterSpeech, 2010.
  • [6] Andriy Mnih and Geoffrey Hinton, “Three new graphical models for statistical language modelling,” in Proc. ICML, 2007, pp. 641–648.
  • [7] Tomas Mikolov, Martin Karafiat, Lukas Burget, Jan Cernocky, and Sanjeev Khudanpur, “Recurrent neural network based language model,” in Proc. InterSpeech, 2010.
  • [8] Martin Sundermeyer, Ilya Oparin, Ben Freiberg, Ralf Schlüter, and Hermann Ney, “Comparison of feedforward and recurrent neural network language models,” in Proc. ICASSP, 2013.
  • [9] Martin Sundermeyer, Ralf Schluter, and Hermann Ney, “Lstm neural networks for language modeling,” in Proc. InterSpeech, 2012.
  • [10] Zhiheng Huang, Geoffrey Zweig, and Benoit Dumoulin, “Cache based recurrent neural network language model inference for first pass speech recognition,” in Proc. ICASSP, 2014.
  • [11] X. Liu, Y. Wang, X. Chen, M. J. F. Gales, and P. C. Woodland, “Efficient lattice rescoring using recurrent neural network language models,” in Proc. ICASSP, 2014.
  • [12] X. Chen, Y. Wang, X. Liu, M.J.F. Gales, and P. C. Woodland, “Efficient gpu-based training of recurrent neural network language models using spliced sentence bunch,” in Proc. InterSpeech, 2014.
  • [13] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber, “Gradient flow in recurrent nets: the difficulty of learning long-term dependencies,” 2001.
  • [14] Sepp Hochreiter and Jürgen Schmidhuber,

    Long short-term memory,”

    Neural Comput., vol. 9, no. 8, pp. 1735–1780, Nov. 1997.
  • [15] Wojciech Zaremba, Ilya Sutskever, and Oriol Vinyals, “Recurrent neural network regularization,” CoRR, vol. abs/1409.2329, 2014.
  • [16] Junyoung Chung, Çaglar Gülçehre, KyungHyun Cho, and Yoshua Bengio, “Empirical evaluation of gated recurrent neural networks on sequence modeling,” CoRR, vol. abs/1412.3555, 2014.
  • [17] Shiliang Zhang, Hui Jiang, Si Wei, and Li-Rong Dai, “Feedforward sequential memory neural networks without recurrent feedback,” CoRR, vol. abs/1510.02693, 2015.
  • [18] Alex Graves and Navdeep Jaitly, “Towards end-to-end speech recognition with recurrent neural networks,” in Proceedings of the 31th International Conference on Machine Learning, ICML 2014, Beijing, China, 21-26 June 2014, 2014, pp. 1764–1772.
  • [19] Michael U. Gutmann and Aapo Hyvärinen, “Noise-contrastive estimation of unnormalized statistical models, with applications to natural image statistics,” J. Mach. Learn. Res., vol. 13, no. 1, pp. 307–361, Feb. 2012.
  • [20] Ebru Arisoy1, Abhinav Sethy, Bhuvana Ramabhadran, and Stanley Chen,

    Bidirectional recurrent neural network language models for automatic speech recognition,”

    in Proc. ICASSP, 2015.
  • [21] Mathias Berglund, Tapani Raiko, Mikko Honkala, Leo Kärkkäinen, Akos Vetek, and Juha Karhunen, “Bidirectional recurrent neural networks as generative models - reconstructing gaps in time series,” CoRR, vol. abs/1504.01575, 2015.
  • [22] “An introduction to computational networks and the computational network toolkit,” Microsoft Research Technical Report, pp. MSR–TR–2014–112, 2014.
  • [23] Andreas Stolcke, “Srilm-an extensible language modeling toolkit,” in Proceedings International Conference on Spoken Language Processing, November 2002, pp. 257–286.
  • [24] “The microsoft research sentence completion challenge,” Microsoft Research Technical Report, pp. MSR–TR–2011–129, 2011.
  • [25] Andriy Mnih and Yee Whye Teh, “A fast and simple algorithm for training neural probabilistic language models,” in Proceedings of the 29th International Conference on Machine Learning, 2012, pp. 1751–1758.
  • [26] M. J. F. Gales X. Chen, X. Liu and P. C.Woodland, “Recurrent neural network language model training with noise contrastive estimation for speech recognition,” in Proc. ICASSP, 2015.