Title: AN ACTOR-CRITIC ALGORITHM FOR SEQUENCE PREDICTION

Abstract: We present an approach to training neural networks to generate sequences using actor-critic methods from reinforcement learning (RL). Current log-likelihood training methods are limited by the discrepancy between their training and testing modes, as models must generate tokens conditioned on their previous guesses rather than the ground-truth tokens. We address this problem by introducing a critic network that is trained to predict the value of an output token, given the policy of an actor network. This results in a training procedure that is much closer to the test phase, and allows us to directly optimize for a task-specific score such as BLEU. Crucially, since we leverage these techniques in the supervised learning setting rather than the traditional RL setting, we condition the critic network on the ground-truth output. We show that our method leads to improved performance on both a synthetic task, and for German-English machine translation. Our analysis paves the way for such methods to be applied in natural language generation tasks, such as machine translation, caption generation, and dialogue modelling.

1. INTRODUCTION:

In many important applications of machine learning, the task is to develop a system that produces a sequence of discrete tokens given an input. Recent work has shown that recurrent neural networks (RNNs) can deliver excellent performance in many such tasks when trained to predict the next output token given the input and previous tokens. This approach has been applied successfully in machine translation (Sutskever et al., 2014; Bahdanau et al., 2015) , caption generation (Kiros et al., 2014; Donahue et al., 2015; Vinyals et al., 2015; Xu et al., 2015; Karpathy & Fei-Fei, 2015) , and speech recognition (Chorowski et al., 2015; Chan et al., 2015) .

The standard way to train RNNs to generate sequences is to maximize the log-likelihood of the "correct" token given a history of the previous "correct" ones, an approach often called teacher forcing. At evaluation time, the output sequence is often produced by an approximate search for the most likely candidate according to the learned distribution. During this search, the model is conditioned on its own guesses, which may be incorrect and thus lead to a compounding of errors (Bengio et al., 2015) . This can become especially problematic for longer sequences. Due to this discrepancy between training and testing conditions, it has been shown that maximum likelihood training can be suboptimal (Bengio et al., 2015; Ranzato et al., 2015) . In these works, the authors argue that the network should be trained to continue generating correctly given the outputs already produced by the model, rather than the ground-truth reference outputs from the data. This gives rise to the challenging problem of determining the target for the next network output. Bengio et al. (2015) use the token k from the ground-truth answer as the target for the network at step k, whereas Ranzato et al. (2015) rely on the REINFORCE algorithm (Williams, 1992) to decide whether or not the tokens from a sampled prediction lead to a high task-specific score, such as BLEU (Papineni et al., 2002) or ROUGE (Lin & Hovy, 2003) .

In this work, we propose and study an alternative procedure for training sequence prediction networks that aims to directly improve their test time metrics (which are typically not the log-likelihood). In particular, we train an additional network called the critic to output the value of each token, which we define as the expected task-specific score that the network will receive if it outputs the token and continues to sample outputs according to its probability distribution. Furthermore, we show how the predicted values can be used to train the main sequence prediction network, which we refer to as the actor. The theoretical foundation of our method is that, under the assumption that the critic computes exact values, the expression that we use to train the actor is an unbiased estimate of the gradient of the expected task-specific score.

Our approach draws inspiration and borrows the terminology from the field of reinforcement learning (RL) (Sutton & Barto, 1998) , in particular from the actor-critic approach (Sutton, 1984; Sutton et al., 1999; Barto et al., 1983) . RL studies the problem of acting efficiently based only on weak supervision in the form of a reward given for some of the agent's actions. In our case, the reward is analogous to the task-specific score associated with a prediction. However, the tasks we consider are those of supervised learning, and we make use of this crucial difference by allowing the critic to use the ground-truth answer as an input. In other words, the critic has access to a sequence of expert actions that are known to lead to high (or even optimal) returns. To train the critic, we adapt the temporal difference methods from the RL literature (Sutton, 1988) to our setup. While RL methods with non-linear function approximators are not new (Tesauro, 1994; Miller et al., 1995) , they have recently surged in popularity, giving rise to the field of 'deep RL' (Mnih et al., 2015) . We show that some of the techniques recently developed in deep RL, such as having a target network, may also be beneficial for sequence prediction.

The contributions of the paper can be summarized as follows: 1) we describe how RL methodology like the actor-critic approach can be applied to supervised learning problems with structured outputs; and 2) we investigate the performance and behavior of the new method on both a synthetic task and a real-world task of machine translation, demonstrating the improvements over maximum-likelihood and REINFORCE brought by the actor-critic training.

2. BACKGROUND:

We consider the problem of learning to produce an output sequence Y = (y 1 , . . . , y T ), y t ∈ A given an input X, where A is the alphabet of output tokens. We will often use notation Y f ...l to refer to subsequences of the form (y f , . . . , y l ). Two sets of input-output pairs (X, Y ) are assumed to be available for both training and testing. The trained predictor h is evaluated by computing the average task-specific score R( Ŷ , Y ) on the test set, where Ŷ = h(X) is the prediction. To simplify the formulas we always use T to denote the length of an output sequence, ignoring the fact that the output sequences may have different length.

Recurrent neural networks A recurrent neural network (RNN) produces a sequence of state vectors (s 1 , . . . , s T ) given a sequence of input vectors (e 1 , . . . , e T ) by starting from an initial s 0 state and applying T times the transition function f : s t = f (s t-1 , e t ). Popular choices for the mapping f are the Long Short-Term Memory (Hochreiter & Schmidhuber, 1997) and the Gated Recurrent Units (Cho et al., 2014) , the latter of which we use for our models.

