LM - CPPF : Paraphrasing-Guided Data Augmentation for Contrastive Prompt-Based Few-Shot Fine-Tuning (2023)

Abstract: In recent years, there has been significant progress in developing pre-trained language models for NLP. However, these models often struggle when fine-tuned on small datasets. To address this issue, researchers have proposed various adaptation approaches. Prompt-based tuning is arguably the most common way, especially for larger models. Previous research shows that adding contrastive learning to prompt-based fine-tuning is effective as it helps the model generate embeddings that are more distinguishable between classes, and it can also be more sample-efficient as the model learns from positive and negative examples simultaneously. One of the most important components of contrastive learning is data augmentation, but unlike computer vision, effective data augmentation for NLP is still challenging. This paper proposes LM-CPPF, Contrastive Paraphrasing-guided Prompt-based Fine-tuning of Language Models, which leverages prompt-based few-shot paraphrasing using generative language models, especially large language models such as GPT-3 and OPT-175B, for data augmentation. Our experiments on multiple text classification benchmarks show that this augmentation method outperforms other methods, such as easy data augmentation, back translation, and multiple templates.

## introduction pre-trained language models (plms) are trained on large-scaled corpora in a self-supervised fashion. they have fundamentally changed the nlp community in the past few years by achieving impressive results in various tasks @xcite @xcite . however, when plms are finetuned on small datasets, their performance declines. researchers have proposed various techniques to adapt plms to these scenarios @xcite . in addition to performance, fine-tuning plms to learn a new task is parameter inefficient, because an entirely new model is required for every task @xcite . by the introduction of gpt-3 @xcite with 175b parameters, it has been shown that large language models (llms) are efficient few-shot learners as they can use their knowledge more effectively. one of the key features of these llms is their ability to perform multiple tasks using prompts. a language prompt is a piece of text that is added to the input query to help the model make more accurate predictions. in addition, llms can be fine-tuned for specific tasks using few examples. this has made them powerful tools for nlp tasks, especially in few-shot scenarios. however, that might not be practical for many situations because of the model size. therefore, there is a need to adapt smaller plms to work in a similar way to llms. prompt-based fine-tuning is a method for adapting plms to specific tasks or domains by providing a prompt @xcite . this approach has been shown to be effective in various nlp tasks, including text classification @xcite and question answering @xcite . however, it can be challenging to achieve strong performance when only a few examples are available for each task. @xcite introduced a prompt-based fine-tuning method called lm-bff for roberta @xcite to tackle this issue. their approach includes automated prompt generation and a more effective way of using task examples in fine-tuning. building on the success of lm-bff and considering contrastive learning's promising results both in computer vision @xcite and nlp @xcite , @xcite present a contrastive learning framework to improve lm-bff. they propose a supervised contrastive learning (scl) approach @xcite ) that classifies inputs using different augmented views of the data. these views are created using different templates for their demonstrations when building prompts. in this paper, we show that while scl at the feature space can be beneficial, the use of different templates can limit the full potential of this approach. we propose lm-cppf (contrastive paraphrasing-guided prompt-based fine-tuning of language models), in which we integrate the knowledge of llms like gpt-3 and opt-175b @xcite to build different views using paraphrasing. these models can generate paraphrases of a sentence with different syntax, not just by changing the lexicalization. previous studies have considered generating paraphrases a challenging and costly nlp task @xcite @xcite . however, plms can generate paraphrases easily and effectively using in-context learning with few examples. although prior research has studied paraphrase generation with plms @xcite , to the best of our knowledge, this is the first time that large llms are utilized to generate paraphrases with prompts as an augmentation method. our experiments on six different text classification tasks demonstrate that lm-cppf outperforms the previous sota methods of data augmentation in prompt-based fine-tuning, including easy data augmentation (eda) @xcite , back translation (bt) @xcite , and multiple templates @xcite . ## related works llms like gpt-3 @xcite ) can perform nlp tasks with few examples and natural prompts. but smaller models are not efficient with this approach and there are data sparsity and prompt sensitivity issues. to address these challenges, @xcite propose lm-bff, a framework that leverages a large plm to automatically generate task-specific prompts for smaller models. it improves their few-shot performance on different nlp tasks. some work have enhanced lm-bff with different prompt tuning methods. for example, @xcite present a dual context-guided continuous prompt tuning method that uses the language context and connects discrete and continuous prompt tuning. @xcite integrate contrastive learning and data augmentation with lm-bff. in their contrastive part, in addition to comparing different instances from the same or different classes, they introduced a novel promptspecific augmentation method. in their approach, they change the template of the prompt. in this paper, we use few-shot paraphrasing with llms for contrastive prompt-tuning, which fine-tunes models with natural prompts. paraphrasing is the task of expressing the same meaning with different words or structures. it can be used to create training data with increased diversity and naturalness for nlp tasks, such as text classification @xcite , natural language inference @xcite , and text summarization @xcite , surpassing the limitations of traditional approaches. paraphrasing helps with data scarcity and model generalization. there are different ways to generate paraphrases for data augmentation. one is back-translation @xcite , which uses a translation system to convert a sentence to another language and back. another is to use paraphrasing models trained on parallel paraphrase datasets @xcite . plms can also generate paraphrases by using large-scale corpora, but they may produce paraphrases that are not semantically consistent or relevant. llms can reduce this problem as they encode and generate language better. in this paper, we generate paraphrases by carefully prompting llms and then use them for data augmentation. few-shot paraphrasing paraphrasing is one of the best methods for data augmentation in nlp. one of the most popular approaches for paraphrasing is back-translation (bt) @xcite due to its simplicity and efficiency. nonetheless, bt's performance depends a lot on the intermediary language. in this paper, we, instead, use a combination of prompt-learning and llms for paraphrasing. in few-shot paraphrasing, an llm rewrites a sentence given an instruction and a few examples. we believe that llms generate high-quality paraphrases due to their encoded semantic and sentence structure knowledge. we utilize gpt-3 @xcite or opt-175b @xcite via their official apis 2 for generating paraphrases. to avoid violating the prompt-based fine-tuning settings, we do not include any additional task data in generating our paraphrases. following the fewshot setting in lm-bff, we assume to have access to a plm m , datasets d train , and d test with label space y where there are only @xmath0. we use this setting for both promptbased few-shot paraphrasing and fine-tuning. to 2 opt-175b: opt.alpa.ai and gpt-3: openai.com/api generate paraphrases, excluding the one sample that we want to paraphrase, we use quillbot foot_1 to create paraphrases for our prompts for the remaining 15 samples in the same class of d train . we leverage two types of prompts for paraphrasing: (i) only demonstration: here, the samples and their paraphrased versions are given using the templates in table c .3 to demonstrate the task of paraphrasing. (ii) demonstrations with instruction: in addition to the previous method, this one includes instructions at the beginning of the prompt, defining paraphrasing before demonstrations. these instructions can be seen in table c .4. contrastive prompt-based fine-tuning lm-cppf consists of two steps. the first step involves calculating the masked language modeling (mlm) loss by using the target sentence in the given template, the specific demonstrations in the prompt, and the verbalizer matched with the target sentence's label. we calculate the supervised contrastive loss in the second step by comparing the target prompt with another sample with the same template but different random demonstrations. this comparison sample can be in the same or a different class as the target prompt. when the comparison sample belongs to a different class, it is randomly sampled from the dataset. however, in cases where the comparison sample belongs to the same class, an alternative approach is employed. this involves either selecting another sample from the same class within the dataset or applying data augmentation techniques, paraphrasing in our case, to augment the target sample in order to create a new view of it. in both of these cases, the demonstrations are not the same. figure 1 illustrates the fine-tuning process, and algorithm d.1 shows our methodology when paraphrasing creates a new view of the target sample. see appendix d for more information. ## conclusion our experiments demonstrated the effectiveness of using few-shot paraphrasing as a data augmentation method for contrastive prompt-based fine-tuning of plms. it outperformed other data augmentation methods in text classification tasks, such as eda, multiple templates, and back translation. we also found that our approach is effective with gpt-3 or opt-175b models in generating paraphrases. overall, lm-cppf improves the performance of lm-bff by large margins using contrastive learning applied on paraphrases generated by llms.