Abstract
Researchers often rely on humans to code (label, annotate, etc.) large sets of texts. This kind of human coding forms an important part of social science research, yet the coding process is both resource intensive and highly variable from application to application. In some cases, efforts to automate this process have achieved human-level accuracies, but to achieve this, these attempts frequently rely on thousands of hand-labeled training examples, which makes them inapplicable to small-scale research studies and costly for large ones. Recent advances in a specific kind of artificial intelligence tool - language models (LMs) - provide a solution to this problem. Work in computer science makes it clear that LMs are able to classify text, without the cost (in financial terms and human effort) of alternative methods. To demonstrate the possibilities of LMs in this area of political science, we use GPT-3, one of the most advanced LMs, as a synthetic coder and compare it to human coders. We find that GPT-3 can match the performance of typical human coders and offers benefits over other machine learning methods of coding text. We find this across a variety of domains using very different coding procedures. This provides exciting evidence that language models can serve as a critical advance in the coding of open-ended texts in a variety of applications.
Introduction
Social science research frequently encounters a significant bottleneck during the "coding" phase—the labor-intensive process of manually labeling thousands of text snippets to transform qualitative information into quantitative data. Traditionally, researchers have faced a "pick two" dilemma between accuracy, scale, and cost. Human coding is nuanced but slow and expensive; dictionary methods are fast but lack context; and supervised machine learning (SML) requires massive amounts of hand-labeled training data.
This paper explores whether Large Language Models (LLMs), specifically GPT-3, can break this trilemma. By utilizing "few-shot" classification, these models can potentially learn complex coding tasks from just a few examples, drastically reducing the resources required for large-scale textual analysis.
Methodology: Prompt Engineering as Synthetic Coding
The researchers employed GPT-3 (the 175B parameter model) as a "synthetic coder." Rather than traditional training or fine-tuning, they used Prompt Engineering to guide the model. Each prompt consisted of four key components:
- Instructions: A clear description of the coding task.
- Categories: The set of possible labels for classification.
- Exemplars: One to three labeled examples demonstrating the desired logic and output format.
- Target Text: The specific data point to be classified.
Performance was evaluated by comparing GPT-3’s output against both undergraduate assistants and highly trained human coders using standard reliability metrics like Intraclass Correlation (ICC) and Fleiss’ Kappa.
Datasets and Experimental Design
To ensure generalizability, the study tested GPT-3 across four distinct datasets:
- Pigeonholing Partisans (PP): Open-ended descriptions of political supporters.
- Congressional Hearing Summaries: Technical policy-topic categorization of government proceedings.
- New York Times Headlines: Classification of front-page headlines into 28 policy categories.
- The Guardian Populism (TGP): Identifying complex "populist" rhetoric pitting "the people" against "the elite."
Key Insights
Several surprising findings emerged regarding the behavior of LLMs in coding tasks:
- The Three-Exemplar Plateau: Accuracy peaks remarkably early. While 2–3 examples significantly improve performance over zero-shot attempts, adding dozens more provides negligible marginal benefit.
- Format over Logic: The model appears to use exemplars primarily to understand the required output format rather than to learn deep underlying logic. Testing "prototypical" versus "tricky" examples showed little difference in final accuracy.
- Robustness: The model remained stable despite minor changes in prompt formatting, suggesting that LLM-based coding does not require excessive "prompt tuning" to be effective.
- Quantifiable Bias: Unlike the "unknowable" and varying biases of human coders, LLM biases are invariant and quantifiable, making them easier to identify and potentially correct.
Results and Performance Comparison
GPT-3 demonstrated performance comparable to human coders across multiple domains. In the Congressional and New York Times datasets, the level of agreement between GPT-3 and humans was as high as the agreement between the human coders themselves.
On the challenging "Populism" task, GPT-3 achieved 79% accuracy with only four examples. In contrast, a traditional Support Vector Classifier (SVC) required 3,000 hand-labeled examples to reach 86% accuracy. Furthermore, integrating GPT-3 as an additional coder in a group of humans often increased the overall reliability of the resulting dataset.
Limitations and Future Directions
Despite its promise, LLM-based coding has specific constraints. The "First Token" problem requires researchers to ensure category names begin with unique words to avoid prediction errors. There is also the potential for training data contamination, although the model's success on private survey data suggests its capabilities are broadly generalizable. Finally, ethical considerations remain paramount, as LMs can amplify human biases. Future research should focus on calibration techniques to mitigate these biases during the coding process.
Summary updated