stat946w18/Unsupervised Machine Translation Using Monolingual Corpora Only

From statwiki
Revision as of 16:24, 20 February 2018 by Pa2forsy (talk | contribs) (Validation)
Jump to: navigation, search



Neural machine translation systems must be trained on large corpora consisting of pairs of pre-translated sentences. This paper proposes an unsupervised neural machine translation system, which can be trained without such parallel data.

Overview of unsupervised translation system

The unsupervised translation scheme has the following outline:

  • Sentences from the source and target language are mapped to a common latent vector space.
  • A de-noising auto-encoder loss encourages the latent-space representations to be insensitive to noise.
  • An adversarial loss encourages the latent-space representations of source and target sentences to be indistinguishable from each other. It is intended that the latent-space representation of a sentence should reflect its meaning, and not the particular language in which it is expressed.
  • A reconstruction loss encourages the model to able to improve on the translation model of the previous epoch.

I will next discuss this scheme in more detail.


Let [math]S[/math] denote the set of words in the source language, and let [math]T[/math] denote the set of words in the target language. Let [math]H \subset \mathbb{R}^{n_H}[/math] denote the latent vector space. Moreover, let [math]S'[/math] and [math]T'[/math] denote the sets of finite sequences of words in the source and target language, and let [math]H'[/math] denote the set of finite sequences of vectors in the latent space. For any set X, elide measure-theoretic details and let [math]\mathcal{P}(X)[/math] denote the set of probability distributions over X.

Word vector alignment

Conneau et al. (2017) describe an unsupervised method for aligning word vectors across languages. By "alignment", I mean that their method maps words with related meanings to nearby vectors, regardless of the language of words. Moreover, if word C is the target-language literal translation of the source language word B, then-- after alignment -- C's word vector tends to be the closest target-language word vector to the word vector of B. This unsupervised alignment method is crucial to the translation scheme of the current paper. From now on we denote by [math]A: S' \cup T' \to \mathcal{Z}'[/math] the function that maps a source- and target- language word sequence to the corresponding aligned word vector sequence.


The encoder [math]E [/math] reads a sequence of word vectors [math](z_1,\ldots, z_m) \in \mathcal{Z}'[/math] and outputs a sequence of hidden states [math](h_1,\ldots, h_m) \in H'[/math] in the latent space. Crucially, because the word vectors of the two languages have been aligned, the same encoder can be applied to both. That is, to map a source sentence [math]x=(x_1,\ldots, x_M)\in S'[/math] to the latent space, we compute [math]E(A(x))[/math], and to map a target sentence [math]y=(y_1,\ldots, y_K)\in T'[/math] to the latent space, we compute [math]E(A(y))[/math].

The encoder consists of two LSTMs, one of which reads the word-vector sequence in the forward direction, and one of which reads it in the backward direction. The hidden state sequence is generated by concatenating the hidden states produced by the forward and backward LSTMs at each word vector.


The decoder is a mono-directional LSTM that accepts a sequence of hidden states [math]h=(h_1,\ldots, h_m) \in H'[/math] from the latent space and a language [math]L \in \{S,T \}[/math] and outputs a probability distribution over sequences in that language. We have

