S OFTMAX Q-D ISTRIBUTION E STIMATION FOR S TRUCTURED P REDICTION : A T HEORETICAL I NTERPRETATION FOR RAML
Anonymous authors
Paper under double-blind review
A BSTRACT
Reward augmented maximum likelihood (RAML), a simple and effective learning framework to directly optimize towards the reward function in structured prediction tasks, has led to a number of impressive empirical successes.
RAML incorporates task-speciﬁc reward by performing maximum-likelihood updates on candidate outputs sampled according to an exponentiated payoff distribution, which gives higher probabilities to candidates that are close to the reference output.
While RAML is notable for its simplicity, efﬁciency and its impressive empirical successes, the theoretical properties of RAML, especially the behavior of the exponentiated payoff distribution, has not been examined thoroughly.
In this work, we introduce softmax Q-distribution estimation, a novel theoretical interpretation of RAML, which reveals the relation between RAML and Bayesian decision theory.
The softmax Q-distribution can be regarded as a smooth approximation of the Bayes decision boundary and the Bayes decision rule is achieved by decoding with this Qdistribution.
We further show that RAML is equivalent to approximately estimating the softmax Q-distribution, with the temperature τ controlling approximation error.
We perform two experiments, one on synthetic data of multi-class classiﬁcation and one on real data of image captioning, to demonstrate the relationship between
RAML and the proposed softmax Q-distribution estimation method, verifying our theoretical analysis.
Additional experiments on three structured prediction tasks with rewards deﬁned on sequential (named entity recognition), tree-based (dependency parsing) and irregular (machine translation)
structures show notable improvements over maximum likelihood baselines.
I NTRODUCTION
Many problems in machine learning involve structured prediction, i.e., predicting a group of outputs that depend on each other.
Recent advances in sequence labeling (Ma & Hovy, 2016), syntactic parsing (McDonald et al., 2005) and machine translation (Bahdanau et al., 2015) beneﬁt from the development of more sophisticated discriminative models for structured outputs, such as the seminal work on conditional random ﬁelds (CRFs) (Lafferty et al., 2001) and large margin methods (Taskar et al., 2004), demonstrating the importance of the joint predictions across multiple output components.
A principal problem in structured prediction is direct optimization towards the task-speciﬁc metrics (i.e., rewards) used in evaluation, such as token-level accuracy for sequence labeling or BLEU score for machine translation.
In contrast to maximum likelihood (ML) estimation which uses likelihood to serve as a reasonable surrogate for the task-speciﬁc metric, a number of techniques (Taskar et al., 2004; Gimpel & Smith, 2010; Volkovs et al., 2011; Shen et al., 2016) have emerged to incorporate task-speciﬁc rewards in optimization.
Among these methods, reward augmented maximum likelihood (RAML)
(Norouzi et al., 2016) has stood out for its simplicity and effectiveness, leading to state-ofthe-art performance on several structured prediction tasks, such as machine translation (Wu et al., 2016) and image captioning (Liu et al., 2016).
Instead of only maximizing the log-likelihood of the ground-truth output as in ML, RAML attempts to maximize the expected log-likelihood of all possible candidate outputs w.r.t.
the exponentiated payoff distribution , which is deﬁned as the normalized exponentiated reward.
By incorporating task-speciﬁc reward into the payoff distribution, RAML combines the computational efﬁciency of ML with the conceptual advantages of reinforcement learning (RL) algorithms that optimize the expected reward (Ranzato et al., 2016; Bahdanau et al., 2017).
Simple as RAML appears to be, its empirical success has piqued interest in analyzing and justifying RAML from both theoretical and empirical perspectives.
In their pioneering work, Norouzi et al.
(2016) showed that both RAML and RL optimize the KL divergence between the exponentiated payoff distribution and model distribution, but in opposite directions.
Moreover, when applied to log-linear model, RAML can also be shown to be equivalent to the softmax-margin training method (Gimpel & Smith, 2010; Gimpel, 2012).
Nachum et al.
(2016) applied the payoff distribution to improve the exploration properties of policy gradient for model-free reinforcement learning.
Despite these efforts, the theoretical properties of RAML, especially the interpretation and behavior of the exponentiated payoff distribution, have largely remained under-studied (§2).
First, RAML attempts to match the model distribution with the heuristically designed exponentiated payoff distribution whose behavior has largely remained under-appreciated, resulting in a non-intuitive asymptotic property.
Second, there is no direct theoretical proof showing that RAML can deliver a prediction function better than ML.
Third, no attempt (to our best knowledge) has been made to further improve
RAML from the algorithmic and practical perspectives.
In this paper, we attempt to resolve the above-mentioned under-studied problems by providing an theoretical interpretation of RAML.
Our contributions are three-fold: (1) Theoretically, we introduce the framework of softmax Q-distribution estimation , through which we are able to interpret the role the payoff distribution plays in RAML (§3).
Speciﬁcally, the softmax Q-distribution serves as a smooth approximation to the Bayes decision boundary.
By comparing the payoff distribution with this softmax Q-distribution, we show that RAML approximately estimates the softmax Q-distribution, therefore approximating the Bayes decision rule.
Hence, our theoretical results provide an explanation of what distribution RAML asymptotically models, and why the prediction function provided by
RAML outperforms the one provided by ML.
(2) Algorithmically, we further propose softmax
Q-distribution maximum likelihood (SQDML) which improves RAML by achieving the exact Bayes decision boundary asymptotically.
(3) Experimentally, through one experiment using synthetic data on multi-class classiﬁcation and one using real data on image captioning, we verify our theoretical analysis, showing that SQDML is consistently as good or better than RAML on the task-speciﬁc metrics we desire to optimize.
Additionally, through three structured prediction tasks in natural language processing (NLP) with rewards deﬁned on sequential (named entity recognition), tree-based (dependency parsing) and complex irregular structures (machine translation), we deepen the empirical analysis of Norouzi et al.
(2016), showing that RAML consistently leads to improved performance over ML on task-speciﬁc metrics, while ML yields better exact match accuracy (§4).
B ACKGROUND 2. N OTATIONS
Throughout we use uppercase letters for random variables (and occasionally for matrices as well), and lowercase letters for realizations of the corresponding random variables.
Let X ∈ X be the input, and
Y ∈ Y be the desired structured output, e.g., in machine translation X and Y are French and English sentences, resp.
We assume that the set of all possible outputs Y is ﬁnite.
For instance, in machine translation all English sentences are up to a maximum length.
r ( y, y ∗ ) denotes the task-speciﬁc reward function (e.g., BLEU score) which evaluates a predicted output y against the ground-truth y ∗ .
Let P denote the true distribution of the data, i.e., ( X, Y ) ∼ P , and D = { ( x i , y i ) } ni =1 be our training samples, where { x i , i = 1 , . . . , n } (resp.
y i ) are usually i.i.d.
samples of X (resp.
Y ).
Let
P =
{ P θ : θ ∈ Θ } denote a parametric statistical model indexed by parameter θ ∈ Θ , where Θ is the parameter space.
Some widely used parametric models are conditional log-linear models (Lafferty et al., 2001) and deep neural networks (Sutskever et al., 2014) (details in Appendix D.2).
Once the parametric statistical model is learned, given an input x , model inference (a.k.a. decoding) is performed by ﬁnding an output y ∗ achieving the highest conditional probability:
[Equation]
where ˆ θ is the set of parameters learned on training data D .
2. M AXIMUM L IKELIHOOD
Maximum likelihood minimizes the negative log-likelihood of the parameters given training data:
[Equation]
where ˜ P ( X ) and ˜ P ( ·| X ) is derived from the empirical distribution of training data D :
[Equation]
and I ( · ) is the indicator function.
From (2), ML attempts to learn a conditional model distribution
P ˆ θ ML ( ·| X = x ) that is as close to the conditional empirical distribution ˜ P ( ·| X = x ) as possible, for each x ∈ X .
Theoretically, under certain regularity conditions (Wasserman, 2013), asymptotically as n → ∞ , P ˆ θ ML ( ·| X = x ) converges to the true distribution P ( ·| X = x ) , since ˜ P ( ·
| X = x ) converges to P ( ·| X = x ) for each x ∈ X .
2. R EWARD A UGMENTED M AXIMUM L IKELIHOOD
As proposed in Norouzi et al.
, RAML incorporates task-speciﬁc rewards by re-weighting the log-likelihood of each possible candidate output proportionally to its exponentiated scaled reward:
[Equation]
(4) where the reward information is encoded by the exponentiated payoff distribution with the temperature τ controlling it smoothness
[Equation]
Norouzi et al.
(2016) showed that (4) can be re-expressed in terms of KL divergence as follows:
[Equation]
where ˜ P is the empirical distribution in (3).
Discussion As discussed in Norouzi et al.
(2016), the globally optimal solution of RAML is achieved when the learned model distribution matches the exponentiated payoff distribution, i.e., P ˆ θ RAML ( ·| X = x ) =
q ( ·| Y =
y ; τ ) for each ( x, y ) ∈ D with some ﬁxed value of τ .
It makes the payoff distribution appear to be the “target” that the model is attempting to learn.
Though both P ˆ θ RAML ( ·| X = x ) and q ( ·| Y =
y ; τ ) are distributions deﬁned over the output space Y , the latter is conditioned on the output Y which appears to serve as ground-truth but is sampled from data distribution P .
This makes the behavior of RAML attempting to match them unintuitive; Speciﬁcally, supposing that in the training data there exist two training instances with the same input but different outputs, i.e., ( x, y ) , ( x, y (cid:48) ) ∈ D .
Then P ˆ θ RAML ( ·| X = x ) has two “targets” q ( ·| Y =
y ; τ ) and q ( ·| Y =
y (cid:48) ; τ ) , making it unclear what distribution P ˆ θ RAML ( ·| X = x ) asymptotically converges to.
Open Problems in RAML Based on the discussion above, we identify two open issues in the theoretical interpretation of RAML: i) What is the (asymptotically) globally optimal solution of RAML, i.e. what distribution P ˆ θ RAML ( ·| X = x ) (asymptotically) converges to; ii)
There is no rigorous theoretical evidence showing that generating from P ˆ θ RAML ( y | x ) yields a better prediction function than generating from P ˆ θ ML ( y | x )
To our best knowledge, no attempt has been made to theoretically address these problems.
The main goal of this work is to theoretically analyze the properties of RAML, in hope that we may eventually better understand it by answering these questions and further improve it by proposing new training framework.
To this end, in the next section we introduce a softmax Q-distribution estimation framework, facilitating our later analysis.
S OFTMAX Q-D ISTRIBUTION E STIMATION
With the end goal of theoretically interpreting RAML in mind, in this section we present the softmax
Q-distribution estimation framework.
We ﬁrst provide background on Bayesian decision theory (§3.1) and softmax approximation of deterministic distributions (§3.2).
Then, we propose the softmax
Q-distribution (§3.3), and establish the framework of estimating the softmax Q-distribution from training data, called softmax Q-distribution maximum likelihood (SQDML, §3.4).
In §3.5, we analyze
SQDML, which is central in linking RAML and softmax Q-distribution estimation.
3. B AYESIAN D ECISION T HEORY
Bayesian decision theory is a fundamental statistical approach to the problem of pattern classiﬁcation, which quantiﬁes the trade-offs between various classiﬁcation decisions using the probabilities and rewards (losses) that accompany such decisions.
Based on the notations setup in §2.1, let H denote all the possible prediction functions from input to output space,
i.e., H =
{ h : X → Y} .
Then, the expected reward of a prediction function h is:
[Equation]
where r ( · , · ) is the reward function accompanied with the structured prediction task.
Bayesian decision theory states that the global maximum of R ( h ) , i.e., the optimal expected prediction reward is achieved when the prediction function is the so-called Bayes decision rule :
[Equation]
where R ( y | x ) =
E P ( Y | X = x ) [ r ( y, Y )] is called the conditional reward .
Thus, the Bayes decision rule states that to maximize the overall reward, compute the conditional reward for each output y ∈ Y and then select the output y for which R ( y | x ) is maximized.
Importantly, when the reward function is the indicator function, i.e., I ( y = y (cid:48) ) , the Bayes decision rule reduces to a speciﬁc instantiation called the Bayes classiﬁer :
[Equation]
where P ( Y | X = x ) is the true conditional distribution of data deﬁned in §2.1.
In §2.2, we see that ML attempts to learn the true distribution P .
Thus, in the optimal case, decoding from the distribution learned with ML, i.e., P ˆ θ ML ( Y | X = x ) , produces the Bayes classiﬁer h c ( x ) , but not the more general Bayes decision rule h ∗ ( x ) .
In the rest of this section, we derive a theoretical proof showing that decoding from the distribution learned with RAML, i.e., P ˆ θ RAML ( Y | X = x ) approximately achieves h ∗ ( x ) , illustrating why RAML yields a prediction function with improved performance towards the optimized reward function r ( · , · ) over ML.
3. S OFTMAX A PPROXIMATION OF D ETERMINISTIC D ISTRIBUTIONS
Aimed at providing a smooth approximation of the Bayes decision boundary determined by the Bayes decision rule in (8), we ﬁrst describe a widely used approximation of deterministic distributions using the softmax function.
Let F = { f k : k ∈ K} denote a class of functions, where f k : X → R , ∀ k ∈ K .
We assume that K is ﬁnite.
Then, we deﬁne the random variable Z = argmax k ∈K f k ( X ) where X ∈ X is our input random variable.
Obviously, Z is deterministic when X is given, i.e.,
[Equation]
for each z ∈ K and x ∈ X .
The softmax function provides a smooth approximation of the point distribution in (10), with a temperature parameter, τ > 0 , serving as a hyper-parameter that controls the smoothness of the approximating distribution around the target one:
[Equation]
It should be noted that at τ → 0 , the distribution Q reduces to the original deterministic distribution
P in (10), and in the limit as τ → ∞ , Q is equivalent to the uniform distribution Unif( K ) .
3. S OFTMAX Q- DISTRIBUTION
We are now ready to propose the softmax Q-distribution , which is central in revealing the relationship between RAML and Bayes decision rule.
We ﬁrst deﬁne random variable
Z
= h ∗ ( X ) =
argmax y ∈Y E P
( Y | X ) [ r ( y, Y )] .
Then, Z is deterministic given X , and according to (11), we deﬁne the softmax Q-distribution to approximate the conditional distribution of Z given X :
[Equation]
for each x ∈ X and z ∈ Y .
Importantly, one can verify that decoding from the softmax Q-distribution provides us with the Bayes decision rule,
[Equation]
with any value of τ > 0 .
3. S OFTMAX Q- DISTRIBUTION M AXIMUM L IKELIHOOD
Because making predictions according to the softmax Q-distribution is equivalent to the Bayes decision rule, we would like to construct a (parametric) statistical model P to directly model the softmax Q-distribution in (12), similarly to how ML models the true data distribution P .
We call this framework softmax Q-distribution maximum likelihood (SQDML) .
This framework is modelagnostic, so any probabilistic model used in ML such as conditional log-linear models and deep neural networks, can be directly applied to modeling the softmax Q-distribution.
Suppose that we use a parametric statistical model P = { P θ : θ ∈ Θ } to model the softmax
Q-distribution.
In order to learn “optimal” parameters θ from training data D = { ( x i , y i ) } ni =1 , an intuitive and well-motivated objective function is the KL-divergence between the empirical conditional distribution of Q ( ·| X ) , denoted as ˜ Q ( ·| X ) , and the model distribution P θ ( ·| X ) :
[Equation]
We can directly set ˜ Q ( X ) =
˜ P ( X ) , which leaves the problem of deﬁning the empirical conditional distribution ˜ Q ( Z | X ) .
Before deﬁning ˜ Q ( Z | X ) , we ﬁrst note that if the deﬁned empirical distribution ˜ Q ( X, Z ) asymptotically converges to the true Q-distribution Q ( X, Z ) , the learned model distribution
P ˆ θ SQDML ( ·| X = x ) converges to Q ( ·| X = x ) .
Therefore, decoding from P ˆ θ SQDML ( ·| X = x ) ideally achieves the Bayes decision rule h ∗ ( x ) .
A straightforward way to deﬁne ˜ Q ( Z | X = x ) is to use the empirical distribution ˜ P
( Y | X = x ) :
[Equation] [Equation]
where ˜ P is the empirical distribution of P deﬁned in (3).
Asymptotically as n → ∞ , ˜ P converges to
P .
Thus, ˜ Q asymptotically converges to Q .
Unfortunately, the empirical distribution ˜ Q (15) is not efﬁcient to compute, since the expectation term is inside the exponential function (See appendix D.2 for approximately learning ˜ θ SQDML in practice).
This leads us to seek an approximation of the softmax Q-distribution and its corresponding empirical distribution.
Here we propose the following Q (cid:48) distribution to approximate the softmax
Q-distribution Q deﬁned in (12):
[Equation] [Equation]
where we move the expectation term outside the exponential function.
Then, the corresponding empirical distribution of Q (cid:48)
( X, Z ) can be written in the following form:
[Equation]
Approximating ˜ Q ( X, Z ) with ˜ Q (cid:48)
( X, Z )
[Equation]
and plugging (17) into the RHS in (14)
[Equation]
we have:
[Equation]
where q ( y | y ∗ ; τ ) is the exponentiated payoff distribution of RAML in (5).
Equation (18) states that RAML is an approximation of our proposed SQDML by approximating ˜
Q with ˜ Q (cid:48) .
Interestingly and mostly in practice, when the input is unique in the training data, i.e., (cid:54) ∃ ( x 1 , y 1 ) , ( x 2 , y 2 ) ∈ D, s.t. x 1 = x 2 ∧ y 1 (cid:54) =
y 2 , we have ˜ Q = ˜ Q (cid:48) , resulting in ˆ θ SQDML =
ˆ θ RAML .
It states that the estimated distribution P ˆ θ SQDML and P ˆ θ RAML are exactly the same when the input x is unique in the training data, since the empirical distributions ˜ Q and ˜ Q (cid:48) estimated from the training data are the same.
3. A NALYSIS AND D ISCUSSION OF SQDML
In §3.4, we provided a theoretical interpretation of RAML by establishing the relationship between
RAML and SQDML.
In this section, we try to answer the questions of RAML raised in §2.3 using this interpretation and further analyze the level of approximation from the softmax Q-distribution Q in (13) to Q (cid:48) in (16) by proving a upper bound of the approximation error.
Let’s ﬁrst use our interpretation to answer the open questions regarding RAML in §2.3.
First, instead of optimizing the KL divergence between the artiﬁcially designed exponentiated payoff distribution and the model distribution, RAML in our formulation approximately matches model distribution
P θ ( ·| X = x ) with the softmax Q-distribution Q ( ·| X = x ; τ ) .
Second, based on our interpretation, asymptotically as n → ∞ , RAML learns a distribution that converges to Q (cid:48) ( · ) in (16), and therefore approximately converges to the softmax Q-distribution.
Third, as mentioned in §3.3, generating from the softmax Q-distribution produces the Bayes decision rule, which theoretically outperforms the prediction function from ML, w.r.t.
the expected reward.
It is necessary to mention that both RAML and SQDML are trying to learn distributions, decoding from which (approximately) delivers the Bayes decision rule.
There are other directions that can also achieve the Bayes decision rule, such as minimum Bayes risk decoding (Kumar & Byrne, 2004), which attempts to estimate the Bayes decision rule directly by computing expectation w.r.t the data distribution learned from training data.
So far our discussion has concentrated on the theoretical interpretation and analysis of RAML, without any concerns for how well Q (cid:48)
( X, Z ) approximates Q ( X, Z ) .
Now, we characterize the approximating error by proving a upper bound of the KL divergence between them:
Theorem 1.
Given the input and output random variable X ∈ X and Y ∈ Y and the data distribution
P ( X, Y ) .
Suppose that the reward function is bounded 0 ≤ r ( y, y ∗ ) ≤ R .
Let Q ( Z | X ; τ ) and
Q (cid:48)
( Z | X ; τ ) be the softmax Q-distribution and its approximation deﬁned in (12) and (16) .
Assume that Q ( X ) = Q (cid:48)
( X ) =
P ( X ) .
Then,
[Equation]
From Theorem 1 (proof in Appendix A.1) we observe that the level of approximation mainly depends on two factors: the upper bound of the reward function ( R ) and the temperature parameter τ .
In practice, R is often less than or equal to 1, when metrics like accuracy or BLEU are applied.
It should be noted that, at one extreme when τ becomes larger, the approximation error tends to be zero.
At the same time, however, the softmax Q-distribution becomes closer to the uniform distribution Unif( Y ) , providing less information for prediction.
Thus, in practice, it is necessary to consider the trade-off between approximation error and predictive power.
What about the other extreme — τ “as close to zero as possible”?
With suitable assumptions about the data distribution P , we can characterize the approximating error by using the same KL divergence:
Theorem 2.
Suppose that the reward function is bounded 0 ≤ r ( y, y ∗ ) ≤ R , and ∀ y (cid:48) (cid:54) =
y , r ( y, y ) − r
( y (cid:48) , y ) ≥ γR where γ ∈ (0 , 1) is a constant.
Suppose additionally that, like a subGaussian, for every x ∈ X , P ( Y | X = x ) satisﬁes the exponential tail bound w.r.t.
r — that is, for each x ∈ X , there exists a unique y ∗ ∈ Y such that for every t ∈ [0 , 1)
[Equation]
) where c is a distribution-dependent constant.
Assume that Q ( X ) = Q (cid:48)
( X ) =
P ( X ) .
Denote b =
[Equation] [Equation]
Then, as τ → 0 ,
[Equation]
Theorem 2 (proof in Appendix A.2) indicates that RAML can also achieve little approximating error when τ is close to zero.
E XPERIMENTS
In this section, we performed two sets of experiments to verity our theoretical analysis of the relation between SQDML and RAML.
As discussed in §3.4, RAML and SQDML deliver the same predictions when the input x is unique in the data.
Thus, in order to compare SQDML against RAML, the ﬁrst set of experiments are designed on two data sets in which x is not unique — synthetic data for cost-sensitive multi-class classiﬁcation, and the MSCOCO benchmark dataset (Chen et al., 2015) for image captioning.
To further conﬁrm the advantages of RAML (and SQDML) over ML, and thus the necessity for better theoretical understanding, we performed the second set of experiments on three structured prediction tasks in NLP.
In these cases SQDML reduces to RAML, as the input is unique in these three data sets.
4. E XPERIMENTS ON SQDML 4.1. C OST - SENSITIVE M ULTI - CLASS C LASSIFICATION
First, we perform experiments on synthetic data for cost-sensitive multi-class classiﬁcation designed to demonstrate that RAML learns a distribution approximately producing the Bayes decision rule, which is asymptotically the prediction function delivered by SQDML.
The synthetic data set is for a 4-class classiﬁcation task, where x ∈ X =
[ − 1 , +1] × [ − 1 , +1] ⊂ R 2 , and y ∈ Y = { 0 , 1 , 2 , 3 } .
We deﬁne four base points, one for each class:
[Equation]

