Elamur Research

Do sequence-to-sequence VAEs learn global features of sentences?

Paper · 2020 · Tom Bosc and Pascal Vincent

Summary

A system can get better at reconstructing a sentence by remembering how it begins. That improvement tells us little about whether the system has inferred what the sentence is about. Tom Bosc and Pascal Vincent examine this distinction in sequence-to-sequence variational autoencoders, or VAEs. These systems give a decoder a compact, sampled representation of the input, alongside the words the decoder has already seen. The hope was that the representation would carry properties such as topic, sentiment, or style, while the decoder handled the details of putting words together. The authors ask what the representation actually carries when training gives it a limited amount of capacity.

Their first test compares reconstruction errors at each word position with those of an ordinary left-to-right predictor. The largest improvements concentrate near the beginning and end of documents. In a separate reconstruction test, the standard VAE variants often produce the exact opening word and sometimes recover the original length more often than a predictor that already knows the correct topic or sentiment. The results identify a training shortcut. The latent vector can help the decoder by supplying details that are difficult to predict at particular positions, even when those details have limited value for expressing a property of the whole document.

The authors test changes that alter what the encoder can see or what the decoder needs. An order-insensitive encoder pools word embeddings directly. A unigram decoder uses the same word distribution at every position during representation learning. A third approach pools features from a pretrained recurrent predictor whose weights stay fixed. The paper evaluates the resulting representations through classifiers that receive the same kind of noisy sample as the decoder, and through the topic or sentiment of the texts reconstructed from those samples.

The difference is clearest on Amazon and Yahoo, where the opening words give relatively weak clues to the labels. On the Yahoo test set, with the whole labeled training set available to the classifier, macro F1 reaches 42.6 with the order-insensitive encoder, compared with 37.2 for the pretrained last-state baseline. In beam-search reconstruction on Yahoo, that baseline reproduces the opening word in 56.6% of cases, compared with 37.7% for the variant trained with a recurrent encoder and an auxiliary unigram decoder. The order-insensitive variants generally pay a small price in approximate perplexity. The paper gives a way to see what that trade buys: more evidence about topic or sentiment, and less dependence on the wording or length of the source.

Deep dive: Do sequence-to-sequence VAEs learn global features of sentences?

Bosc and Vincent test what sentence VAEs store, why they favor openings and length, and which changes help them retain topic or sentiment. · about 35 minutes to read

The problem and its context

Why give the decoder a latent variable?

A left-to-right language model assigns a probability to each next word using the words that precede it. It can form expectations about a document as it reads. During generation, however, the first decision takes place before any of the document's words are available. Later decisions inherit whatever the system has already generated. A writer who wants a particular tone or topic has no dedicated variable to supply it unless the system has been designed to accept such a condition. Bosc and Vincent take this as a motivation for learning a compact conditioning signal from unannotated text.

A sequence-to-sequence architecture supplies an encoder that reads the source and a decoder that produces an output sequence. Bowman and colleagues adapted that architecture to the variational autoencoder. During training, the encoder reads a document and specifies a distribution over latent vectors. The decoder draws on a vector from that distribution as it tries to reconstruct the document. For generation without a source, the vector comes from a prior distribution. The same sampled vector can influence the opening, the continuation, and the decision to finish. The architecture builds on work on sequence-to-sequence learning and variational inference. Sequence to Sequence Learning with Neural Networks · Auto-Encoding Variational Bayes · Stochastic Backpropagation and Approximate Inference in Deep Generative Models

The latent vector was intended to give the decoder access to information that extends across the text. In that division of labor, the recurrent decoder would account for dependencies among nearby words, and the vector would supply information of a broader kind. A vector that represented the underlying sentiment of a review, for example, could support a positive reconstruction even if the decoder chose different words. A vector that primarily represented the review's opening phrase would offer a kind of control already available by supplying a prefix. The distinction matters for text generation because reproducing the wording and preserving a broad property can pull training in different directions. Generating Sentences from a Continuous Space

The paper discusses several uses that motivate this division. If a system could infer formality or tone without labeled training examples, a developer could in principle use that signal in machine translation or in a dialogue system. A latent variable could also give the decoder a source of variation when several translations or replies are plausible. In such cases, the useful variation depends on what changing the vector actually changes. A capacity to alter wording is easy to demonstrate with different prefixes. A capacity to maintain a chosen property across differently worded outputs requires separate evidence.

Keeping the channel open is only part of the problem

The recurrent decoder has a direct source of information during training. When it predicts a word, it receives the true earlier words of that document. Some predictions can therefore be made well without consulting the latent vector. Meanwhile, the training objective charges the encoder for making its per-document distribution differ from the prior. If the decoder becomes good at predicting from the prefix alone, the easiest way to reduce that charge is to make the encoder's distribution approach the prior. This is posterior collapse. Samples then carry little or no usable information about which document was encoded.

Earlier work used interventions such as changing the weight of the divergence penalty over the course of training, pretraining a deterministic autoencoder, or pooling information across recurrent encoder states. Bosc and Vincent use a version of free bits, which lets the encoder move away from the prior up to a threshold without an increasing penalty. That intervention addresses the incentive to abandon the latent vector. It leaves the encoder and decoder free to decide which details make the best use of the available capacity.

The authors distinguish two questions that follow. The first is whether the vector carries any input information that reaches the decoder. The second is whether that information supports the intended division of labor. The distinction is especially important when capacity is small. An opening word can be an efficient use of that capacity because the decoder has almost no text to go on at the start. Knowing the length can also make decisions about the final tokens easier. Neither choice requires the encoder to infer a topic or a sentiment that persists across alternative phrasings.

The earlier saliency study by Kim and colleagues had already drawn attention to the beginning and the end-of-sentence token. Saliency in that work concerns how strongly a prediction or representation responds to inputs, as assessed through gradients. Bosc and Vincent approach the question through prediction loss. Their comparison asks where an actual sequence predictor gains the most when it has access to a sampled vector. They then ask whether those gains correspond to details that the decoder reproduces at generation time.

