Elamur Research

Variational Attention for Sequence-to-Sequence Models

Paper · 2018 · Hareesh Bahuleyan, Lili Mou, Olga Vechtomova et al.

Summary

A system that turns a sentence into a question has to do two things. It has to use the sentence closely enough to ask a relevant question, and it has to leave room for several questions when the sentence supports them. Bahuleyan and colleagues examine an architectural choice that puts these goals in tension. A variational encoder–decoder gives the generator a sampled representation of the input, so it can produce different outputs on repeated runs. An attention mechanism gives it a more direct route to the input, letting it pick out useful details as it writes. If the direct route supplies everything the generator needs, it can learn to ignore the sampled representation. The authors call this bypassing.

Their proposal keeps the mechanism that selects source information and changes what the decoder receives from it. At each output step, ordinary attention computes a weighted average of the encoder’s representations of the source words. The paper uses that average as the center of a Gaussian distribution and learns how broadly to sample around it. The decoder receives a draw from this distribution. It still has access to a separate, sentence-level draw. The authors compare two ways to regularize the attention distributions, one centered at the origin and the other at the average of the source representations.

On question generation with SQuAD, sampling with variational attention produced more diverse outputs than sampling with deterministic attention. The added diversity came with somewhat lower reference overlap. The source-centered variant scored 4.96 on the sampled BLEU score at the BLEU-4 setting, compared with 5.08 for deterministic attention in the same sampling condition. Human fluency ratings averaged 4.01 for the source-centered variant and 3.99 for deterministic attention, with no statistically significant difference. In the movie-dialogue experiment, the source-centered variant improved both diversity and BLEU-2 over the variational system with deterministic attention. The paper reports a higher BLEU-2 result for the fully deterministic dialogue system.

The experiments show what changes at the level of generated text. Making attention stochastic can broaden the outputs available for a fixed input while preserving much of the quality that made attention useful. The exact balance depends on the task and on how strongly training regularizes attention. Because the method introduces a fresh source of variation inside attention itself, the diversity results also leave an architectural question open. They cannot establish how much of the variation comes from the original sentence-level representation.

Deep dive: Variational Attention for Sequence-to-Sequence Models

Variational attention samples what a decoder sees from its input, producing more varied questions and dialogue replies while retaining fluency. · about 35 minutes to read

The problem and its context

An input can support several outputs

In question generation, an input sentence is given and the system writes a question about it. A sentence may say who acted, when the action took place, where it happened and what followed. A question can focus on any detail that the sentence supports. The input constrains the response without prescribing its wording or its focus. A single reference question records one of those choices. Dialogue has a related structure. An utterance establishes what the reply should respond to, while leaving a range of plausible things to say. The paper studies whether repeated generation can expose some of that range while keeping the result usable.

A sequence-to-sequence encoder–decoder divides the work between two recurrent networks. The encoder reads the source in order and computes numerical representations, called hidden states. These states depend on the input words and the recurrent computation that has processed them. The decoder generates an output sequence one word at a time. Its own hidden state carries information forward from one output step to the next. The encoder and decoder may be used for reconstruction, where the target is the input itself, or for a transformation, where the target is a different sequence.

An ordinary deterministic encoder supplies a fixed representation for a given input. The output layer of the decoder can still assign probabilities to words, but the encoder’s representation does not change between runs. A variational encoder instead describes a distribution over representations. Drawing from it gives the decoder a particular vector to work with. Another draw can lead to different words or a different overall sentence even with the same input. The experiments use that distinction to ask whether the architecture makes room for diversity through its learned representations. Text generation

What the variational approach adds

The starting point is the variational autoencoder, developed by Kingma and Welling. An autoencoder learns by reconstructing its input. The variational version puts a probability distribution over a hidden representation, often called a latent variable because its value is learned and sampled rather than supplied as a label. A recognition network uses the observed sentence to estimate which latent values would represent it. A decoder uses a draw from that estimate to reconstruct the sentence. Training rewards successful reconstruction and charges for departing from a reference distribution known as the prior. Auto-Encoding Variational Bayes

The prior gives the latent space a structure shared across examples. A sentence is associated with a region in that space, so nearby draws can give the decoder related representations. The reconstruction objective supplies the reason to preserve information about particular sentences. Either part of the objective can make the other relevant. A decoder that can reconstruct from sampled representations makes it worthwhile to learn them, and a recognition network that puts those samples in useful regions makes it worthwhile for the decoder to consult them. In prior work described by the authors, Bowman and colleagues trained a recurrent variational autoencoder and generated sentences from its continuous latent space. The present paper adopts training techniques from that work. Generating Sentences from a Continuous Space

For a variational encoder–decoder, the difference between source and target raises a choice about recognition. Previous approaches discussed in the paper condition the latent recognition distribution on both the source and the observed target. During supervised training, those sequences are available together. During prediction, the target is the unknown object the decoder is about to produce. A design that conditions recognition on both sequences therefore cannot obtain the same distribution in the same way at prediction time. The paper follows a source-only alternative, associated with Zhou and Neubig, and computes its recognition distribution from the input. That choice allows samples to be obtained from the input at prediction time as well as during training.

Earlier work had already used variational encoder–decoders for tasks where a range of outputs is useful. The paper discusses dialogue research that uses latent variables to generate a broader range of replies. It also distinguishes a learned distribution over continuous representations from approaches that diversify a list of output sequences during search. Those approaches operate at different points in generation. A search procedure can encourage different sequences among its candidates, while a draw from a learned representation changes the evidence on which the decoder bases its next predictions. The authors describe the possibilities as compatible. A Hierarchical Latent Variable Encoder-Decoder Model for Generating Dialogues · Diverse Beam Search

Why attention can make a sampled representation dispensable