For data generation, the distribution P ( X ) is the uniform distribution on X , and the log form of the conditional distribution P
( Y | X = x ) for each x ∈ X is proportional to the negative distance of each base point:
[Equation]
(22) where d ( · , · ) is the Euclidean distance between two points.
To generate training data, we ﬁrst drawmillion inputs x from P ( X ) .
Then, we independently generate 10 outputs y from P ( Y | X = x ) for
[Figure] [Figure]
each x to build a data set with multiple references.
Thus, the total number of training instances is 10 million.
For validation and test data, we independently generate 0.1 million pairs of ( x, y ) from
P ( X, Y ) , respectively.
The model we used is a feed-forward (dense) neural networks with 2 hidden layers, each of which has 8 units.
Optimization is performed with mini-batch stochastic gradient descent (SGD) with learning rate 0.1 and momentum 0.9.
Each model is trained with 100 epochs and we apply early stopping (Caruana et al., 2001) based on performance on validation sets.
The reward function r ( · , · ) is designed to distinguish the four classes.
For “correct” predictions, the speciﬁc reward values assigned for the four classes are:
[Equation]
For “wrong” predictions, rewards are always zero, i.e. r ( y, y ∗ )
=
when y (cid:54) = y ∗ .
Figure 1 depicts the effect of varying the temperature parameter τ on model performance, ranging from 0.1 to 3.0 with step 0.1.
For each ﬁxed τ , we report the mean performance over 5 repetitions.
Figure 1 shows the averaged rewards obtained as a function of τ on both validation and test datasets
[Table]
of ML, RAML and SQDML, respectively.
From Figure 1 we can see that when τ increases, the performance gap between SQDML and RAML keeps decreasing, indicting that RAML achieves better approximation to SQDML.
This evidence verities the statement in Theorem 1 that the approximating error between RAML and SQDML decreases when τ continues to grow.
The results in Figure 1 raise a question: does larger τ necessarily yield better performance for
RAML?
To further illustrate the effect of τ on model performance of RAML and SQDML, we perform experiments with a wide range of τ — from 1 to 10,000 with step 200.
We also repeat each experiment 5 times.
The results are shown in Figure 2.
We see that the model performance (average reward), however, has not kept growing with increasing τ .
As discussed in §3.5, the softmax
Q-distribution becomes closer to the uniform distribution when τ becomes larger, making it less expressive for prediction.
Thus, when applying RAML in practice, considerations regarding the trade-off between approximating error and predictive power of model are needed.
More details, results and analysis of the conducted experiments are provided in Appendix B.
4.1. I MAGE C APTIONING WITH M ULTIPLE R EFERENCES
Second, to show that optimizing toward our proposed SQDML objective yields better predictions than
RAML on real-world structured prediction tasks, we evaluate on the MSCOCO image captioning dataset.
This dataset contains 123,000 images, each of which is paired with as least ﬁve manually annotated captions.
We follow the ofﬂine evaluation setting in (Karpathy & Li, 2015), and reserve 5,000 images for validation and testing, respectively.
We implemented a simple neural image captioning model using a pre-trained VGGNet as the encoder and a Long Short-Term Memory (LSTM) network as the decoder.
Details of the experimental setup are in Appendix C.
As in §4.1.1, for the sake of comparing SQDML with RAML to verify our theoretical analysis, we use the average reward as the performance measure by simply deﬁning the reward as pairwise sentence level BLEU score between model’s prediction and each reference caption 2 , though the standard benchmark metric commonly used in image captioning (e.g., corpus-level BLEU-4 score) is not simply deﬁned as averaging over the pairwise rewards between prediction and reference captions.
We use stochastic gradient descent to optimize the objectives for SQDML (14) and RAML (4).
However, the denominators of the softmax-Q distribution for SQDML ˜ Q ( Z | X ; τ ) (15) and the payoff distribution for RAML q ( y | y ∗ ; τ ) (5) contain summations over intractable exponential hypotheses space Y .
We therefore propose a simple heuristic approach to approximate the denominator by restricting the exponential space Y using a ﬁxed set S of sampled targets, i.e., Y ≈ S .
Approximating the intractable hypotheses space using sampling is not new in structured prediction, and has been shown effective in optimizing neural structured prediction models (Shen et al., 2016).
Speciﬁcally, the sampled candidate set S is constructed by (i) including each ground-truth reference y ∗ into S ; and (ii) uniformly replacing an n -gram ( n ∈ { 1 , 2 , 3 } ) in one (randomly sampled) reference y ∗ with a randomly sampled n -gram.
We refer to this approach as n -gram replacement .
We provide more details of the training procedure in Appendix C.
Table 1 lists the results.
We evaluate on both the average reward and the benchmark metric (corpuslevel BLEU-4).
We also tested on a vanilla ML baseline, which achieves 10.71 average reward and 26.91 corpus-level BLEU.
Both SQDML and RAML outperform ML according to the two metrics.
Interestingly, comparing SQDML with RAML we did not observe a signiﬁcant improvement of
Ref
A group of people standing around a wine cellar
Ref
A couple of people are standing around a table with wine
Ref
Men and women are gathered around the table
Ref
People standing at a table with a lot of wine glasses and different flavors of wine
Ref
A bunch of people at a table filled with wine glasses
SQDML A group of people standing around a table with wine glasses
Avg.
Reward: 0.3040 Max Reward: 0.
RAML A group of people standing around a table
Avg.
Reward: 0.2557 Max Reward: 0.
ML
A group of people standing around a table
Avg.
Reward: 0.2557 Max Reward: 0.
Ref
A one way sign that is on a pole
Ref
A black and white picture of a traffic signal in a city
Ref
A black and white image of some buildings and a street light
Ref
Intersection with traffic signals in large metropolitan area
Ref
Traffic lights in front of large buildings with a one way sign
SQDML A black and white photo of a street sign on a pole Avg.
Reward: 0.1424 Max Reward: 0.
RAML A black and white photo of a traffic light Avg.
Reward: 0.1409 Max Reward: 0.
ML
[Figure]
average reward.
We hypothesize that this is due to the fact that the reference captions for each image are largely different, making it highly non-trivial for the model to predict a “consensus” caption that agrees with multiple references.
As an example, we randomly sampled 300 images from the validation set and compute the averaged sentence-level BLEU between two references, which is only 10.09.
Nevertheless, through case studies we still found some interesting examples, which demonstrate that SQDML is capable of generating predictions that match with multiple candidates.
Figure 3 gives two examples.
In the two examples, SQDML’s predictions match with multiple references, registering the highest average reward.
On the other hand, RAML gives sub-optimal predictions in terms of average reward since it is an approximation of SQDML.
And ﬁnally for ML, since its objective is solely maximizing the reward w.r.t a single reference, it gives the lowest average reward, while achieving higher maximum reward.
4. E XPERIMENTS ON S TRUCTURED P REDICTION
Norouzi et al.
(2016) already evaluated the effectiveness of RAML on sequence prediction tasks of speech recognition and machine translation using neural sequence-to-sequence models.
In this section, we further conﬁrm the empirical success of RAML (and SQDML) over ML: (i)
We apply RAML on three structured prediction tasks in NLP, including named entity recognition (NER), dependency parsing and machine translation (MT), using both classical feature-based log-linear models (NER and parsing) and state-of-the-art attentional recurrent neural networks (MT).
(ii) Different from Norouzi et al.
(2016) where edit distance is uniformly used as a surrogate training reward and the learning objective in (4) is approximated through sampling, we use task-speciﬁc rewards, deﬁned on sequential (NER), tree-based (parsing) and complex irregular structures (MT).
Speciﬁcally, instead of sampling, we apply efﬁcient dynamic programming algorithms (NER and parsing) to directly compute the analytical solution of (4).
(iii)
We present further analysis comparing RAML with ML, showing that due to different learning objectives, RAML registers better results under task-speciﬁc metrics, while
ML yields better exact-match accuracy.
4.2. S ETUP
In this section we describe experimental setups for three evaluation tasks.
We refer readers to
Appendix D for dataset statistics, modeling details and training procedure.
[Table] [Table]
Named Entity Recognition (NER)
For NER, we experimented on the English data from CoNLL 2003 shared task (Tjong Kim et al., 2003).
There are four predeﬁned types of named entities:
PERSON, LOCATION, ORGANIZATION, and MISC .
The dataset includes 15K training sentences, 3.4K for validation
[Table]
and 3.7K for testing.
We built a linear CRF model ( al
with same features
Finkel al.
Instead of using the ofﬁcial F1 score over complete span predictions, we use token-level accuracy as the training reward, as this metric can be factorized to each word, and hence there exists efﬁcient dynamic programming algorithm to compute the expected log-likelihood objective in (4).
Dependency Parsing For dependency parsing, we evaluate on the English Penn Treebanks (PTB) (Marcus et al., 1993).
We follow the standard splits of PTB, using sections 2-21 for training, section 22 for validation and 23 for testing.
We adopt the Stanford Basic Dependencies (De Marneffe et al., 2006) using the Stanford parser v3.3.0 3 .
We applied the same data preprocessing procedure as in Dyer et al.
We adopt an edge-factorized tree-structure log-linear model with the same features used in Ma &
Zhao (2012).
We use the unlabeled attachment score (UAS) as the training reward, which is also the ofﬁcial evaluation metric of parsing performance.
Similar as NER, the expectation in (4) can be computed deﬁciently using dynamic programming since UAS can be factorized to each edge.
Machine Translation (MT)
We tested on the German-English machine translation task in the
IWSLT 2014 evaluation campaign (Cettolo et al., 2014), a widely-used benchmark for evaluating optimization techniques for neural sequence-to-sequence models.
The dataset contains 153K training sentence pairs.
We follow previous works (Wiseman & Rush, 2016;
Bahdanau et al., 2017; Li et al., 2017) and use an attentional neural encoder-decoder model with LSTM networks.
The size of the
LSTM hidden states is 256.
Similar as in §4.1.2, we use the sentence level BLEU score as the training reward and approximate the learning objective using n -gram replacement ( n ∈ { 1 , 2 , 3 , 4 } ).
We evaluate using standard corpus-level BLEU.
4.2. M AIN R ESULTS
The results of NER and dependency parsing are shown in Table 2 and Table 3, respectively.
We observed that the RAML model obtained the best results at τ = 0 .
2 for NER, and τ = 0 .
3 for dependency parsing.
Beyond τ = 0 .
, RAML models get worse than the ML baseline for both the two tasks, showing that in practice selection of temperature τ is needed.
In addition, the rewards we directly optimized in training (token-level accuracy for NER and UAS for dependency parsing) are more stable w.r.t.
τ than the evaluation metrics (F1 in NER), illustrating that in practice, choosing a training reward that correlates well with the evaluation metric is important.
Table 4 summarizes the results for MT.
We also compare our model with previous works on incorporating task-speciﬁc rewards (i.e., BLEU score) in optimizing neural sequence-to-sequence models (c.f.
Table 5).
Our approach, albeit simple, surprisingly outperforms previous works.
Speciﬁcally,
[Table] [Table]
[Table]
all previous methods require a pre-trained ML baseline to initialize the model, while RAML learns from scratch.
This suggests that RAML is easier and more stable to optimize compared with existing approaches like RL (e.g., Ranzato et al.
and Bahdanau et al.
(2017)), which requires sampling from the moving model distribution and suffers from high variance.
Finally, we remark that RAML performs consistently better than the ML (27.66) across most temperature terms.
4.2. F URTHER C OMPARISON WITH M AXIMUM L IKELIHOOD
Table 6 illustrates the performance of ML and RAML under different metrics of the three tasks.
We observe that RAML outperforms ML on both the directly optimized rewards (token-level accuracy for
NER, UAS for dependency parsing and sentence-level BLEU for MT) and task-speciﬁc evaluation metrics (F1 for NER and corpus-level BLEU for MT).
Interestingly, we ﬁnd a trend that ML gets better results on two out of the three tasks under exact match accuracy, which is the reward that ML attempts to optimize (as discussed in (9)).
This is in line with our theoretical analysis, in that RAML and ML achieve better prediction functions w.r.t.
their corresponding rewards they try to optimize.
C ONCLUSION
In this work, we propose the framework of estimating the softmax Q-distribution from training data.
Based on our theoretical analysis, asymptotically, the prediction function learned by RAML approximately achieves the Bayes decision rule.
Experiments on three structured prediction tasks demonstrate that RAML consistently outperforms ML baselines.
A PPENDIX : S OFTMAX Q-D ISTRIBUTION E STIMATION FOR S TRUCTURED P REDICTION : A T HEORETICAL I NTERPRETATION FOR RAML A S OFTMAX Q- DISTRIBUTION M AXIMUM L IKELIHOOD A. P ROOF OF T HEOREM
Proof.
Since the reward function is bounded 0 ≤ r ( y, y ∗ ) ≤ R, ∀ y, y ∗ ∈ Y , we have:
[Equation] [Equation]
[Equation] [Equation]
Then,
[Equation]
Now we can bound the conditional distribution Q ( z | x ) and Q (cid:48)
( z | x ) :
[Equation] [Equation]
Z
[Equation]
X
[Equation]
) =
[Equation]
and, |Y|
[Equation]
/τ
[Equation]
Thus, ∀ x ∈ X , z ∈ Y ,
[Equation]
To sum up, we have:
[Equation]
A. P ROOF OF T HEOREM
Lemma 3.
For every x ∈ X ,
[Equation]
where b ∆ = γ 2 (1 − γ ) 2 .
Proof.
From the assumption in Theorem 2 of Eq.
(20) in §3.5, we have
[Equation]
Lemma 4.
[Equation]
Proof.
From Eq.
(1), we have
[Equation]
If y (cid:54) =
y ∗ , q ( y | y ∗ ) =
[Equation]
If y = y ∗ ,
[Equation]
y
[Equation]
y
[Equation]
Lemma
[Equation]
Proof.
[Equation]
From Eq.
(3) we have,
[Equation]
z | x ) ≤ 1 + ( |Y| − 1) e − R/τ
If z (cid:54) =
y ∗ ,
Q (cid:48)
( z | x ) = p ( y ∗ | x ) q ( z | y ∗ )+ (cid:88) y (cid:54) =
y ∗ p ( y | x ) q
( z | y ) ≤ q ( z | y ∗ )
+ 1 + ( |Y| − 1) e − R/τ P ( Y (cid:54) =
y ∗ | X = x )
From Lemma 3 and Lemma 4,
Q (cid:48)
( z | x ) ≤ e γR/τ + ( |Y| − 1) e − R/τ
+ e − cb 1 + ( |Y| − 1) e − R/τ
If z = y ∗ ,
Q (cid:48)
( z | x ) = p ( y ∗ | x ) q ( z | y ∗ ) + (cid:88) y (cid:54) =
y ∗ p ( y | x ) q
( z | y ) ≥ p ( y ∗ | x ) q ( z | y ∗ )
From Lemma 3 and Lemma 4,
Q (cid:48)
( z | x ) ≥ 1 − e − cb 1 + ( |Y| − 1) e − γR/τ
Lemma 6.
0 ≤ E[ r ( z, Y ) /τ ] ≤ P ( y ∗ | x ) r
( z, y ∗ )
/τ
+ e − cb R/τ , if z (cid:54) =
y ∗
P ( y ∗ | x ) r ( y ∗ , y ∗ ) /τ ≤ E[ r ( z, Y ) /τ ] ≤ R/τ , if z = y ∗
Proof.
E[ r ( z, Y ) /τ ] = (cid:88)
y ∈Y
P ( y | x ) r ( z, y ) /τ
Since for every y, y (cid:48) ∈ Y , 0 ≤ r ( y, y (cid:48) ) ≤ R , we have 0 ≤ E[ r ( z, Y ) /τ ]
≤ R/τ
If z (cid:54) =
y ∗ ,
E[ r ( z, Y ) /τ ]
=
P ( y ∗ | x ) r ( z, y ∗ ) /τ
+ (cid:88) y
(cid:54)
[Equation]
y
[Equation]
P ( y | x ) r ( z, y ) /τ ≤ P ( y ∗ | x ) r ( z, y ∗ ) /τ + e − cb R/τ
If z = y ∗ ,
E[ r ( z, Y ) /τ ]
=
P ( y ∗ | x ) r ( z, y ∗ ) /τ
+ (cid:88) y
(cid:54)
[Equation]
y
[Equation]
P ( y
[Equation] [Equation]
[Equation] [Equation]
y
[Equation]
) /τ
Lemma 7.
[Equation] [Equation]
if y = y
[Equation]
where α = γ − (1 + γ )
e − cb < γ .
Proof.
Q ( z | x ) =
e
[Equation]
[ r
[Equation] [Equation]
] (cid:80) y (cid:48)
[Equation]
e E[
[Equation]
( y (cid:48)
[Equation]
From Lemma 6, 1 + ( |Y| − 1) e R/τ ≤ Q ( z | x ) ≤ 1 + ( |Y| − 1) e − R/τ
If z (cid:54) =
y ∗ ,
Q ( z | x ) ≤ e E[ r ( z,Y ) /τ ]
e E[ r ( y ∗ ,Y ) /τ ]
+ |Y|− 1 ≤ (cid:0) e E[ r ( y ∗ ,Y ) /τ ]
− E[ r ( z,Y ) /τ ]
+ ( |Y|
[Equation]
If z = y ∗ ,
[Equation]
Now
[Equation]
we can prove Theorem 2 with the above lemmas
[Equation]
Proof of Theorem
Proof
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Figure]
B C OST - SENSITIVE M ULTI - CLASS C LASSIFICATION
To better illustrate the properties of ML, RAML and SQDML, we display the decision boundary of the learned models in Figure 4.
Figure 4a gives the boundary of the Bayes decision rule, and
Figure 4b is the boundary of ML.
We can see that, as expected, ML gives “unbiased” boundary because it does not incorporating any information of the task-speciﬁc reward.
Figure 4c and 4f are the decision boundaries of RAML and SQDML with τ = 0 .
We can see that, even with small τ , SQDML is able to achieve good decision boundary similar to that of the Bayes decision rule, while the boundary of RAML is similar to that of ML.
This might suggest that RAML, as an approximation of SQDML, might “degenerates” to ML due to approximation error.
Figure 4d and 4g provide the boundary of RAML and SQDML that achieve the best performance ( τ = 2 .
4 for RAML and τ = 1 . 1 for SQDML).
RAML is able to produce surprisingly good decisions with proper τ , which is comparable with SQDML.
Figure 4e and 4h are the decision boundaries of RAML and SQDML with large τ = 10000 .
We can see that, consistently matching our analysis, neither RAML or SQDML can learn reasonable prediction function.
The reason is, as we discussed in §3.5, when τ becomes larger, the softmax
Q-distribution becomes closer to the uniform distribution, providing less information of prediction, even though the approximation error tends to be zero.
C I MAGE C APTIONING WITH M ULTIPLE R EFERENCES
Encoder Following (Yang et al., 2016), we adopt the widely-used CNN architecture VGGNet (Simonyan & Zisserman, 2015) as the image encoder.
Speciﬁcally, we use the last fully connected layer fc7 as image representation (4096-dimensional), which is further fed into a decoder to generate captions.
We use a pre-trained VGGNet model 4 , and keep it ﬁxed during the training of decoder.
Decoder We use an LSTM network as the decoder to predicate a sequence of target words: { y 1 , y 2 , . . .
, y T } .
Formally, the decoder uses its internal hidden state s t at each time step to track the generation process, deﬁned as
[Equation]
where y t − 1 is the embedding of the previous word y t − 1 .
We initialize the memory cell of the decoder by passing the ﬁxed-length image representation x through an afﬁne transformation layer.
The probability of the target word y t is then given by
[Equation]
Training by N -gram Replacement As discussed in §4.1.2, we approximate the exponentially large hypotheses space Y using a subset of sampled hypotheses S .
Formally, the training set D consists of pairs of images x and multiple references { y ∗ } , i.e., D = {(cid:104) x, { y ∗ }(cid:105)} .
For RAML, we split a single training instance (cid:104) x, { y ∗ }(cid:105) into multiple ones by pairing x with each y ∗ , i.e., {(cid:104) x, y ∗ (cid:105)} .
And for each instance (cid:104) x, y ∗ (cid:105) we maximize (cid:88)
[Equation]
For SQDML, for each training example (cid:104) x, { y ∗ }(cid:105) we directly maximize the weighted log-likelihood w.r.t.
the softmax-Q distribution
[Equation]
In our experiments, the size of the sampled targets S is 500 for SQDML and 100 for RAML 5 .
For the sake of efﬁciency, at each iteration of stochastic gradient descent, we only use k randomly-selected hypotheses from S to perform gradient update.
k is 50 for SQDML and 10 for RAML.
Conﬁguration We use the sentence-level BLEU with NIST geometric smoothing as the reward.
We replace word types whose frequency is less than ﬁve with a special <unk> token.
The resulting vocabulary size is 10,102.
The dimensionality of word embeddings and LSTM hidden sates isand 512, respectively.
For decoding, we use beam search with a beam size of 5.
We use a batch size of 10 for the ML baseline and a larger size of 100 for SQDML and RAML for the sake of efﬁciency.
D E XPERIMENTS ON S TRUCTURED P REDICTION D. D ATASET S TATISTICS
We present statistics of the datasets we used in Table 7.
[Table]
D. M ODELS FOR S TRUCTURED P REDICTION D.2. L OG - LINEAR M ODEL
A commonly used log-linear model deﬁnes a family of conditional probability P θ ( y | x ) over Y with the following form:
[Equation]
[Equation]
where φ ( y, x ) are the feature functions, θ are parameters of the model and Φ( y, x ; θ ) captures the dependency between the input and output variables.
We deﬁne the partition function : Z ( x ; θ ) =
(cid:80) y
[Equation]
∈Y exp
[Equation]
θ T φ
[Equation]
y (cid:48) , x )) .
Then, the conditional probability in (4) can be written as:
[Equation]
Now, the objective of RAML for one training instance ( x, y ) is:
[Equation]
and the gradient is:
[Equation]
To optimize L ( θ )
[Equation]
we need to efﬁciently compute the objective and its gradient.
In the next two sections
[Equation]
we see that when the feature φ ( y, x ) and the reward r ( y, y ∗ ) follow some certain factorizations, efﬁcient dynamic programming algorithms exist.
D.2. S EQUENCE CRF
In sequence CRF
[Equation]
Φ usually factorizes as sum of potential functions deﬁned on pairs of successive labels:
[Equation]
where ψ i ( y i − 1 , y i , x ; θ ) =
exp( θ T φ i ( y i − 1 , y i , x )) .
When we use the token level label accuracy as reward, the reward function can be factorized as:
[Equation]
where y i is the label of the i th token (word).
Then, the objective and gradient in (5) and (6) can be computed by using the forward-backward algorithm (Wallach, 2004).
D.2. E DGE - FACTORIZED T REE - STRUCTURE M ODEL
In dependency parsing, y represents a generic dependency tree which consists of directed edges between heads and their dependents (modiﬁers).
The edge-factorized model factorizes potential function Φ into the set of edges:
[Equation]
where e is an edge belonging to the tree y .
ψ e ( e ; θ ) =
[Equation]
θ T φ e ( e, x )) .
The reward of UAS can be factorized as:
[Equation]
where y i is the head of the i th word in the sentence x .
Then, we have:
[Equation]
where E is the set of all possible edges for sentence x and Y ( e ) =
{ y ∈ Y : e ∈ y } .
With similar derivation, we have
[Equation]
Both (7) and (8) can be computed by using the inside-outside algorithm (Paskin, 2001; Ma & Zhao, 2012)
D.2. A TTENTIONAL N EURAL M ACHINE T RANSLATION M
ODEL
Model Overview
We apply a neural encoder-decoder model with attention and input feeding (Luong et al., 2015).
Given a source sentence x of N words { x i } Ni =1 , the conditional probability of the target sentence y =
{ y i } Ti =1 , p ( y | x ) , is factorized as p ( y | x ) = (cid:81)
Tt =1 p ( y t | y <t , x ) .
The probability is computed using a bi-directional LSTM encoder and an LSTM decoder:
Encoder Let x i denote the embedding of the i -th source word x i .
We use two unidirectional LSTMs to process x in forward and backward order, and get the sequence of hidden states { (cid:126) h i } Ni =1 and { (cid:126) h i } N i =1 in the two directions:
[Equation]
where f → LSTM and f ← LSTM are standard LSTM update functions as in Hochreiter & Schmidhuber (1997).
The representation of the i -th word, h i , is then given by concatenating (cid:126) h
i and (cid:126) h i .
Decoder An LSTM is used as the decoder to predict a target word y t at each time step t .
Formally, the decoder maintains a hidden state s t to track the translation process, deﬁned as
[Equation]
where [:] denotes vector concatenation, and y t − 1 is the embedding of the previous target word.
We initialize the ﬁrst memory cell of the decoder using the last hidden states of the two encoding LSTMs: cell
= W [ (cid:126) h N : (cid:126) h N ]+ b .
And the ﬁrst hidden state of the decoder is initialized as s 0 =
tanh( cell 0 ) .
The attentional vector ˜ s t is computed as ˜ s t = tanh( W c [ s t : c t ]) ,
[Table] [Table]
where the context vector c t is a weighted sum of the source encodings { h i } via attention (Bahdanau et al., 2015).
The probability of the target word y t is then given by
[Equation]
Conﬁguration We use the same pre-processed dataset as in Wiseman & Rush (2016).
The vocabulary size of the German and English data is 32,008 and 22,821 words, resp.
Similar as Bahdanau et al.
(2017), the dimensionality of word embeddings and LSTM hidden states is 256.
All neural network parameters are uniformly initialized between [ − 0 .
1 , +0 . 1] .
We use Adam optimizer.
We validate the perplexity of the development set after every epoch, and halve the learning rate if the validation performance drops
We use the sentence geometric smoothing reward use size
Approximating the Learning Objective using Importance Sampling
As suggested in Norouzi et al.
(2016), with BLEU as the training reward, the objective function (4) of RAML could be optimized using importance sampling.
To verify this, we conducted experiment using importance sampling.
Since we cannot directly sample from the exponentiated payoff distribution parameterized by BLEU score (i.e., q BLEU ( y | y ∗ , τ ) ), we use the payoff distribution with negative
Hamming distance (i.e., q hm ( y | y ∗ , τ ) ) as the proposal distribution, and sample from q hm ( y | y ∗ , τ ) instead.
Speciﬁcally, at each training iteration, we approximate (4) by (cid:88)
[Equation]
where the ˜ q ( · ) ’s denote the payoff distributions without normalization terms.
BLEU ( · ) and hm ( · ) denote sentence-level BLEU score and negative Hamming distance, respectively.
We use a sample size of 10.
To draw a sample y from q hm ( y | y ∗ , τ ) , we follow Norouzi et al.
and apply stratiﬁed sampling.
We ﬁrst sample a distance d ∈ [0 , 1 , 2 , . . .
, | y ∗ |− 1 , | y ∗ | ] , and then sample a sentence y with Hamming distance d from y ∗ .
Let c ( d, L ) denote the number of y ’s with length L and an Hamming distance of d from the ground-truth y ∗ , q hm ( y | y ∗ , τ ) is then deﬁned as:
[Equation]
Similar as in Norouzi et al.
c ( d, L ) is approximated by considering d substitutions of words from y ∗ :
[Equation]
where V is the vocabulary size.
Table 8 lists the performance of importance sampling with different temperatures.
The best model (under τ = 0 . 8 ) is comparable with the one achieved by n -gram replacement.
However, n -gram replacement is much simpler to implement, and importance sampling requires extra computation of the proposal distribution and associated importance weights, which would be less computationally efﬁcient.
In our experiments, our highly optimized RAML model achieves a training speed of 18, words/sec for importance sampling and 21,000 words/sec for n -gram replacement.
Extra Experiments using Negative Hamming Distance as Training Reward
For the sake of completeness, we also experimented using the negative Hamming distance as the reward function for RAML, as proposed in Norouzi et al.
Results are listed in Table 9.
The best model gets a corpus-level BLEU score of 28.39, which is worse than the best results achieved by optimizing directly towards BLEU scores (c.f. Table 4).
[Equation]