Introduction
In political science and sociology, "text coding"—the systematic labeling of text according to theoretical categories—is a fundamental yet resource-intensive process. Researchers often face a "triple threat" of challenges: high conceptual complexity, dense domain-specific jargon, and severe resource constraints. Traditional manual coding is slow and expensive, while earlier NLP methods require massive amounts of hand-labeled data. This study investigates whether modern Large Language Models (LLMs) can bridge this gap, specifically within the context of Swedish parliamentary documents.
Methodology
The researchers evaluated several proprietary and open-source models, including GPT-4, GPT-3, Llama-2-13b, Mixtral-8x7b, and the Nordic-focused GPT-SW3. The dataset consisted of 1,910 sentences from the Swedish parliament (Riksdagen) spanning 1993–2021, focused on fatherhood roles.
To optimize performance, the team employed various prompt engineering strategies:
- Few-shot Prompting: Providing 15 labeled examples versus zero-shot attempts.
- Codebook Integration: Testing the impact of "short" versus "long" (full) label descriptions.
- Multi-tasking: Prompting models to code three interdependent dimensions (involvement, explicitness, and normativeness) simultaneously.
Performance was benchmarked against a validation set of 350 sentences coded by three independent political scientists.
Performance Benchmarks
The study found that LLMs perform best when treated like human trainees. By providing the model with the full codebook (long descriptions) and specific examples, performance improved significantly. GPT-4 emerged as the top performer, reaching the "frontier" of human-level accuracy.
As shown in the figure above, GPT-4 achieved an F1 score of 61.7, surpassing the average human-to-human agreement of 57.5. Notably, the progression from basic GPT-3 to a few-shot, long-description configuration demonstrates the critical role of prompt engineering in achieving expert-level results.
Economic and Operational Efficiency
Beyond accuracy, the operational advantages of LLMs were stark:
- Speed: GPT-3 processed the entire dataset in 16 minutes, a task that would require approximately 19 hours for a human coder—a 270x speedup.
- Cost: The API costs for the entire corpus were approximately $93. In contrast, hiring three human coders was estimated to cost between $235 and $880.
- Open-Source Viability: While GPT-4 led on complex tasks, open-source models like Mixtral-8x7b proved highly effective for simpler binary classification tasks, offering a cost-effective alternative for less nuanced research.
Discussion and Conclusion
The study highlights that in social science, "ground truth" is often elusive due to the interpretive nature of the work. The relatively low human agreement scores (50-60%) reflect this inherent subjectivity. However, the ability of LLMs to handle complex legal jargon in a minority language (Swedish) while being prompted in English suggests a high degree of linguistic resilience.
The researchers conclude that LLMs are not just tools for automation but can act as "human-level" coders when provided with the same instructional depth as human experts. To facilitate further research, the authors have released their workflow software, PAPPA, on GitHub.
Summary updated