To build a probabilistic model for sequence generation with an RNN, one adds a stochastic output layer g (typically a softmax for discrete outputs) that generates outputs y t ∈ A and can feed these outputs back by replacing them with their embedding e(y t ):

y t ∼ g(s t-1 ) (1) s t = f (s t-1 , e(y t )).

(2) Thus, the RNN defines a probability distribution p(y t |y 1 , . . . , y t-1 ) of the next output token y t given the previous tokens (y 1 , . . . , y t-1 ). Upon adding a special end-of-sequence token ∅ to the alphabet A, the RNN can define the distribution p(Y ) over all possible sequences as p(Y ) = p(y 1 )p(y 2 |y 1 ) . . . p(y T |y 1 , . . . , y T -1 )p(∅|y 1 , . . . , y T ).

RNNs for sequence prediction To use RNNs for sequence prediction, they must be augmented to generate Y conditioned on an input X. The simplest way to do this is to start with an initial state s 0 = s 0 (X) (Sutskever et al., 2014; Cho et al., 2014) . Alternatively, one can encode X as a variable-length sequence of vectors (h 1 , . . . , h L ) and condition the RNN on this sequence using an attention mechanism. In our models, the sequence of vectors is produced by either a bidirectional RNN (Schuster & Paliwal, 1997) or a convolutional encoder (Rush et al., 2015) .

We use a soft attention mechanism (Bahdanau et al., 2015) that computes a weighted sum of a sequence of vectors. The attention weights determine the relative importance of each vector. More formally, we consider the following equations for RNNs with attention:

y t ∼ g(s t-1 , c t-1 ) (3) s t = f (s t-1 , c t-1 , e(y t )) (4) α t = β(s t , (h 1 , . . . , h L ))

(5)

EQUATION

)

where β is the attention mechanism that produces the attention weights α t and c t is the context vector, or 'glimpse', for time step t. The attention weights are computed by an MLP that takes as input the current RNN state and each individual vector to focus on. The weights are typically (as in our work) constrained to be positive and sum to 1 by using the softmax function.

A conditioned RNN can be trained for sequence prediction by gradient ascent on the log-likelihood log p(Y |X) for the input-output pairs (X, Y ) from the training set. To produce a prediction Ŷ for a test input sequence X, an approximate beam search for the maximum of p(•|X) is usually conducted. During this search the probabilities p(•|ŷ 1 , . . . , ŷt-1 ) are considered, where the previous tokens ŷ1 , . . . , ŷt-1 comprise a candidate beginning of the prediction Ŷ .

Value functions:

We view the conditioned RNN as a stochastic policy that generates actions and receives the task score (e.g., BLEU score) as the return. We furthermore consider the case when the return R is partially received at the intermediate steps in the form of rewards r t : R( Ŷ , Y ) = T t=1 r t (ŷ t ; Ŷ1...t-1 , Y ). This is more general than the case of receiving the full return at the end of the sequence, as we can simply define all rewards other than r T to be zero. Receiving intermediate rewards may ease the learning for the critic, and we use reward shaping as explained in Section 3. Given the policy, possible actions and reward function, the value represents the expected future return as a function of the current state of the system, which in our case is uniquely defined by the sequence of actions taken so far, Ŷ1...t-1 .

We define the value of an unfinished prediction Ŷ1...t as follows:

V ( Ŷ1...t ; X, Y ) = E Ŷt+1...T ∼p(.| Ŷ1...t,X) T τ =t+1 r τ (ŷ τ ; Ŷ1...τ-1 , Y ).

We define the value of a candidate next token a for an unfinished prediction Ŷ1...t-1 as the expected future return after generating token a:

Q(a; Ŷ1...t-1 , X, Y ) = E Ŷt+1...T ∼p(.| Ŷ1...t-1a,X) r t (a; Ŷ1...t-1 , Y ) + T τ =t+1

r τ (ŷ τ ; Ŷ1...t-1 a Ŷt+1...τ , Y ) .

We will refer to the candidate next tokens as actions. For notational simplicity, we henceforth drop X and Y from the signature of p, V , Q, R and r t , assuming it is clear from the context which of X and Y is meant. We will also use V without arguments for the expected reward of a random prediction. Receive a random example (X, Y ).

4::

Generate a sequence of actions Ŷ from p .

5::

Compute targets for the critic Update the critic weights φ using the gradient

q t =

d dφ T t=1 Q(ŷ t ; Ŷ1...t-1 , Y ) -q t 2 + λ C C t where C t = a Q(a; Ŷ1...t-1 ) - 1 |A| b Q(b; Ŷ1...t-1 ) 2 7:

Update actor weights θ using the following gradient estimate

dV (X, Y ) dθ = T t=1 a∈A dp(a| Ŷ1...t-1 , X) dθ Q(a; Ŷ1...t-1 , Y ) + λ LL T t=1 dp(y t |Y 1...t-1 , X) dθ 8:

Update delayed actor and target critic, with constants γ θ 1, γ φ 1 

θ = γ θ θ + (1 -γ θ )θ , φ = γ φ φ + (1 -γ φ )

3. ACTOR-CRITIC FOR SEQUENCE PREDICTION:

Let θ be the parameters of the conditioned RNN, which we will also refer to as the actor. Our training algorithm is based on the following way of rewriting the gradient of the expected return dV dθ :

EQUATION

)

This equality is known in RL under the names policy gradient theorem (Sutton et al., 1999) and stochastic actor-critic (Sutton, 1984) .1 Note that we use the probability rather than the log probability in this formula (which is more typical in RL applications) as we are summing over actions rather than taking an expectation. Intuitively, this equality corresponds to increasing the probability of actions that give high values, and decreasing the probability of actions that give low values. Since this gradient expression is an expectation, it is trivial to build an unbiased estimate for it:

EQUATION

where Ŷ k are M random samples from p( Ŷ ). By replacing Q with a parameteric estimate Q one can obtain a biased estimate with relatively low variance. The parameteric estimate Q is called the critic.

The above formula is similar in spirit to the REINFORCE learning rule that Ranzato et al. ( 2015) use in the same context:

EQUATION

where the scalar b t (X) is called baseline or control variate. The difference is that in REINFORCE the inner sum over all actions is replaced by its 1-sample estimate, namely is introduced to correct for the sampling of ŷt . Furthermore, instead of the value Q(ŷ t ; Ŷ1...t-1 ), REIN-FORCE uses the cumulative reward T τ =t r τ (ŷ τ ; Ŷ1...τ-1 ) following the action ŷt , which again can be seen as a 1-sample estimate of Q. Due to these simplifications and the potential high variance in the cumulative reward, the REINFORCE gradient estimator has very high variance. In order to improve upon it, we consider the actor-critic estimate from Equation 8, which has a lower variance at the cost of significant bias, since the critic is not perfect and trained simultaneously with the actor. The success depends on our ability to control the bias by designing the critic network and using an appropriate training criterion for it.

To implement the critic, we propose to use a separate RNN parameterized by φ. The critic RNN is run in parallel with the actor, consumes the tokens ŷt that the actor outputs and produces the estimates Q(a; Ŷ1...t ) for all a ∈ A. A key difference between the critic and the actor is that the correct answer Y is given to the critic as an input, similarly to how the actor is conditioned on X. Indeed, the return R( Ŷ , Y ) is a deterministic function of Y , and we argue that using Y to compute Q should be of great help. We can do this because the values are only required during training and we do not use the critic at test time. We also experimented with providing the actor states s t as additional inputs to the critic. See Figure 1 for a visual representation of our actor-critic architecture.

Temporal-difference learning A crucial component of our approach is policy evaluation, that is the training of the critic to produce useful estimates of Q. With a naïve Monte-Carlo method, one could use the future return T τ =t r τ (ŷ τ ; Ŷ1...τ-1 ) as a target to Q(ŷ t ; Ŷ1...t-1 ), and use the critic parameters φ to minimize the square error between these two values. However, like with REINFORCE, using such a target yields to very high variance which quickly grows with the number of steps T . We use a temporal difference (TD) method for policy evaluation (Sutton, 1988) . Namely, we use the right-hand side q t = r t (ŷ t ; Ŷ1...t-1 ) + a∈A p(a| Ŷ1...t ) Q(a; Ŷ1...t ) of the Bellman equation as the target for the left-hand Q(ŷ t ; Ŷ1...t-1 ).

Figure 1 : Both the actor and the critic are encoder-decoder networks. The actor receives an input sequence X and produces samples Ŷ which are evaluated by the critic. The critic takes in the ground-truth sequence Y as input to the encoder, and takes the input summary (calculated using an attention mechanism) and the actor's prediction ŷt as input at time step t of the decoder. The values

Q 1 , Q 2 , • • • , Q T computed

by the critic are used to approximate the gradient of the expected returns with respect to the parameters of the actor. This gradient is used to train the actor to optimize these expected task specific returns (e.g., BLEU score). The critic may also receive the hidden state activations of the actor as input.

Applying deep RL techniques It has been shown in the RL literature that if Q is non-linear (like in our case), the TD policy evaluation might diverge (Tsitsiklis & Van Roy, 1997) . Previous work has shown that this problem can be alleviated by using an additional target network Q to compute q t , which is updated less often and/or more slowly than Q. Similarly to (Lillicrap et al., 2015) , we update the parameters φ of the target critic by linearly interpolating them with the parameters of the trained one. Attempts to remove the target network by propagating the gradient through q t resulted in a lower square error ( Q(ŷ t ; Ŷ1...T ) -q t ) 2 , but the resulting Q values proved very unreliable as training signals for the actor.

The fact that both actor and critic use outputs of each other for training creates a potentially dangerous feedback loop. To address this, we sample predictions from a delayed actor (Lillicrap et al., 2015) , whose weights are slowly updated to follow the actor that is actually trained.

Dealing with large action spaces One of the challenges of our work is that the action space is very large (as is typically the case in NLP tasks with large vocabularies). This can be alleviated by putting constraints on the critic values for actions that are rarely sampled. We found experimentally that shrinking the values of these rare actions is necessary for the algorithm to converge. Specifically, we add a term C t for every step t to the critic's optimization objective which drives all value predictions of the critic closer to their mean:

C t = a Q(a; Ŷ1...t-1 ) - 1 |A| b Q(b; Ŷ1...t-1 ) 2 (10)

This corresponds to penalizing the variance of the outputs of the critic. Without this penalty the values of rare actions can be severely overestimated, which biases the gradient estimates and can cause divergence. A similar trick was used in the context of learning simple algorithms with Q-learning (Zaremba et al., 2015) .

Reward shaping While we are ultimately interested in the maximization of the score of a complete prediction, simply awarding this score at the last step provides a very sparse training signal for the critic. For this reason we use potential-based reward shaping with potentials Φ( Ŷ1...t ) = R( Ŷ1...t ) for incomplete sequences and Φ( Ŷ ) = 0 for complete ones (Ng et al., 1999) . Namely, for a predicted sequence Ŷ we compute score values for all prefixes to obtain the sequence of scores (R( Ŷ1...1 ), R( Ŷ1...2 ), . . . , R( Ŷ1...T )). The difference between the consecutive pairs of scores is then used as the reward at each step: r t (ŷ t ; Ŷ1...t-1 ) = R( Ŷ1...t ) -R( Ŷ1...t-1 ). Using the shaped reward r t instead of awarding the whole score R at the last step does not change the optimal policy (Ng et al., 1999) .