Increasing capacity might appear to resolve the competition among details. The authors give reasons to study the small-capacity case directly. They cite earlier evidence that higher rates can degrade fit and that samples can become less coherent as the target rate rises. They also point out that much of the literature reports low rates, with the base of the logarithm frequently left unspecified. A study of the information chosen under that constraint addresses the regime in which the method was commonly used.

The method, step by step

From a document to a distribution

The starting point is a recurrent encoder and a recurrent decoder. Here a document can be a single sentence or several sentences. The encoder turns each word into a learned vector and reads those vectors in order. An LSTM, or long short-term memory network, updates a hidden state as it reads. The final hidden state serves as a document representation in the standard last-state encoder. The variants change how that representation is formed or what the decoder is asked to do with it.

Training a sequence-to-sequence variational autoencoder

The steps in order.

Training a sequence-to-sequence variational autoencoderStep 1: Map document tokens to learned embeddings1. Map document tokens to learned embeddingsStep 2: Encode and pool a document representation2. Encode and pool a document representationStep 3: Predict posterior means and variances3. Predict posterior means and variancesStep 4: Sample a latent vector for the document4. Sample a latent vector for the documentStep 5: Predict each target from its true prefix5. Predict each target from its true prefixStep 6: Combine reconstruction loss and free bits penalty6. Combine reconstruction loss and free bits penaltyStep 7: Update the trainable parameters7. Update the trainable parameters
(h₁, …, hₗ) = LSTM(e₁, …, eₗ)

Here the final subscript in each sequence stands for the document length, denoted by capital L in the paper. Each eᵢ is the embedding of the word at position i, and hᵢ is the encoder state after reading that position. LSTM denotes the sequence of recurrent updates. The ellipses stand for the intermediate embeddings and states. Each state is influenced by the prefix the encoder has read.

r = h_L

Here r is the vector representing the complete document, and h_L is the last encoder state. L is the length of the input sequence. This choice lets the representation depend on order and gives the final recurrent state responsibility for retaining whatever information the rest of the system may need.

μ = L₁r

Here μ is the vector of means of the approximate posterior. L₁ is the first learned linear transformation, and r is the document representation. The subscript identifies the transformation. The means specify where the encoder centers its distribution for the document.

σ² = exp(L₂r)

Here σ² is the vector of variances, L₂ is the second learned linear transformation, and r is the same document representation. exp applies the exponential separately to each output of the transformation, producing positive variances. The mean and variance vectors both have length d, the dimension of the latent space.

q_φ(z | x) = 𝒩(z | μ, diag(σ²))

Here x is the input document, z is a possible latent vector, and q_φ is the approximate posterior produced by encoder parameters φ. The vertical bar denotes conditioning. 𝒩 is a multivariate normal distribution centered at μ. The function diag places the entries of σ² on the diagonal of its covariance matrix. Conditional on the document, the sampling noise acts separately in those coordinates. The decoder receives a draw from this distribution. The distinction between that draw and the mean becomes important in the classification experiments.

From the sample back to text

The recurrent decoder receives the same latent sample at every step. Its first input includes a beginning-of-sentence marker. It then processes embedded words from the prefix, each joined to the latent vector. The loss also accounts for predicting the end-of-sentence marker, which the authors append to every document. Using the true prefix during training is called teacher forcing. It makes it possible to ask how well the system predicts a word once the actual earlier words are known.

(h′₁, …, h′_L) = LSTM([e_BOS ; z], [e₁ ; z], …)

Here the primed h′ vectors are decoder states, indexed in decoding order through L in the displayed sequence. LSTM is the decoder recurrence. e_BOS embeds the special beginning-of-sentence token, and e₁ embeds the first document word. Square brackets with a semicolon indicate concatenation of an embedding and the sampled vector z. The ellipses indicate the remaining states and inputs. Each state used for prediction is computed from the beginning marker and the prefix available at that step.

p_θ(xᵢ₊₁ | x₁,…,ᵢ, z) = softmax(Wh′ᵢ + b)

Here p_θ is the decoder probability distribution, with trainable parameters θ. The target xᵢ₊₁ is the next token, and x₁,…,ᵢ denotes the prefix through position i. The decoder state h′ᵢ summarizes the inputs available for that prediction, including z. A learned matrix W and bias vector b turn the state into scores for the vocabulary. softmax converts the scores to probabilities.

softmax(v)ᵢ = exp(vᵢ) / Σⱼ exp(vⱼ)

Here v is the vector of vocabulary scores and vᵢ is the score for candidate i. The numerator exponentiates that candidate's score. The denominator sums the exponentials across candidates indexed by j. The resulting value is the probability assigned to candidate i. Taking the negative logarithm of the probability assigned to the actual target gives its contribution to reconstruction loss. Summing those contributions over the sequence gives the document's reconstruction cost.

During reconstruction at evaluation time, the encoder still reads the source, but the decoder has to build a prefix from its own choices. A difference at the start can therefore lead to further differences even when the vector stays fixed. The loss analysis under teacher forcing and the generated reconstructions give complementary views. One holds the prefix correct to isolate prediction at a given position. The other reveals what happens after predictions become part of the decoder's input.

The objective and the capacity constraint

The VAE learns from documents without using their topic or sentiment labels. Its objective balances accurate reconstruction against keeping the document-conditioned distributions reasonably close to the prior. The prior is available when a document has yet to be generated and there is no input for the encoder. The marginal likelihood is the probability of a document when latent vectors are integrated out. The evidence lower bound, abbreviated ELBO, gives the authors an objective they can optimize instead of the marginal log-likelihood directly.

ELBO(x, φ, θ) = −D_KL(q_φ(z | x) ∥ p(z)) + E_qφ[log p_θ(x | z)] ≤ log p(x)

