Data Noising as Smoothing in Neural Network Language Models

03/07/2017 ∙ by Ziang Xie, et al. ∙ Stanford University 0

Data noising is an effective technique for regularizing neural network models. While noising is widely adopted in application domains such as vision and speech, commonly used noising primitives have not been developed for discrete sequence-level settings such as language modeling. In this paper, we derive a connection between input noising in neural network language models and smoothing in n-gram models. Using this connection, we draw upon ideas from smoothing to develop effective noising schemes. We demonstrate performance gains when applying the proposed schemes to language modeling and machine translation. Finally, we provide empirical analysis validating the relationship between noising and smoothing.

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

Language models are a crucial component in many domains, such as autocompletion, machine translation, and speech recognition. A key challenge when performing estimation in language modeling is the

data sparsity problem: due to large vocabulary sizes and the exponential number of possible contexts, the majority of possible sequences are rarely or never observed, even for very short subsequences.

In other application domains, data augmentation has been key to improving the performance of neural network models in the face of insufficient data. In computer vision, for example, there exist well-established primitives for synthesizing additional image data, such as by rescaling or applying affine distortions to images

(LeCun et al., 1998; Krizhevsky et al., 2012). Similarly, in speech recognition adding a background audio track or applying small shifts along the time dimension has been shown to yield significant gains, especially in noisy settings (Deng et al., 2000; Hannun et al., 2014). However, widely-adopted noising primitives have not yet been developed for neural network language models.

Classic

-gram models of language cope with rare and unseen sequences by using smoothing methods, such as interpolation or absolute discounting 

(Chen & Goodman, 1996)

. Neural network models, however, have no notion of discrete counts, and instead use distributed representations to combat the curse of dimensionality

(Bengio et al., 2003). Despite the effectiveness of distributed representations, overfitting due to data sparsity remains an issue. Existing regularization methods, however, are typically applied to weights or hidden units within the network (Srivastava et al., 2014; Le et al., 2015) instead of directly considering the input data.

In this work, we consider noising primitives as a form of data augmentation for recurrent neural network-based language models. By examining the expected pseudocounts from applying the noising schemes, we draw connections between noising and linear interpolation smoothing. Using this connection, we then derive noising schemes that are analogues of more advanced smoothing methods. We demonstrate the effectiveness of these schemes for regularization through experiments on language modeling and machine translation. Finally, we validate our theoretical claims by examining the empirical effects of noising.

2 Related Work

Our work can be viewed as a form of data augmentation, for which to the best of our knowledge there exists no widely adopted schemes in language modeling with neural networks. Classical regularization methods such as -regularization are typically applied to the model parameters, while dropout is applied to activations which can be along the forward as well as the recurrent directions (Zaremba et al., 2014; Semeniuta et al., 2016; Gal, 2015)

. Others have introduced methods for recurrent neural networks encouraging the hidden activations to remain stable in norm, or constraining the recurrent weight matrix to have eigenvalues close to one 

(Krueger & Memisevic, 2015; Arjovsky et al., 2015; Le et al., 2015)

. These methods, however, all consider weights and hidden units instead of the input data, and are motivated by the vanishing and exploding gradient problem.

Feature noising has been demonstrated to be effective for structured prediction tasks, and has been interpreted as an explicit regularizer (Wang et al., 2013). Additionally, Wager et al. (2014) show that noising can inject appropriate generative assumptions into discriminative models to reduce their generalization error, but do not consider sequence models (Wager et al., 2016).

The technique of randomly zero-masking input word embeddings for learning sentence representations has been proposed by Iyyer et al. (2015)Kumar et al. (2015), and Dai & Le (2015), and adopted by others such as Bowman et al. (2015). However, to the best of our knowledge, no analysis has been provided besides reasoning that zeroing embeddings may result in a model ensembling effect similar to that in standard dropout. This analysis is applicable to classification tasks involving sum-of-embeddings or bag-of-words models, but does not capture sequence-level effects. Bengio et al. (2015)

also make an empirical observation that the method of randomly replacing words with fixed probability with a draw from the uniform distribution improved performance slightly for an image captioning task; however, they do not examine why performance improved.

3 Method

3.1 Preliminaries

We consider language models where given a sequence of indices , over the vocabulary , we model

In -gram models, it is not feasible to model the full context for large due to the exponential number of possible histories. Recurrent neural network (RNN) language models can (in theory) model longer dependencies, since they operate over distributed hidden states instead of modeling an exponential number of discrete counts (Bengio et al., 2003; Mikolov, 2012).