Putting it all together Algorithm 1 describes the proposed method in detail. We consider adding the weighted log-likelihood gradient to the actor's gradient estimate. This is in line with the prior work by (Ranzato et al., 2015) and (Shen et al., 2015) . It is also motivated by our preliminary experiments that showed that using the actor-critic estimate alone can lead to an early determinization of the policy and vanishing gradients (also discussed in Section 6). Starting training with a randomly initialized actor and critic would be problematic, because neither the actor nor the critic would provide adequate training signals for one another. The actor would sample completely random predictions that receive very little reward, thus providing a very weak training signal for the critic. A random critic would be similarly useless for training the actor. Motivated by these considerations, we pre-train the actor using standard log-likelihood training. Furthermore, we pre-train the critic by feeding it samples from the pre-trained actor, while the actor's parameters are frozen. The complete training procedure including pre-training is described by Algorithm 2.

4. RELATED WORK:

In other recent RL-inspired work on sequence prediction, Ranzato et al. ( 2015) trained a translation model by gradually transitioning from maximum likelihood learning into optimizing BLEU or ROUGE scores using the REINFORCE algorithm. However, REINFORCE is known to have very high variance and does not exploit the availability of the ground-truth like the critic network does.

The approach also relies on a curriculum learning scheme. Standard value-based RL algorithms like SARSA and OLPOMDP have also been applied to structured prediction (Maes et al., 2009) . Again, these systems do not use the ground-truth for value prediction.

Imitation learning has also been applied to structured prediction (Vlachos, 2012) . Methods of this type include the SEARN (Daumé Iii et al., 2009) and DAGGER (Ross et al., 2010) algorithms. These methods rely on an expert policy to provide action sequences that the policy learns to imitate.

Unfortunately, it's not always easy or even possible to construct an expert policy for a task-specific score. In our approach, the critic plays a role that is similar to the expert policy, but is learned without requiring prior knowledge about the task-specific score. The recently proposed 'scheduled sampling' (Bengio et al., 2015) can also be seen as imitation learning. In this method, ground-truth tokens are occasionally replaced by samples from the model itself during training. A limitation is that the token k for the ground-truth answer is used as the target at step k, which might not always be the optimal strategy.

There are also approaches that aim to approximate the gradient of the expected score. One such approach is 'Direct Loss Minimization' (Hazan et al., 2010) in which the inference procedure is adapted to take both the model likelihood and task-specific score into account. Another popular approach is to replace the domain over which the task score expectation is defined with a small subset of it, as is done in Minimum (Bayes) Risk Training (Goel & Byrne, 2000; Shen et al., 2015; Och, 2003) . This small subset is typically an n-best list or a sample (like in REINFORCE) that may or may not include the ground-truth as well. None of these methods provide intermediate targets for the actor during training, and Shen et al. (2015) report that as many as 100 samples were required for the best results.

Another recently proposed method is to optimize a global sequence cost with respect to the selection and pruning behavior of the beam search procedure itself (Wiseman & Rush, 2016) . This method follows the more general strategy called 'learning as search optimization' (Daumé III & Marcu, 2005) . This is an interesting alternative to our approach; however, it is designed specifically for the precise inference procedure involved.

5. EXPERIMENTS:

To validate our approach, we performed two sets of experiments2 . First, we trained the proposed model to recover strings of natural text from their corrupted versions. Specifically, we consider each character in a natural language corpus and with some probability replace it with a random character. We call this synthetic task spelling correction. A desirable property of this synthetic task is that data is essentially infinite and overfitting is no concern. Our second series of experiments is done on the task of automatic machine translation using different models and datasets.

Published as a conference paper at ICLR 2017

In addition to maximum likelihood and actor-critic training we implemented two versions of the REINFORCE gradient estimator. In the first version, we use a linear baseline network that takes the actor states as input, exactly as in (Ranzato et al., 2015) . We also propose a novel extension of REINFORCE that leverages the extra information available in the ground-truth output Y . Specifically, we use the Q estimates produced by the critic network as the baseline for the REINFORCE algorithm. The motivation behind this approach is that using the ground-truth output should produce a better baseline that lowers the variance of REINFORCE, resulting in higher task-specific scores. We refer to this method as REINFORCE-critic.

5.1. SPELLING CORRECTION:

We use text from the One Billion Word dataset for the spelling correction task (Chelba et al., 2013) , which has pre-defined training and testing sets. The training data was abundant, and we never used any example twice. We evaluate trained models on a section of the test data that comprises 6075 sentences. To speed up experiments, we clipped all sentences to the first 10 or 30 characters.

For the spelling correction actor network, we use an RNN with 100 Gated Recurrent Units (GRU) and a bidirectional GRU network for the encoder. We use the same attention mechanism as proposed in (Bahdanau et al., 2015) , which effectively makes our actor network a smaller version of the model used in that work. For the critic network, we employed a model with the same architecture as the actor.

We use character error rate (CER) to measure performance on the spelling task, which we define as the ratio between the total of Levenshtein distances between predictions and ground-truth outputs and the total length of the ground-truth outputs. This is a corpus-level metric for which a lower value is better. We use it as the return by negating per-sentence ratios. At the evaluation time greedy search is used to extract predictions from the model. We use the ADAM optimizer (Kingma & Ba, 2015) to train all the networks with the parameters recommended in the original paper, with the exception of the scale parameter α. The latter is first set to 10 -3 and then annealed to 10 -4 for log-likelihood training. For the pre-training stage of the actor-critic, we use α = 10 -3 and decrease it to 10 -4 for the joint actor-critic training. We pretrain the actor until its score on the development set stops improving. We pretrain the critic until its TD error stabilizes 3 . We used M = 1 sample for both actor-critic and REIN-FORCE. For exact hyperparameter settings we refer the reader to Appendix A.