A single sentence vector has to carry any source detail the decoder may later need. Attention supplies a more selective route. At each output step, it weighs the source hidden states according to their relevance to the decoder and gives the decoder a weighted average. The next output step can use a different weighting. A generator can consequently use the same source sentence to obtain information suited to different parts of its output. The paper points to earlier results in machine translation and summarization as reasons to keep this capability. It also discusses translation evidence suggesting that attention can remain useful when other links between the encoder and decoder are removed. Neural Machine Translation by Jointly Learning to Align and Translate · A Neural Attention Model for Abstractive Sentence Summarization

The term deterministic refers here to how the attention vector is computed. The attention weights are non-negative and sum to a full allocation of weight, so they resemble probabilities over positions. Ordinary attention uses all those weights to compute the same average whenever its inputs are the same. It does not draw a position or a vector from that calculation. Different sequence-level draws can still change recurrent states and, through those states, affect deterministic attention. The concern is that the decoder can learn a solution in which it barely uses those draws in the first place.

That solution is attractive under the training objective. If a direct source connection supplies the necessary information, the decoder can predict the target while paying little attention to the latent variable. The recognition distribution can then move towards its prior, reducing the divergence penalty while preserving reconstruction. In this account, the problem lies in how the two routes interact under the objective. Looking at reconstruction alone would give little reason to object to a decoder that had found a reliable way to recover the desired sentence.

The authors illustrate the mechanism first with a simpler connection. A recurrent decoder needs an initial hidden state. One design choice is to copy the encoder’s final state into that initial state. The decoder thereby receives a deterministic representation of the sentence alongside the sampled one. The paper uses this setup as a pilot because the role of the direct connection is easy to identify. Attention raises a similar concern in a stronger form. It can supply a tailored source summary throughout decoding, which is exactly why a straightforward ban on encoder-to-decoder access would come at a cost. The proposal asks whether attention can keep its ability to select source information while contributing to the stochastic behavior of the system.

The method, step by step

From the source sentence to a generated word

The encoder begins by reading the source and producing a hidden state at each position. It also predicts the parameters of a Gaussian distribution for the sentence-level vector. A draw from that distribution gives the decoder an input that can vary between runs on the same sentence. At each output step, the attention mechanism scores the source states and averages them using normalized weights. That average retains its usual role as a summary of the source information relevant to the step.

The new operation comes after the average. The mechanism takes the average as the center of a Gaussian for the attention vector and uses learned transformations to set the spread. It samples a vector from this Gaussian and supplies the draw alongside the embedding of the previous word. During training, the previous word is typically taken from the observed target. At prediction time, it comes from the sequence generated so far. The decoder updates its recurrent state and uses that state to assign probabilities to possible next words.

How variational attention produces an output sequence

The steps in order.

How variational attention produces an output sequenceStep 1: Encode the source into recurrent hidden states1. Encode the source into recurrent hidden statesStep 2: Draw the sentence-level representation2. Draw the sentence-level representationStep 3: Score source positions for the current decoding step3. Score source positions for the current decoding stepStep 4: Average source states using normalized attention weights4. Average source states using normalized attention weightsStep 5: Predict the spread around the attention average5. Predict the spread around the attention averageStep 6: Draw an attention vector for this step6. Draw an attention vector for this stepStep 7: Use the draw and previous word to decode7. Use the draw and previous word to decodeStep 8: Repeat for subsequent output positions8. Repeat for subsequent output positions

The sentence-level draw and the attention draws work at different scales. The sentence-level draw belongs to the source example as a whole. A distinct attention distribution is formed for each decoding step, so the information available to the decoder can vary locally as a sentence unfolds. A change early in generation can also propagate. The selected word and updated hidden state affect later steps, where the process recomputes attention. The mechanism therefore offers a way for a local change in the attention vector to influence the eventual sentence without specifying in advance which aspect of the sentence should vary.

The variational objective before attention

The paper starts with a generative account of reconstruction. A latent value is drawn from a prior, and observed data are generated conditional on that value. Its joint distribution is written as follows.

pθ(Z, Y) = pθ(Z) pθ(Y | Z)

Here Z is the latent random variable, and Y is the observed data variable, such as a sentence. pθ denotes the generative distributions indexed by parameters θ. pθ(Z) is the prior factor, and pθ(Y | Z) is the decoder’s distribution over observations conditional on the latent value. The vertical bar marks conditioning, and multiplication joins the prior and conditional factors. In the usual training setup described by the paper, the prior is specified directly.

For a training sentence, the likelihood depends on the possible values of the hidden vector. The recognition network makes it possible to train using draws from an approximate posterior, a distribution inferred for an observation. The paper writes the resulting evidence lower bound first in terms of a ratio of joint and recognition densities.

log pθ(y⁽ⁿ⁾) ≥ E[z ∼ qφ(z | y⁽ⁿ⁾)] {log [pθ(y⁽ⁿ⁾, z) / qφ(z | y⁽ⁿ⁾)]}

The superscript (n) indexes the observed training example y⁽ⁿ⁾, and z is a possible realized value of Z. The encoder’s recognition density is qφ, with trainable parameters φ. Its conditioning input here is that observed example. The generative density retains parameters θ. The expectation E averages the quantity in braces under the draw convention ∼, which says that z is drawn from the recognition distribution. Inside the expectation, / divides the joint density of the example and draw by the recognition density at that draw. log takes the logarithm. The inequality states that this expected log ratio is a lower bound on the log likelihood at the left.

Factoring the joint density exposes the two parts of the bound that matter for bypassing.

L⁽ⁿ⁾(θ, φ) = E[z ∼ qφ(z | y⁽ⁿ⁾)] {log pθ(y⁽ⁿ⁾ | z)} − KL(qφ(z | y⁽ⁿ⁾) ∥ p(z))

