Prompt Selection Matters: Enhancing Text Annotations for Social Sciences with Large Language Models

Louis Abraham, Charles Arnal, Antoine Marie · DOI

Abstract: Large Language Models have recently been applied to text annotation tasks from social sciences, equalling or surpassing the performance of human workers at a fraction of the cost. However, no inquiry has yet been made on the impact of prompt selection on labelling accuracy. In this study, we show that performance greatly varies between prompts, and we apply the method of automatic prompt optimization to systematically craft high quality prompts. We also provide the community with a simple, browser-based implementation of the method at https://prompt-ultra.github.io/ .

Introduction

Social scientists frequently encounter the challenge of categorizing massive volumes of text data—ranging from identifying political slant in news headlines to detecting hate speech in social media posts. Traditionally, this labor-intensive process required either expensive human experts or the development of complex, custom-trained machine learning models.

The advent of Large Language Models (LLMs) like GPT-4 has revolutionized this workflow, offering expert-level annotation at a fraction of the traditional cost. However, LLMs are notoriously sensitive to the specific phrasing of instructions. This study addresses a critical gap in the literature: how much does prompt selection actually matter for social science tasks, and can we automate the discovery of optimal prompts?

Methodology

To investigate the impact of prompt engineering, we compared two primary approaches across seven diverse social science classification tasks:

  1. Hand-crafted Heuristics: We tested five common strategies from the prompt engineering literature:
  2. Simple: Minimalist instructions.
  3. Explanations: Including specific definitions of terms (e.g., defining "hate speech").
  4. Examples: Providing "few-shot" labeled examples within the prompt.
  5. Roleplay: Instructing the model to adopt a specific professional persona (e.g., "Act as a political analyst").
  6. Chain of Thought (CoT): Requiring the model to explain its reasoning step-by-step before providing a final label.
  7. Automatic Prompt Optimization (APO): Rather than manual iteration, we utilized an LLM to iteratively refine its own instructions. Starting with a base prompt, the model generated variations which were evaluated on a small validation subset (400 samples). The best-performing prompts were then "mutated" over 15 generations to evolve a high-performing final instruction set.

The Prompt Ultra Tool

To facilitate the adoption of these techniques by the research community, we developed Prompt Ultra. This browser-based tool allows researchers to upload datasets and run automatic prompt optimizations without requiring any programming knowledge.

The Prompt Ultra interface for automated text annotation and prompt optimization.

Experimental Results

Our evaluation spanned seven datasets, including TweetEval (Hate, Emotion, Sentiment, and Offensive Language), TML-sent (multilingual sentiment), AS-pol (US news political inclination), and LibCon (Reddit political classification).

Performance Variability and the "18% Gap"

A central finding of this study is that there is no universal "best" prompt. Performance is highly task-dependent; for instance, Chain of Thought may excel in hate speech detection but underperform in sentiment analysis. Crucially, the difference between the best and worst hand-crafted prompts reached as high as 18% in F1 score. For researchers, this variance represents the difference between high-quality, publishable data and fundamentally flawed results.

Comparison of F1 scores across different prompting strategies and datasets.

The Success of APO

Automatic Prompt Optimization (APO) emerged as a robust, "consistently good" baseline. It achieved the highest scores in four out of seven tasks—specifically TML-sent (69.2%), AS-pol (55.4%), and LibCon (74.4%)—and remained highly competitive in the others. While APO requires more API calls to test variations, the financial cost remains negligible (often under $10) compared to human labor.

Discussion and Limitations

While LLMs offer significant advantages, we identified several critical challenges:

  • Data Leakage: GPT-3.5 performed significantly better on the training sets of well-known public benchmarks (like TweetEval) than on their corresponding test sets. This suggests the models may have memorized parts of these datasets during pre-training, posing a risk for researchers using public benchmarks to validate LLM performance.
  • Replicability: The constant updates to proprietary models mean that a prompt's performance may drift over time.
  • Complexity: Our study focused on short-to-medium texts; further research is required to determine if these optimization patterns hold for long-form documents or highly nuanced tasks where human experts frequently disagree.

Conclusion

Prompt selection is not a trivial detail but a primary determinant of annotation accuracy in social science research. By utilizing Automatic Prompt Optimization and tools like Prompt Ultra, researchers can systematically improve the reliability of their text annotations while minimizing the need for manual prompt engineering.

Summary updated

BibTeX
@article{abraham2025prompt,
  author = {Louis Abraham and Charles Arnal and Antoine Marie},
  title = {{Prompt Selection Matters: Enhancing Text Annotations for Social Sciences with Large Language Models}},
  journal = {J. Comput. Soc. sci},
  year = {2025},
  doi = {10.1007/s42001-025-00388-6},
}
Figure