Source-linked AI summary
Fine-grained Analysis of Sentence Embeddings Using Auxiliary Prediction Tasks
Yossi Adi, Einat Kermany, Yonatan Belinkov, Ofer Lavi, Yoav Goldberg
TL;DR
Sentence embeddings are widely used, but the information they encode is not well understood. The paper introduces auxiliary prediction tasks for sentence length, word content, and word order, then compares representation methods and dimensions. CBOW and LSTM auto-encoders show different strengths across these properties, while BLEU is not fully indicative of encoder quality.
Problem
The paper addresses limited understanding of which information different sentence embedding mechanisms capture, beyond coarse downstream-task comparisons.
Method
The authors evaluate representations with classifiers trained on auxiliary tasks predicting sentence length, word content, and word order.
Results
CBOW is effective across content, length, and some word-order prediction, while sufficiently dimensional LSTM auto-encoders effectively encode content and order; BLEU is sub-optimal for model selection.
Takeaways & Limitations
Fine-grained auxiliary tasks expose relative strengths and weaknesses of sentence representations and reveal that larger embeddings are not always better.
Takeaways & Limitations
The empirical conclusions may not generalize beyond the measured datasets, and the tasks do not measure syntactic or semantic generalization abilities.
Abstract
from arXiv · showhide
There is a lot of research interest in encoding variable length sentences into fixed length vectors, in a way that preserves the sentence meanings. Two common methods include representations based on averaging word vectors, and representations based on the hidden states of recurrent neural networks such as LSTMs. The sentence vectors are used as features for subsequent machine learning tasks or for pre-training in the context of deep learning. However, not much is known about the properties that are encoded in these sentence representations and about the language information they capture. We propose a framework that facilitates better understanding of the encoded representations. We define prediction tasks around isolated aspects of sentence structure (namely sentence length, word content, and word order), and score representations by the ability to train a classifier to solve each prediction task when using the representation as input. We demonstrate the potential contribution of the approach by analyzing different sentence representation mechanisms. The analysis sheds light on the relative strengths of different sentence embedding methods with respect to these low level prediction tasks, and on the effect of the encoded vector's dimensionality on the resulting representations.
1 INTRODUCTION
The paper proposes fine-grained auxiliary prediction tasks to reveal what sentence representations encode, comparing CBOW and LSTM-based methods across sentence properties and dimensionalities.
- The methodology addresses the limited understanding of information captured by different sentence embedding mechanisms.
- The study targets sentence length, word content, and word order as core properties for comparing sentence representations.
- CBOW representations encode sentence length and permit probabilistic reconstruction of non-trivial word-order information despite disregarding order directly.
- LSTM auto-encoders are very effective at encoding word order and word content.
- Increasing dimensionality benefits some prediction tasks more than others, while additional hidden units can degrade word-content encoding.
- Auto-encoder LSTM encoders do not rely on training-sentence ordering patterns for novel sentences, unlike skip-thought encoders.
2 RELATED WORK
Prior sentence-representation analyses often rely on downstream performance or model-specific hidden-unit studies, leaving the properties captured by final embeddings unclear.
- Existing comparisons commonly evaluate sentence embeddings on downstream tasks, but this approach is coarse-grained and does not explain which linguistic properties they capture.
- Hidden-unit analyses associate linguistic aspects with neural representations but depend on specific learning models and do not directly characterize final sentence embeddings.
- The proposed auxiliary-task methodology is orthogonal and complementary to prior work and applies to arbitrary sentence representation models.
3 APPROACH
The approach measures how well classifiers predict isolated sentence properties from fixed-length representations, using controlled datasets and task-specific baselines.
- The method trains classifiers to predict isolated sentence properties from sentence vectors, treating predictability as evidence that a property is usefully encoded.
- The experiments examine sentence length, word identities, and word order as core elements of sentence structure.
- The corpus contains 200,000 Wikipedia sentences, divided into 150,000 training and 25,000 development and test sentences.
- Length Task: The length task predicts eight binned sentence-length classes from a representation, with majority-class baseline accuracy of 20.1%.
- Word-content Task: The word-content task determines whether a word appears in a sentence using concatenated sentence and word representations, with a balanced 50% baseline.
- Word-order Task: The word-order task predicts whether one sentence word precedes another using positive examples and reversed-order negatives, with a balanced 50% baseline.
4 SENTENCE REPRESENTATION MODELS
The paper analyzes CBOW averaging and LSTM encoder-decoder representations, comparing how model design and embedding size affect sentence encodings.
- CBOW represents a sentence by element-wise averaging of word vectors, making it simple to compute but oblivious to word order.
- LSTM encoder-decoder models encode sentences with an LSTM and use a decoder to map the representation back to the word sequence.
- The framework compares task accuracy across embedding sizes, with encoder-decoder BLEU scores included as a reference.
5 EXPERIMENTAL SETUP
The models are trained on a large Wikipedia corpus with controlled vocabulary, sentence-length, and embedding-size settings.
- The models are trained on 1 million Wikipedia sentences using a 50,000-token vocabulary and sentence lengths between 5 and 70 words.
- Embedding sizes are controlled at 100, 300, 500, 750, and 1000 dimensions for both word and sentence vectors.
6 RESULTS
The experiments measure sentence length, word content, and word order encoding across representation models and embedding sizes, revealing distinct strengths for LSTM and CBOW.
- Length: LSTM embeddings capture sentence length well at sufficient dimensionality, reaching 82%–87% accuracy, while CBOW reaches 45%–65% against a 20% baseline.
- Length: LSTM length accuracy remains relatively stable from 300 dimensions onward even as encoder-decoder BLEU increases with dimensionality.
- Word content: All representations outperform the 50% random baseline on word content, but LSTM content performance peaks at 750 dimensions and then drops.
- Word content: CBOW performs exceptionally well on word content at 100 and 300 dimensions, outperforming the sequence-aware models, but its scores drop at higher dimensions.
- Word order: LSTM-1000 recovers word order in 91% of cases, while CBOW reaches 70% accuracy, 20% above the baseline.
7 IMPORTANCE OF “NATURAL LANGUAGENESS”
Additional experiments test whether sentence-property predictions depend on natural-language word distributions, separating sentence information from general language statistics.
- Sentence length: Replacing every word with a random dictionary word causes only a slight CBOW length-accuracy decrease, indicating word identity is not its main source of length information.
- Sentence length: CBOW embedding norms decrease as sentences grow longer, which the authors believe is a main reason for its strong length-prediction performance.
- Word-order statistics: Removing sentence embeddings causes a significant order-accuracy drop for LSTM-ED but only a minor change for CBOW.
- Word-order statistics: CBOW order accuracy is mostly explained by general language statistics, although sentence representations add approximately 3 accuracy points.
- Permuted sentences: LSTM encoder-decoder results remain comparable across natural and permuted sentences on all three tests, with a small consistent order-accuracy drop.
- Permuted sentences: On permuted sentences, CBOW order accuracy falls to chance while its other test results remain unchanged.
- Permuted sentences: On the permuted dataset, LSTM-1000 decoder BLEU drops from 32.5 to 8.2, suggesting language-specific information is concentrated in the discarded decoder.
8 SKIP-THOUGHT VECTORS
Skip-thought embeddings perform strongly across the auxiliary prediction tasks, but their representations are sensitive to sentence word-order regularities and differ from the controlled comparisons.
- Direct comparison is limited because skip-thought was trained on a different corpus and used a recommended embedding size of 4800.
- Skip-thought predicts length, word content, and order well above the baselines, with performance roughly similar across tasks.
- Its performance resembles higher-dimensional encoder-decoder models, except that it lags somewhat on the order task.
- Permuting sentences causes a large drop in skip-thought performance, including significant degradation for length and word-content prediction.
- The degradation suggests skip-thought encoding is specialized toward natural-language texts.
9 CONCLUSION
The conclusion finds distinct strengths and dimensionality effects across CBOW, LSTM auto-encoders, and skip-thought, while questioning BLEU as a sufficient encoder-selection criterion.
- CBOW is strong at content, predicts sentence length, and reconstructs a non-trivial amount of word order; 300 dimensions perform best overall.
- Higher-dimensional CBOW models show greatly degraded word-content prediction performance.
- LSTM auto-encoders encode word content and order effectively with enough dimensions, while dimensionality does not significantly improve length encoding.
- LSTM word-content accuracy peaks at 750 dimensions and drops at 1000, while order encoding gains little beyond 500 dimensions.
- Auto-encoder-trained LSTM encoders do not rely on training-sentence ordering patterns for novel sequences, unlike skip-thought encoders.
- Encoder-decoder BLEU is not entirely indicative of word-identity and order representation quality, making it sub-optimal for model selection.
APPENDIX I: EXPERIMENTAL SETUP
The experiments train CBOW and LSTM encoder-decoder sentence representations on Wikipedia and evaluate them with auxiliary classifiers and BLEU.
- CBOW and encoder-decoder models use 1 million Wikipedia sentences, a 50,000-token vocabulary, and sentence lengths from 5 to 70 words.
- CBOW uses Skip-gram word vectors with hierarchical softmax, a five-word window, and embedding sizes of 100, 300, 500, 750, and 1000.
- The encoder-decoder uses one LSTM layer for both encoder and decoder, with the decoder trained as a language model using cross-entropy loss.
- Word and sentence representation sizes are matched, using dimensions 100, 300, 500, 750, and 1000; input sentences are reversed and gradients clipped.
- Encoder-decoder quality is evaluated with BLEU alongside the three auxiliary prediction tasks.
- Auxiliary predictors are single-hidden-layer multilayer perceptrons with ReLU activation, tuned separately for each task.
APPENDIX II: TECHNICAL DETAILS
The technical appendix describes tuned training procedures, sentence-length analyses, and paired significance tests for encoder-decoder and CBOW comparisons.
- Training: Encoder-decoder parameters were tuned over learning rates, dropout rates, optimizers, and batch sizes; batch-size changes improved runtime but not performance significantly.
- Training: Final encoder-decoder training used learning rate 0.01, dropout 0.1, AdaGrad, batch size 32, and early stopping after five epochs without validation improvement.
- Classifiers: The best auxiliary classifier is a one-hidden-layer ReLU network with hidden size equal to the input, task-specific softmax output, dropout 0.8, and learning rate 0.01.
- Content versus length: Figure 4 plots content prediction accuracy against sentence length for different models.
- Content versus length: All models lose content accuracy as sentences lengthen, with degradation roughly linear in sentence length.
- Significance tests: Paired t-tests evaluate the reported findings; most summary results are highly significant with p-value ≪0.0001.
- Significance tests: Non-significant differences include encoder-decoder sizes 500 versus 750 on order, with p-value=0.11, and CBOW sizes 750 versus 1000, with p-value=0.3.