L⁽ⁿ⁾ denotes the lower bound for instance n. The expectation of the log conditional probability measures how well the decoder with parameters θ reconstructs y⁽ⁿ⁾ when z is sampled using recognition parameters φ. KL is Kullback–Leibler divergence, a penalty for the difference between the recognition distribution on the left of ∥ and the prior p(z) on its right. The order of those arguments is part of the definition. E, ∼, log and | retain their meanings from the preceding formula. The minus sign makes departures from the prior a cost when maximizing the bound.

The same terms can be written as a loss to minimize.

J⁽ⁿ⁾ = Jrec(θ, φ, y⁽ⁿ⁾) + KL(qφ(z | y⁽ⁿ⁾) ∥ p(z))

J⁽ⁿ⁾ is the loss for instance n, and Jrec is the reconstruction loss, the negative expected log probability of y⁽ⁿ⁾ under the decoder. θ and φ are still the decoder and recognition parameters. The second term adds the divergence between the recognition density for the latent vector z and its prior p(z). The paper estimates the expectation using Monte Carlo sampling, meaning it approximates the average using actual draws. It uses a standard normal prior for the sentence-level vector. In the paper’s notation, N(0, I) is a Gaussian with a zero mean vector and identity covariance matrix I.

The objective shows how a useful reconstruction can coexist with a weak latent representation. If a decoder has independent access to the source, it can make its conditional predictions insensitive to which z was drawn. Under that behavior, moving recognition closer to the prior can make the divergence smaller without raising the reconstruction loss appreciably. The loss is therefore a reason to consider the information pathways into the decoder alongside the family of distributions used by the recognition network.

From reconstruction to conditional generation

In the encoder–decoder setup, the input x and target y are different sequences. The paper adapts source-only recognition from an earlier variational encoder–decoder. It writes the justification by viewing the target in a training pair as determined from the source.

qφ(z | y) = qφ(z | Y(x)) = qφ(z | x)

Y(x) denotes the target treated as a function of the input x for this argument, and y is that target value. qφ is the recognition distribution with parameters φ, and z is the sampled sentence representation. The equalities express the substitution the authors use to motivate recognition based on the input alone. In operation the encoder computes the parameters from x. The decoder learns from the paired target during training and can use the encoder’s distribution when only x is available. The possibility that a source supports several plausible outputs is reflected in the sampling experiment and in the conditional predictions, even though the paper motivates its recognition choice using the paired target.

Computing the center of attention

Let the decoder currently be at output step j. To score the source state at position i, the paper uses a bilinear comparison, a multiplication that lets a trainable matrix determine which features of the two states interact.

α̃ⱼᵢ = (hⱼ⁽ᵗᵃʳ⁾)ᵀ W hᵢ⁽ˢʳᶜ⁾

α̃ⱼᵢ is the unnormalized attention score for source position i at target step j. hⱼ⁽ᵗᵃʳ⁾ is the decoder state used in scoring, with tar denoting target. hᵢ⁽ˢʳᶜ⁾ is the encoder’s state at position i, with src denoting source. W is the learned scoring matrix, and ᵀ transposes the target state so that the product gives a scalar score. The source and target position indices identify steps in their respective recurrent sequences.

The score is then normalized across all source positions.

αⱼᵢ = exp(α̃ⱼᵢ) / Σᵢ′₌₁⁽|x|⁾ exp(α̃ⱼᵢ′)

αⱼᵢ is the normalized weight for source position i at target step j. exp exponentiates an unnormalized score α̃. Σ adds over the index i′, a separate variable that runs from 1 through the input length |x|. Dividing by the sum yields non-negative weights that add to a full allocation across the source. This normalization is a softmax over source positions. It can give more influence to one state than to another while preserving contributions from several positions.

The normalized weights determine a single attention vector.

aⱼ = Σᵢ₌₁⁽|x|⁾ αⱼᵢ hᵢ⁽ˢʳᶜ⁾

aⱼ is the attention vector for target step j. The sum visits each source position i from 1 to |x|, multiplies its encoder state hᵢ⁽ˢʳᶜ⁾ by its weight αⱼᵢ, and adds the products. In deterministic attention, this vector is passed to the decoder. For the variational version, the paper denotes this deterministic calculation by aⱼᵈᵉᵗ and uses it to construct the distribution from which the attention vector will actually be drawn.

Learning how far attention can move

At each step, the attention recognition network supplies a Gaussian distribution. The identity map sets the center directly to the result of the deterministic calculation.

μₐⱼ ≡ aⱼᵈᵉᵗ

μₐⱼ is the mean of the recognition distribution for attention vector aⱼ. aⱼᵈᵉᵗ is the weighted source average just computed. ≡ indicates that the equality holds by construction. The choice preserves the interpretation of the mean as the information selected by attention. The learned variability is defined around an already meaningful position in the space of source representations.

The same source average goes through a separate sequence of transformations to determine the scale. A neural layer with a hyperbolic tangent activation transforms the vector. A linear transformation follows, and an exponential activation makes each resulting scale positive. The paper writes the recognition distribution in terms of the resulting mean and spread.

qφ⁽ᵃ⁾(aⱼ | x) = N(μₐⱼ, σₐⱼ)

qφ⁽ᵃ⁾ denotes the attention part of recognition, with φ standing for recognition parameters. aⱼ is the attention variable for output step j, x is the source, and N denotes a Gaussian. μₐⱼ specifies its center, while σₐⱼ describes its positive spread as output by the network. The conditioning notation summarizes the paper’s recognition setup. The step-specific mean itself is formed using the recurrent attention calculation. The distribution is computed anew as decoding advances, so the vectors drawn from it can reflect different parts of the source.