Here x is the document, φ contains encoder parameters, and θ contains decoder parameters. D_KL denotes Kullback–Leibler divergence, with ∥ separating the approximate posterior q_φ from the prior p(z). The expectation E_qφ averages the decoder's conditional log-probability over draws of z from the approximate posterior. log p(x) is the marginal log-likelihood, and ≤ expresses the lower-bound relationship. The divergence subtracts from the bound. Greater probability for the observed words increases it.

arg max over φ, θ  Σⱼ₌₁ᴺ ELBO(x⁽ʲ⁾, φ, θ)

Here arg max selects the encoder and decoder parameters that maximize the expression. N is the number of training documents and x⁽ʲ⁾ is the document indexed by j. The sum adds their ELBO values. The authors call the average divergence across examples the rate. It tracks how far the document-conditioned distributions move from the prior on average. A rate close to collapse leaves samples from different documents hard to distinguish.

max(D_KL(q_φ(z | x) ∥ p(z)), λ) − E_qφ[log p_θ(x | z)]

This is the loss the authors minimize with their free bits modification. λ is the desired rate, and max selects the larger of that threshold and the divergence for the document. The other term is the expected negative log-probability of the reconstruction. Below the threshold, reducing divergence further leaves the penalty unchanged. Above the threshold, an increase in divergence has to earn its place through better reconstruction. The threshold changes the penalty. The achieved rate is measured after training.

The original free bits formulation considered in the paper allocates a separate allowance to each latent coordinate. The authors compare it with the version above, which treats the coordinates jointly.

Σⱼ max(λ / K, KL(qⱼ(zⱼ | x) ∥ pⱼ(zⱼ)))

Here K is the number of coordinates in this formulation and j indexes them. zⱼ is coordinate j of the latent vector. qⱼ and pⱼ are its posterior and prior distributions, conditional on x for the posterior. KL is the divergence for that coordinate. The sum adds the coordinate penalties after comparing each with its allowance λ / K. In the joint version, a coordinate can make use of capacity that other coordinates leave unused. The main experiments use the joint, δ-VAE-style penalty without KL annealing. Annealing would change the strength of the divergence term during training.

The authors search over target rates of 2 and 8 nats and vector sizes of 4 and 16. Rate and dimension are separate choices. The vector size sets the number of coordinates, and the free bits threshold affects how much divergence can be incurred without an extra cost. The authors compare these rates with the entropy of the labels to check their scale. A rate of 2 nats exceeds the reported label entropy for AGNews, Amazon, and Yelp. Yahoo has label entropy of 2.30 nats. The authors choose 8 nats to leave room beyond label information on every dataset. These are capacity considerations. Reconstruction training still has to discover whatever signals it uses.

Baselines and variants

The unconditional LSTM-LM predicts text from the prefix and supplies the reference curve for positional loss. It has the same recurrent size as the VAE decoders, with input dimensions adjusted for the decoder's additional latent input. The deterministic autoencoder, called AE, provides a reference at the other end of the comparison. It learns solely through reconstruction, and the dimension of its latent representation provides the constraint in place of a target rate.

The stronger VAE baselines include two changes from earlier work. In last-PreAE, the encoder starts with weights learned in a deterministic autoencoder. The decoder is reset, and the encoder and new decoder are then trained together on the VAE objective. The document representation still comes from the last encoder state. The max baseline replaces the last state with a component-wise maximum over the recurrent states. Max-PreAE combines recurrent max pooling with deterministic autoencoder pretraining.

rⱼ = maxᵢ hᵢⱼ

Here rⱼ is coordinate j of the document representation, hᵢⱼ is coordinate j of the recurrent state at position i, and maxᵢ selects the highest value across positions. Different coordinates may come from different positions. Pooling across states gives the encoder a way to retain features from anywhere in the sequence. Each candidate state, however, is already a product of ordered computation.

The first proposed variant applies max pooling directly to embeddings. It is called BoW-max-LSTM, with BoW standing for bag of words. The order-insensitive operation takes place at the encoder. The recurrent decoder still generates words in sequence. The authors choose maximum pooling following earlier comparisons that favor it over averaging for this family of encoders.

rⱼ = maxᵢ eᵢⱼ

Here eᵢⱼ is coordinate j of the embedding at position i, and rⱼ is the pooled value in that coordinate. The maximum ranges over all input positions. Rearranging the same words preserves this representation. The encoder can still respond to a word that frequently appears first, because its embedding is present. It has no position index with which to identify that word as the opening.

The second variant changes the decoder used to train the representation. The unigram decoder, shortened to Uni, predicts the words using a common distribution conditioned on z. It uses a multilayer perceptron, or MLP, with one hidden layer. The word occupying the first position and a word in the middle both receive their probabilities from the same distribution.

p_θ(xᵢ | z) = softmax(W₂ ReLU(W₁z) + b)

Here xᵢ is the observed word at position i, and p_θ is the conditional probability from the decoder with parameters θ. W₁ transforms the latent sample z into hidden-layer inputs, ReLU acts on those inputs, W₂ maps the result to vocabulary scores, and b is a bias vector. softmax normalizes the scores. The position index specifies which observed word is scored. The distribution on the right stays fixed across positions in that document.

ReLU(u) = max(u, 0)

Here u is a hidden-layer input and 0 is the value used in place of a negative input. With a vector, the function acts coordinate by coordinate. The unigram objective can reward a vector that makes the document's vocabulary more probable. It cannot give an extra reward for identifying which particular word occupies the opening slot. The authors use unigram decoders with both recurrent and bag-of-words encoders. The bag-of-words combination corresponds to the earlier NVDM architecture discussed in the paper.

For reconstruction experiments, the authors turn Uni into a training procedure called PreUni. In the first phase they train the encoder and the unigram decoder jointly. After that phase, they keep the encoder and its mean and variance transformations fixed, discard the unigram decoder, and train a fresh recurrent decoder with reconstruction loss alone. The trained representation is therefore carried over to ordered generation. Earlier work on dialogue combined an auxiliary unigram loss with a recurrent loss during training. The staged procedure used here gives each decoder its own phase and avoids a weight for balancing their losses. The authors also relate this setup to earlier auxiliary decoders for image generation. Learning Discourse-level Diversity for Neural Dialog Models using Conditional Variational Autoencoders

