Intrinsic Dimensionality Explains the Effectiveness of Language Model Fine-Tuning (2021)

Abstract: Although pretrained language models can be fine-tuned to produce state-of-the-art results for a very wide range of language understanding tasks, the dynamics of this process are not well understood, especially in the low data regime. Why can we use relatively vanilla gradient descent algorithms (e.g., without strong regularization) to tune a model with hundreds of millions of parameters on datasets with only hundreds or thousands of labeled examples? In this paper, we argue that analyzing fine-tuning through the lens of intrinsic dimension provides us with empirical and theoretical intuitions to explain this remarkable phenomenon. We empirically show that common pre-trained models have a very low intrinsic dimension; in other words, there exists a low dimension reparameterization that is as effective for fine-tuning as the full parameter space. For example, by optimizing only 200 trainable parameters randomly projected back into the full space, we can tune a RoBERTa model to achieve 90% of the full parameter performance levels on MRPC. Furthermore, we empirically show that pre-training implicitly minimizes intrinsic dimension and, perhaps surprisingly, larger models tend to have lower intrinsic dimension after a fixed number of pre-training updates, at least in part explaining their extreme effectiveness. Lastly, we connect intrinsic dimensionality with low dimensional task representations and compression based generalization bounds to provide intrinsic-dimension-based generalization bounds that are independent of the full parameter count.