During training, a draw has to participate in the reconstruction calculation without cutting off the learning signal to the network that set its parameters. The paper discusses this in terms of reparameterization. The random part can be drawn from a fixed distribution and transformed using the learned parameters to obtain the desired sample. The reconstruction error can then supply gradients along that transformation to the recognition network. For a Gaussian, it is possible to express the draw by scaling fixed-distribution noise and shifting it by the mean. This property also explains a practical distinction between the Gaussian the authors use and the alternative they leave to future work.

Setting the prior for attention

The first attention prior gives every attention vector the same reference distribution.

p(aⱼ) = N(0, I)

p(aⱼ) is the prior for attention at output step j. N specifies a Gaussian, 0 is its zero mean vector, and I is its identity covariance matrix. The identity covariance gives the prior equal unit variance in each coordinate and zero covariance between different coordinates. The divergence penalty encourages the learned attention distribution to resemble this reference. The prior has no explicit sentence-dependent center.

The second prior uses the source hidden states to locate the reference distribution. It takes their unweighted average.

h̄⁽ˢʳᶜ⁾ = (1 / |x|) Σᵢ₌₁⁽|x|⁾ hᵢ⁽ˢʳᶜ⁾

h̄⁽ˢʳᶜ⁾ is the average source state. The sum adds the state hᵢ⁽ˢʳᶜ⁾ at each source position i, and 1 / |x| divides the result by the source length. Each state contributes equally. The computation can be done from the encoder states before the decoder assigns any step-specific attention weights.

p(aⱼ) = N(h̄⁽ˢʳᶜ⁾, I)

p(aⱼ) again denotes the prior for the attention vector at step j. N is the Gaussian family, h̄⁽ˢʳᶜ⁾ gives the mean for the current source, and I retains the same covariance as in the other prior. Though the paper uses the shorthand p(aⱼ), the center depends on the input in this variant. It is shared across target steps for that input. During learning, the divergence term can send a gradient back through the source average itself. The average depends on encoder states and so participates in the computation being trained.

The paper explains the two priors geometrically. A weighted average with non-negative weights that sum to a full allocation belongs to the convex hull of the source states, the region made up of all convex combinations of those states. The deterministic attention vector is in that region, as is the mean of the variational attention distribution. The mean of the source-centered prior is there as well. The Gaussian draw can fall outside the region because its support extends through the ambient space. The origin-centered reference encourages a mean closer to the origin, while the source-centered reference encourages a mean closer to the source average. In both cases the divergence also depends on the spreads of the distributions.

This difference between a center and a draw matters for interpretation. The center has the same weighted-average construction as ordinary attention. A sampled vector can contain an offset that has no equivalent as another allocation of weights across the source states. The proposal thus permits variability in the numerical context the decoder sees, including variability that cannot be described as choosing to attend a little more to one word and a little less to another.

Using the vector in the decoder

The authors use long short-term memory units, or LSTMs, for the recurrent transitions. The paper first gives the decoder update without attention.

hⱼ⁽ᵗᵃʳ⁾ = RNNθ(hⱼ₋₁⁽ᵗᵃʳ⁾, yⱼ₋₁)

hⱼ⁽ᵗᵃʳ⁾ is the new target-side hidden state at step j, and hⱼ₋₁⁽ᵗᵃʳ⁾ is the state at the preceding step. RNNθ is the recurrent transition with parameters θ. In this formula, yⱼ₋₁ is the embedding of the preceding output word. The subscript j−1 refers to its position in the output sequence. A word embedding is the vector supplied to the recurrent computation for a word.

With attention, the previous word and the current attention vector are both supplied to the transition.

hⱼ⁽ᵗᵃʳ⁾ = RNNθ(hⱼ₋₁⁽ᵗᵃʳ⁾, [yⱼ₋₁ ; aⱼ])

RNNθ, hⱼ⁽ᵗᵃʳ⁾, hⱼ₋₁⁽ᵗᵃʳ⁾ and yⱼ₋₁ retain their preceding meanings. aⱼ is the attention vector associated with step j. The brackets and separator indicate concatenation, so the word and attention vectors form one input to the transition. In the proposed system aⱼ is a draw, whereas the deterministic system uses the weighted average. The scoring and transition equations both use the target-step index j. They describe the attention associated with a decoding step and its use by the recurrent transition. Read together, they leave the precise within-step scheduling of the scoring state implicit.

The decoder then converts the hidden state to probabilities for the output word.

p(yⱼ) = softmax(Wout hⱼ⁽ᵗᵃʳ⁾)

yⱼ here denotes the word at position j, and p(yⱼ) represents its predicted distribution. Wout is a learned output weight matrix, hⱼ⁽ᵗᵃʳ⁾ is the decoder state, and softmax normalizes the resulting vocabulary scores. The earlier softmax distributed weight among input positions. This one distributes probability among output words. The distinction matters because sampling variational attention changes what the decoder is given before it computes those word probabilities.

Putting both latent variables into the loss

The paper extends the variational lower bound by treating the sentence-level representation and step-specific attention as latent variables. It writes the stepwise bound first in terms of their joint recognition distribution.

Lⱼ⁽ⁿ⁾(θ, φ) = E[(z, a) ∼ qφ(z, a | x⁽ⁿ⁾)] {log pθ(y⁽ⁿ⁾ | z, a)} − KL(qφ(z, a | x⁽ⁿ⁾) ∥ p(z, a))

Lⱼ⁽ⁿ⁾ is the bound associated with decoder step j for example n. θ and φ are the generative and recognition parameters. x⁽ⁿ⁾ is the source, y⁽ⁿ⁾ is the target as written in the paper’s likelihood term, z is the sentence-level latent vector and a stands for the attention variable at the step. E averages under draws from the joint recognition distribution qφ. pθ is the decoder distribution, log gives log likelihood and p(z, a) is the joint prior. The KL term compares recognition with that prior, using ∥ to separate its arguments.

