Comparing Text Representations: A Theory-Driven Approach (2021)

Abstract: Much of the progress in contemporary NLP has come from learning representations, such as masked language model (MLM) contextual embeddings, that turn challenging problems into simple classification tasks. But how do we quantify and explain this effect? We adapt general tools from computational learning theory to fit the specific characteristics of text datasets and present a method to evaluate the compatibility between representations and tasks. Even though many tasks can be easily solved with simple bag-of-words (BOW) representations, BOW does poorly on hard natural language inference tasks. For one such task we find that BOW cannot distinguish between real and randomized labelings, while pre-trained MLM representations show 72x greater distinction between real and random labelings than BOW. This method provides a calibrated, quantitative measure of the difficulty of a classification-based NLP task, enabling comparisons between representations without requiring empirical evaluations that may be sensitive to initializations and hyperparameters. The method provides a fresh perspective on the patterns in a dataset and the alignment of those patterns with specific labels.

## introduction a common theme in contemporary machine learning is representation learning: a task that is complicated and difficult can be transformed into a simple classification task by filtering the input through a deep neural network. for example, we know empirically that it is difficult to train a classifier for natural language inference (nli)-determining whether a sentence logically entails another-using bag-of-words features as inputs, but training the same type of classifier on the output of a pre-trained masked language model (mlm) results in much better performance @xcite . fine-tuned representations do even better. but why is switching from raw text features to mlm contextual embeddings so successful for downstream classification tasks? probing strategies can map the syntactic and semantic information encoded in contextual embeddings @xcite , but it remains difficult to compare embeddings for classification beyond simply measuring differences in task accuracy. what makes a given input representation easier or harder to map to a specific set of labels? in this work we adapt a tool from computational learning theory, data-dependent complexity (ddc) @xcite , to analyze the properties of a given text representation for a classification task. given input vectors and an output labeling, ddc provides theoretical bounds on the performance of an idealized two-layer relu network. at first, this method may not seem applicable to contemporary nlp: this network is simple enough to prove bounds about, but does not even begin to match the complexity of current transformer-based models. although there has been work to extend the analysis of @xcite to more complicated networks @xcite , the simple network is a good approximation for a task-specific classifier head. we therefore take a different approach, and use ddc to measure the properties of representations learned by networks, not the networks themselves. this approach does not require training any actual classification models, and is therefore not dependent on hyperparameter settings, initializations, or stochastic gradient descent. quantifying the relationship between representations and labels has important practical impacts for nlp. text data has long been known to differ from other kinds of data in its high dimensionality and sparsity @xcite . we analyze the difficulty of nlp tasks with respect to two distinct factors: the complexity of patterns in the dataset, and the alignment of those patterns with the labels. better ways to analyze relationships between mnli accuracy 99.8% 99.4% 75.4% 79.6% 52.8% 67.1% 96.6% var@100 81.8% 43.8% 44.1% 23.9% 31.9% 98.4% 88.1% representations and labels may enable us to better handle problems with datasets, such as "shortcut" features that are spuriously correlated with labels @xcite @xcite . our contributions are the following. first, we identify and address several practical issues in applying ddc for data-label alignment in text classification problems, including better comparisons to "null" distributions to handle harder classification problems and enable comparisons across distinct representations. second, we define three evaluation patterns that provide calibrated feedback for data curation and modeling choices: for a given representation (such as mlm embeddings), are some labelings more or less compatible with that representation? for a given target labeling, is one or another representation more effective? how can we measure and explain the difficulty of text classification problems between datasets? third, we provide case studies for each of these usages. in particular, we use our method to quantify the difference between various localist and neural representations of nli datasets for classification, identifying differences between datasets and explaining the difference between mlm embeddings and simpler representations. 1 2 data-dependent complexity data-dependent complexity @xcite combines measurements of two properties of a binary-labeled dataset: the strength of patterns in 1 code is available at: https://github.com/ gyauney/data-label-alignment the input data and the alignment of the output labels with those patterns. patterns in data are captured by a pairwise document-similarity (gram) matrix. an eigendecomposition is a representation of a matrix in terms of a set of basis vectors (the eigenvectors) and the relative importance of those vectors (the eigenvalues). if we can reconstruct the original matrix with high accuracy using only a few eigenvectors, their corresponding eigenvalues will be large relative to the remaining eigenvalues. a matrix with more complicated structure will have a more uniform sequence of eigenvalues. ddc measures the projections of the label vector onto each eigenvector, scaled by the inverse of the corresponding eigenvalue. a label vector that can be reconstructed with high accuracy using only the eigenvectors with the largest eigenvalues will therefore have low ddc, while a label vector that can only be reconstructed using many eigenvectors with small eigenvalues will have high ddc. ## making data-dependent complexity a practical tool for text data unlike previous work, our goal is not to prove theoretical bounds on neural networks, but to evaluate the theoretical properties of different representations of datasets. rather than compare ddc across representations directly, data-label alignment takes inspiration from rademacher complexity and compares the gap between ddc of real and random labelings to account for different embedding spaces. figure 2 provides a simplified view of this approach, showing the ddc of real labels relative to ddc for random labelings for two trivial representations of a synthetic dataset. we also find that several additional adaptations from @xcite are required to make ddc an effective tool for text datasets. subsampling large datasets can provide good approximations with reduced computational cost, and we show that duplicate documents, which are more likely in text than in images, can significantly affect ddc if not handled. difficult datasets require distributions of random labels. we recommend comparing the ddc of the real labeling to the distribution of ddcs from many random labelings. for easier tasks, there is subsampling is effective for large datasets. calculating ddc requires matrix operations that scale more than quadratically in the number of data points (pan and chen, 1999), which are prohibitive to compute exactly for large datasets. truncated eigendecompositions are tempting but may underestimate complexity for extremely difficult datasets; we leave exploration of truncated approximations to future work. we recommend instead calculating ddc for a random subsample. for ## related work we see this work as part of a more general increase in quantitative evaluations of datasets. swayamdipta et al. (2020) identify subsets of nli datasets that are hard to learn by analyzing how a classifier's predictions change over the course of training. sakaguchi et al. (2020) and le bras et al. (2020) similarly filter nli datasets by finding examples frequently misclassified by simple linear classifiers. rather than find difficult examples within a dataset, we seek to understand how different data representations impact task difficulty. our results complement le bras et al. (2020) in finding that categories containing more dissimilar examples are more complex. they find that filtering data under the roberta representation leads to the most difficult reduced dataset; our work suggests this might be because contextual embeddings better differentiate the entailment and contradiction classes in nli tasks than baseline representations. minimum description length (mdl) treats a classifier as a method for data compression and has recently been used to measure the extent to which representations learned by mlms capture linguistic structure @xcite . @xcite use mdl to determine if additional textual features are expected to lead to easier tasks, finding, for instance, that providing answers to subquestions in question-answering tasks decreases dataset complexity. in contrast, our work investigates the relationship between different representations of fixed data and labelings. mielke et al. (2019) also use information-theoretic tools (surprisal/negative log-likelihood) to empirically evaluate differences in language model effectiveness across languages. this work also relates to prior work on evaluating the capabilities of embeddings. non-contextual dense vector word representations encode syntax and semantics @xcite as well as world information like gender biases @xcite . linguistic probing and comparison of mlm layers and representations has identified specific capabilities of mlms @xcite @xcite . many works have identified and proposed antidotes to the anisotropy of non-contextual word embeddings @xcite @xcite . @xcite use a kernel approach to compare embeddings learned by mlms pre-trained on different languages. while analyzing the geometry of contextual embedding vectors remains an active line of work @xcite , we instead analyze the relationship between embeddings and the labels of downstream tasks. ## conclusion we present a method for quantifying the alignment between a representation of data and a set of associated labels. we argue that the difficulty of a dataset is a function of the alignment between the chosen representation and a labeling, relative to the distribution of alternative labelings, and we demonstrate how this method can be used to compare different text representations for classification. we used nli datasets as well-understood case studies in order to demonstrate our method, which replicates results from less general methods that were surprising when introduced, such as @xcite on lexical mutual information. our method supplements traditional held-out test set accuracy: while accuracy answers which representations en-able high performance for a task, our approach offers more explanation of why. we hope that future work can study novel datasets and settings. our method can be readily applied to new datasets, and it could especially be used to quantify the difficulty of adversarially constructed datasets like winogrande @xcite and adversarial nli @xcite . our method could be used to measure data-label alignment while changing the information present in each document, as in the recent work of @xcite . the method can also be extended to both other classification models by analyzing gram matrices produced by different similarity kernels and to multi-class, imbalanced, and noisy settings where uniformly-random labelings are not as applicable. more theoretical work could provide further generalization guarantees. our method provides a new lens that can be used in multiple ways. nlp practitioners want to design models that achieve high accuracy on specific tasks, and our method can identify which representation most aligns with the task's labeling and whether certain processing steps are useful. dataset designers, on the other hand, often seek to provide challenging datasets in order to spur new modeling advances @xcite . our method helps diagnose when current text representations do not capture the variation in a dataset, as we showed for the case of wnli, necessitating richer embeddings. it can also indicate when datasets are not robust to patterns in existing embeddings, as we found with snli and qnli aligning with baseline lexical features. finally, while empirical exploration has been an effective strategy in nlp, better theoretical analysis may reveal simpler yet more powerful and more explainable solutions @xcite . applying theory-based analysis to representations rather than to nlp models as a whole offers a way to benefit immediately from such perspectives without requiring full theoretical analyses of deep networks.