S parse F it: Few-shot Prompting with Sparse Fine-tuning for Jointly Generating Predictions and Natural Language Explanations (2024)

Abstract: Models that generate natural language explanations (NLEs) for their predictions have recently gained increasing interest. However, this approach usually demands large datasets of human-written NLEs for the ground-truth answers at training time, which can be expensive and potentially infeasible for some applications. When only a few NLEs are available (a few-shot setup), fine-tuning pre-trained language models (PLMs) in conjunction with prompt-based learning has recently shown promising results. However, PLMs typically have billions of parameters, making full fine-tuning expensive. We propose SparseFit, a sparse few-shot fine-tuning strategy that leverages discrete prompts to jointly generate predictions and NLEs. We experiment with SparseFit on three sizes of the T5 language model and four datasets and compare it against existing state-of-the-art Parameter-Efficient Fine-Tuning (PEFT) techniques. We find that fine-tuning only 6.8% of the model parameters leads to competitive results for both the task performance and the quality of the generated NLEs compared to full fine-tuning of the model and produces better results on average than other PEFT methods in terms of predictive accuracy and NLE quality.

## introduction despite the tremendous success of neural networks @xcite , these models usually lack human-intelligible explanations for their predictions, which are paramount for ensuring their trustworthiness. building neural models that explain their predictions in natural language has seen increasing interest in recent years @xcite . natural language explanations (nles) are generally easy to interpret by humans and more expressive than other types of explanations @xcite . however, a significant downside of these models is that they require large datasets of human-written nles at training time, which can be expensive and time-consuming to collect. to this end, few-shot learning of nles has recently emerged @xcite . however, current techniques involve fine-tuning the entire model with a few training nle examples. this is computationally expensive since current nle models can have billions of parameters @xcite . in this paper, we investigate whether sparse finetuning (i.e. fine-tuning only a subset of parameters), in conjunction with prompt-based learning (i.e., textual instructions provided to a model @xcite ), can help in scenarios with limited availability of training instances with labels and nles. while sparse fine-tuning has been used in natural language processing (nlp) @xcite @xcite , to our knowledge, our work is the first to analyze sparse fine-tuning in the context of jointly generating predictions and nles. we extend the existing sparse fine-tuning strategy that looks only at bias terms @xcite to a comprehensive list of all layers and pairs of layers in a language model. thus, we propose sparsefit, an efficient fewshot prompt-based training regime for models generating both predictions and nles for their predictions. we experiment with sparsefit on two pre-trained language models (plms) that have previously shown high performance on task performance and nle generation, namely t5 @xcite and unifiedqa @xcite . we test our approach on four popular nle datasets: e-snli @xcite , ecqa @xcite , sbic @xcite , and comve @xcite , and evaluate both the task performance and the quality of the generated nles, the latter with both automatic metrics and human evaluation. overall, sparsefit shows competitive performance in few-shot learning settings with 48 training instances. for exam-ple, fine-tuning only the normalization layer together with the self-attention query layer, which amounts to 6.84% of the model's parameters, consistently gave the best performance (penalized by the number of fine-tuned parameters) on both t5 and unifiedqa over all four datasets. remarkably, sparsefit outperforms the current stateof-the-art parameter-efficient fine-tuning (peft) models in terms of both task performance and quality of generated nles in two of the four datasets. furthermore, we find that fine-tuning other model components that comprise a small fraction of the parameters also consistently leads to competitive results; for instance, the self-attention query (∼6.8% of the parameters), the self-attention query + lm head (∼11.3%), and the entire selfattention layer (∼20%). moreover, we also applied sparsefit to larger language models (i.e. llama 2-7b) and found that sparsefit has competitive performance compared to the best peft strategy for all datasets. therefore, we conclude that fewshot sparse fine-tuning of plms can achieve results competitive with fine-tuning the entire model. ## related work few-shot learning refers to training models with limited labeled data for a given task @xcite .it has been successfully applied to several tasks such as image captioning @xcite , object classification @xcite , behavioral bio-metrics @xcite , graph node classification @xcite , and language modeling @xcite . large language models (llms) have shown impressive skills to learn in few-shot scenarios @xcite thanks to the pre-training corpora size and the statistical capacity of the models @xcite . parameter-efficient fine-tuning using finetuning, llms have shown breakthrough language understanding and generation capabilities in a wide range of domains @xcite @xcite . however, in nlp, the up-stream model (i.e., the model to be finetuned) is commonly a llm with millions of parameters, such as t5 @xcite , bert @xcite , or gpt-3 @xcite , which makes them computationally expensive to fine-tune. this has led to approaches known in the literature as parameter-efficient fine-tuning (peft) methods, which fine-tune only a small set of the plm's parameters or an extra small set of parameters to keep competitive performance in the downstream task. in this regard, li and liang (2021) introduced prefix-tuning, a strategy that focuses on adding a small task-specific vector to the input so the frozen plm can adapt its knowledge to further downstream tasks. @xcite developed lora, a technique that injects trainable lowrank matrices in the transformer architecture while freezing the pre-trained model weights. @xcite extended this by proposing adalora, a method that adaptively allocates the rank budget among the low-rank matrices during training according to an importance score. later, @xcite presented bitfit, a novel approach aimed at only fine-tuning the bias terms in each layer of a transformer-based lm. we extend their work to fine-tuning some layers, or pairs of them, in the lm. more recently, @xcite introduced (ia) 3 , a fine-tuning method that scales the intermediate activations in a model with learned vectors. explainability of neural models several approaches have been proposed in the literature to bring a degree of explainability to the predictions of neural models, using different forms of explanations, such as (1) feature-based explanations @xcite @xcite , (2) natural language explanations @xcite @xcite , (3) counterfactual explanations @xcite , and (4) surrogate explanations @xcite . in this paper, we focus on models that provide nles, i.e., free-form text stating the reasons behind a prediction. being in natural language, nles should be easy to interpret by humans and more expressive than other types of explanations, as they can present arguments that are not present in the input @xcite @xcite . nles have been applied to several domains such as question answering @xcite , natural language inference @xcite , recommendation systems (chen et al., 2021), reinforcement learning @xcite , medical imagining @xcite , visualtextual reasoning @xcite @xcite , and solving mathematical problems @xcite . to make neural models capable of generating accurate nles, the most common approach con-sists of annotating predictions with human-written explanations and training models to generate the nles by casting them as a sequence generation task @xcite . however, gathering large datasets with human-written nles is expensive and time-consuming. to address this, @xcite proposed a vanilla transfer learning strategy to learn from a few nles but abundant labels in a task by fine-tuning a plm trained on a vast number of nles from other domains. more recently, @xcite introduced the feb benchmark for few-shot learning of nles and a prompt-based fine-tuning strategy, which we use as a baseline in our work. ## sparsefit we propose sparsefit, an efficient few-shot nle training strategy that focuses on fine-tuning only a subset of parameters in a large lm. sparsefit is inspired by (1) @xcite , who used fine-tuning and prompts to do few-shot learning of labels and nles; and (2) bitfit zaken et al. ( 2022 ), who showed that fine-tuning only the bias terms in a plm leads to competitive (and sometimes better) performance than fine-tuning the entire model. we extend bitfit by exploring the fine-tuning of different components (i.e., layers or blocks) in the plm's architecture. in particular, we study the self-rationalization performance after fine-tuning the following components in the t5 model: (1) the encoder blocks, (2) the decoder blocks, (3) the language model head, (4) the self-attention layers, (5) the feed-forward networks, (6) the normalization layer, and (7) all pairs of the above components that do not contain the encoder and decoder (see appendix c). given that unifiedqa model's architecture is the same as the one in t5, the interpretation of active parameters holds for unifiedqa. we aim to identify a set of guidelines for identifying which components should be fine-tuned to achieve competitive performance while updating a minimum number of parameters. notice that when fine-tuning any component, or pair of components, we freeze all other plm's parameters and train the lm to conditionally generate a text in the form of "[label] because [explanation]". encoder the t5 encoder comprises n transformer blocks, each composed of three layers: selfattention, position-wise fully connected layer, and layer normalization. the number of blocks depends on the t5 variant (12 blocks for t5-base, 24 for t5-large, and 36 for t5-3b). the encoder accounts for roughly 41% of the model parameters. decoder the decoder accounts for roughly 54% of t5 model parameters. in addition to the selfattention, fully connected layer, and layer normalization, it also includes an encoder-decoder attention layer in its blocks, which we fine-tune as part of fine-tuning the decoder. lm head on top of the decoder, t5 has a language modeling head for generating text based on the corpus. the lm head accounts for roughly 5% of total model parameters. attention layer each of the transformer blocks starts with a self-attention layer. there are three types of parameters in the self-attention layer, namely, for computing the query matrix q, the key matrix k, and the value matrix v . we propose to explore the fine-tuning of each self-attention matrix as a possible sparsefit configuration. we also explore fine-tuning the entire self-attention layer (q, k, v ). on average, the percentage of trainable parameters associated with each matrix accounts for roughly 6% of model parameters. note that the attention parameters in the encoderdecoder attention are not updated in this setting (they are only updated together with the decoder). ## experiments datasets we follow the feb benchmark for fewshot learning of nles @xcite and consider four nle datasets: e-snli for natural language inference @xcite , ecqa for multiple-choice question answering @xcite , comve for commonsense classification @xcite , and sbic for offensiveness classification @xcite . ## summary we introduced sparsefit, a strategy that combines sparse fine-tuning with prompt-based learning to train nle models in a few-shot setup. sparsefit shows consistently competitive performance while only updating a minimal subset of parameters (i.e. the self-attention query + layer normalization, having ∼6.8% of the model parameters). we found that the sparse fine-tuning of t5-large consistently achieves better performance than fine-tuning t5-base and is slightly worse (< 5%) than t5-3b, no matter the sparse-fit strategy. moreover, the top three best performers for t5-base are achieved by the same set of sparsefit configurations found for t5-large. compared to other peft techniques, sparsefit produces better average predictive accuracy and nle quality. we aim for sparsefit to inspire the community to investigate sparse fine-tuning at different model components.