In the paper’s probabilistic formulation, the recognition distribution splits into a sentence-level factor and an attention factor given the source. The prior also splits into corresponding factors, with the source mean entering the attention factor if that prior is used. The result is a bound with separate divergence terms.

Lⱼ⁽ⁿ⁾(θ, φ) = E[z ∼ qφ⁽ᶻ⁾(z | x⁽ⁿ⁾), a ∼ qφ⁽ᵃ⁾(a | x⁽ⁿ⁾)] {log pθ(y⁽ⁿ⁾ | z, a)} − KL(qφ⁽ᶻ⁾(z | x⁽ⁿ⁾) ∥ p(z)) − KL(qφ⁽ᵃ⁾(a | x⁽ⁿ⁾) ∥ p(a))

qφ⁽ᶻ⁾ and qφ⁽ᵃ⁾ denote the recognition factors for z and a. p(z) and p(a) are their prior factors. The expectation E uses draws from the two recognition factors, and the same decoder likelihood pθ depends on both draws. Each KL compares one factor to its own prior. Lⱼ⁽ⁿ⁾, θ, φ, x⁽ⁿ⁾ and y⁽ⁿ⁾ retain their meanings from the joint form. The split concerns the distributions in the bound. The decoder can use both sampled values together when constructing the output.

Training minimizes the following objective. The displayed sum follows the scope of the brackets in the paper’s objective.

J⁽ⁿ⁾(θ, φ) = Jrec(θ, φ, y⁽ⁿ⁾) + λKL Σⱼ₌₁⁽|y|⁾ [KL(qφ⁽ᶻ⁾(z | x⁽ⁿ⁾) ∥ p(z)) + γₐ KL(qφ⁽ᵃ⁾(aⱼ | x⁽ⁿ⁾) ∥ p(aⱼ))]

J⁽ⁿ⁾ is the total loss for example n. Jrec is its reconstruction loss, which this setup evaluates using the sampled representations. θ and φ are the parameters being trained, and x⁽ⁿ⁾ and y⁽ⁿ⁾ are the paired source and target. The sum Σ runs over target positions j from 1 to the target length |y|. The first divergence inside it concerns the sentence-level draw z and has no step index. The second concerns aⱼ, the attention at the particular step. qφ⁽ᶻ⁾, qφ⁽ᵃ⁾, p(z), p(aⱼ) and ∥ have the meanings they have in the corresponding separate divergences. The weight λKL controls the overall contribution of the divergence penalties, while γₐ controls the attention penalty relative to the sentence-level penalty.

The authors increase the shared weight during training, a technique called KL annealing. Early in training, the system is given more latitude to learn reconstruction. The gradual increase makes matching the priors more important later. They use a logistic schedule for the shared weight and keep the relative attention weight fixed for a given run. They also use word dropout during training, a technique adopted from earlier sentence autoencoding work that reduces the decoder’s access to words in its training history. Both decisions address the practical difficulty of teaching a recurrent decoder to use sampled representations. The choice of relative attention weight is then examined separately through question-generation validation results.

Experiments and results

Question generation from a sentence

The question-generation task uses a sentence from a SQuAD paragraph as input and asks the decoder to produce a question. SQuAD provides questions associated with passages for reading comprehension. This experiment runs in the other direction, supplying source text and generating the question. The authors adopt the training, validation and test split used by Du and colleagues. The source–target relationship makes attention particularly relevant. A question can refer to an event, person, place or quantity whose representation needs to remain available as the question is written. Learning to Ask

The recurrent encoder and decoder each have 100 hidden units, and the sentence-level latent vector is 100d. The word embeddings are 300d and were pretrained on SQuAD. Each side uses a vocabulary limited to its most frequent 40k tokens. Training uses Adam with an initial learning rate of 0.005, multiplicative decay of 0.95 and batch size 100. The paper reports a fixed word dropout rate of 25%. The authors tuned shared hyper-parameters on validation performance in the motivating autoencoder setup and used those settings across the architectures they compared. They report the accompanying implementation in a repository named tf-var-attention. Adam · Distributed Representations of Words and Phrases and their Compositionality

The deterministic encoder–decoder without attention checks how well the basic implementation reproduces earlier question-generation performance. Adding deterministic attention shows what attention contributes before there is ever a sampled representation. The variational encoder–decoder with deterministic attention is the main comparison for the proposed change. Both variational systems can draw a sentence-level vector. The proposed system also draws attention vectors. The paper further evaluates a staged training schedule for deterministic attention and compares the two Gaussian attention priors.

For the variational conditions the authors report maximum a posteriori inference, abbreviated MAP, and sampling. MAP uses a most probable latent value under the recognition distribution, corresponding to the center for the Gaussians at issue. Sampling instead explores representations given the source. In the question-generation sampling condition, the paper draws 10 samples per input and averages the BLEU scores. Which variables are drawn depends on the architecture. A deterministic attention vector is computed for each step even when the sentence-level vector was sampled.

What the quality and diversity metrics count

The paper reports BLEU-1 through BLEU-4 as measures of agreement with reference questions. The suffix indicates the maximum order of word sequences used in the score. Longer sequences require a closer wording match. Accordingly, reference overlap can decline when generation moves from one plausible focus in the source to another. Conversely, recurring phrases can contribute overlap without making a question accurate or answerable. BLEU gives the experiments a comparable measure of reference agreement. The authors use a separate human evaluation to assess fluency.

The diversity metrics look at the generated outputs themselves. Entropy is based on the frequencies of individual words. The paper defines it as follows.

H = −Σw p(w) log p(w)

