ContextGen: Targeted Data Generation for Low Resource Domain Specific Text Classification

Lukas Fromme, Jasmina Bogojeska, Jonas KuhnAISTATS 2022

Introduction

Training high-performing text classifiers typically requires substantial labeled datasets. However, in specialized domains such as medical research or contract law, data is often scarce and expert labeling is prohibitively expensive. These "low-resource" settings are further complicated when tasks are non-topical—requiring the identification of subtle semantic qualities like user intent, subjectivity, or legal rights rather than simple keyword matching.

To address these challenges, we present ContextGen, a targeted data augmentation approach designed for specialized, low-resource scenarios. ContextGen leverages pre-trained large language models (LLMs) to generate synthetic training data without requiring expensive fine-tuning of the generator, thereby avoiding the risks of overfitting and memorization common in small-data regimes.

Methodology

ContextGen operates through a three-step pipeline: context construction, generation, and label assignment.

Context Construction

Rather than using generic prompts, ContextGen uses "cues" or "contexts" derived from the existing small dataset to guide a pre-trained GPT-2 model. Two primary strategies were evaluated:

  1. Sentence-beginning context: The prompt consists of the start of an existing sentence up to the first noun phrase.
  2. Attention-target context: A BERT classifier identifies the words it "attends" to most (the most task-relevant words), which are then used as the prompt.

Generation and Labeling

These cues are fed into a vanilla, pre-trained gpt2-medium model. Grounding the prompt in the domain allows the model to generate stylistically and contextually appropriate text. For label assignment, the authors compared Inherited labels (assigning the source sentence's label) and Ensemble Voting (using an ensemble of 10 BERT classifiers trained on the original small dataset to predict the label for synthetic sentences).

Experimental Results

The effectiveness of ContextGen was evaluated across four binary classification tasks: medical abstracts (DISONLY), legal rights (RIGHT), terms-of-service fairness (TOS), and a subjectivity baseline.

Performance of ContextGen across four datasets compared to no augmentation.

As shown in the performance plots above, ContextGen consistently outperforms the "No Augmentation" baseline. The performance gains are most pronounced at the smallest sample sizes (50 and 100 sentences). For instance, on the TOS dataset with 100 training samples, ContextGen improved the F1 score by 0.16 over the baseline.

Analysis: Diversity vs. Fidelity

A critical factor in data augmentation is the balance between generating data that is faithful to the domain and providing enough diversity to aid generalization.

Comparison of copied sentences and vocabulary overlap between basic and attention-target contexts.

Analysis of the generated text reveals that the "Sentence-beginning" (Basic) context often leads to higher vocabulary overlap and a greater frequency of copied sentences. In contrast, the "Attention-target" approach forces the model to be more creative, resulting in lower overlap and better generalization, particularly for very small datasets where the classifier's attention highlights the most informative features.

Conclusion

ContextGen demonstrates that large language models can act as effective "creative partners" for data augmentation in specialized domains without the need for fine-tuning. By using targeted contextual cues, researchers can significantly boost classifier performance in data-starved environments, providing a practical and cost-effective path for specialized NLP tasks.

Summary updated

BibTeX
@inproceedings{fromme2022contextgen,
  author = {Lukas Fromme and Jasmina Bogojeska and Jonas Kuhn},
  title = {{ContextGen: Targeted Data Generation for Low Resource Domain Specific Text Classification}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2022},
}
Figure