Supporting Qualitative Analysis with Large Language Models: Combining Codebook with GPT-3 for Deductive Coding

Ziang Xiao, Xingdi Yuan, Q. Vera Liao, Rania Abdelghani, Pierre-Yves Oudeyer · DOI

Abstract

Qualitative analysis is a cornerstone of social science and Human-Computer Interaction (HCI), yet it remains a labor-intensive process. This paper investigates the potential of Large Language Models (LLMs), specifically GPT-3, to automate deductive coding—the process of labeling text based on a pre-defined codebook. By framing codebooks as prompts, we evaluate the model's performance in zero-shot and few-shot classification tasks. Our results indicate that GPT-3 can achieve fair to substantial agreement with human experts, offering a promising path for researchers to scale qualitative analysis without requiring extensive machine learning expertise or massive labeled datasets.

Introduction

The primary challenge in qualitative research is the "bottleneck" of manual coding. Researchers often spend hundreds of hours manually labeling thousands of text snippets. While traditional machine learning offers solutions, unsupervised models like topic modeling often lack the nuance required for specific research questions, and supervised models require prohibitively large training sets. This study explores whether LLMs can act as "digital research assistants," applying codebook definitions to new data with minimal prior examples.

Methods

We utilized the GPT-3 (davinci-text-002) model with a temperature of 0.0 to ensure deterministic results. The experimental design focused on two prompt structures:

  1. Codebook-centered: Structured like a manual with code names, descriptions, and examples.
  2. Example-centered: Structured as a series of rationales (e.g., "Text A is Code X because...").

We further varied the number of "shots" (examples) provided: Zero-shot (definitions only), One-shot (one example per code), and Few-shot (five examples per code). To prime the model, an "identity modifier" was included, casting the AI as an expert developmental psychologist.

Datasets

The evaluation used a dataset of 668 curiosity-driven questions asked by children in French. Two distinct tasks were performed:

  • Question Complexity: A binary semantic task (Simple Fact vs. Complex Mechanism) performed on English translations.
  • Syntactic Structure: A four-category linguistic task (e.g., interrogative syntax) performed on the original French text to preserve grammatical nuances.

Results

Performance was measured using Cohen’s Kappa ($\kappa$), which adjusts for agreement occurring by chance.

Question Complexity

For the semantic task of determining question complexity, GPT-3 achieved a maximum $\kappa$ of 0.61, indicating "substantial agreement" with human experts. The model performed best when using a codebook-centered prompt with few-shot examples.

Cohen’s κ for Question Complexity across different prompt types and shot counts.

Syntactic Structure

The model found the linguistic task more challenging. It achieved a maximum $\kappa$ of 0.38, representing "fair agreement." This disparity highlights a "semantic-syntactic gap," where the model excels at understanding broad meaning but struggles with formal grammatical rules compared to human experts who maintain high agreement ($\kappa = 0.90$).

Cohen’s κ for Syntactic Structure, showing lower agreement compared to semantic tasks.

Key Insights

  • Prompt Structure Matters: The "Codebook-centered" approach consistently outperformed the example-centered approach, suggesting LLMs are adept at following structured instructional manuals.
  • The Power of One: The most significant performance gain occurred when moving from zero-shot to one-shot. Adding further examples (few-shot) provided only marginal improvements, suggesting that a single "gold standard" example per category is highly efficient for researchers.
  • Human-AI Gap: Despite strong performance, human experts still maintain a significantly higher level of inter-rater agreement, indicating that LLMs are currently best suited as support tools rather than full replacements.

Discussion and Future Work

While LLMs show great promise, they should be integrated into research workflows with caution. We recommend using LLMs for a "first pass" of coding to identify broad patterns, followed by human verification. Future research should focus on developing "machine-readable" codebooks optimized for LLM interpretation and exploring inductive coding, where AI assists in discovering new themes from raw data.

Summary updated

BibTeX
@inproceedings{xiao2023supporting,
  author = {Ziang Xiao and Xingdi Yuan and Q. Vera Liao and Rania Abdelghani and Pierre-Yves Oudeyer},
  title = {{Supporting Qualitative Analysis with Large Language Models: Combining Codebook with GPT-3 for Deductive Coding}},
  booktitle = {IUI Companion},
  year = {2023},
  doi = {10.1145/3581754.3584136},
}
Figure