We start REINFORCE training from a pretrained actor, but we do not use the curriculum learning employed in MIXER. The critic is trained in the same way for both REINFORCE and actorcritic, including the pretraining stage. We report results obtained with the reward shaping described in Section 3, as we found that it slightly improves REINFORCE performance. out of four settings. In the fourth case, actor-critic and REINFORCE-critic have similar performance.

Adding the log-likelihood gradient with a cofficient λ LL = 0.1 helps both of the methods, but actor-critic still retains a margin of improvement over REINFORCE-critic.

5.2. MACHINE TRANSLATION:

For our first translation experiment, we use data from the German-English machine translation track of the IWSLT 2014 evaluation campaign (Cettolo et al., 2014) , as used in Ranzato et al. (2015) , and closely follow the pre-processing described in that work. The training data comprises about 153,000 German-English sentence pairs. In addition we considered a larger WMT14 English-French dataset Cho et al. (2014) with more than 12 million examples. For further information about the data we refer the reader to Appendix B.

The return is defined as a smoothed and rescaled version of the BLEU score. Specifically, we start all n-gram counts from 1 instead of 0, and multiply the resulting score by the length of the ground-truth translation. Smoothing is a common practice when sentence-level BLEU score is considered, and it has been used to apply REINFORCE in similar settings (Ranzato et al., 2015) .

IWSLT 2014 with a convolutional encoder In our first experiment we use a convolutional encoder in the actor to make our results more comparable with Ranzato et al. (2015) . For the same reason, we use 256 hidden units in the networks. For the critic, we replaced the convolutional network with a bidirectional GRU network. For training this model we mostly used the same hyperparameter values as in the spelling correction experiments, with a few differences highlighted in Appendix A. For decoding we used greedy search and beam search with a beam size of 10. We found that penalizing candidate sentences that are too short was required to obtain the best results. Similarly to (Hannun et al., 2014) , we subtracted ρT from the negative log-likelihood of each candidate sentence, where T is the candidate's length, and ρ is a hyperparameter tuned on the validation set.

The results are summarized in Table 2 . We report a significant improvement of 2.3 BLEU points over the log-likelihood baseline when greedy search is used for decoding. Surprisingly, the best performing method is REINFORCE with critic, with an additional 0.6 BLEU point advantage over the actor-critic. When beam-search is used, the ranking of the compared approaches is the same, but the margin between the proposed methods and log-likelihood training becomes smaller. The final performances of the actor-critic and the REINFORCE-critic with greedy search are also 0.7 and 1.3 BLEU points respectively better than what Ranzato et al. ( 2015) report for their MIXER approach. This comparison should be treated with caution, because our log-likelihood baseline is 1.6 BLEU 1 for an explanation of abbreviations. The apostrophy and the asterisk identify results from (Bahdanau et al., 2015) and (Shen et al., 2015) To better understand the IWSLT 2014 results we provide the learning curves for the considered approaches in Figure 2 . We can clearly see that the training methods that use generated predictions have a strong regularization effect -that is, better progress on the validation set in exchange for slower or negative progress on the training set. The effect is stronger for both REINFORCE varieties, especially for the one without a critic. The actor-critic training does a much better job of fitting the training set than REINFORCE and is the only method except log-likelihood that shows a clear overfitting, which is a healthy behaviour for such a small dataset.

In addition, we performed an ablation study. We found that using a target network was crucial; while the joint actor-critic training was still progressing with γ θ = 0.1, with γ θ = 1.0 it did not work at all. Similarly important was the value penalty described in Equation (10). We found that good values of the λ coefficient were in the range [10 -3 , 10 -6 ]. Other techniques, such as reward shaping and a delayed actor, brought moderate performance gains. We refer the reader to Appendix A for more details.

IWSLT 2014 with a bidirectional GRU encoder In order to compare our results with those reported by Wiseman & Rush (2016) we repeated our IWSLT 2014 investigation with a different encoder, a bidirectional RNN with 256 GRU units. In this round of experiments we also tried to used combined training objectives in the same way as in our spelling correction experiments. The results are summarized in Table 3 . One can see that the actor-critic training, especially its AC+LL version, yields significant improvements (1.7 with greedy search and 1.0 with beam search) upon the pure log-likelihood training, which are comparable to those brought by Beam Search Optimization (BSO), even though our log-likelihood baseline is much stronger. In this round of experiments actor-critic and REINFORCE-critic performed on par.

WMT 14 Finally we report our results on a very popular large WMT14 English-French dataset (Cho et al., 2014) in Table 4 . Our model closely follows the achitecture from (Bahdanau et al., 2015) , however we achieved a higher baseline performance by annealing the learning rate α and penalizing output sequences that were too short during beam search. The actor-critic training brings a significant 1.5 BLEU improvement with greedy search and a noticeable 0.4 BLEU improvement with beam search. In previous work Shen et al. (2015) report a higher improvement of 1.4 BLEU with beam search, however they use 100 samples for each training example, whereas we use just one. We note that in this experiment, which is perhaps the most realistic settings, the actor-critic enjoys a significant advantage over the REINFORCE-critic.

6. DISCUSSION:

We proposed an actor-critic approach to sequence prediction. Our method takes the task objective into account during training and uses the ground-truth output to aid the critic in its prediction of intermediate targets for the actor. We showed that our method leads to significant improvements over maximum likelihood training on both a synthetic task and a machine translation benchmark.