PreLM, the third approach, trains an LSTM first on next-word prediction using the same training corpus. Once trained, the LSTM becomes a frozen feature extractor. The document representation averages its hidden states, and training learns the transformations that turn this average into a posterior. The authors initially tried maximum pooling for this approach and report that it made training extremely unstable. They keep the recurrent architecture comparable to the other variants so that the comparison focuses on the training procedure. The paper relates this use of fixed features to earlier work on contextualized representations. Deep Contextualized Word Representations

r = (1 / L) Σᵢ₌₁ᴸ hᵢ

Here L is the number of input positions and hᵢ is the frozen predictor's hidden state at position i. The sum adds those vectors, and the factor 1 / L averages them to form r. The pretrained states were learned for predicting subsequent words, so they may carry evidence from both nearby words and longer contexts. Training on reconstruction can learn which pooled features to use through the posterior transformations. It cannot rewrite the recurrent features themselves.

Training and evaluation procedure

The paper identifies a public PyTorch implementation in the exps-s2svae repository. The recurrent hidden state size is 512 and the training batch size is 64. The authors train with stochastic gradient descent at a learning rate of 0.5 and clip gradients when their norm exceeds 5. When validation error has failed to improve for two consecutive epochs, they halve the learning rate. Training ends after four such reductions. The embeddings start randomly and are learned. Dropout with probability 0.5 applies to the recurrent decoder embeddings and hidden states, and dropout also applies before the final score projection of the unigram decoder. The encoders use no dropout. PyTorch

To locate reconstruction gains, the authors group documents by length and compare average token loss at corresponding positions. Length grouping makes a position near the end comparable across documents in the group. They inspect the absolute loss and the improvement relative to the unconditional recurrent predictor.

r̃(i) = max(r_LSTM(i) − r(i), 0) / r_LSTM(i)

Here i is a token position. r_LSTM(i) is the average loss of the unconditional predictor there, and r(i) is the corresponding average reconstruction loss of the system under study. These uses of r denote losses instead of the document vector. r̃(i) is the fraction of baseline loss removed. The maximum with 0 sets negative improvements to zero. The absolute curves remain necessary for identifying positions where the VAE does worse.

For the classification test, the authors train the encoders without labels and then use them to produce inputs for supervised text classification. Their classifiers receive sampled vectors. For each labeled regime of 5, 50, 500, or 5000 examples per class, they draw 5 balanced subsamples. Each representation system is trained with 3 initialization seeds. The classifiers use logistic regression with L2 regularization, which discourages large weights. The regularization search considers 0.01, 0.1, 1, 10, and 100. Repeated stratified cross-validation supplies validation scores within the labeled subsample. Stratification preserves class proportions in the folds. The full-label regime uses a one-hidden-layer classifier and early stopping on the separate validation set.

H_C* = arg max over H_C  F̂ᵢⱼ(H_M, H_C)

Here H_C is a candidate classifier setting and H_C* is the setting with the highest internal validation score F̂ᵢⱼ. The index i identifies the labeled subsample and j identifies the initialization. H_M denotes the candidate VAE settings, including rate and latent size. The hat indicates a cross-validation score.

H_M* = arg max over H_M  (1 / s) Σⱼ₌₁ˢ F̂ᵢⱼ(H_M, H_C*)

Here H_M* denotes the selected VAE settings. s is the number of initialization seeds. The sum averages the validation scores over those seeds for a given labeled subsample i, using the selected classifier setting for each candidate comparison. The optimization thus considers whether an architecture setting works across initializations.

Fᵢⱼ = Fᵢⱼ(H_M*, H_C*)

Here the left-hand Fᵢⱼ is the final held-out macro F1 for the particular subsample and initialization. The right-hand expression evaluates the chosen VAE and classifier settings on the test set. Macro F1 gives each label equal weight by averaging the label-wise F1 scores, which reflect precision and recall. A bar with a dot in one index position denotes averaging across that index. The reported mean F̄·· averages across both subsamples and initializations.

Fᵢⱼ = μ + αⱼ + εᵢⱼ

Here μ is the overall expected classifier score, a separate use of the symbol from the posterior mean. αⱼ is the random effect associated with initialization j. The residual εᵢⱼ covers the remaining variation across observations indexed by subsample and initialization.

Var(Fᵢⱼ) = Var(αⱼ) + Var(εᵢⱼ)

Here Var denotes variance. The equality follows in the paper's one-factor analysis from treating the initialization effect and the residual as independent and centered. The statistics reported alongside the scores summarize between-initialization variation and remaining variation.

σ_init = √[(1 / (s − 1)) Σⱼ₌₁ˢ g(F̄·ⱼ − F̄··)²]

Here σ_init is the square root of the between-initialization mean square. s counts initializations and g counts subsamples per initialization. F̄·ⱼ is the mean over subsamples for initialization j, while F̄·· is the overall mean. Squaring their differences makes deviations in either direction contribute to the statistic.

σ = √[(1 / g)(1 / (s − 1)) Σᵢ₌₁ᵍ Σⱼ₌₁ˢ (Fᵢⱼ − F̄·ⱼ)²]

Here σ is the square root of the residual mean square. The inner difference measures the deviation of a test score Fᵢⱼ from its initialization's average F̄·ⱼ. The sums aggregate those deviations after squaring, using the counts g and s in the denominator. This residual summarizes variability left after accounting for differences in initialization means.

The reconstruction test uses a separate classifier trained on the original labeled corpus. The VAE encodes a source, a recurrent decoder reconstructs it, and the classifier assigns a label to the generated text. Agreement is the F1 between original annotations and those predicted labels. The authors also check whether the output has the source's first word and whether its length matches. Those checks use exact equality. Agreement asks whether the labeled property survives even when the wording changes. Approximate perplexity per word, estimated by an importance-weighted bound with 500 samples, checks the fit to observed text. Importance Weighted Autoencoders