H is entropy and w is a word type present in the generated text. p(w) is its unigram probability under the frequency distribution estimated from the outputs. Σw adds the contributions of word types, log takes the logarithm, and the minus sign is part of the entropy definition. An output collection whose word probability concentrates on a small set of recurring words can have lower entropy than one that distributes probability more broadly. The other diversity measures, Dist-1 and Dist-2, express the percentage of distinct unigrams and bigrams. Unigrams are individual words and bigrams are adjacent word pairs. Together the measures capture repetition at the level of words and short phrases. N-gram · A Diversity-Promoting Objective Function for Neural Conversation Models

Question generation results

The deterministic baselines establish the value of attention on this task. In the main SQuAD results, the authors’ deterministic encoder–decoder without attention scores 3.61 on BLEU-4 under MAP inference. With deterministic attention it reaches 4.96 in the same condition. The corresponding BLEU-2 scores are 12.42 without attention and 14.33 with it. These comparisons concern overlap with the reference questions and help explain why the paper pursues a modification that can retain attention’s access to source details.

The comparison within the variational systems tells a different part of the story. Under sampling, deterministic attention scores 30.87 on BLEU-1 and 14.71 on BLEU-2. The source-centered variational attention system scores 30.47 and 14.35, while the origin-centered system scores 30.22 and 14.22. The BLEU-4 comparison points in the same direction. The chart marks the two proposed priors, whose main advantage in this experiment appears in the diversity measures.

SQuAD question generation BLEU-4 under posterior sampling

Deterministic attention has the highest reference overlap while both proposed priors outperform staged training.

SQuAD question generation BLEU-4 under posterior samplingVariational encoder–decoder with deterministic attention: 5.08Variational encoder–decoder withdeterministic attention5.08Variational encoder–decoder with staged deterministic attention: 4.25Variational encoder–decoder with stageddeterministic attention4.25Variational attention with origin-centered prior (this paper): 4.87Variational attention withorigin-centered prior (this paper)4.87Variational attention with source-centered prior: 4.96Variational attention withsource-centered prior4.96
The numbers
System or settingBLEU-4
Variational encoder–decoder with deterministic attention5.08
Variational encoder–decoder with staged deterministic attention4.25
Variational attention with origin-centered prior (this paper)4.87
Variational attention with source-centered prior4.96

The MAP rows show a similar ordering. The SQuAD BLEU-4 score is 5.02 for the variational system with deterministic attention, 4.93 for the source-centered attention prior and 4.92 for the origin-centered attention prior. The difference between the diversity and overlap rankings is central to the paper’s interpretation. The authors report that the proposed systems produce greater word entropy and more distinct unigrams and bigrams. They describe the origin-centered prior as producing slightly greater diversity, with the source-centered prior retaining slightly more overlap overall. The evidence supports a tradeoff on this task. A higher diversity result is compatible with a modest loss of reference agreement.

The paper also presents generated questions to show what a diversity measurement can represent in practice. In a source sentence about a British evacuation and resettlement, draws from source-centered variational attention change the type of information requested, moving among quantity, place and time. Draws with deterministic attention repeat one question and then switch to another. In the example about evacuation near a dam, the deterministic-attention system repeats essentially the same question, while variational attention alters the phrases or entities around the evacuation. That example also illustrates the limits of surface variety. Some changes introduce a location or detail that the source does not support. A vocabulary statistic gives credit for variation of this kind alongside variation that produces a better question.

What human readers rated

The human study compares the variational systems with deterministic attention and with source-centered variational attention. For each system, the authors choose 100 of the questions it generated and present them in random order. Six evaluators rate the fluency of the resulting 200 questions on a 5-point scale whose endpoints are 1 for incomprehensible and 5 for flawless. The mean for deterministic attention is 3.99. The mean for source-centered variational attention is 4.01. The difference is not statistically significant.

The paper reports 0.61 as the mean pairwise Spearman correlation between annotators. Spearman correlation measures the extent to which raters order items similarly. The authors interpret this result as moderate to strong agreement. The comparison gives a direct check on whether sampled attention led to less fluent questions in the evaluated subset. Fluency is a property readers can rate separately from whether the question refers to the right source detail. The study therefore complements reference overlap while leaving the examples’ grounding problems unresolved.

Generating replies to movie dialogue

The second experiment generates a reply given a preceding utterance. The authors use the Cornell Movie-Dialogs Corpus, which contains more than 200k conversational exchanges. They report using the question-generation settings except for a vocabulary of 30k words on each side. The comparisons use a fully deterministic encoder–decoder with attention, a variational encoder–decoder with deterministic attention and the variational system with source-centered attention. Dialogue systems · Chameleons in Imagined Conversations

The quality measure for this task is BLEU-2. The paper selects it based on earlier work that found some agreement with human assessments relative to other BLEU variants, and it uses the same diversity measures as in question generation. Dialogue differs from the question task in what an effective output has to recover from its input. A reply can respond appropriately even when there is little correspondence between its words and the preceding utterance. That makes a reference reply a partial record of what might be said and leaves attention with a different relationship to the desired output. How NOT To Evaluate Your Dialogue System

Movie-dialogue BLEU-2 for the variational systems

Source-centered variational attention improves reference overlap in both inference conditions.

Movie-dialogue BLEU-2 for the variational systemsDeterministic attention, MAP: 1.68Deterministic attention, MAP1.68Deterministic attention, sampling: 1.68Deterministic attention, sampling1.68Source-centered variational attention, MAP (this paper): 1.78Source-centered variational attention,MAP (this paper)1.78Source-centered variational attention, sampling: 1.79Source-centered variational attention,sampling1.79
The numbers
System or settingBLEU-2
Deterministic attention, MAP1.68
Deterministic attention, sampling1.68
Source-centered variational attention, MAP (this paper)1.78
Source-centered variational attention, sampling1.79