## introduction pre-trained language models @xcite @xcite @xcite provide the defacto initialization for modeling most existing nlp tasks. however, the process of fine-tuning them on often very small target task datasets remains somewhat mysterious. why can we use relatively vanilla gradient descent algorithms (e.g., without strong regularization) to tune a model with hundreds of millions of parameters on datasets with only hundreds or thousands of labeled examples? we propose intrinsic dimensionality as a new lens through which fine-tuning can be analyzed @xcite . an objective function's intrinsic dimensionality describes the minimum dimension needed to solve the optimization problem it defines to some precision level. in the context of pre-trained language models, measuring intrinsic dimensional will tell us how many free parameters are required to closely approximate the optimization problem that is solved while fine-tuning for each end task. for example, we will show that 200 parameters (randomly projected back into the full parameter space) are enough to represent the problem of tuning a roberta model to within 90% of the performance of the full model. more generally, we also describe a set of strong empirical and theoretical connections between intrinsic dimensionality, number of parameters, pre-training, and generalization. we first empirically show that standard pretrained models can learn a large set of nlp tasks with very few parameters and that the process of pre-training itself implicitly minimizes the intrinsic dimension of later tuning for different nlp tasks. we study over a dozen different pre-trained models to show that the number of parameters strongly inversely correlates with intrinsic dimensionality, at least in part justifying the extreme effectiveness of such models. we interpret pre-training as providing a framework that learns how to compress the average nlp task. finally, we connect intrinsic dimensional with low dimensional task representations and compression-based generalization bounds to provide intrinsic-dimension-based generalization bounds independent of the full parameter count, further justifying why these methods generalize so well in practice across tasks. the contributions of our paper are the following: ## related work calculating the intrinsic dimension of an objective function in the context of deep-learning was first proposed by @xcite . they analyzed the impact of various architectures on the intrinsic dimensionality of their objective. our work is a direct extension of this approach, focusing on analyzing pre-trained representations instead. there is a large collection of literature analyzing pre-trained models from the perspective of capacity. for example, a recent line of work has shown that pre-trained models such as bert are redundant in their capacity, allowing for significant sparsification without much degradation in end metrics @xcite @xcite . @xcite showed that finetuning top layers of pre-trained models is not effective and that alternate methods allow fine-tuning effectively with a couple of percent of the parameters. furthermore, we can view computing the intrinsic dimensionality as a continuous relaxation of the sparsification problem. there also exist connections between intrinsic dimensionality, knowledge distillation, and other model compression methods. fundamentally intrinsic dimensionality attempts to find the smallest set of parameters needed to tune to reach satisfactory solutions, which can be thought of as a sparsification or distillation problem @xcite . unlike distillation approaches, the approach of intrinsic dimensionality does not change parameter count, sparsity, or architecture but instead looks at the underlying rank of the objective function @xcite . there are also connections between representing multiple tasks within a pre-trained model and compression which we explore in §5. moreover, standard approaches towards finetuning seem to have non-trivial effects on the generalization of pre-trained representations @xcite . a holistic explanatory picture of the successes of fine-tuning has not yet been painted. a clear understanding of the underlying mechanisms which lead to the incredible generalization of fine-tuned pre-trained representations is currently missing. moreover, we still do not understand why various pre-training methodology manifests in universally useful representations, although recent line of works have attempted to cover this gap by looking at loss landscapes, and the learned linguistic properties of pre-trained models @xcite . ## intrinsic dimensionality of finetuning background the intrinsic dimension of an objective function measures the minimum number of parameters needed to reach satisfactory solutions to the respective objective @xcite . alternatively, the intrinsic dimension represents the lowest dimensional subspace in which one can optimize the original function to within a certain level of approximation error. computing the exact intrinsic dimensional of the objective function is computation intractable; therefore, we resort to heuristic methods to calculate an upper bound. let θ @xmath0, θ 1 , ..., θ m ] be a set of d parameters that parameterize some model f (•, θ). instead of optimizing the empirical loss in the original parameterization (θ d ), the subspace method fine-tunes the model via the following re-parameterization in the lower-dimensional d-dimensions: we will primarily use the fastfood transform, defined as: the factorization of m consists of h, a hadamard matrix, g, a random diagonal matrix with independent standard normal entries, b a random diagonal matrix with equal @xmath1, and π a random permutation matrix. furthermore, the matrix multiplication with a hadamard matrix can be computed in o(d log d) via the fast walsh-hadamard transform. everything except θ d is fixed; therefore, the optimization problem lies only in d-dimensions. 1 we use the fastfood transform due to its computational complexity. specifically, using hadamard matrices instead of dense matrices allows us to compute a linear projection significantly faster than a dense matrix projection. furthermore, when working with large models such as roberta, the memory required to store even a low-dimensional dense matrix to calculate intrinsic dimension is unreasonable (@xmath2, 330, 000, 000 * 1000 * 4 @xmath3.32 terabytes). the standard method of measuring the intrinsic dimensionality of an objective as proposed by @xcite requires searching over various d, training using standard sgd over the subspace reparameterization θ d and selecting the smallest d which provides us with a satisfactory solution (d 90 ). @xcite defined the satisfactory solution as being 90% of the full training metric. for example, if we reach 85% accuracy training a model with all of its parameters, the goal is to find the smallest d, which would reach 0.9 * 85% = 76.5% accuracy; we call this dimension d 90 . 2 the way @xcite define a satisfactory solution reduces the dependence of the dataset size on the calculation of intrinsic dimension. for a small dataset, we will generally have worse end metrics; therefore, we have a lower d 90 cut-off; inversely, a larger dataset will require a more nontrivial d 90 cut-off. ## intrinsic dimension, pre-training, and generalization gap one interpretation of the intrinsic parameter vector is that it encodes the task at hand with respect to the original pre-trained representations. therefore, we can interpret d as the minimal description length of the task within the framework dictated by the pretrained representations @xcite . under this interpretation of intrinsic dimensionality, we hypothesize that pre-training is implicitly lowering the intrinsic dimensionality of the average nlp task, and therefore compressing the minimal description length of those same tasks. what do we more precisely mean by intrinsic parameter encoding a task within the framework provided by the pre-trained representations? traditionally, a finetuned model (e.g. for a classification tasks) simply consists of a classification head g, parameterized by w g applied to fine-tuned representations f , parameterized by w f per sample x. therefore, to fully describe a task, we need to pack together parameterizations and weights {g, f, w g , w f }. this model description is completely decoupled from the original weights of the pre-trained representation w f 0 , therefore to represent n classification tasks, we need to maintain n {w g , w f }; additionally, the task representation is incredibly high dimensional. conversely, finetuning utilizing said in d-dimensions requires storing only θ d per task, a single random seed used to generate m and the original pre-trained weights w f 0 . therefore, we can represent arbitrary nlp tasks within a single pre-trained model framework with d + 1 parameters. for example, in the last section, we represented mrpc with roughly 200 parameters, which translates to needing less than a kilobyte of data to encode a complex natural language task within the framework provided by roberta. we hypothesize that the better the pre-trained models are, the fewer bits (description length) are needed to represent the average nlp task, as we will demonstrate empirically in the next section. ## conclusion in conclusion, we proposed viewing the various phenomena surrounding fine-tuning and pretraining through the lens of intrinsic dimensionality. we empirically showed that common natural language tasks could be learned with very few parameters, sometimes in the order of hundreds, when utilizing pre-trained representations. we provided an interpretation of pre-training as providing a compression framework for minimizing the average description length of natural language tasks and showed that pre-training implicitly minimizes this average description length. we continued by doing an empirical study of existing pre-training methods and their respective intrinsic dimension, uncovering the phenomena that intrinsic dimensionality decreases as we increase the number of pre-trained representation parameters. this phenomenon provides some intuitions to the trend of growing pre-trained representations. we connected intrinsic dimensionality with generalization by first showing that pre-trained models with lower intrinsic dimensions across various tasks achieve higher evaluation accuracies and lower relative generalization gaps. furthermore, we explain these empirical results by applying well-known generalization bounds to the intrinsic dimension to get generalization bounds that grow on the order of the intrinsic dimension, not the parameter count. intrinsic dimensionality is a useful tool for understanding the complex behavior of large models. we hope that future work will make explicit theoretical connections between sgd and optimizing the intrinsic dimension as well as explain exactly why pre-training methods optimize the intrinsic dimensionailty of tasks before not seen. zhilin yang, zihang dai, yiming yang, jaime carbonell, russ r salakhutdinov, and quoc v le. 2019. xlnet: generalized autoregressive pretraining for language understanding. in advances in neural information processing systems, pages 5753-5763. xiang zhang, junbo zhao, and yann lecun. 2015. character-level convolutional networks for text classification. arxiv:1509.01626 @xcite .