Experiments and results

The documents and what their openings reveal

The experiments use smaller versions of four English document collections. AGNews and Yahoo supply topic labels. Amazon and Yelp supply sentiment labels. Documents may span more than one sentence, and the authors describe the label frequencies as close to balanced. The train, validation, and test sizes, in thousands of documents, are 110/10/10 for AGNews and 100/10/10 for each of the other collections. AGNews has 4 topics, Yahoo has 10 topics, Amazon has 5 sentiment labels, and Yelp has 2 sentiment labels. The source collections come from prior work on text classification. Character-level Convolutional Networks for Text Classification

The collections make different demands on an encoder. The paper notes that a news item may begin with a country, company, or athlete whose name gives a clue to its category. A question can instead begin with a generic inquiry that recurs across unrelated topics, with the distinguishing word arriving later. A representation that retains only the opening has a better chance of succeeding on the first kind of document. The experiments use this variation to interpret why the same training change has a large effect on one corpus and a modest effect on another.

The authors also report mean negative log-likelihood for the unconditional LSTM baseline. The values are 128.77 for AGNews, 82.90 for Amazon, 81.91 for Yahoo, and 34.60 for Yelp. These are document-level losses, whereas the approximate perplexity in the reconstruction comparison is reported per word. The paper uses the losses to give a sense of the information needed to predict a whole document and to explain why exact reconstruction is a demanding expectation at its chosen rates.

Where the reconstruction loss falls

The main positional plot uses Yahoo documents of 15 words. The error bars show the minimum and maximum across 3 runs. As the target rate increases, the reconstruction loss falls. The additional gains cluster towards the beginning and the end, with the middle receiving less benefit. The deterministic autoencoder and the variational systems all improve on the unconditional LSTM at the first few positions and around the penultimate token. The authors report losses around 50% lower than the baseline at favored positions with a target rate of 8.

The other corpora show related patterns. On Yelp, the paper explains that punctuation immediately precedes the end marker, so an advantage at the penultimate token can signal knowledge of where the document finishes. At a target rate of 2, the Yelp absolute reconstruction curves show worse performance than the baseline between positions 6 and 13. The clipped relative-improvement curve cannot display how much worse those positions are. Reading the two plots together helps distinguish little benefit from a genuine increase in prediction loss.

To check whether the early loss gains matter for generated text, the authors compare last-PreAE with a predictor that knows the true label. The predictor chooses the most frequent opening word or length for that label. On held-out AGNews documents, last-PreAE reproduces the first word in 29.6% of reconstructions, and the label-only predictor gets 12.9%. On Amazon the corresponding first-word figures are 42.4% and 14.0%. On Yahoo they are 56.6% and 11.3%, and on Yelp they are 53.0% and 14.1%. These comparisons use last-PreAE at a target rate of 8 and latent size of 16, with beam size 5.

The results for length vary more. On AGNews, last-PreAE gives an exact length match for 3.6% of documents and the label-only predictor reaches 4.8%. On Yelp, the corresponding figures are 33.7% and 9.7%. These measures concern the complete output of the decoder. The positional curves show where a correct prefix leaves a useful role for the vector. The exact-match comparison shows what the decoder can reproduce once it has to produce the whole text by itself.

Can a classifier read topic or sentiment from a sample?

The classification comparison tests the availability of label information in the latent sample. In a small labeled regime, a simple classifier has little evidence with which to learn how the coordinates relate to labels. A high score there suggests that the signal is accessible from few examples. The full-label regime gives the classifier more training data and more expressive decision rules. It can find label information that the smaller classifier may struggle to use. The reported scores in both cases come from the full held-out test sets.

With all labeled Yahoo training examples available, both the bag-of-words recurrent variant and PreLM outperform the pretrained recurrent baselines. The separation accompanies a lower starting point for the baselines than on AGNews or Yelp. The unpretrained recurrent variants fare especially poorly on this corpus. Their full-label Yahoo test macro F1 is 14.9 for the last-state recurrent encoder and 15.7 for the recurrent max-pooling encoder, compared with 37.2 and 36.6 for the corresponding PreAE versions. These comparisons show why pretraining is part of the stronger baseline.

Yahoo test macro F1 with all labeled training documents

Pooling word embeddings or using frozen recurrent features yields more predictive latent samples than the pretrained recurrent baselines.

Yahoo test macro F1 with all labeled training documentsLast-state LSTM with PreAE: 37.2Last-state LSTM with PreAE37.2Max-pooled LSTM with PreAE: 36.6Max-pooled LSTM with PreAE36.6Bag-of-words encoder with recurrent decoder (this paper): 42.6Bag-of-words encoder with recurrentdecoder (this paper)42.6Max-pooled LSTM with unigram decoder: 38.9Max-pooled LSTM with unigram decoder38.9Bag-of-words encoder with unigram decoder: 40.1Bag-of-words encoder with unigramdecoder40.1Frozen predictor with average pooling: 41.7Frozen predictor with average pooling41.7
The numbers
System or settingmacro F1
Last-state LSTM with PreAE37.2
Max-pooled LSTM with PreAE36.6
Bag-of-words encoder with recurrent decoder (this paper)42.6
Max-pooled LSTM with unigram decoder38.9
Bag-of-words encoder with unigram decoder40.1
Frozen predictor with average pooling41.7

Amazon shows a similar advantage for the strongest variants with the full labeled training set. On the Amazon test set, macro F1 is 28.1 for last-PreAE and 34.0 for max-PreAE. BoW-max-LSTM reaches 38.9 and PreLM reaches 40.0. The advantage is visible below the full-label regime, too. With 50 labeled examples per class on Amazon, PreLM gets test macro F1 of 35.3, while last-PreAE gets 24.7 and max-PreAE gets 30.5. Those sub-sampled classifiers use the cross-validation procedure instead of the full-label MLP.