An -layer recurrent neural network is modeled as , where denotes the layer index,

contains the one-hot encoding of

, and in its simplest form applies an affine transformation followed by a nonlinearity. In this work, we use RNNs with a more complex form of

, namely long short-term memory (LSTM) units

(Hochreiter & Schmidhuber, 1997), which have been shown to ease training and allow RNNs to capture longer dependencies. The output distribution over the vocabulary at time is , where applies an affine transformation. The RNN is then trained by minimizing over its parameters the sequence cross-entropy loss , thus maximizing the likelihood .

As an extension, we also consider encoder-decoder or sequence-to-sequence (Cho et al., 2014; Sutskever et al., 2014) models where given an input sequence and output sequence of length , we model

and minimize the loss . This setting can also be seen as conditional language modeling, and encompasses tasks such as machine translation, where is a source language sequence and a target language sequence, as well as language modeling, where is the given sequence and is the empty sequence.

3.2 Smoothing and Noising

Recall that for a given context length , an -gram model of order is optimal under the log-likelihood criterion. Hence in the case where an RNN with finite context achieves near the lowest possible cross-entropy loss, it behaves like an -gram model.

Like -gram models, RNNs are trained using maximum likelihood, and can easily overfit (Zaremba et al., 2014). While generic regularization methods such -regularization and dropout are effective, they do not take advantage of specific properties of sequence modeling. In order to understand sequence-specific regularization, it is helpful to examine -gram language models, whose properties are well-understood.

Smoothing for -gram models

When modeling , the maximum likelihood estimate based on empirical counts puts zero probability on unseen sequences, and thus smoothing is crucial for obtaining good estimates. In particular, we consider interpolation, which performs a weighted average between higher and lower order models. The idea is that when there are not enough observations of the full sequence, observations of subsequences can help us obtain better estimates.111For a thorough review of smoothing methods, we defer to Chen & Goodman (1996). For example, in a bigram model, , where .

Noising for RNN models

We would like to apply well-understood smoothing methods such as interpolation to RNNs, which are also trained using maximum likelihood. Unfortunately, RNN models have no notion of counts, and we cannot directly apply one of the usual smoothing methods. In this section, we consider two simple noising schemes which we proceed to show correspond to smoothing methods. Since we can noise the data while training an RNN, we can then incorporate well-understood generative assumptions that are known to be helpful in the domain. First consider the following two noising schemes:

  • [leftmargin=*]

  • unigram noising    For each in , with probability replace with a sample from the unigram frequency distribution.

  • blank noising    For each in , with probability replace with a placeholder token “   ”.

While blank noising can be seen as a way to avoid overfitting on specific contexts, we will see that both schemes are related to smoothing, and that unigram noising provides a path to analogues of more advanced smoothing methods.

3.3 Noising as Smoothing

We now consider the maximum likelihood estimate of -gram probabilities estimated using the pseudocounts of the noised data. By examining these estimates, we draw a connection between linear interpolation smoothing and noising.

Unigram noising as interpolation

To start, we consider the simplest case of bigram probabilities. Let denote the count of a token in the original data, and let be the expected count of under the unigram noising scheme. We then have

where since our proposal distribution is the unigram distribution, and the last line follows since is equal to the total number of tokens in the training set. Thus we see that the noised data has pseudocounts corresponding to interpolation or a mixture of different order -gram models with fixed weighting.

More generally, let be noised tokens from . We consider the expected prediction under noise

where the mixture coefficients are with . denotes the set of indices whose corresponding tokens are left unchanged, and the set of indices that were replaced.

Blank noising as interpolation

Next we consider the blank noising scheme and show that it corresponds to interpolation as well. This also serves as an alternative explanation for the gains that other related work have found with the “word-dropout” idea (Kumar et al., 2015; Dai & Le, 2015; Bowman et al., 2015). As before, we do not noise the token being predicted . Let

denote the random variable where each of its tokens is replaced by “

   ” with probability , and let denote the sequence with indices unchanged, and the rest replaced by “   ”. To make a prediction, we use the expected probability over different noisings of the context

where , which is also a mixture of the unnoised probabilities over subsequences of the current context. For example, in the case of trigrams, we have

where the mixture coefficient .

3.4 Borrowing Techniques