For the sampled dialogue replies, entropy is 2.113 with deterministic attention and 2.167 with source-centered variational attention. The reported Dist-1 values are 0.311 and 0.324, respectively. Dist-2 is 0.450 and 0.467. The authors describe the diversity gain as smaller than in question generation. They also report that the fully deterministic dialogue system achieves greater BLEU-2 overlap than either variational system. The improvement in the chart is specific to the comparison within the variational encoder–decoders. Taken together with the SQuAD findings, the dialogue experiment shows that adding stochastic attention can increase diversity in both applications, while the direction of the BLEU comparison with deterministic attention depends on the task.

What the ablations show

Giving the decoder a deterministic initialization

The clearest test of bypassing in the paper precedes the attention experiments. The authors train sentence autoencoders on a subset of approximately ∼80k examples from the natural language inference corpus described by Bowman and colleagues. The autoencoder’s target is the input sentence. The comparison is between a decoder that receives the encoder’s final hidden state as its initial state and one without that direct initialization. Both conditions permit draws from a latent space, so the question is how much those draws affect the outputs once a direct representation is available. A Large Annotated Corpus for Learning Natural Language Inference

The paper illustrates the comparison with a sentence about people playing music. Without direct initialization, draws in the example change the people or the activity while retaining recognizable aspects of the source. With direct initialization, the original sentence recurs, with limited variation in the displayed alternatives. The authors compute entropy using 10 draws per sentence over 1k unseen inputs. They report average entropy of 2.52 without hidden-state initialization and 2.01 with it. They characterize the average decrease as 0.5. This comparison shows that making deterministic source information available to the decoder can reduce the variation observed when sampling its latent representation.

The result gives the subsequent attention comparison its rationale. A direct initialization passes a fixed source state at the beginning of decoding. Attention can instead pass a different source summary at each step. The pilot supports the underlying concern that a source route can make sampling less consequential. It does not isolate a contribution from attention itself, because attention is the subject of the experiments that follow. Its value is that the competing route is particularly easy to identify in the initialization comparison.

Delaying the addition of deterministic attention

The authors test whether a change in training order could preserve diversity while leaving attention deterministic. They first train the variational question generator without attention for 6 epochs, then add deterministic attention. The hope is that a decoder initially dependent on the sampled representation will continue to make use of it after gaining direct access to source states.

In the SQuAD results, this staged condition scores 13.21 on BLEU-2 under sampling and 13.02 under MAP. Both Gaussian attention variants score higher under the corresponding inference settings. The paper also reports worse diversity for staged training than for variational attention. Early exposure to a latent representation was insufficient in this experiment. Once attention was added, the final architecture still allowed the decoder to use deterministic, step-specific source information. The experiment evaluates a concrete schedule and leaves open whether a different schedule or training intervention could preserve greater use of the original latent representation.

Changing the prior and regularization strength

Comparing the origin-centered and source-centered priors keeps the main sampling mechanism intact and changes the reference mean used in the attention penalty. For SQuAD BLEU-3 under sampling, the origin-centered system scores 8.28 and the source-centered system scores 8.39. The authors report greater diversity with the origin-centered prior. The comparison therefore supplies evidence that the effect does not require the prior to be centered on the source. It also shows how an input-dependent center can change the balance between overlap and diversity with the rest of the attention construction held fixed.

The attention weight provides a separate control. The authors vary γₐ, which determines the strength of the attention divergence relative to the sentence-level divergence, and inspect question-generation validation curves for BLEU-2, BLEU-4, entropy and Dist-1. Reducing the weight improves reference overlap and tends to reduce the diversity gain. The authors attribute the pattern to a weaker incentive to fit the Gaussian attention prior, which lets the system behave more like a deterministic generator. The weight controls a training penalty, so the effect arises through how the learned distribution responds to that penalty.

For the main question-generation comparison, they use γₐ of 0.1. This setting produces a middle course among the validation curves they compare. At 0.01, the paper reports a validation setting with higher overlap and diversity than the variational system with deterministic attention, although the diversity gain is small. That distinction helps account for the difference between the main SQuAD result and the stronger-sounding validation observation. The former reports the chosen balance, while the latter is evidence that a different point on the tradeoff can improve both measured outcomes in validation.

Following learning over time

The validation learning curves track BLEU-2 and BLEU-4 alongside entropy and Dist-1. The authors describe a conflict as training proceeds. Greater resemblance to the available questions can coincide with more repetitive outputs. The two variational-attention variants maintain relatively high values on both sets of measures along the displayed curves. This analysis shows how the tradeoff develops during training, alongside the end-of-training comparison in the main results.

The curves and illustrative questions also distinguish two senses in which a result might be described as diverse. One is stability across evaluation checkpoints, where corpus-level diversity remains visible as reconstruction improves. The other is what repeated draws do for an individual input. The examples show that the same architecture can sometimes shift a question to a different aspect of a sentence and sometimes merely vary the phrasing of an unsuitable question. The curves establish a recurring pattern in the metrics. The examples give that pattern a more concrete interpretation without establishing how often each kind of variation occurs.

Limitations

Limits identified by the authors

The authors describe the dialogue gain as smaller than the question-generation gain and offer weaker alignment as a possible explanation. Questions in the SQuAD task are generated from sentences expected to contain relevant information. An appropriate conversational reply can depend on the preceding utterance without closely reusing its details. If attention has less work to do in that setting, altering its distribution may have a smaller effect. The paper gives this as a conjecture. The dialogue experiment does not vary alignment independently, so it cannot identify weaker alignment as the measured cause.