The full-label scores on AGNews leave much less separation. Test macro F1 is 83.4 for last-PreAE and 83.3 for max-PreAE, compared with 83.1 for BoW-max-LSTM and 83.5 for PreLM. One recurrent unigram variant departs sharply from that pattern. LSTM-last-Uni receives 59.3 with the full AGNews labeled training set, and the authors report instability for this combination. Changing the decoder's task is therefore insufficient to ensure a strong representation across encoder choices.

With 5 examples per class, the results are more sensitive to the choice of training examples and initialization. On the AGNews test set, BoW-max-LSTM reaches 72.7 macro F1, compared with 65.8 for last-PreAE and 55.7 for max-PreAE. The between-initialization statistic for max-PreAE in that regime is 18.7. On the Yelp test set, the bag-of-words recurrent variant has a mean of 67.1 at the same label budget, compared with 59.3 for last-PreAE and 59.9 for max-PreAE. Its between-initialization statistic there is 15.7. The means favor the bag-of-words encoder in these comparisons, while the variation shows why the authors repeat the sub-sampling and training.

What carries through to generated text?

The reconstruction evaluation fixes the target rate at 8 and the latent dimension at 16 for every system and uses three seeds. For the primary comparison, beam search runs with a width of 5. Beam search keeps several partial continuations under consideration; greedy decoding picks the most probable next token at each step. The paper reports a similar overall pattern with greedy decoding, though some scores shift. The two PreUni systems in the comparison use a recurrent decoder trained after the unigram stage. The last-state Uni combination is dropped from this evaluation after its weak classification results.

Amazon beam-search reconstruction sentiment agreement

The proposed variants preserve the source sentiment label more often by the classifier-based measure, with the frozen language predictor scoring highest.

Amazon beam-search reconstruction sentiment agreementLast-state LSTM with PreAE: 24.5Last-state LSTM with PreAE24.5Max-pooled LSTM with PreAE: 30.8Max-pooled LSTM with PreAE30.8Bag-of-words encoder with recurrent decoder: 34.2Bag-of-words encoder with recurrentdecoder34.2Bag-of-words encoder with PreUni: 33.3Bag-of-words encoder with PreUni33.3Max-pooled LSTM with PreUni: 34.1Max-pooled LSTM with PreUni34.1Frozen predictor with average pooling (this paper): 35.8Frozen predictor with average pooling(this paper)35.8
The numbers
System or settingF1
Last-state LSTM with PreAE24.5
Max-pooled LSTM with PreAE30.8
Bag-of-words encoder with recurrent decoder34.2
Bag-of-words encoder with PreUni33.3
Max-pooled LSTM with PreUni34.1
Frozen predictor with average pooling (this paper)35.8

Agreement on Yahoo follows the same broad direction as classification, although the scores remain low. The last-state and max-pooled pretrained recurrent baselines obtain agreement F1 of 23.8 and 22.9. The bag-of-words recurrent variant reaches 26.9. The recurrent encoder trained with PreUni reaches 27.1. The absolute figures differ from the full-label classifier scores because a reconstruction goes through a decoder and then through a classifier trained on original texts. That test asks whether the generated document expresses the property, after both stages have had an opportunity to lose it.

Yahoo beam-search reconstructions that match the source first word

Training with an auxiliary unigram decoder produces the lowest opening-word match rates among the compared settings.

Yahoo beam-search reconstructions that match the source first wordLast-state LSTM with PreAE: 56.6Last-state LSTM with PreAE56.6Max-pooled LSTM with PreAE: 58.7Max-pooled LSTM with PreAE58.7Bag-of-words encoder with recurrent decoder: 49.3Bag-of-words encoder with recurrentdecoder49.3Bag-of-words encoder with PreUni (this paper): 37.6Bag-of-words encoder with PreUni (thispaper)37.6Max-pooled LSTM with PreUni: 37.7Max-pooled LSTM with PreUni37.7Frozen predictor with average pooling: 51.9Frozen predictor with average pooling51.9
The numbers
System or settingfirst-word matches %
Last-state LSTM with PreAE56.6
Max-pooled LSTM with PreAE58.7
Bag-of-words encoder with recurrent decoder49.3
Bag-of-words encoder with PreUni (this paper)37.6
Max-pooled LSTM with PreUni37.7
Frozen predictor with average pooling51.9

In this chart, lower exact matching indicates less copying under the paper's diagnostic. Read alongside agreement, the result helps distinguish retaining a property from repeating its original wording. The same effect is visible on AGNews. Under beam search, the last-state baseline has agreement F1 of 80.2 and an opening-word match rate of 29.6%. The recurrent PreUni variant has agreement F1 of 82.0 and an opening match rate of 13.9%. On Yelp, last-PreAE reaches 81.7 agreement F1 and matches the opening in 53.0% of its reconstructions. Recurrent PreUni gives 80.9 agreement F1 and a first-word match rate of 32.0%. Near parity on agreement can therefore coexist with quite different dependence on the source wording.

Length preservation also falls in several important comparisons. On beam-search Yelp reconstructions, the last-state baseline has a length match rate of 33.7%. The variant with a bag-of-words encoder and an auxiliary unigram decoder gets 15.4%, and the recurrent PreUni variant gets 17.2%. On Yahoo, last-PreAE matches the length in 17.1% of reconstructions, while recurrent PreUni gets 11.0%. Across the corpora, the relationship between length matching and agreement depends on the dataset and system. A large reduction in exact length matching can occur with little change in agreement, as it does for these Yelp systems.

Approximate perplexity indicates a cost to some improvements. On Amazon, the last-state and max-pooled PreAE baselines have approximate per-word perplexities of 44.5 and 44.4, respectively. Both bag-of-words variants report 45.3, and recurrent PreUni reports 45.4. PreLM is at 44.2. On Yahoo, the max-pooled PreAE system reaches 48.6, the recurrent PreUni system reaches 50.0, and PreLM reaches 48.5. These results make the tradeoff architecture-dependent. The bag-of-words changes and auxiliary decoders generally give up some fit, while the frozen predictor can recover more predictive representations at perplexities close to the strongest recurrent baselines.