With the connection between noising and smoothing in place, we now consider how we can improve the two components of the noising scheme by considering:

  1. Adaptively computing noising probability to reflect our confidence about a particular input subsequence.

  2. Selecting a proposal distribution that is less naive than the unigram distribution by leveraging higher order -gram statistics.

Noising Probability

Although it simplifies analysis, there is no reason why we should choose fixed ; we now consider defining an adaptive which depends on the input sequence. Consider the following bigrams:

“and the”                            “Humpty Dumpty”

The first bigram is one of the most common in English corpora; its probability is hence well estimated and should not be interpolated with lower order distributions. In expectation, however, using fixed when noising results in the same lower order interpolation weight for common as well as rare bigrams. Intuitively, we should define such that commonly seen bigrams are less likely to be noised.

The second bigram, “Humpty Dumpty,” is relatively uncommon, as are its constituent unigrams. However, it forms what Brown et al. (1992) term a “sticky pair”: the unigram “Dumpty” almost always follows the unigram “Humpty”, and similarly, “Humpty” almost always precedes “Dumpty”. For pairs with high mutual information, we wish to avoid backing off from the bigram to the unigram distribution.

Let be the number of distinct continutions following , or equivalently the number of bigram types beginning with (Chen & Goodman, 1996). From the above intuitions, we arrive at the absolute discounting noising probability

where for we have , though in practice we can also clip larger noising probabilities to . Note that this encourages noising of unigrams that precede many possible other tokens while discouraging noising of common unigrams, since if we ignore the final token, .

Proposal Distribution

Noised Analogue
interpolation
unigram interpolation
unigram absolute discounting
Kneser-Ney
Table 1: Noising schemes Example noising schemes and their bigram smoothing analogues. Here we consider the bigram probability . Notation: denotes the noising probability for a given input sequence , denotes the proposal distribution, and denotes the number of distinct bigrams in the training set where is the first unigram. In all but the last case we only noise the context and not the target prediction .

While choosing the unigram distribution as the proposal distribution preserves unigram frequencies, by borrowing from the smoothing literature we find another distribution performs better. We again begin with two motivating examples:

“San Francisco”                          “New York”

Both bigrams appear frequently in text corpora. As a direct consequence, the unigrams “Francisco” and “York” also appear frequently. However, since “Francisco” and “York” typically follow “San” and “New”, respectively, they should not have high probability in the proposal distribution as they might if we use unigram frequencies (Chen & Goodman, 1996). Instead, it would be better to increase the proposal probability of unigrams with diverse histories, or more precisely unigrams that complete a large number of bigram types. Thus instead of drawing from the unigram distribution, we consider drawing from

Note that we now noise the prediction in addition to the context . Combining this new proposal distribution with the discounted from the previous section, we obtain the noising analogue of Kneser-Ney smoothing.

Table 1 summarizes the discussed noising schemes.

3.5 Training and Testing

During training, noising is performed per batch and is done online such that each epoch of training sees a different noised version of the training data. At test time, to match the training objective we should sample multiple corrupted versions of the test data, then average the predictions 

(Srivastava et al., 2014). In practice, however, we find that simply using the maximum likelihood (uncorrupted) input sequence works well; evaluation runtime remains unchanged.

3.6 Extensions

The schemes described are for the language model setting. To extend them to the sequence-to-sequence or encoder-decoder setting, we noise both as well as . While in the decoder we have and as analogues to language model context and target prediction, it is unclear whether noising should be beneficial. Empirically, however, we find this to be the case (Table 4).

4 Experiments

4.1 Language Modeling

Penn Treebank

Noising scheme Validation Test
Medium models (512 hidden size)
none (dropout only) 84.3 80.4
blank 82.7 78.8
unigram 83.1 80.1
bigram Kneser-Ney 79.9 76.9
Large models (1500 hidden size)
none (dropout only) 81.6 77.5
blank 79.4 75.5
unigram 79.4 76.1
bigram Kneser-Ney 76.2 73.4
Zaremba et al. (2014) 82.2 78.4
Gal (2015) variational dropout (tied weights) 77.3 75.0
Gal (2015) (untied weights, Monte Carlo) 73.4
Table 2: Single-model perplexity on Penn Treebank with different noising schemes. We also compare to the variational method of Gal (2015), who also train LSTM models with the same hidden dimension. Note that performing Monte Carlo dropout at test time is significantly more expensive than our approach, where test time is unchanged.
Noising scheme Validation Test
none 94.3 123.6
blank 85.0 110.7
unigram 85.2 111.3
bigram Kneser-Ney 84.5 110.6
Table 3:

Perplexity on Text8 with different noising schemes.

(a) Penn Treebank corpus.
(b) Text8 corpus.
Figure 1: Example training and validation curves for an unnoised model and model regularized using the bigram Kneser-Ney noising scheme.

We train networks for word-level language modeling on the Penn Treebank dataset, using the standard preprocessed splits with a 10K size vocabulary 

(Mikolov, 2012). The PTB dataset contains 929k training tokens, 73k validation tokens, and 82k test tokens. Following Zaremba et al. (2014)

, we use minibatches of size 20 and unroll for 35 time steps when performing backpropagation through time. All models have two hidden layers and use LSTM units. Weights are initialized uniformly in the range

. We consider models with hidden sizes of and .

We train using stochastic gradient descent with an initial learning rate of 1.0, clipping the gradient if its norm exceeds 5.0. When the validation cross entropy does not decrease after a training epoch, we halve the learning rate. We anneal the learning rate 8 times before stopping training, and pick the model with the lowest perplexity on the validation set.

For regularization, we apply feed-forward dropout (Pham et al., 2014) in combination with our noising schemes. We report results in Table 2 for the best setting of the dropout rate (which we find to match the settings reported in Zaremba et al. (2014)) as well as the best setting of noising probability on the validation set.222Code will be made available at: http://deeplearning.stanford.edu/noising Figure 1 shows the training and validation perplexity curves for a noised versus an unnoised run.

Our large models match the state-of-the-art regularization method for single model performance on this task. In particular, we find that picking and corresponding to Kneser-Ney smoothing yields significant gains in validation perplexity, both for the medium and large size models. Recent work  (Merity et al., 2016; Zilly et al., 2016) has also achieved impressive results on this task by proposing different architectures which are orthogonal to our data augmentation schemes.

Text8

In order to determine whether noising remains effective with a larger dataset, we perform experiments on the Text8 corpus333http://mattmahoney.net/dc/text8.zip. The first 90M characters are used for training, the next 5M for validation, and the final 5M for testing, resulting in 15.3M training tokens, 848K validation tokens, and 855K test tokens. We preprocess the data by mapping all words which appear 10 or fewer times to the unknown token, resulting in a 42K size vocabulary. Other parameter settings are the same as described in the Penn Treebank experiments, besides that only models with hidden size 512 are considered, and noising is not combined with feed-forward dropout. Results are given in Table 3.

4.2 Machine Translation

Scheme Perplexity BLEU
dropout, no noising 8.84 24.6
blank noising 8.28 25.3 ()
unigram noising 8.15 25.5 ()
bigram Kneser-Ney 7.92 26.0 ()
source only 8.74 24.8 ()
target only 8.14 25.6 ()
Table 4: Perplexities and BLEU scores for machine translation task. Results for bigram KN noising on only the source sequence and only the target sequence are given as well.

For our machine translation experiments we consider the English-German machine translation track of IWSLT 2015444http://workshop2015.iwslt.org/. The IWSLT 2015 corpus consists of sentence-aligned subtitles of TED and TEDx talks. The training set contains roughly 190K sentence pairs with 5.4M tokens. Following Luong & Manning (2015), we use TED tst2012 as a validation set and report BLEU score results (Papineni et al., 2002) on tst2014. We limit the vocabulary to the top 50K most frequent words for each language.

We train a two-layer LSTM encoder-decoder network (Sutskever et al., 2014; Cho et al., 2014) with hidden units in each layer. The decoder uses an attention mechanism (Bahdanau et al., 2014) with the dot alignment function (Luong et al., 2015). The initial learning rate is 1.0 and we start halving the learning rate when the relative difference in perplexity on the validation set between two consecutive epochs is less than . We follow training protocols as described in Sutskever et al. (2014): (a) LSTM parameters and word embeddings are initialized from a uniform distribution between

, (b) inputs are reversed, (c) batch size is set to 128, (d) gradient clipping is performed when the norm exceeds a threshold of 5. We set hidden unit dropout rate to 0.2 across all settings as suggested in

Luong et al. (2015). We compare unigram, blank, and bigram Kneser-Ney noising. Noising rate is selected on the validation set.

