Making Large Language Models Better Data Creators (2023)

Abstract: Although large language models (LLMs) have advanced the state-of-the-art in NLP significantly, deploying them for downstream applications is still challenging due to cost, responsiveness, control, or concerns around privacy and security. As such, trainable models are still the preferred option in some cases. However, these models still require human-labeled data for optimal performance, which is expensive and time-consuming to obtain. In order to address this issue, several techniques to reduce human effort involve labeling or generating data using LLMs. Although these methods are effective for certain applications, in practice they encounter difficulties in real-world scenarios. Labeling data requires careful data selection, while generating data necessitates task-specific prompt engineering. In this paper, we propose a unified data creation pipeline that requires only a single formatting example, and which is applicable to a broad range of tasks, including traditionally problematic ones with semantically devoid label spaces. In our experiments we demonstrate that instruction-following LLMs are highly cost-effective data creators, and that models trained with these data exhibit performance better than those trained with human-labeled data (by up to 17.5%) on out-of-distribution evaluation, while maintaining comparable performance on in-distribution tasks. These results have important implications for the robustness of NLP systems deployed in the real-world.

## introduction large language models (llms) have revolutionized the field of nlp, yielding impressive performance on various conventional natural language understanding (nlu) and generation (nlg) tasks. they are able to do this with only a handful (i.e., few-shot) or sometimes even no training examples (i.e., zero-shot) (brown et al., 2020; du et al., 2022; * work done during microsoft research internship. has the uk been hit by a hurricane? unlabeled instances llm input yes output llm yes output generate 'input' where the label is yes has the uk been hit by a hurricane? input llm question: has the uk been hit by a hurricane? option: [yes, no] answer: yes input / output (single-formatting example) question: does france have a prime minister? option: [yes, no] answer: yes question: have the san jose sharks won a stanley cup? option: [yes, no] answer: yes … following 'example' to generate diverse examples rae @xcite @xcite . however, despite their effectiveness, there is a continued demand for the deployment of smaller trainable or tunable models in real-world scenarios due to cost constraints, existing servicelevel agreement response times, or privacy and security concerns around using black-box apis. unfortunately, application-specific custom models sometimes require large amounts of high-quality human-labeled data, in order to perform well. thus, in order to reduce time and cost in the model deployment cycle, recent work has focused on trying to obtain training data by leveraging llms as either labelers to annotate unlabeled data @xcite @xcite , or generators to generate new data samples @xcite @xcite . despite initial successes, constraints for these techniques continue to hinder their applicability in broader real-world settings. first, in the context of using llms as labelers, it is essential to have raw data that closely resembles the distribution of data in the predictive task. most previous research has assumed access to a training dataset from which the labels are elided; however, for cold-start problems in the real-world, no such assumptions can be made. curating raw data for tasks in specialized domains, such as those in the biomedical or legal fields, can be particularly challenging. conversely, sampling a large volume of data at random can result in an imbalanced label distribution due to rare events @xcite . meanwhile, leveraging llms as generators requires careful curation of few-shot examples @xcite , or composition of prompts that highlight the semantic meaning of labels @xcite @xcite , such as positive v. negative in sentiment classification. the latter has been a bottleneck to the broader applicability of llms as generators, however, since not all tasks have labels that are semantically meaningful, or are enumerable. consider, for example the label yes v. no, which have no meaning when taken without context; or the options of a multiple choice qa (see figure 1 ), which are an effectively open-ended label-set that varies from instance to instance. for these kinds of problems llms as generators continue to be inadequate. in this paper, we first present a formal framework for characterizing different approaches for llm data creation. specifically, we use graphical models as a way to characterize and unify disparate approaches that include llms as either labelers or generators (section 2). next, we propose a novel data creation pipeline that only requires a single formatting example to generate heterogeneous labeled data for various downstream applications, including those that focus on specialized domains. in contrast to current methods that require dataset-specific components (e.g., label description, example selection), our pipeline serves as a unified solution that can be applied to a wide range of tasks, including those where the label set is either semantically devoid of meaning, or unenumerable. our data creation pipeline leverages an instruction-following llm as a generator in conjunction with a single formatting example as a simple yet effective way of imposing structured constraints. specifically, our approach iteratively conditions the generator on an instruction and a unique formatting example in a json format to yield multiple examples that vary in content but are formatted uniformly (section 3.1-3.2). furthermore, as an efficient means of diversifying the generated data, we propose a "self-reference" strategy, which iteratively samples from the pool of newly created examples to seed the prompt for the next round of generation (section 3.4). specifically, we outline 4 distinct instantiations of "self-reference" including random, contrastive, similar, and tree sampling for controlled diversification of data. we evaluate our data creation pipeline on a battery of tests involving three distinct types of tasks, namely multiple-choice question answering (qa), open-book yes/no qa, and closed-book yes/no qa. the datasets for these tasks range across a variety of domains, including specialized ones such as the biomedical domain. furthermore, for each category of task, we use a minimum of two datasets in order to compare the out-of-distribution (ood) generalization of models using original data to synthetically generated llm data. our results demonstrate that leveraging llms as generators using our formatting-based creation approach is a highly costeffective way of creating data that can be effectively used to train models for a variety of downstream tasks, including those in specialized domains, and ones where labels are devoid of semantic meaning or vary across the data. for in-distribution (id) settings, naturally having access to large amounts of high-quality manually curated and labeled data is still ideal. however, when only a small amount of human-labeled data is available, our approach yields results that are often comparable, and sometimes even better than the original datasets. this highlights the potential role llms can play in the model development cycle, especially in resourcepoor or specialized domains. further, for the ood settings, models trained on data generated by our pipeline consistently, and by large margins, outperform their counterparts trained on data from human sources. this robustness and generalizability has important implications for the deployment of realworld systems that deal with data that are variable, chaotic and often very different from curated academic datasets. we are realeasing our code and prompts to the community to spur future research in the area foot_0 . ## formalization of llm-based data creation in this section, we attempt to draw different data creation strategies using llms into a unified framework, and discuss related research using this framework. ## example-based data creation this paper proposes a unified data creation approach using llms, which does not need indomain unlabeled examples x @xmath0. as illustrated in figure 3 , our framework iteratively creates data d g beginning with a single initial formatting example (x f , y f ) and an instruction w i (section 3.1). the process begins by converting (x f , y f ) into a structured prompt w f (section 3.2-3.3). after conditioning m on [w i ; w f ] to generate data, we sample an instance from the pool of newly created data to serve as formatting example for the next iteration (section 3.4). we continue to iterate in this manner until the required number of instances k is obtained, after discarding duplicate and ill-formatted data. this is done by caching data and checking newly created candidates against previously generated ones for duplicates, and by using the python json.loads() method for verifying the validity of the json output. the resulting data creation pipeline is generally suitable for most classification tasks. although, in this paper we specifically focus on tasks where the label set is potentially open-ended (e.g., multiple-choice qa), or lacks inherent semantic meaning (e.g., binary qa) -problem spaces that have posed challenges to past work in llm data creation. ## experimental setup in this section we describe the experimental setup that we use to evaluate our single-shot examplebased data creation framework. ## experimental results we conduct a comprehensive set of experiments that seek to evaluate the effectiveness of data created by llms for focused downstream application modeling. our first evaluation involves examining the performance of models trained on data generated by variants of our single-shot data creation pipeline and comparing them against manually curated training data. we investigate both in-distributed (id) and out-of-distribution test data settings, each of which are explained in greater detail below. ## conclusion in this paper, we have presented a formal framework for data creation using llms and proposed a single-shot formatting example-based data creation pipeline that leverages an instruction-following llm. specifically, we showed how multiple varied examples can be generated from a single seed example in a machine-friendly json format by conditioning the llm on a structured prompt consisting of instructions and a formatted example. we further expand the diversity of the output by introducing a "self-reference" mechanism that selects formatting examples for subsequent iterations of generation from newly created data, and present four different instantiations of the sampling strategy. while prior efforts at llm data creation in the literature have avoided domains where the label space is open-ended and varies from instance to instance, or is semantically devoid of inherent meaning, our structured prompts are able to tackle both. on a battery of evaluations our findings indicate that llms can act as highly cost-effective data generators for the development of small trainable or tunable models in downstream applications. for example, a budget of $5 usd is enough to generate 2m tokens with gpt-3.5-turbo, and depending on the task can yield several thousand data samples. these models exhibit noteworthy predictive abilities in generalizing to out-of-distribution data, a key desiderata in real-world systems where data can be messy, variable and evolving. the impact of these findings are meaningful in a number of enterprise scenarios, including for applications that require strict governance on predictive models due to privacy and security concerns, or due to response-time service-level agreements, or indeed for small businesses where human annotation costs, especially from domain experts, can be prohibitively high.