What the ablations show

Where the label signal sits in the document

The authors train separate bag-of-words classifiers on the original data using either all words or only the first three. This comparison removes the latent vector and asks how much evidence about the actual labels is present in the openings. For AGNews, the test macro F1 scores are 89.0 with all words and 71.9 with the opening words. The paper reports that the opening-only score reaches 80.8% of the all-word score. Yelp shows the same general pattern, with 96.5 and 82.4 test macro F1 and a reported proportion of 85.4%.

Amazon and Yahoo are much more sensitive to the omission. The Amazon comparison goes from 48.9 test macro F1 with all words to 29.7 with the opening, or 60.7% of the all-word score as reported. Yahoo scores 63.0 with all words and 19.1 with the opening, giving the reported proportion of 30.3%. A reader assessing the VAE from AGNews and Yelp alone would see high scores from representations that recover the opening frequently. Amazon and Yahoo help expose the cost of relying on the opening when the label depends on evidence elsewhere.

The text feature test also clarifies why the classification and generation results are worth reporting together. A topic classifier may assign the correct class to an output because a recognizable name was copied from the source. Agreement still counts that as a correct label. When opening-word matches fall and agreement holds steady, the pair of measurements gives evidence that the decoder has another way to express the label. The test does not identify the particular words that the agreement classifier used on any individual reconstruction.

What the sample reveals that the posterior mean can hide

The authors induce near-collapse in the standard architecture on Yelp by training with the original objective and a target rate of 0. They run it with and without deterministic autoencoder pretraining, then train classifiers with 5000 labeled examples per class. For each representation, the downstream task is held constant while the classifier input changes between a draw from the posterior and the posterior mean.

Without pretraining, test macro F1 is 49.5 with the sampled vector and 64.7 with the mean. With pretraining, it is 49.6 with the sample and 81.5 with the mean. The mean can retain small systematic shifts that a separate classifier learns to use. When the posterior variance remains close to that of the prior, those shifts can be swamped in individual draws. The downstream contrast is particularly large after deterministic pretraining, which the authors suggest leaves readable structure in the mean.

This test explains the paper's choice of classifier input. If a goal is to extract a point representation for a downstream classifier, the mean has a legitimate role. In the generative VAE studied here, the decoder actually receives a noisy draw. Inspecting that draw makes the classification test address the information transmitted along the decoder's own path. Reading the means in isolation would give a much more favorable impression of label access on Yelp under near-collapse.

What recurrent pooling can preserve

A maximum taken over a collection of vectors seems insensitive to where a vector occurred. With recurrent states, however, the candidates already reflect the order in which the inputs arrived. The authors inspect which position supplies each coordinate's maximum. In the max-PreAE system with target rate 8 and latent size 16, they find 70 of 512 coordinates on Yelp that select the same position on 80% of documents. The paper attributes 68 of those coordinates to the first word and 2 to the second. On Amazon it reports 78 position-consistent coordinates, with 57 at the first word and 21 at the second.

The pattern supplies a concrete explanation for why pooling hidden states can preserve information about particular positions. A coordinate that frequently peaks at the beginning can reliably pass through a feature of the first word. Pooling raw embeddings removes the recurrent stage that makes such a position preference possible. Even with raw embeddings, a feature correlated with an opening word can influence the maximum. The authors mention that capitalization might allow this in some collections, while leaving that possibility untested. They also suggest recurrent counting as a possible explanation for the fixed-position maxima. The maxima establish the preference for positions, and the explanation in terms of counting is a hypothesis. LSTM Networks Can Perform Dynamic Counting

The decoder comparison shows that an ordered encoder can still work well when its training task changes. On Yahoo, the bag-of-words and recurrent PreUni variants agree with the source labels at F1 of 26.8 and 27.1, respectively. The same systems have similarly low first-word recovery in the Yahoo chart. Their encoders have access to different information about word order, but the auxiliary decoder gives both the same incentive to predict useful vocabulary without tying it to a position. The authors interpret the close scores as evidence for the importance of the decoder's training objective under these conditions.

Which parts of pretraining matter?

The authors compare original per-coordinate free bits with the joint δ formulation, each with and without KL annealing, on Yelp. They fix the latent dimension at 16. At a target rate of 2, annealing over 10 epochs with the original formulation results in an achieved rate of 5.27, and the joint formulation without annealing reaches 2.27. At target 8, the corresponding achieved rates are 10.67 and 8.12. These are rates measured after training. A comparison at a fixed nominal threshold could otherwise mix an architectural effect with the effect of actual capacity.

The Yelp classification results favor the joint formulation without annealing in this comparison. At target rate 2, full-label Yelp test macro F1 is 78.6 with the joint formulation and no annealing, compared with 73.6 for the original formulation with annealing. At target rate 8, the corresponding scores are 83.5 and 81.2. This establishes why the authors use the joint threshold without annealing as a common setting for the other experiments. The control concerns which formulation keeps the achieved rate near the requested value while giving strong classification performance in this setup.

Resetting the decoder after deterministic pretraining is tested separately on Yelp with joint free bits and no annealing. At target rate 2 and with 50 labels per class, resetting raises test macro F1 from 61.3 to 74.0. The achieved rates are 2.36 with the old decoder and 2.27 with the reset. At target rate 8, the corresponding test F1 scores are 73.4 and 80.0, and the achieved rates are 8.23 and 8.12. The classifier improves when the decoder is reset even though the resulting rate is slightly lower. The control establishes the practical importance of the reset in the reported baseline. It leaves open which dynamics of joint training cause the improvement.

What changes in individual outputs

The qualitative analysis compares selected reconstructions at one initialization and one latent draw per source and system. Each draw is decoded with beam search and greedily. In a sports example from AGNews, the last-state baseline preserves the opening player's name while generating a different story. The recurrent PreUni output shifts to a different opening and stays around England's qualifying match. The example makes the topic-versus-wording distinction concrete. It also shows how much factual content can change while the category remains recognizable.