The paper also identifies an alternative distribution it does not implement. The proposed Gaussian operates on the attention vector after the source states have been combined. Another design could randomly draw the attention weights themselves. A Dirichlet distribution is a candidate because it gives a distribution over non-negative weights whose total is fixed. Any weighted average obtained in that way would stay within the convex hull of the source states. The authors leave this direction for future study because they regard a suitable reparameterization for training with Dirichlet draws as nontrivial. The experiments therefore compare two Gaussian priors over vectors, without evidence about how a distribution over attention weights would perform.

The authors also treat the strength of attention regularization as a choice that changes the balance between quality and diversity. Their validation sweep gives a reason for the setting used in the main question-generation experiment. It yields no general rule for choosing that weight on a different dataset or for a task with a different kind of acceptable variation. The dialogue experiment transfers the setup and evaluates the resulting behavior. It does not reproduce the full regularization comparison on dialogue.

Limits of what the evidence can establish

The paper’s strongest observation about bypassing is behavioral. Repeated draws change the outputs less when the decoder has a deterministic side connection in the pilot. Changing attention to a sampled vector then increases diversity in the main tasks. The attention draws themselves provide an additional route for changes in output, however. A decoder could respond to them while remaining relatively insensitive to the sentence-level vector. The reported comparisons do not vary one source of randomness while holding the other fixed in the trained variational-attention system. They therefore do not quantify how much information the original latent vector recovers, or even how much it contributes to the observed diversity gain.

The metric design also limits what can be said about quality. Question-generation BLEU is lower with variational attention than with deterministic attention in the main sampled comparison. The human ratings find no significant fluency difference for the selected pair of systems. Both can be true because the measures concern different properties. Readers can find a question fluent even when it asks about an unsupported place or presupposes the wrong event. The human study does not rate answerability, factual support from the source or usefulness for building a reading-comprehension dataset. The illustrations in the paper show why those distinctions affect the interpretation of greater diversity.

The same concern applies to dialogue, where the paper reports BLEU-2 and lexical diversity without a comparable rating study of the replies. Higher BLEU-2 within the variational systems demonstrates additional reference overlap in that experiment, and the diversity values document less uniform output at the level measured. Neither determines whether a reply would be preferred by a person in context. More generally, unigram entropy and distinct word sequences can respond to changes in length, wording or unsupported details. They do not directly count different valid questions, different reply intentions or the breadth with which the output covers a source.

The setup gives evidence for recurrent encoder–decoders on the tasks examined. It does not test variational attention in machine translation or summarization, even though earlier work in those fields motivates keeping attention. The two Gaussian priors are compared directly in question generation. The dialogue experiment uses the source-centered prior, so evidence for the origin-centered alternative comes from SQuAD. The study likewise offers no comparison with combining variational attention and the diverse decoding procedures discussed in related work. Their compatibility is an architectural observation.

Finally, the source-only recognition choice is useful for prediction but coarser than recognition that could see the desired target during training. All acceptable targets for a given input would be approached from the recognition distribution supplied by that input, although their generation can diverge as decoding proceeds. The paper motivates the approach by writing a target as a function of a source, while the tasks themselves allow several sensible targets. The experiments show that this choice can produce observable variety. They do not establish that the recognition distribution covers the full range of suitable outputs or assigns probabilities that reflect how often people would choose them.

What came after

Latent Alignment and Variational Attention cites Bahuleyan and colleagues and places latent alignment at the center of its title. The connection is a question about where to represent uncertainty in attention. Bahuleyan and colleagues form an ordinary weighted source average and then draw a continuous vector around it. An alignment concerns the relation between positions in the source and target. The citing work’s title identifies alignment as its subject, while leaving open how its treatment relates mathematically to the Gaussian over vectors in Bahuleyan and colleagues’ approach.

Disentangled Representation Learning for Non-Parallel Text Style Transfer cites the paper in work on separating learned representations for style transfer without paired texts. Its stated focus shifts the question from how much repeated samples can vary to how a representation can separate aspects of a text for a transformation. Bahuleyan and colleagues study whether an information route can render a sampled representation dispensable. That architectural issue is relevant to a task whose operation depends on using learned representations for different purposes. The citation alone does not establish that the style-transfer system samples Gaussian attention.

Stochastic Wasserstein Autoencoder for Probabilistic Sentence Generation cites the paper in a study of probabilistic generation with a stochastic autoencoder. The title’s emphasis is on the distribution used to generate sentences and the autoencoding framework around it. That connects to the original paper’s starting point, where a draw from a continuous representation is supposed to affect the sentence produced. The attention paper asks what happens to that role when another route carries source information. The Wasserstein autoencoder title identifies a different autoencoding framework, with no basis in the citation alone for attributing either Gaussian attention prior to it.

Diverse Keyphrase Generation with Neural Unlikelihood Training cites the work while pursuing diversity through a training objective for keyphrase generation. The connection is the problem of obtaining useful variety across outputs. Variational attention addresses it by making the source context drawn at a decoding step stochastic. The keyphrase study’s title locates its own intervention in unlikelihood training. That difference shows how the diversity question can persist when the prediction task and the point of intervention change. The citation establishes the relationship between the papers without identifying a reused attention mechanism or a shared experimental result.

Cite

Cite as Hareesh Bahuleyan, Lili Mou, Olga Vechtomova and Pascal Poupart. 2018. Variational Attention for Sequence-to-Sequence Models. Proceedings of the 27th International Conference on Computational Linguistics.

The paper itself, not this page. BibTeX from the library's record of the work.

@inproceedings{bahuleyan2018variational,
  title = {{Variational Attention for Sequence-to-Sequence Models}},
  author = {Hareesh Bahuleyan, Lili Mou, Olga Vechtomova and Pascal Poupart},
  booktitle = {Proceedings of the 27th International Conference on Computational Linguistics},
  year = {2018},
  url = {https://aclanthology.org/C18-1142/}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/bahuleyan-2018-variational-attention-sequence-sequence-models/