Results are shown in Table 4. We observe performance gains for both blank noising and unigram noising, giving roughly BLEU score on the test set. The proposed bigram Kneser-Ney noising scheme gives an additional performance boost of - on top of the blank noising and unigram noising models, yielding a total gain of BLEU.

5 Discussion

Figure 2: Perplexity with noising on Penn Treebank while varying the value of . Using discounting to scale (yielding ) maintains gains for a range of values of noising probability, which is not true for the unscaled case.
Figure 3: Mean KL-divergence over validation set between softmax distributions of noised and unnoised models and lower order distributions. Noised model distributions are closer to the uniform and unigram frequency distributions.

5.1 Scaling via Discounting

We now examine whether discounting has the desired effect of noising subsequences according to their uncertainty. If we consider the discounting

we observe that the denominator can dominate than the numerator . Common tokens are often noised infrequently when discounting is used to rescale the noising probability, while rare tokens are noised comparatively much more frequently, where in the extreme case when a token appears exactly once, we have . Due to word frequencies following a Zipfian power law distribution, however, common tokens constitute the majority of most texts, and thus discounting leads to significantly less noising.

We compare the performance of models trained with a fixed versus a rescaled using discounting. As shown in Figure 3, bigram discounting leads to gains in perplexity for a much broader range of . Thus the discounting ratio seems to effectively capture the “right” tokens to noise.

5.2 Noised versus Unnoised Models

Smoothed distributions

In order to validate that data noising for RNN models has a similar effect to that of smoothing counts in -gram models, we consider three models trained with unigram noising as described in Section 4.1 on the Penn Treebank corpus with (no noising), , and

. Using the trained models, we measure the Kullback-Leibler divergence

over the validation set between the predicted softmax distributions, , and the uniform distribution as well as the unigram frequency distribution. We then take the mean KL divergence over all tokens in the validation set.

Recall that in interpolation smoothing, a weighted combination of higher and lower order -gram models is used. As seen in Figure 3, the softmax distributions of noised models are significantly closer to the lower order frequency distributions than unnoised models, in particular in the case of the unigram distribution, thus validating our analysis in Section 3.3.

Noising Bigrams Trigrams
none (dropout only) 2881 381
blank noising 2760 372
unigram noising 2612 365
Table 5: Perplexity of last unigram for unseen bigrams and trigrams in Penn Treebank validation set. We compare noised and unnoised models with noising probabilities chosen such that models have near-identical perplexity on full validation set.

Unseen -grams

Smoothing is most beneficial for increasing the probability of unobserved sequences. To measure whether noising has a similar effect, we consider bigrams and trigrams in the validation set that do not appear in the training set. For these unseen bigrams (15062 occurrences) and trigrams (43051 occurrences), we measure the perplexity for noised and unnoised models with near-identical perplexity on the full set. As expected, noising yields lower perplexity for these unseen instances.

6 Conclusion

In this work, we show that data noising is effective for regularizing neural network-based sequence models. By deriving a correspondence between noising and smoothing, we are able to adapt advanced smoothing methods for -gram models to the neural network setting, thereby incorporating well-understood generative assumptions of language. Possible applications include exploring noising for improving performance in low resource settings, or examining how these techniques generalize to sequence modeling in other domains.

Acknowledgments

We thank Will Monroe for feedback on a draft of this paper, Anand Avati for help running experiments, and Jimmy Wu for computing support. We also thank the developers of Theano 

(Theano Development Team, 2016)

and Tensorflow 

(Abadi et al., 2016). Some GPUs used in this work were donated by NVIDIA Corporation. ZX, SW, and JL were supported by an NDSEG Fellowship, NSERC PGS-D Fellowship, and Facebook Fellowship, respectively. This project was funded in part by DARPA MUSE award FA8750-15-C-0242 AFRL/RIKF.

References

Appendix A Sketch of Noising Algorithm

We provide pseudocode of the noising algorithm corresponding to bigram Kneser-Ney smoothing for -grams (In the case of sequence-to-sequence tasks, we estimate the count-based parameters separately for source and target). To simplify, we assume a batch size of one. The noising algorithm is applied to each data batch during training. No noising is applied at test time.

0.35cm0.0cm Require counts , number of distinct continuations , proposal distribution
Inputs , batch of unnoised data indices, scaling factor
 

procedure NoiseBGKN()
     
     for  do
         
         if  then
               Updates
              
         end if
     end for
     return Run training iteration with noised batch
end procedure
Algorithm 1 Bigram KN noising (Language modeling setting)