\begin{align} D: H' \times \{S,T \} \to \mathcal{P}(S') \cup \mathcal{P}(T'). \end{align}

In detail, the decoder is a mono-directional LSTM that makes use of the attention mechanism of Bahdanau et al. (2014). To compute the probability of a given sentence [math]y=(y_1,\ldots,y_K)[/math] , the LSTM processes the sentence one word at a time, accepting at step [math]k[/math] the aligned word vector of the previous word in the sentence [math]A(y_{k-1})[/math] and a context vector [math]c_k\in H[/math] computed from the hidden sequence [math]h\in H'[/math], and outputting a probability distribution over next words. The LSTM is initiated with a special, language-specific start-of-sequence token. Otherwise, the decoder is does not depend on the language of the sentence it is producing. The context vector is computed as described by Bahdanau et al. (2014), where we let [math]l_{k}[/math] denote the hidden state of the LSTM at step [math]k[/math], and where [math]U,W[/math] are learnable weight matrices, and [math]v[/math] is a learnable weight vector: \begin{align} c_k&= \sum_{m=1}^M \alpha_{k,m} h_m\\ \alpha_{k,m}&= \frac{\exp(e_{k,m})}{\sum_{m'=1}^M\exp(e_{k,m'}) },\\ e_{k,m} &= v^T \tanh (Wl_{k-1} + U h_m ). \end{align}

By learning [math]U,W[/math] and [math]v[/math], the decoder can learn which vectors in the sequence [math]h[/math] are relevant to computing which words in the output sequence.

At step [math]k[/math], after receiving the context vector [math]c_k\in H[/math] and the aligned word vector of the previous word in the sequence,[math]A(y_{k-1})[/math], the LSTM outputs a probability distribution over words, which should be interpreted as the distribution of the next word according to the decoder. The probability the decoder assigns to a sentence is then the product of the probabilities computed for each word in this manner.

Overview of objective

The objective function is the sum of three terms:

  1. The de-noising auto-encoder loss
  2. The translation loss
  3. The adversarial loss

I shall describe these in the following sections.

De-noising Auto-encoder Loss

A de-noising auto-encoder is a function optimized to map a corrupted sample from some dataset to the original un-corrupted sample. De-noising auto-encoders were introduced by Vincent et al. (2008), who provided numerous justifications, one of which is particularly illuminating. If we think of the dataset of interest as a thin manifold in a high-dimensional space, the corruption process is likely perturb a datapoint off the manifold. To learn to restore the corrupted datapoint, the de-noising auto-encoder must learn the shape of the manifold.

Hill et al. (2016), used a de-noising auto-encoder to learn vectors representing sentences. They corrupted input sentences by randomly dropping and swapping words, and then trained a neural network to map the corrupted sentence to a vector, and then map the vector to the un-corrupted sentence. Interestingly, they found that sentence vectors learned this way were particularly effective when applied to tasks that involved generating paraphrases. This makes some sense: for a vector to be useful in restoring a corrupted sentence, it must capture something of the sentence's underlying meaning.

The present paper uses the principal of de-noising auto-encoders to compute one of the terms in its loss function. In each iteration, a sentence is sampled from the source or target language, and a corruption process [math] C[/math] is applied to it. [math] C[/math] works by deleting each word in the sentence with probability [math]p_C[/math] and applying to the sentence a permutation randomly selected from those that do not move words more than [math]k_C[/math] spots from their original positions. The authors select [math]p_D=0.1[/math] and [math]k_D=3[/math]. The corrupted sentence is then mapped to the latent space using [math]E\circ A[/math]. The loss is then the negative log probability of the original uncorrupted sentence according to the decoder [math]D[/math] applied to the latent space sequence.

The explanation of Vincent et al. (2008) can help us understand this loss-function term: the de-noising auto-encoder loss forces the translation system to learn the shapes of the manifolds of the source and target languages.

Translation Loss

To compute the translation loss, we sample a sentence from one of the languages, translate it with the encoder and decoder of the previous epoch, and then corrupt its output with [math]C[/math]. We then use the current encoder [math]E[/math] to map the corrupted translation to a sequence [math]h \in H'[/math] and the decoder [math]D[/math] to map [math]h[/math] to a probability distribution over sentences. The translation loss is the negative log probability the decoder assigns to the original uncorrupted sentence.

It is interesting and useful to consider why this translation loss, which depends on the the translation model of the previous iteration, should promote an improved translation model in the current iteration. One loose way to understand this is to think of the translator as a de-noising translator. We are given a sentence perturbed from the manifold of possible sentences from a given language both by the corruption process and by the poor quality of the translation. The model must learn to both project and translate. The technique employed here resembles that used by Sennrich et al. (2014), who trained a neural machine translation system using both parallel and monolingual data. To make use of the monolingual data target-language data, they used an auxiliary model to translate it to the source language, then trained their model to reconstruct the original target-language data from the source-language translation. Sennrich et al. argued that training the model to reconstruct true data from synthetic data was more robust than the opposite approach. The authors of the present paper use similar reasoning.

Adversarial Loss

The intuition underlying the latent space is that it should encode the meaning of a sentence in a language-independent way. Accordingly, the authors introduce an adversarial loss, to encourage latent-space vectors mapped from the source and target languages to be indistinguishable. Central to this adversarial loss is the discriminator [math]R:H' \to [0,1][/math], which makes use of [math]r: H\to [0,1][/math] a three-layer fully-connected neural network with 1024 hidden units per layer. Given a sequence of latent-space vectors [math]h=(h_1,\ldots,h_m)\in H'[/math] the discriminator assigns probability [math]R(h)=\prod_{i=1}^m r(h_i)[/math] that they originated in the target space. Each iteration, the discriminator is trained to maximize the objective function

\begin{align} I_T(q) \log (R(E(q))) +(1-I_T(q) )\log(1-R(E(q))) \end{align}

where [math]q[/math] is a randomly selected sentence, and [math]I_T(q)[/math] is 1 with [math]q[/math] is from the source language and 0 otherwise.

The same term is added to the primary objective function, which the encoder and decoder are trained to minimize. The result is that the encoder and decoder learn to fool the discriminator by mapping sentences from the source and target language to similar sequences of latent-space vectors.

The authors note that they make use of label smoothing, a technique recommended by Goodfellow (2016) for regularizing GANs, in which the objective described above is replaced by

\begin{align} I_T(q)( (1-\alpha)\log (R(E(q))) +\alpha\log(1-R(E(q))) )+(1-I_T(q) ) ( (1-\beta) \log(1-R(E(q))) +\beta\log (R(E(q)) )) \end{align} for some small nonnegative values of [math]\alpha, \beta[/math], the idea being to prevent the discriminator from making extreme predictions. While one-sided label smoothing ([math]\beta = 0[/math]) is generally recommended, the present model differs from a standard GAN in that it is symmetric, and hence two-sided label smoothing would appear more reasonable.

Objective Function

Combining the above described terms, we can write the objective function for the encoder and decoder. Let [math]Q_S[/math] denote the monolingual dataset for the source language, and let [math]Q_T[/math] denote the monolingual dataset for the target language. Let [math]D_S:= D(\cdot, S)[/math] and[math]D_T= D(\cdot, T)[/math] (i.e. [math]D_S, D_T(\cdot, S)[/math]) are the decoder restricted to the source or target language, respectively. Then our objective function is

\begin{align} \mathcal{L}(D,E,R)=\text{T Translation Loss}+\text{T de-noising Loss} +\text{T adversarial loss} +\text{S Translation loss} +\text{S de-noising } +\text{S adversarial loss}\\ \end{align} \begin{align} =\sum_{q\in Q_T}\left( -\log D_T \circ E \circ C \circ M _S(q) (q) -\log D_T \circ E \circ C (q) (q)+(1-\alpha)\log (R(E(q))) +\alpha\log(1-R(E(q))) \right)+\sum_{q\in Q_S}\left( -\log D_S \circ E \circ C \circ M_T (q) (q) -\log D_S \circ E \circ C (q) (q)(1-\beta) \log(1-R(E(q))) +\beta\log (R(E(q)) \right). \end{align}

They alternate between iterations minimizing [math]\mathcal{L} [/math] with respect to [math]E, D[/math] and iterations maximizing with respect to [math]R[/math]. ADAM is used for minimization, while RMSprop is used for maximization. After each epoch, M is updated so that [math]M_S=D_S \circ E[/math] and [math]M_T=D_T \circ E[/math], after which [math] M [/math] is frozen until the next epoch.


The authors' aim is for their method to be completely unsupervised, and so use parallel corpora even for the selection of hyper-parmaeters. Instead, they validate by translating source sentences to the target language and back, and comparing the resulting sentence with the original according to BLEU, a similarity metric frequently used in translation (Papineni et al. 2002).


  1. Bahdanau, Dzmitry, Kyunghyun Cho, and Yoshua Bengio. "Neural machine translation by jointly learning to align and translate." arXiv preprint arXiv:1409.0473 (2014).
  2. Conneau, Alexis, Guillaume Lample, Marc’Aurelio Ranzato, Ludovic Denoyer, Hervé Jégou. "Word Translation without Parallel Data". arXiv:1710.04087, (2017)
  3. Goodfellow, Ian. "NIPS 2016 tutorial: Generative adversarial networks." arXiv preprint arXiv:1701.00160 (2016).
  4. Hill, Felix, Kyunghyun Cho, and Anna Korhonen. "Learning distributed representations of sentences from unlabelled data." arXiv preprint arXiv:1602.03483 (2016).
  5. Papineni, Kishore, et al. "BLEU: a method for automatic evaluation of machine translation." Proceedings of the 40th annual meeting on association for computational linguistics. Association for Computational Linguistics, 2002.
  6. Mikolov, Tomas, Quoc V Le, and Ilya Sutskever. "Exploiting similarities among languages for machine translation." arXiv preprint arXiv:1309.4168. (2013).
  7. Sennrich, Rico, Barry Haddow, and Alexandra Birch. "Improving neural machine translation models with monolingual data." arXiv preprint arXiv:1511.06709 (2015).
  8. Sutskever, Ilya, Oriol Vinyals, and Quoc V. Le. "Sequence to sequence learning with neural networks." Advances in neural information processing systems. 2014.
  9. Vincent, Pascal, et al. "Extracting and composing robust features with denoising autoencoders." Proceedings of the 25th international conference on Machine learning. ACM, 2008.