SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Yue Yu $^{1}$ , Yuchen Zhuang $^{1}$ , Jieyu Zhang $^{2}$ , Yu Meng $^{3}$ , Alexander Ratner $^{2}$ , Ranjay Krishna $^{2}$ , Jiaming Shen $^{4}$ , Chao Zhang $^{1}$ $^{1}$  Georgia Tech  $^{2}$  University of Washington  $^{3}$  UIUC  $^{4}$  Google Research {yueyu, yczhuang, chaozhang}@gatech.edu, yumeng5@illinois.edu {jieyuz2, ajratner, ranjay}@cs.washington.edu, jmshen@google.com
Large language models (LLMs) have been recently leveraged as training data generators for various natural language processing (NLP) tasks. While previous research has explored different approaches to training models using generated data, they generally rely on simple class-conditional prompts, which may limit the diversity of the generated data and inherit systematic biases of LLM. Thus, we investigate training data generation with diversely attributed prompts (e.g., specifying attributes like length and style), which have the potential to yield diverse and attributed generated data. Our investigation focuses on datasets with high cardinality and diverse domains, wherein we demonstrate that attributed prompts outperform simple class-conditional prompts in terms of the resulting model's performance. Additionally, we present a comprehensive empirical study on data generation encompassing vital aspects like bias, diversity, and efficiency, and highlight three key observations: firstly, synthetic datasets generated by simple prompts exhibit significant biases, such as regional bias; secondly, attribute diversity plays a pivotal role in enhancing model performance; lastly, attributed prompts achieve the performance of simple class-conditional prompts while utilizing only  $5\%$  of the querying cost of ChatGPT associated with the latter<sup>2</sup>.
Large language models (LLMs) have demonstrated exceptional performance across a broad range of NLP tasks [3, 39, 28, 37, 38, 58]. In recent research, LLMs have been proposed as training data generators, particularly for text classification, aiming to alleviate the need for task-specific data and annotations [54, 15, 55, 31, 57, 6]. While these efforts have showcased the effectiveness of LLMs as data generators, the focus has primarily been on advancing the training stage, where the generated data are utilized to train task-specific models, leaving the upstream data generation process relatively unexplored. Notably, the prevailing approach employs a simple class-conditional prompt for querying LLMs during data generation, potentially limiting the diversity of the generated data [6, 51] and inheriting systematic biases inherent in LLMs [13, 60, 24]. We refer to this simple class-conditional prompt as SimPrompt, providing an example in Table 1.
In this work, we ground the LLM to ChatGPT [38] for its ability to generate high-quality, human-like text, and consider four challenging topic classification tasks with high cardinality from various domains. Our investigation primarily revolves around assessing the bias and diversity present within the generated training set through the lens of data attributes. In particular, data attributes encompass multiple attribute dimensions and their corresponding attribute values, where the latter represent
2The data and code are available on https://github.com/yueyu1030/AttrPrompt.
Figure 1: The overall workflow of AttrPrompt.
Table 1: Prompt template for the NYT news dataset.
Method	Prompt
SimPrompt	Suppose you are a news writer. Please generate a {topic-class} news in NYT.
AttrPrompt	Suppose you are a news writer. Please generate a {topic-class} news in NYT following the requirements below:1. Should focus on {subtopic};2. Should be in length between {length:min-words} and {length:max-words} words;3. The writing style of the news should be {style};4. The location of the news should be in {location}.
possible instantiations of the former. For example, an attribute value such as "shorter than 200 words" could serve as an instantiation of the attribute dimension "length".
On one hand, we employ a trained attribute classifier to examine the attribute bias present in the dataset generated using SimPrompt. When analyzing the "location" attribute in the NYT news dataset, we observe a striking bias towards "North America" in the predicted values of the generated data, accounting for a significant majority (68.01%). In contrast, instances associated with "Africa" are remarkably rare, comprising only 0.69% of the dataset (100 times less prevalent than "North America"). This regional bias exhibited in the generated dataset can pose substantial challenges when constructing reliable machine learning models [27, 4].
On the other hand, we explore the influence of attribute diversity on the downstream model performance. Specifically, we leverage ChatGPT to generate attributed data by incorporating desired attributes as constraints in the prompts. By comparing the performance of models trained on datasets generated using prompts with random attributes against those with fixed attributes, we observe a substantial underperformance of the latter, uncovering the importance of attribute diversity of the generated dataset. The workflow of AttrPrompt is shown in Figure 1.
To alleviate attribute biases and enhance the attribute diversity of the generated data, we propose to generate data with diversely attributed prompts. For a given classification task, we start by identifying attribute dimensions and their corresponding attribute values in an interactive, semi-automated process facilitated by the LLM. Subsequently, we generate diverse prompts by combining attributes randomly, replacing the simple class-conditional prompt typically used for querying data from the LLM. We refer to these diversely attributed prompts as AttrPrompt. An example of such prompts can be found in Table 1, where the LLM is instructed to generate training data based on attributes such as location and style.
On the four classification tasks, we empirically evaluate the generated datasets by measuring the performance of models trained using two scenarios: 1) solely on the generated dataset, and 2) on a merged dataset comprising the real training set and the generated set. In both scenarios, the dataset generated with AttrPrompt significantly outperforms its counterpart generated with SimPrompt. Furthermore, we demonstrate the superiority of AttrPrompt over SimPrompt in terms of data/budget
efficiency and compatibility with different model sizes/ various LLM-as-training-data-generator approaches. Notably, AttrPrompt achieves the performance of SimPrompt while utilizing only  $5\%$  of the querying cost of ChatGPT associated with SimPrompt. Lastly, we extend the LLM-as-training-data-generator paradigm to the more challenging multi-label classification tasks for the first time, and AttrPrompt outperforms SimPrompt across all evaluation metrics.
LLMs as Training Data Generators. With the remarkable success of large language models (LLMs), researchers have recently attempted to leverage them as training data generators. Such applications include generating tabular data [2], medical dialogue [7], sentence pairs [47], instruction data [40, 50, 53, 48], etc.. Among these applications, we anchor on training data generation for topic classification in a zero-shot setting where no labeled data is available. In this direction, existing approaches typically use simple class-conditional prompts while focusing on mitigating low-quality issues after generation. In particular, SuperGen [31] and ZeroGen [54] took initial steps to explore using LLM as a training data generator for text classification with simple class-conditional prompts, and leveraged additional noise robust learning techniques [26, 36, 52] to deal with the low-quality issue of the generated data. SunGen [15] reweights the generated data during training with learned data quality weight, and ProGen [55] leverages the model feedback to select highly influential generated data which then serve as labeled examples for generation. In this work, we instead explore attributed prompts to reduce the issue of low informativeness and redundancy, which can be readily incorporated into the existing systems mentioned above. Notably, Chen et al. [6] also explores prompts to advance the data generation process, yet it adopts soft prompts and requires a white-box LLM and seed examples to tune them. In contrast, our method is applicable to black-box LLMs and even LLM APIs (e.g., ChatGPT) and does not rely on any labeled examples. Similarly, WANLI [29] also considers human-AI collaboration for creating more challenging training data, but requires an initial dataset and a strong task model. Instead, we aim to generate training data without any initial dataset or a pre-existing task model, which allows us to effectively handle resource-limited scenarios.
Discrete Prompt Optimization. Several works attempt to optimize discrete prompts for querying LLMs, such as prompt paraphrasing [22], prompt editing [42], or prompt searching [11]. Recently, [45, 59, 35] use large language models to optimize prompts. More related to us, [34] reframe prompts by decomposing a complex task instruction into multiple simple ones. However, these approaches mainly focus on the inference stage for directly predicting the answer and may rely on additional labeled examples for validation. Our focus is on an orthogonal setting, optimizing prompts for LLMs with attributes to diversify the generated training data. This approach improves the model's overall performance without the need for additional labeled examples.
3 Large Language Model as Attributed Training Data Generator
While previous research has primarily focused on binary classification datasets [54, 31, 55] or datasets containing a maximum of 14 classes [15, 57], the performance of LLM as a data generator for topic classification with high cardinality (i.e., many topic classes) remains unclear. Thus, we consider the following datasets from various domains with the number of topics ranging from 23 to 50:
- NYT [32]: The NYT dataset comprises news articles that were authored and published by The New York Times. These articles are categorized into 26 fine-grained categories.
- Amazon [1]: The Amazon dataset contains customer reviews on products from Amazon's online store. It covers products from 23 different categories.
- Reddit [17]: The Reddit dataset consists of a vast collection of user-generated content from the popular social media platform Reddit. It encompasses a wide range of topics, discussions, and interactions among users across numerous communities.
- **StackExchange [17]:** The StackExchange dataset is a rich collection of structured data encompassing various online communities and knowledge-sharing platforms. It contains a vast array of questions, answers, comments, tags, and user interactions about specific technical problems.
Table 2: Statistics of datasets.
Dataset	Domain	Task	# Train	# Valid	# Test	# Class	Imbalance Ratio
Amazon [1]	Reviews	Multi-class	15.0K	0.2K	1.2K	23	155.6
NYT [32]	News	Multi-class	9.0K	0.2K	1.2K	26	357.0
Reddit [17]	Web	Multi-class	26.6K	0.2K	2.3K	45	447.4
StackExchange [17]	Web	Multi-class	27.0K	0.3K	2.5K	50	1283.7
Table 3: Attribute dimensions and values. Attributes with an asterisk* are class-dependent attributes.
Dataset	# configurations / class	Attribute dimension	Attribute value
NYT	600	Subtopic*	Appendix H.1.1
Location	Asia, North America, South America, Africa, Oceania, Europe
Writing Style	Investigative journalism, Op-Eds, Feature writing, News analysis, Profiles and interviews
Length	short (30-80 words); long (100-150 words)
Amazon	1000	Product Brands*	Appendix H.2.1
Product Names*	Appendix H.2.2
Usage Experience	Worst, Bad, Average, Good, Excellent
Writing Style	Detailed Review; Comparative Review; Pros and Cons Review; Recommendation Review
Length	short (30-80 words); long (100-150 words)
Reddit	500	Resources*	Appendix H.3.1
Experience*	Appendix H.3.2
Writing Style	Informative/Educational; Entertaining/Funny; Discussion; Storytelling; Help/Advice
Length	short (30-80 words); long (100-150 words)
StackExchange	400	Scenario*	Appendix H.4.1
Technical Depth	Beginner; Intermediate; Advanced; Expert
Writing Style	Specific; Comparative; Problem-Solution; Troubleshooting; Tutorial
Length	short (30-80 words); long (100-150 words)
We summarize the statistics of used dataset in Table 2, from which we can see that the involved datasets not only have high cardinality but also come with high imbalance ratio, i.e., the ratio of the sample size of the majority class to that of the minority class, which reflects the long-tail class issue in real applications.
3.2 Attributes
Our initial step involves identifying various types of data attributes (or metadata) that can be manipulated to generate attributed data samples. To facilitate this process, we employ ChatGPT to help establish both attribute dimensions and attribute values. Specifically, we begin by engaging ChatGPT in generating essential attribute dimensions. This is achieved by posing questions such as "Which attribute dimensions do you consider vital in determining the topic of a news article?" for the NYT dataset, resulting in responses like "subtopics, length, location, reader group, style, time". Then, we manually select the attribute dimensions of the highest quality that best suit the dataset. Similarly, we prompt ChatGPT (the prompt format is listed in Appendix G) to suggest potential attribute values within each attribute dimension and choose high-quality candidates.
Attribute dimensions and values. There are two types of attribute dimensions: class-independent attributes and class-dependent attributes. Class-independent attributes, such as "length", remain unchanged across different classes, while class-dependent attributes, like "subtotal", have varying attribute values for each class. We list attribute dimensions and values for all datasets in Table 3. These data attributes provide a human-manipulatable interface for generating attributed data. In this study, we explore the potential of leveraging attributes to enhance the data generation process, while leaving the search for the optimal data attributes for a specific task to future work.
Class-dependent attribute value filtering. When dealing with class-dependent attributes, it is crucial to ensure that their attribute values are specifically associated with the corresponding class to avoid ambiguity and potential connections to multiple classes. For example, in the case of the "economy" class in the NYT dataset, a candidate attribute value generated by ChatGPT for the "subtopic" could be "effect of trade tariffs on manufacturing companies", which is also relevant to the "international business" class in the NYT. This overlap may introduce ambiguity in the generated data. To address this issue, we employ a filtering process called Class-Dependent Attribute Value Filtering (CAF). First, we query ChatGPT for the top-5 similar classes and then check with ChatGPT whether each class-dependent attribute value is related to these top-5 similar classes. Then, if the answer is positive which indicates a potential ambiguity, we remove that attribute value for the specific class.
3.3 Data generation and model training
Given the data attributes, one could prompt LLMs to generate data samples with diverse attribute configurations. For example, an attribute configuration for the "federal budget" class of the NYT dataset could be {"subtopic"="defense spending", "length"="short:min-words=30, max-words=80", "style"="investigative journalism", "location"="North America"}. In Table 3, we list the number of configurations per class, and one can further expand the number of configurations by adding more attribute dimensions and values. To generate attributed data samples, we prompt ChatGPT with random configurations. In particular, each time we generate a random configuration, complete a prompt template (see Table 1) with the generated configuration, and query ChatGPT with the completed prompt to collect generated data samples.
Throughout the experiments, we compare our method (AttrPrompt) against simple class-conditional prompt (SimPrompt, [54]) and the original training set of each dataset (Gold). For a fair comparison, we set the number of generated data the same as Gold for both AttrPrompt and SimPrompt. In principle, the generated dataset can be combined with any classifier (Sec. 5.4) and training techniques (Sec. 5.5); if not otherwise specified, we choose to fine-tune BERT-base-uncased [12] as the backbone and use the standard cross-entropy loss by default. For hyperparameter selection, we adhere to the recommendation in [41, 31] for SimPrompt and AttrPrompt, and do not use the validation set for model selection. Detailed hyperparameter configurations can be found in Appendix C.
4 Analysis of the Generated Data
4.1 A glimpse of the generated data
We begin by presenting examples of data generated by AttrPrompt and SimPrompt, and real data from the Gold set for the "federal budget" class in the NYT dataset (Table 4). It is evident that the data generated by ChatGPT exhibit high quality. Particularly, when comparing AttrPrompt to SimPrompt, we observe that AttrPrompt renders more diverse samples. This is because SimPrompt tends to generate news focused on the U.S., while AttrPrompt has the capability to generate news from various locations around the world.
Table 4: Data examples of different datasets: the "federal budget" class of the NYT dataset.
Method	Example
Gold	1. The emergency manager who was sent to reverse the fortunes of this financially troubled city asked some of its creditors on Friday to accept pennies on the dollar as he laid out his plan for tackling Detroit's staggering debt, kick starting negotiations that could determine whether the city is headed to bankruptcy court...2. Saying that its debt could reach 45 billion by 2017 if Congress does not act, the Postal Service on Wednesday called on lawmakers to give it the flexibility to change its business model to keep itself solvent3. Governmental Affairs Committee, Patrick R. Donahoe, the postmaster general, asked Congress to give the Postal Service permission to run its own health plan for employees and retirees, modify a Congressional mandate that requires the agency to pay...
SimPrompt	1. Washington D.C. The United States government has recently passed its federal budget for the next fiscal year, setting aside a whopping 4.8 trillion for spending. This is the largest budget in the country's history and reflects the government's commitment to improving the country's economy and infrastructural development.2. WASHINGTON D.C. The Trump administration released its proposed budget for the federal government on Monday, calling for cuts to programs that provide assistance to low income Americans while increasing military spending. The proposed budget includes a 10 percent increase in defense spending, bringing the total military budget to 574 billion...3. Washington D.C. The U.S. federal government has presented its budget for the fiscal year 2022, which includes a total of 6 trillion in spending and initiatives aimed at making the country more competitive and sustainable. The budget plan includes significant investments in infrastructure, healthcare, education, and renewable energy.
AttrPrompt	1. In Germany, public opinion on federal budget issues has been influenced by The Federal Agency for Civic Education. Using in depth storytelling, this agency communicates budget policies to citizens, emphasizing their impact on society. Its efforts have led to greater engagement and awareness of budget issues among the public in recent years.2. Op Eds The Government Spending Priorities in Mexico As the Mexican federal budget draws near, all eyes are on the government's spending priorities. One area of concern is the role of the Banco de Mexico in managing the country's finances. Many experts argue that the central bank should play a more active role in balancing the budget and stimulating economic growth...3. TOKYO The recent federal budget proposal has triggered a wave of agency budget cuts and restructuring in Japan, with the Japan Foundation for Regional Development being one of the latest casualties. The foundation, which aims to promote regional development and revitalization, is set to have its budget slashed by 20 next year.
Then, we show the vocabulary size of the generated dataset and the Gold dataset, which is a natural way to check the lexical diversity of datasets (Table 5). From the table, we can see that AttrPrompt has higher lexical diversity than SimPrompt in terms of both vocabulary size of the whole dataset (All in the table) and the averaged vocabulary size across classes (Class Avg. in the table). Yet, both have much smaller vocabulary sizes than the Gold, indicating there is still room for improvement of the ChatGPT's lexical diversity.
Lastly, we visualize the diversity of datasets via the distribution of cosine similarity of same-class text pairs (Figure 2), where the cosine similarity is calculated based on the embedding of SentenceBERT [44], as well as including two additional metrics, namely average pairwise sample similarity (APS) and inter-sample  $N$ -gram Frequency (INGF) [33], as shown in table 6. We can see that the Gold dataset has the lowest cosine similarity, indicating that real data has the largest diversity. In contrast, the similarity between samples generated by SimPrompt is high Compared to SimPrompt,
Table 5: Comparison of the vocabulary size of different datasets.
Method	NYT	Amazon	Reddit	StackExchange
All	Class Avg.	All	Class Avg.	All	Class Avg.	All	Class Avg.
Gold	70.8k	11.3k	44.7k	6.64k	50.8k	4.62k	52.3k	3.60k
SimPrompt	20.6k	3.13k	11.6k	2.50k	19.9k	3.06k	13.3k	2.20k
AttrPrompt	21.4k	3.50k	14.0k	2.76k	25.4k	3.64k	17.8k	2.93k
Table 6: Comparison of two quantitative metrics on diversity: the average pairwise sample similarity (APS) and inter-sample N-gram frequency (INGF) of different datasets. For APS, the lower stands for better diversity. For INGF, the higher stands for better diversity.
Method	NYT	Amazon
Inter-Class APS	Intra-Class APS	APS	INGF	Inter-Class APS	Intra-Class APS	APS	INGF
Gold	0.098	0.358	0.122	7618.1	0.101	0.251	0.114	4992.1
SimPrompt	0.101	0.568	0.135	5277.2	0.207	0.620	0.241	2266.5
AttrPrompt	0.159	0.474	0.182	6688.6	0.225	0.483	0.246	2605.5
Reddit	StackExchange
Inter-Class APS	Intra-Class APS	APS	INGF	Inter-Class APS	Intra-Class APS	APS	INGF
Gold	0.044	0.261	0.054	9079.6	0.056	0.196	0.063	5492.4
SimPrompt	0.173	0.818	0.201	2697.8	0.282	0.804	0.302	2259.8
AttrPrompt	0.106	0.474	0.122	3994.5	0.105	0.375	0.114	2464.3
(a) NYT
(b) Amazon
(c) Reddit
Figure 2: The distribution of cosine similarity of text pairs sampled from the same class.
(d) StackExchange
dataset generated with AttrPrompt exhibits lower cosine similarity and the distribution is close to that of the Gold, which shows AttrPrompt could render more diverse data. Apart from the above automatic evaluation processes, we also conduct human study in Appendix E to manually evaluate the quality of the generated training data.
4.2 Is there attribute bias in real and generated data?
We study the attribute bias in both real dataset (Gold) and generated dataset of SimPrompt using dataset generated by AttrPrompt as a probe. In particular, we leverage the attributes associated with each data of AttrPrompt to train an attribute classifier, which is in turn used to make attribute predictions on Gold and SimPrompt dataset. Note that the attribute values associated with each data of AttrPrompt are not necessary the ground truth, yet since ChatGPT has shown remarkable performance in following instructions [39], the generated data could decently reflect the desired attributes and therefore the attribute classifier trained with them could partially reveal the underlying attribute distribution of tested dataset, i.e., Gold and SimPrompt.