In short Yelp reviews, the recurrent PreUni system can express similar praise or disappointment with a different opening. The order-insensitive PreUni variant sometimes misses the negative wording, turning a negative judgment about whether something is worthwhile into praise. The authors suggest that ordered processing helps with negation. The Amazon examples show related differences in sentiment and also failures shared across systems. In Yahoo, an opening question pattern can survive even when the subject drifts. The examples support the aggregate interpretation while showing that even the better-performing variants can lose the most important detail of a particular source.

Limitations

Limits the authors identify

The paper does not settle why recurrent VAEs favor the opening. The authors propose an optimization explanation: early words are initially hard to predict, their errors may contribute heavily to the gradients, and the resulting training signal may encourage the encoder to retain them. The architecture comparisons show that changing the decoder's training task reduces opening-word recovery. They do not trace the preference through gradients over training or establish that left-to-right prediction on its own is the cause.

The authors also qualify the inference from per-position loss. Teacher forcing means the true prefix is already supplied, so information that merely duplicates the earlier words has no inherent value for predicting the next one. Information about a later word can still help predict an earlier word when the two are correlated. The authors argue that this effect is typically strongest for nearby words, making the loss curve an approximate locator of useful information. A peak is evidence about where conditioning helps. It is an indirect observation of what any coordinate encodes.

The chosen rates constrain the reconstruction task severely. The authors use the unconditional predictor's document loss as a rough upper bound on source entropy and explain that the target rate of 8 leaves exact reproduction out of reach for many documents. Their qualitative analysis selects generic examples to illustrate the behavior in relatively favorable cases. Those examples can reveal failure types and show that a paraphrase is possible. Their selection and small set of latent draws prevent estimating how frequently such a paraphrase occurs.

The paper reports limited agreement on Yahoo even for its stronger variants. The authors suggest that a question's topic may depend on a small number of distinguishing words, some of which are outside the vocabulary. Under reconstruction training, a generic question pattern may offer a more dependable reduction in loss than those sparse cues. The examples are consistent with that explanation, while the experiments establish the low agreement and the weak predictive value of openings more directly.

The authors also acknowledge a fit tradeoff. Encoding stronger label information under their bag-of-words assumptions frequently comes with higher approximate perplexity. They investigate the particular combination of small rates and comparable LSTM sizes used in the paper. Testing PreAE initialization for the bag-of-words and unigram variants is left for future work. The paper leaves other approaches to targeting the rate outside its comparison.

Limits apparent from the design

The term global has a specific operational meaning in the experiments. A representation is more global when a downstream classifier can use it to predict topic or sentiment, and when a decoder can generate text that a separate classifier assigns the source label. A label may itself depend on a single striking adjective or a name. The tests allow that clue to count. They cannot establish whether the vector contains a coherent account of the entire discourse or represents several properties as independently controllable factors.

The agreement classifier is trained on original documents and applied to generated ones. A generated phrase can be enough for the classifier to assign the correct label even if the output contains a factual error or expresses a mixed view. A reasonable reconstruction can also be misclassified. The experiment therefore gives an automatic estimate of agreement conditional on the classifier. It supplies no direct human ratings of fluency, semantic fidelity, or how reliably the outputs express nuanced sentiment.

Opening-word and length matches probe two visible kinds of copying. Lower match rates support the interpretation of reduced dependence on those details. They do not characterize the full variety of text that can be generated. The reported reconstructions come from encoded sources and particular decoding algorithms. The tests do not separately measure diversity across many draws from the prior, demonstrate that a user can pick a target style through a latent coordinate, or establish that paraphrasing preserves the propositions in the source.

The baselines and controls limit the mechanism that can be inferred. Removing recurrent processing from the encoder both removes positional cues and changes the kind of features available to the system. Using PreUni changes the training objective and introduces a separate decoder-training phase. Freezing pretrained features changes which parameters can adapt under the VAE objective. The ablations help locate the influence of these choices in this setting. They leave room for interactions with encoder capacity, decoder factorization, and the distribution of clues in the corpus.

Finally, all four corpora are English collections with readily available topic or sentiment labels. The comparison spans useful variation in where those labels are signaled, while its evidence remains tied to these tasks and the tested recurrent architectures. The paper motivates translation, dialogue, and other forms of controllable generation through examples of what latent variables could do. Its observed outcomes concern document classification and reconstruction.

What came after

A subsequent empirical follow-up to Bosc and Vincent's study is undocumented here. The paper closes by identifying open directions that follow from its findings. One concerns the order in which a decoder predicts words. The authors point to earlier non-autoregressive translation and insertion-based generation research as ways to investigate whether a more flexible prediction order can reduce the exceptional reconstruction value of the opening. That comparison would bear on the conjecture that the left-to-right decoder's task creates the preference. The cited work supplies possible architectures for the comparison. Non-Autoregressive Neural Machine Translation · Insertion-based Decoding with Automatically Inferred Generation Order

The other direction concerns where uncertainty is introduced. In the experiments, the encoder sees intact text and adds uncertainty through the distribution from which the decoder's vector is drawn. BERT-style training corrupts the input and places the prediction objective on the corrupted targets. The authors propose combining aspects of the two approaches. Their discussion frames this as a way to change which details are directly available and which must be inferred, a question their own comparison addresses by changing the encoder's view of order or the decoder's access to position. BERT

Cite

Cite as Tom Bosc and Pascal Vincent. 2020. Do sequence-to-sequence VAEs learn global features of sentences?. Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP).

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/2020.emnlp-main.350

@inproceedings{bosc2020do,
  title = {{Do sequence-to-sequence VAEs learn global features of sentences?}},
  author = {Tom Bosc and Pascal Vincent},
  booktitle = {Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)},
  year = {2020},
  doi = {10.18653/v1/2020.emnlp-main.350},
  url = {https://doi.org/10.18653/v1/2020.emnlp-main.350}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/bosc-2020-do-sequence-sequence-vaes-learn/