Compared to REINFORCE training on machine translation, actor-critic fits the training data much faster, although in some of our experiments we were able to significantly reduce the gap in the training speed and achieve a better test error using our critic network as the baseline for REINFORCE.

One interesting observation we made from the machine translation results is that the training methods that use generated predictions have a strong regularization effect. Our understanding is that conditioning on the sampled outputs effectively increases the diversity of training data. This phenomenon makes it harder to judge whether the actor-critic training meets our expectations, because a noisier gradient estimate yielded a better test set performance. We argue that the spelling correction results obtained on a virtually infinite dataset in conjuction with better machine translation performance on the large WMT 14 dataset provide convincing evidence that the actor-training can be effective. In future work we will consider larger machine translation datasets.

We ran into several optimization issues. The critic would sometimes assign very high values to actions with a very low probability according to the actor. We were able to resolve this by penalizing the critic's variance. Additionally, the actor would sometimes have trouble to adapt to the demands of the critic. We noticed that the action distribution tends to saturate and become deterministic, causing the gradient to vanish. We found that combining an RL training objective with log-likelihood can help, but in general we think this issue deserves further investigation. For example, one can look for suitable training criteria that have a well-behaved gradient even when the policy has little or no stochasticity.

In a concurrent work Wu et al. (2016) show that a version of REINFORCE with the baseline computed using multiple samples can improve performance of a very strong machine translation system. This result, and our REINFORCE-critic experiments, suggest that often the variance of REINFORCE can be reduced enough to make its application practical. That said, we would like to emphasize that this paper attacks the problem of gradient estimation from a very different angle as it aims for low-variance but potentially high-bias estimates. The idea of using the ground-truth output that we proposed is an absolutely necessary first step in this direction. Future work could focus on further reducing the bias of the actor-critic estimate, for example, by using a multi-sample training criterion for the critic. 

A HYPERPARAMETERS:

For machine translation experiments the variance penalty coefficient λ was set to 10 -4 , and the delay coefficients γ θ and γ φ were both set to 10 -4 . For REINFORCE with the critic we did not use a delayed actor, i.e. γ θ was set to 1. For the spelling correction task we used the same γ θ and γ φ but a different λ = 10 -3 . When we used a combined training criterion, the weight of the log-likelihood gradient λ LL was always 0.1. All initial weights were sampled from a centered uniform distribution with width 0.1.

In some of our experiments we provided the actor states as additional inputs to the critic. Specifically, we did so in our spelling correction experiments and in our WMT 14 machine translation study. All the other results were obtained without this technique.

For decoding with beam search we substracted the length of a candidate times ρ from the loglikelihood cost. The exact value of ρ was selected on the validation set and was equal to 0.8 for models trained by log-likelihood and REINFORCE and to 1.0 for models trained by actor-critic and REINFORCE-critic.

For some of the hyperparameters we performed an ablation study. The results are reported in Table 5 .

B DATA:

For the IWSLT 2014 data the sizes of validation and tests set were 6,969 and 6,750, respectively. We limited the number of words in the English and German vocabularies to the 22,822 and 32,009 most frequent words, respectively, and replaced all other words with a special token. The maximum sentence length in our dataset was 50. For WMT14 we used vocabularies of 30,000 words for both English and French, and the maximum sentence length was also 50.

C GENERATED Q-VALUES:

In Table C we provide an example of value predictions that the critic outputs for candidate next words. One can see that the critic has indeed learnt to assign larger values for the appropriate next words. While the critic does not always produce sensible estimates and can often predict a high return for irrelevant rare words, this is greatly reduced using the variance penalty term from Equation (10). The numbers in parentheses are the value predictions Q. The German original is "über eine davon will ich hier erzählen ." The reference translation is "and there's one I want to talk about". 

:

We also provide a simple self-contained proof of Equation (7) in Supplementary Material.

The source code is available at https://github.com/rizar/actor-critic-public

A typical behaviour for TD error was to grow at first and then start decreasing slowly. We found that stopping pretraining shortly after TD error stops growing leads to good results.

Figures and Tables:

log p(ŷt| Ŷ1...t-1) dθ Q(ŷ t ; Ŷ1...t-1 ), where the log probability d log p(ŷt|.

Figure 2: Progress of log-likelihood (LL), RE-INFORCE (RF) and actor-critic (AC) training in terms of BLEU score on the training (train) and validation (valid) datasets. LL* stands for the annealing phase of log-likelihood training. The curves start from the epoch of log-likelihood pretraining from which the parameters were initialized.

Figure 3: The best 3 words according to the critic at intermediate steps of generating a translation.The numbers in parentheses are the value predictions Q. The German original is "über eine davon will ich hier erzählen ." The reference translation is "and there's one I want to talk about". Word Words with largest Q one and(6.623) there(6.200) but(5.967) of that(6.197) one(5.668) &apos;s(5.467) them that(5.408) one(5.118) i(5.002) i that(4.796) i(4.629) ,(4.139) want want(5.008) i(4.160) &apos;t(3.361) to to(4.729) want(3.497) going(3.396) tell talk(3.717) you(2.407) to(2.133) you about(1.209) that(0.989) talk(0.924) about about(0.706) .(0.660) right(0.653) here .(0.498) ?(0.291) -(0.285) . .(0.195) there(0.175) know(0.087) ∅ .(0.168) ∅ (-0.093) ?(-0.173)



Table content: <table><tr><td>presents our results on the spelling cor-</td></tr><tr><td>rection task. We observe an improvement in</td></tr><tr><td>CER over log-likelihood training for all four</td></tr><tr><td>settings considered. Without simultaneous log-</td></tr><tr><td>likelihood training, actor-critic training results</td></tr><tr><td>in a better CER than REINFORCE-critic in three</td></tr></table>

Character error rate of different methods on the spelling correction task. In the table L is the length of input strings, η is the probability of replacing a character with a random one. LL stands for the log-likelihood training, AC and RF-C and for the actor-critic and the REINFORCE-critic respectively, AC+LL and RF-C+LL for the combinations of AC and RF-C with LL.

Table content: <table><tr><td>Setup</td><td colspan="4">Character Error Rate LL AC RF-C AC+LL RF-C+LL</td></tr><tr><td colspan="3">L = 10, η = 0.3 17.81 17.24 17.82</td><td>16.65</td><td>16.97</td></tr><tr><td colspan="3">L = 30, η = 0.3 18.4 17.31 18.16</td><td>17.1</td><td>17.47</td></tr><tr><td colspan="3">L = 10, η = 0.5 38.12 35.89 35.84</td><td>34.6</td><td>35</td></tr><tr><td colspan="2">L = 30, η = 0.5 40.87 37.0</td><td>37.6</td><td>36.36</td><td>36.6</td></tr></table>

Our IWSLT 2014 machine translation results with a convolutional encoder compared to the previous work by Ranzato et al. Please see 1 for an explanation of abbreviations. The asterisk identifies results from(Ranzato et al., 2015). The numbers reported with ≤ were approximately read from Figure6of(Ranzato et al., 2015)

Table content: <table><tr><td>Decoding method</td><td>LL*</td><td>MIXER*</td><td>Model LL</td><td>RF</td><td>RF-C</td><td>AC</td></tr><tr><td>greedy search</td><td>17.74</td><td>20.73</td><td colspan="4">19.33 20.92 22.24 21.66</td></tr><tr><td>beam search</td><td>≤ 20.3</td><td>≤ 21.9</td><td colspan="4">21.46 21.35 22.58 22.45</td></tr></table>

Our IWSLT 2014 machine translation results with a bidirectional recurrent encoder compared to the previous work. Please see Table1for an explanation of abbreviations. The asterisk identifies results from(Wiseman & Rush, 2016).

Table content: <table><tr><td>Decoding method</td><td>LL* BSO*</td><td>LL</td><td colspan="2">Model RF-C RF-C+LL</td><td>AC</td><td>AC+LL</td></tr><tr><td>greedy search</td><td colspan="3">22.53 23.83 25.82 27.42</td><td>27.7</td><td>27.27</td><td>27.49</td></tr><tr><td>beam search</td><td colspan="3">23.87 25.48 27.56 27.75</td><td>28.3</td><td>27.75</td><td>28.53</td></tr></table>

Our WMT 14 machine translation results compared to the previous work. Please see Table

Table content: <table/>

respectively.   Ranzato et al., 2015). The performance of REINFORCE with a simple baseline matches the score reported for MIXER inRanzato et al. (2015).

Table content: <table><tr><td>Decoding method</td><td>LL'</td><td colspan="2">LL* MRT *</td><td>Model LL</td><td colspan="2">AC+LL RF-C+LL</td></tr><tr><td>greedy search</td><td>n/a</td><td>n/a</td><td>n/a</td><td>29.33</td><td>30.85</td><td>29.83</td></tr><tr><td>beam search</td><td colspan="2">28.45 29.88</td><td>31.3</td><td>30.71</td><td>31.13</td><td>30.37</td></tr><tr><td colspan="3">points stronger than its equivalent from (</td><td/><td/><td/><td/></tr></table>

Results of an ablation study. We tried varying the actor update speed γ θ , the critic update speed γ φ , the value penalty coefficient λ, whether or not reward shaping is used, whether or not temporal difference (TD) learning is used for the critic. Reported are the best training and validation BLEU score obtained in the course of the first 10 training epochs. Some of the validation scores would still improve with longer training. Greedy search was used for decoding.

Table content: <table><tr><td>γ θ</td><td>γ φ</td><td>λ</td><td colspan="4">reward shaping TD train BLEU valid BLEU</td></tr><tr><td/><td/><td/><td>baseline</td><td/><td/><td/></tr><tr><td colspan="2">0.001 0.001</td><td>10 -3</td><td>yes</td><td>yes</td><td>33.73</td><td>23.16</td></tr><tr><td/><td/><td/><td colspan="2">with different γ φ</td><td/><td/></tr><tr><td colspan="2">0.001 0.01</td><td>10 -3</td><td>yes</td><td>yes</td><td>33.52</td><td>23.03</td></tr><tr><td>0.001</td><td>0.1</td><td>10 -3</td><td>yes</td><td>yes</td><td>32.63</td><td>22.80</td></tr><tr><td>0.001</td><td>1</td><td>10 -3</td><td>yes</td><td>yes</td><td>9.59</td><td>8.14</td></tr><tr><td/><td/><td/><td colspan="2">with different γ θ</td><td/><td/></tr><tr><td>1</td><td>0.001</td><td>10 -3</td><td>yes</td><td>yes</td><td>32.9</td><td>22.88</td></tr><tr><td/><td/><td/><td colspan="2">without reward shaping</td><td/><td/></tr><tr><td colspan="2">0.001 0.001</td><td>10 -3</td><td>no</td><td>yes</td><td>32.74</td><td>22.61</td></tr><tr><td/><td/><td colspan="4">without temporal difference learning</td><td/></tr><tr><td colspan="2">0.001 0.001</td><td>10 -3</td><td>yes</td><td>no</td><td>23.2</td><td>16.36</td></tr><tr><td/><td/><td/><td colspan="2">with different λ</td><td/><td/></tr><tr><td colspan="3">0.001 0.001 3  *  10 -3</td><td>yes</td><td>yes</td><td>32.4</td><td>22.48</td></tr><tr><td colspan="2">0.001 0.001</td><td>10 -4</td><td>yes</td><td>yes</td><td>34.10</td><td>23.15</td></tr><tr><td colspan="2">0.001 0.001</td><td>10 -6</td><td>yes</td><td>yes</td><td>35.00</td><td>23.10</td></tr><tr><td colspan="2">0.001 0.001</td><td>10 -8</td><td>yes</td><td>yes</td><td>33.6</td><td>22.72</td></tr><tr><td colspan="2">0.001 0.001</td><td>0</td><td>yes</td><td>yes</td><td>27.41</td><td>20.55</td></tr></table>

)p(ŷ 2 |ŷ 1 ) . . . p(ŷ T |ŷ 1 . . . ŷT -1 )] R( Ŷ ) =

