Hostname: page-component-76d6cb85b7-mgxrv Total loading time: 0 Render date: 2026-07-16T13:16:28.947Z Has data issue: false hasContentIssue false

Codebook LLMs: Evaluating LLMs as Measurement Tools for Political Science Concepts

Published online by Cambridge University Press:  19 September 2025

Andrew Halterman*
Affiliation:
Department of Political Science, Michigan State University , East Lansing, MI, USA
Katherine A. Keith
Affiliation:
Department of Computer Science, Williams College , Williamstown, MA, USA
*
Corresponding author: Andrew Halterman; Email: halterm3@msu.edu
Rights & Permissions [Opens in a new window]

Abstract

Codebooks—documents that operationalize concepts and outline annotation procedures—are used almost universally by social scientists when coding political texts. To code these texts automatically, researchers are increasingly turning to generative large language models (LLMs). However, there is limited empirical evidence on whether “off-the-shelf” LLMs faithfully follow real-world codebook operationalizations and measure complex political constructs with sufficient accuracy. To address this, we gather and curate three real-world political science codebooks—covering protest events, political violence, and manifestos—along with their unstructured texts and human-coded labels. We also propose a five-stage framework for codebook-LLM measurement: Preparing a codebook for both humans and LLMs, testing LLMs’ basic capabilities on a codebook, evaluating zero-shot measurement accuracy (i.e., off-the-shelf performance), analyzing errors, and further (parameter-efficient) supervised training of LLMs. We provide an empirical demonstration of this framework using our three codebook datasets and several pre-trained 7–12 billion open-weight LLMs. We find current open-weight LLMs have limitations in following codebooks zero-shot, but that supervised instruction-tuning can substantially improve performance. Rather than suggesting the “best” LLM, our contribution lies in our codebook datasets, evaluation framework, and guidance for applied researchers who wish to implement their own codebook-LLM measurement projects.

Information

Type
Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https://creativecommons.org/licenses/by/4.0), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2025. Published by Cambridge University Press on behalf of The Society for Political Methodology
Figure 0

Table 1 Descriptive statistics about the codebook datasets.

Figure 1

Figure 1 BFRS codebook as part of an LLM prompt. From the BFRS codebook, this is a (truncated to 2/12 labels) example of how the codebook is formatted as the LLM input.

Figure 2

Figure 2 Zero-shot output generated by Mistral-7B given the full BFRS prompt, an excerpt of which appears in Figure 1. We deterministically match the first part of the beginning of the output with the set of valid labels to determine the predicted label.

Figure 3

Figure 3 Label-free behavioral test results on the BFRS dataset. For all tests, higher numbers are better (see Table 2 for details of each test). For Test IV, dashed lines are the Fleiss Kappa heuristics from Landis (1977).

Figure 4

Table 2 Proposed behavioral tests for codebooks.

Figure 5

Table 3 Zero-shot weighted F1 scores for each LLM on each development dataset.

Figure 6

Table 4 Codebook ablation results for zero-shot predictions from Mistral-7B on the BFRS development dataset.

Figure 7

Figure 4 Labels-required behavioral tests of the two LLMs on the BFRS development dataset (see Table 2 for details of each test).

Figure 8

Table 5 Manual error analysis results on a sample of the zero-shot generative outputs for Mistral-7B given each development dataset.

Figure 9

Table 6 Results of the LLMs after instruction-tuning on each training dataset.

Supplementary material: File

Halterman and Keith supplementary material

Halterman and Keith supplementary material
Download Halterman and Keith supplementary material(File)
File 499.5 KB