Table content: <table><tr><td colspan="7">D PROOF OF EQUATION (7)</td></tr><tr><td>dV dθ</td><td colspan="2">=</td><td>d dθ</td><td>E Ŷ ∼p( Ŷ )</td><td colspan="3">R( Ŷ ) = [p(ŷ 1 T Ŷ d dθ t=1 Ŷ p( Ŷ1...t-1 )</td><td>dp(ŷ t | Ŷ1...t-1 ) dθ</td><td>p( Ŷt+1..T | Ŷ1...t )R( Ŷ ) =</td></tr><tr><td colspan="2">T t=1 Ŷ1...t</td><td colspan="5">Word p( Ŷ1...t-1 ) dp(ŷ t | Ŷ1...t-1 ) dθ</td><td>Words with largest Ŷt+1...T p( Ŷt+1..T | Ŷ1...t ) Q</td><td>T τ =1</td><td>r τ (ŷ τ ; Ŷ1...τ-1 ) =</td></tr><tr><td/><td/><td/><td/><td colspan="4">one of them i p( Ŷ1...t-1 ) and(6.623) there(6.200) but(5.967) that(6.197) one(5.668) &amp;apos;s(5.467) that(5.408) one(5.118) i(5.002) dp(ŷ t | Ŷ1...t-1 ) dθ t=1 Ŷ1...t T that(4.796) i(4.629) ,(4.139) want want(5.008) i(4.160) &amp;apos;t(3.361)  T</td><td></td><td>=</td></tr><tr><td/><td/><td/><td/><td colspan="4">to tell  r t (ŷ t ; Ŷ1...t-1 ) + to(4.729) want(3.497) going(3.396) Ŷt+1...T τ =t+1 talk(3.717) you(2.407) to(2.133) p( Ŷt+1..T | Ŷ1...t )</td><td>r τ (ŷ τ ; Ŷ1...τ-1 ) </td></tr><tr><td/><td/><td/><td/><td colspan="2">you about here .</td><td colspan="2">about(1.209) that(0.989) talk(0.924) about(0.706) .(0.660) right(0.653) .(0.498) ?(0.291) -(0.285) .(0.195) there(0.175) know(0.087) T t=1 E Ŷ1...t-1∼p( Ŷ1...t-1) a∈A dp(a| Ŷ1...t-1 ) dθ</td><td>Q(a; Ŷ1...t-1 ) =</td></tr><tr><td/><td/><td/><td/><td>∅</td><td/><td colspan="2">.(0.168) ∅ (-0.093) ?(-0.173) T</td></tr><tr><td/><td/><td/><td/><td/><td/><td/><td>E Ŷ ∼p( Ŷ )</td><td>t=1 a∈A</td></tr></table>

Peer review (iclr2017):
This paper proposes to use an actor-critic RL technique to train sequence to sequence tasks in natural language processing. In particular, experiments are shown in a synthetic denoising task as well as in machine translation. I like the idea of the paper, however, the experimental evaluation is not convincing. Why is the LL numbers in Ranzato et al. 2015 and your paper so different? Is the metric different? is it the scheduler? are the parameters different? If one extrapolates the numbers, it seems that MIXER will be much better than the proposed approach. I*d like to see a head-to-head comparison, either by reproducing the same setting or by running the mixer baseline. The authors should also compare their results to the state-of-the-art. How good is their machine translation system? Only comparing to a single baseline and without reproducing the numbers is not sufficient. While the idea makes sense, the authors needed to use many heuristics to make the model to work, e.g., using a delayed actor, update phi* with interpolation, penalize the variance, reducing the value of rare actions, etc. Furthermore, there is no in depth analysis of how much performance each of these heuristics brings. It seems that the authors need more work to make the model work without so many heuristics. The authors also mentioned several optimization difficulties (some of which are non-intuitive), 1) why does the critic assign very high value to actions with very low probability according to the actor? 2) why is a lower square error on Q resulting in much worst performance? The paper will benefit from a serious re-write. The technical part is not clearly written. The manuscript also assumes that the reader knows algorithms such as REINFORCE. I strongly suggest to include a brief description in the text. This will help the reader understand how to use the critic within this framework. Also the experimental section will benefit from dividing it by experiment. Right now is cumbersome to look at the details of each experiment as things are mixed up in the text. The paper criticizes the REINFORCE algorithm a lot, particularly for its high variance, however the best results in the real setting are achieved with this algorithm (+ the critic). How do you explain this? The text is also not consistent with what the results show. The discussion claims that using the critic on REINFORCE reduces the gap with the actor critic. However, it is better than the proposed approach. I*ll revise my score if the authors address my questions. In summary, an interesting idea, however many heuristics are used and the experimental evaluation is not sufficient.