Manuscript Offprint
arXiv:2611.09457Definitions, Label Names, or Demonstrations? Auditing What Governs LLM Annotation
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Large language models (LLMs) are increasingly used to annotate social-science texts, but high accuracy does not establish that they apply researcher-supplied category definitions: predictions may instead reflect prior associations with category labels or labeled demonstrations. We introduce a counterfactual audit that reassigns definitions among output labels, distinguishing adherence to supplied definitions from preservation of a dataset's original mapping. Across three political-text datasets, models rarely follow reassigned definitions, and standard fine-tuning strengthens the original mapping without reliably increasing definition adherence. We then study retrieval-augmented annotation. Retrieving the nearest training examples generally outperforms retrieving examples separately within each category despite using fewer demonstrations. On the two tasks with substantial gains, direct k-nearest-neighbor classification recovers 74–93% of the improvement, indicating that neighborhood labels provide much of the predictive signal. Relabeling fixed demonstrations redirects predictions, whereas aligning demonstrations with reassigned definitions substantially increases adherence to the new mapping. Thus, accuracy-improving interventions need not increase codebook adherence; definitions, category labels, demonstrations, retrieval, and training data should be aligned and validated jointly. Code and data for all experiments are available at https://anonymous.4open.science/r/llm-annotation-FD2D.
1 Introduction
Social scientists use annotation codebooks to translate theoretical concepts into observable categories in text. The resulting annotations measure substantively important constructs, such as forms of protest, types of political violence, and policy positions in party platforms (Grimmer et al., 2022).
Large language models (LLMs) offer a scalable approach to producing such annotations and can approach or exceed crowd-worker performance on many classification tasks (Gilardi et al., 2023; Ziems et al., 2024; Törnberg, 2025). Yet predictive accuracy alone leaves a fundamental question unanswered: what annotation rule is the model actually applying?
A correct prediction may reflect the supplied definition in the codebook, prior associations with a category label, or patterns in labeled demonstrations. Because these sources normally imply the same answer, conventional evaluation cannot distinguish them. This matters for construct validity: a model may reproduce historical labels while failing to implement the researcher's intended operationalization, particularly when definitions change or prior annotations depart from the written rules.
Prior work shows that category labels, definitions, and demonstrations all affect LLM classification. Replacing informative labels with generic identifiers, swapping label–definition pairings, or ablating codebook components can substantially change performance (Halterman and Keith, 2026a), and models use definitions and demonstrations un-evenly (Milios et al., 2023; Mohammadi et al., 2025). We ask whether task-specific fine-tuning increases responsiveness to supplied definitions or strengthens reproduction of the original mapping, and how predictions respond when definition and demonstration mappings are varied independently.
We study how LLM annotators combine three sources of guidance: (1) category labels and their prior associations, (2) written definitions, and (3) labeled demonstrations. Our counterfactual audit reassigns definitions among output labels, placing the supplied definition mapping in conflict with the dataset's original mapping. We use it to test whether predictions follow the definitions, preserve the original mapping, or follow neither, and whether fine-tuning changes this behavior. We ex-
*Corresponding authors.
tend the framework to retrieval-augmented annotation. We compare Global Example-RAG, which retrieves the nearest examples across the training pool, with Class-wise Example-RAG, which retrieves examples separately within each category. Holding the retrieved texts fixed, we then independently manipulate definition and demonstration-label mappings to test which mapping governs predictions.
We ask four questions. Q1: When supplied definitions conflict with the original mapping, which mapping do LLM annotators follow? Q2: Do accuracy-improving interventions, including fine-tuning and retrieval, increase adherence to supplied definitions? Q3: How do retrieval strategy and neighborhood label composition affect annotation accuracy? Q4: When definitions and retrieved demonstrations encode conflicting mappings, which source governs predictions?
Across three political-text codebooks, models rarely treat reassigned definitions as authoritative, and fine-tuning reinforces the original mapping without reliably increasing definition adherence. On the more complex tasks, Global Example-RAG outperforms both Class-wise Example-RAG and annotation without retrieval, but direct nearest-neighbor classification recovers much of the gain. Relabeling fixed demonstrations redirects predictions; written definitions moderate but do not eliminate this influence. Thus, higher accuracy need not imply more faithful application of the supplied codebook.
We contribute a behavioral audit that separates definition adherence from preservation of the original mapping; controlled analyses of retrieval architecture, neighborhood composition, and demonstration mappings; and practical guidance for aligning and validating the label system, codebook, retrieval procedure, and demonstration bank as a joint measurement instrument.
Accuracy and codebook adherence. Codebook-based measurement research shows that definitions and other coding guidance affect predictions and downstream estimates (Halterman and Keith, 2026a,b). Recent studies more directly distinguish accuracy from responsiveness to supplied definitions: He et al. (2026) examine richer guidance and reassigned codebook labels, while Casanova et al. (2026) study how models' prior concept knowledge interacts with additional instructions and examples; related perturbation studies also find inconsistent adherence to external definitions (Mohammadi et al., 2025). We extend this work by asking whether fine-tuning increases adherence to reassigned definitions and how that adherence changes when we independently vary definition and demonstration mappings while holding retrieved texts fixed.
Retrieved demonstrations and label mappings. Retrieving examples similar to the text being classified can improve in-context classification, including political-text and many-category tasks (Liu et al., 2022; Milios et al., 2023; Liu and Shi, 2024). What models learn from those examples is less clear. Randomizing demonstration labels sometimes has limited effects, but models can also learn novel mappings from demonstrations and lose accuracy when input-label pairs are corrupted (Min et al., 2022; Wei et al., 2023; Milios et al., 2023). Moreover, nearby labeled examples can support classification without an LLM (Cover and Hart, 1967; Milios et al., 2023). We therefore compare retrieval strategies and benchmark the LLM against direct k-nearest-neighbor classification using the same neighborhood. Whereas prior retrieval studies generally evaluate performance under the original label mapping, we manipulate their labels and cross demonstration and definition mappings to examine responses to conflicting guidance.
3 Methods
3.1 Conceptual Framework
A codebook combines output labels with category entries. An LLM may draw on the entries' substantive content, prior associations with labels, and labeled demonstrations; standard performance can-not separate these sources when they encode the same mapping. Throughout, definition denotes a category entry's substantive content, including any clarifications and codebook-provided examples; codebook information denotes the complete label-and-entry information supplied in a prompt. Codebook adherence means following the active definition-label assignment, with definition adherence denoting the corresponding audit outcome. We call a labeled training item an example before retrieval and a demonstration once it is placed in the prompt.
We separate the three sources by reassigning definitions, comparing retrieval architectures with direct nearest-neighbor prediction, and independently manipulating definition and demonstration mappings. Applying the audit before and after fine-tuning tests whether higher standard performance entails greater definition adherence.
3.2 Counterfactual Codebook Audit
Let denote the label-definition units included in an audit. We construct a counterfactual codebook by assigning each definition to a different label:
where is a derangement, so for every category. For a text from human-labeled category , the original mapping supports , whereas the reassigned definition supports . The entry remains unchanged; only its attached label is replaced.
We classify a prediction as Definition if it equals , Original if it equals , Other if it is another valid output label, and Invalid otherwise. These outcomes identify which mapping a prediction matches, not the information source that produced it. The intervention is diagnostic rather than a proposed alternative taxonomy.
We repeat the audit after task-specific fine-tuning; paired changes in definition and original-label agreement distinguish responsiveness to the supplied mapping from stronger reproduction of the original one.
3.3 Example Retrieval and Mechanism Analysis
Global Example-RAG retrieves the nearest training examples and presents them as a shared demonstration block, producing a query-specific neighborhood that may concentrate on few categories.
| Condition | Definitions | Demo labels |
| Original | Original | Original |
| Reassigned definitions | Reassigned | – |
| Reassigned demos | – | Reassigned |
| Definition conflict | Reassigned | Original |
| Demo conflict | Original | Reassigned |
| Aligned | Reassigned | Reassigned |
Table 1: Conditions crossing the mappings encoded by definitions and demonstrations. A dash indicates that the corresponding source is not supplied.
Class-wise Example-RAG retrieves within each category and attaches the demonstrations to its codebook entry, guaranteeing coverage but potentially including weakly relevant texts. Their comparison tests query-specific against category-balanced retrieval.
We then compare Global Example-RAG with direct -nearest-neighbor classification using the same retrieved examples and examine neighborhood label composition, testing how much gain is already encoded in the local input-label structure.
3.4 Interventions on Demonstration Labels
Demonstrations may help through their texts or their input-label associations. We distinguish these mechanisms by relabeling fixed retrieved texts.
Pairwise label swaps. We swap a frequent label pair while holding the query, retrieved texts, order, and codebook fixed. Movement toward the substituted labels shows influence beyond the texts' semantic content. Comparing prompts with and without codebook information tests whether the full codebook prompt reduces this influence; because these are complete prompt conditions, we interpret the contrast as a prompt-level rather than a pure definition effect.
Crossed definition and demonstration mappings. We independently vary the mappings encoded by definitions and demonstration labels. Category label names retain their original forms in all conditions. Table 1 summarizes the mappings used in this work.
The single-source conditions assess reassigned definitions and demonstrations separately against the original label names. Definition conflict combines reassigned definitions with original demonstration labels; Demo conflict combines original definitions with reassigned demonstration labels; and Aligned makes both sources support the reassigned mapping.
Comparing Definition conflict with Aligned isolates the mapping encoded by demonstration labels: the definitions and retrieved texts remain fixed, while the demonstration labels change from the original to the reassigned mapping. Increased reassigned-mapping agreement under Aligned would show that consistently relabeled demonstrations can help implement the supplied definition mapping.
Comparing Demo conflict with Reassigned demos instead tests whether adding original codebook information restores original-label agreement when demonstrations support the reassigned mapping. This is a definition-specific comparison only when the output-label menu and task instructions are otherwise identical; if they differ, it estimates the effect of adding the complete codebook prompt. Comparing Demo conflict with Aligned more directly isolates the mapping encoded by definitions because both conditions contain the same reassigned demonstrations and differ only in the definition-label mapping.
4 Experimental Setup
4.1 Datasets
We use the human-labeled training, development, and test splits of three political-text datasets prepared by Halterman and Keith (2026a). CCC contains U.S. news reports of protest events (Crowd Counting Consortium, 2024); BFRS, reports of political violence in Pakistan categorized partly by actors, targets, and forms of violence (Bueno de Mesquita et al., 2015); and Manifesto, party-platform sentences classified by policy (Lehmann et al., 2017). We retain all eight CCC and 12 BFRS categories and, after collapsing duplicate output labels, 49 Manifesto categories (Table 7).
Training examples support retrieval and fine-tuning; development data select retrieval depth, and test data provide final evaluation.
4.2 Models and Prompt Construction
Mistral is the primary model. The fine-tuning audit uses Mistral-7B-Instruct-v0.2 and Llama-3.1-8B-Instruct; retrieval and crossed-mapping analyses also use Llama-3.3-70B to vary family and scale. Appendix A gives model versions, decoding, and chat templates; Tables 12 and 6 report additional open-weight models.
Prompt conditions provide labels only, codebook information only, demonstrations only, labels with demonstrations, or codebook information with the same demonstrations. CCC and BFRS use their full codebooks. Manifesto label-only prompts list all 49 retained labels, while codebook prompts generally present the 30 retained entries most similar to the query. Controlled comparisons that vary codebook information while holding the available labels fixed use all 49 Manifesto entries. Dataset descriptions, Manifesto context, and output instructions remain fixed (Appendix F).
4.3 Audit and Fine-Tuning Implementation
The zero-shot audit presents the retained codebook without demonstrations. We evaluate ten independent rearrangements on 1,000 documents per dataset; supporting 200-document analyses use one rearrangement (Appendix B).
For each fine-tuning model, we train one LoRA adapter per dataset on the human-labeled training set (Hu et al., 2022), yielding six adapters. Base and fine-tuned models use the same documents and rearrangements. All adapters share training settings and are distinct from standard-performance baselines (Appendix B).
4.4 Retrieval and Intervention Implementation
After removing training texts duplicated in the evaluation split, we rank training examples by cosine similarity using all-mpnet-base-v2; labels are attached only after retrieval. On development data, Mistral selects k = 8, 10, and 20 for Manifesto, CCC, and BFRS, fixed thereafter. Direct kNN predicts the modal retrieved label, breaking ties by summed similarity.
Class-wise Example-RAG retrieves two demonstrations per represented category (98, 10, and 24 for Manifesto, CCC, and BFRS). Matched-budget Global conditions separate retrieval strategy from count. Manifesto retrieval is restricted to its 49 retained labels. Additional retrieval, leakage, prompt-placement, and constrained-decoding controls appear in Appendix C.
The pairwise intervention swaps WEL-FARE_POSITIVE/ENVIRONMENTALISM_POSITIVE (Manifesto), PROTEST/RALLY (CCC), and ASSASSINATION/TERRORISM (BFRS). Retrieval precedes relabeling, and neighbors are reused across crossed-mapping conditions. Paired comparisons hold fixed the query, texts, order, count, category order, label menu, instructions, decoding, and parser except for the manipulated
| Dataset | Definition | Original | Other | Invalid |
|---|---|---|---|---|
| CCC | 10.75 (4.0) | 55.80 (6.4) | 32.35 (6.9) | 1.10 (0.5) |
| BFRS | 12.87 (6.5) | 20.93 (4.0) | 65.34 (6.1) | 0.86 (0.9) |
| Manifesto | 3.24 (1.9) | 30.25 (2.5) | 57.94 (2.3) | 8.57 (1.3) |
Table 2: Zero-shot audit outcomes for Mistral-7B, in percent, across ten definition-label rearrangements (mean with standard deviation in parentheses; 1,000 documents per dataset).
component. For the supporting full-reassignment analysis, we test five rearrangements with Mistral and one with Llama-3.3-70B; additional controls appear in Appendix E.
4.5 Evaluation and Uncertainty
Standard performance is weighted against human labels; Appendix Table 14 reports macro-. Counterfactual uses the supplied mapping. The audit also reports Definition, Original, Other, and Invalid outcomes; in crossed conditions, reassigned-mapping agreement replaces definition adherence when demonstrations may support .
For pairwise swaps, we report weighted- loss and the rate at which baseline predictions in the swapped pair change to the paired label.
All direct comparisons use the same evaluation documents. Retrieval analyses use 500 document-level bootstrap resamples for individual scores and 2,000 paired resamples for differences, with common draws across conditions.
The fine-tuning audit uses 5,000 hierarchical paired-bootstrap replicates, resampling rearrangements and then documents within them with common draws across checkpoints. Counterfactual is calculated over valid outputs; invalid outputs are reported separately.
5 Results
5.1 Original-Label Agreement Exceeds Definition Adherence
To test whether models follow supplied definitions when they conflict with the original mapping, we reassign definitions among output labels. Under reassignment, original-label agreement exceeds definition adherence on all three datasets: 55.80% versus 10.75% on CCC, 20.93% versus 12.87% on BFRS, and 30.25% versus 3.24% on Manifesto (Table 2). Predictions therefore more often preserve the original mapping; definition adherence varies across rearrangements, particularly on BFRS, but remains low on average.
| Definition | Original | |
|---|---|---|
| Mistral-7B | ||
| CCC | -3.92 [-8.13, -0.25] | +10.81 [+6.90, +15.41] |
| BFRS | -0.18 [-3.20, +2.84] | +29.44 [+24.13, +34.46] |
| Manifesto | -0.12 [-0.99, +0.73] | +7.78 [+5.89, +9.60] |
| Llama-3.1-8B | ||
| CCC | -2.97 [-4.80, -1.21] | +9.93 [+7.99, +11.88] |
| BFRS | +1.15 [-3.96, +5.73] | +18.96 [+14.39, +23.14] |
| Manifesto | +1.96 [+0.73, +3.19] | +4.63 [+2.54, +6.70] |
Table 3: Paired percentage-point changes from base to fine-tuned models across ten definition-label rearrangements, with 95% confidence intervals in brackets.
CCC has the highest original-label agreement, potentially reflecting its small label space and informative names such as rally and march. BFRS has the lowest original-label agreement and most valid predictions matching neither mapping. Manifesto has the lowest definition adherence and highest invalid rate, consistent with selection among 49 labels.
5.2 Fine-Tuning Reinforces the Original Mapping, Not Definition Adherence
We compare base and LoRA-fine-tuned models on the same 1,000 documents under the same ten rearrangements to test whether fine-tuning increases responsiveness to supplied definitions.
Fine-tuning increases original-label agreement in all six model-dataset combinations (4.63–29.44 points) and all 60 rearrangement-level comparisons (Table 3). Definition adherence decreases on CCC for both models, changes unreliably in three combinations, and increases only for Llama on Manifesto; even there, its 1.96-point gain is smaller than the 4.63-point original-label gain.
Standard weighted also improves (Appendix B); better standard performance can therefore reflect reproduction of original annotations without greater definition adherence. The audit tests adoption of a revised label–definition mapping, not new category boundaries.
5.3 Global Retrieval Gains Largely Reflect Neighborhood Labels
To assess the effect and mechanism of retrieval, we compare Global and Class-wise Example-RAG and then analyze Global retrieval in greater detail. Global retrieval is evaluated with demonstrations alone and with codebook information. All conditions retain the Original mapping in Table 1.
| Prompt information | Manifesto dev/test | CCC dev/test | BFRS dev/test |
|---|---|---|---|
| Mistral-7B | |||
| Label only | .394/.394 | .647/.665 | .441/.449 |
| Codebook only | .416/.404 | .639/.658 | .545/.548 |
| Global: demo only | .563/.555 | .696/.710 | .782/.778 |
| Global: codebook+demo | .580/.551 | .691/.677 | .794/.774 |
| Class-wise: codebook+demo | .538/.513 | .667/.668 | .738/.719 |
| Llama-3.3-70B | |||
| Label only | .465/.443 | .665/.664 | .591/.591 |
| Codebook only | .495/.485 | .682/.652 | .707/.704 |
| Global: demo only | .615/.610 | .680/.685 | .812/.805 |
| Global: codebook+demo | .583/.570 | .641/.639 | .813/.806 |
| Class-wise: codebook+demo | .543/.527 | .644/.644 | .773/.767 |
Table 4: Development/test weighted under the original mapping. Global conditions use 8, 10, and 20 demonstrations for Manifesto, CCC, and BFRS, respectively. Class-wise retrieval uses 98, 10, and 24 demonstrations. Matched-count Global comparisons appear in Table 11. Bold marks the best condition within each model, dataset, and split.
Retrieval architecture and performance. Retrieval generally improves weighted , most on Manifesto and BFRS. Adding Global demonstrations to Mistral's codebook prompt raises development/test from .416/.404 to .580/.551 on Manifesto and from .545/.548 to .794/.774 on BFRS (Table 4); CCC gains are smaller and model-dependent. Random demonstrations reduce in all 12 model–dataset–split comparisons, showing that relevant retrieval, rather than demonstrations alone, drives the gains (Appendix C.1). Macro- gains are uneven across categories, particularly on CCC (Appendix Table 14).
Despite using more demonstrations, Class-wise retrieval underperforms Global demo-only in all 12 comparisons and Global codebook+demo in 10; the other differences are at most .005. At matched demonstration counts, Global retrieval also significantly outperforms Class-wise retrieval on Manifesto and BFRS for both models and splits (Appendix Table 11). We therefore focus on Global retrieval.
Predictive information in the retrieved neighborhood. Global demo-only outperforms codebook-only prompting in 11 of 12 paired bootstrap comparisons and exceeds label-only prompting numerically in all 12 (Appendix Figure 3). Adding label names or codebook information after retrieval has smaller, sometimes negative effects, suggesting that the neighborhood supplies most of the improve-

Figure 1: Weighted- difference between Global codebook-plus-demonstrations prompting and direct kNN using the same demonstrations. Positive values favor the LLM prompt; error bars show paired 95% confidence intervals. The numeric results are in Table 16
ment.
Direct kNN using the same retrieved examples recovers 74%/75% of Mistral's Global codebook+demo gain on Manifesto development/test and 88%/93% on BFRS, relative to codebook-only. We omit CCC because its small, prompt-dependent gain makes the ratio unstable. Global codebook+demo exceeds kNN in five of six model–dataset pairs, but only by .015–.056 weighted ; the exception is Llama on CCC (Figure 1). Thus, neighborhood labels explain most of the gain on Manifesto and BFRS, with a smaller contribution from the complete LLM prompt.
The modal label averages 52.5%, 70.0%, and 75.9% of retrieved demonstrations on Manifesto, CCC, and BFRS, providing a strong local predictive signal. The LLM's advantage is largest when leading labels have similar similarity support; with unanimous labels, kNN matches or exceeds the LLMs (Appendix D).
5.4 Definitions and Demonstrations Compete Under Conflict
We compare the conditions defined in Table 1 to determine which mapping governs predictions when definitions, demonstrations, and category-label associations disagree.
Codebook information partially counters conflicting demonstrations. With labels reassigned away from the original mapping, Reassigned demos yields test of .402–.594, below the corresponding Global labels-demonstrations scores in all six comparisons (Table 18). Adding the original codebook prompt (Demo conflict) recovers .005–.048 in five comparisons but loses .028 for Llama on CCC (Table 5). Demo conflict remains .027–.376 below
| Dataset | Original target | Reassigned target | |||
|---|---|---|---|---|---|
| Orig. | Demo conflict | Reassigned demos | Def. conflict | Aligned | |
| Mistral-7B | |||||
| Manifesto | .551 | .466 | .439 | .415 | .529 |
| CCC | .677 | .515 | .488 | .221 | .567 |
| BFRS | .774 | .455 | .407 | .370 | .739 |
| Llama-70B | |||||
| Manifesto | .570 | .543 | .538 | .433 | .563 |
| CCC | .639 | .566 | .594 | .279 | .597 |
| BFRS | .806 | .430 | .402 | .392 | .793 |
Table 5: Test weighted under original, conflicting, and aligned mappings. Targets follow the column group; Table 1 defines the conditions. Reassigned demo omits codebook information. Retrieved texts remain fixed.
Original, so codebook information only partially counters conflicting demonstration labels.
Alignment supports the reassigned mapping. Under Definition conflict, reassigned-target is low. Relabeling the same demonstrations to match the definitions (Aligned) increases test by .114-.401, with all paired differences significant.
Alignment nevertheless does not fully recover performance under the original mapping. Across development and test sets, Aligned remains significantly below Original in ten of twelve comparisons and is statistically indistinguishable in the other two. Alignment substantially improves performance under the reassigned mapping, but usually does not recover performance under the original mapping.
When every definition receives a different label, Mistral's mean test rises from .021-.025 under Definition conflict to .485-.704 under Aligned, significantly for every reassignment; Llama shows the same direction under its single rearrangement (Appendix E).
Overall, demonstrations strongly influence the followed mapping: the original codebook only partially offsets reassigned labels, whereas alignment sharply increases adherence to the new mapping.
6 Discussion
Accuracy does not establish codebook adherence. Across datasets, models more often preserve the original mapping than follow reassigned definitions. Fine-tuning consistently increases original-label agreement but does not consistently increase definition adherence. Better standard performance can therefore reflect reproduction of his-
torical annotations rather than application of the active codebook. This inference rests on behavioral agreement with competing mappings. The audit distinguishes which mapping predictions match but does not identify their internal cause. Its counterfactual mappings serve as diagnostic tests rather than proposed taxonomies.
Retrieval primarily supplies local supervision. Global Example-RAG generally outperforms Class-wise Example-RAG, including at matched demonstration counts, favoring a focused, query-specific neighborhood over broad category coverage. This comparison does not isolate relevance from label concentration because the architectures change both. Direct kNN recovers 74–93% of the gain on Manifesto and BFRS, showing that neighborhood labels provide much of the predictive signal. The LLM's smaller contribution is concentrated in neighborhoods with competing labels. Retrieval can therefore improve accuracy by supplying a local input–label mapping rather than improving definition use.
Definitions and demonstrations exert competing influence. Reassigned demonstration labels redirect predictions, and the original codebook only partially counters this effect. Aligning demonstrations with reassigned definitions sharply improves performance under the new mapping, although it usually remains below performance under the original mapping. Codebook information can therefore counter conflicting demonstrations without consistently overriding them. Definitions are therefore neither ignored nor uniformly authoritative: their influence depends on whether demonstrations instantiate the same mapping.
Implications for LLM-assisted measurement. The label system, codebook, demonstration bank, retrieval procedure, and fine-tuning data jointly constitute the measurement instrument. Changing only definitions may leave the model following an earlier policy encoded elsewhere. Researchers should therefore evaluate these components jointly, supplementing standard accuracy checks with controlled tests of how predictions respond when definition and demonstration-label mappings are varied independently. Counterfactual auditing provides a stress test before model-generated annotations become substantive measurements.
7 Conclusion
LLM annotation should be evaluated as a joint measurement system in which written definitions, category labels, demonstrations, and training data all shape predictions. Our counterfactual audit separates definition adherence from preservation of a dataset's original mapping. Across three tasks, models rarely followed reassigned definitions; fine-tuning reinforced the original mapping, and retrieval gains largely reflected neighborhood labels. Relabeling demonstrations redirected predictions, while aligning them with definitions increased adherence. For social science measurement, predictive accuracy and responsiveness to the researcher's coding rules are therefore distinct evaluation goals. Counterfactual auditing makes this distinction testable by placing normally aligned sources of guidance in controlled conflict, helping researchers assess what conventional accuracy measures leave unresolved.
Limitations
We study three English-language political-text datasets and selected open-weight models; other models may balance definitions, labels, and demonstrations differently. Reassignment preserves category meanings, so it tests responsiveness to a supplied label-definition mapping rather than learning new category boundaries. Agreement also does not reveal internal causal mechanisms. Our claims concern observable behavior under controlled conflicts that hold queries, retrieved texts, ordering, decoding, and parsing fixed.
Our conflict tests use predefined label swaps and reassignments while holding category content and retrieved texts fixed. They isolate responses to disagreement between mappings, but do not establish how models respond to isolated mislabeled examples or ambiguities in the wording of codebook entries.
References
Louis Abraham, Charles Arnal, and Antoine Marie. 2025. Prompt selection matters: Enhancing text annotations for social sciences with large language models. Journal of Computational Social Science, 8(3):1–20. Article 73.
Meysam Alizadeh, Maël Kubli, Zeynab Samei, Shirin Dehghani, Mohammadmasiha Zahedivafa, Juan D. Bermeo, Maria Korobeynikova, and Fabrizio Gilardi. 2025. Open-source LLMs for text annotation: A practical guide for model setting and fine-tuning. Journal of Computational Social Science, 8:17.
Ethan Bueno de Mesquita, C. Christine Fair, Jenna Jordan, Rasul Bakhsh Rais, and Jacob N. Shapiro. 2015. Measuring political violence in pakistan: Insights from the BFRS dataset. Conflict Management and Peace Science, 32(5):536–558.
Etienne Casanova, Rafal Kocielnik, and R. Michael Alvarez. 2026. On the limits of LLM adaptability: Impact of model-internalized priors on annotation task performance. In Proceedings of the 43rd International Conference on Machine Learning, volume 306 of Proceedings of Machine Learning Research, pages 11976–12000. PMLR.
Thomas Cover and Peter Hart. 1967. Nearest neighbor pattern classification. IEEE Transactions on Information Theory, 13(1):21–27.
Crowd Counting Consortium. 2024. crowdcounting.org.
Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, and Luke Zettlemoyer. 2023. QLoRA: Efficient fine-tuning of quantized LLMs. In Advances in Neural Information Processing Systems, volume 36, pages 10088–10115. Curran Associates, Inc.
Fabrizio Gilardi, Meysam Alizadeh, and Maël Kubli. 2023. ChatGPT outperforms crowd workers for text-annotation tasks. Proceedings of the National Academy of Sciences, 120(30):e2305016120.
Aaron Grattafori, Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, Abhishek Kadian, et al. 2024. The Llama 3 herd of models. arXiv preprint arXiv:2407.21783.
Justin Grimmer, Margaret E. Roberts, and Brandon M. Stewart. 2022. Text as Data: A New Framework for Machine Learning and the Social Sciences. Princeton University Press, Princeton, NJ.
Andrew Halterman and Katherine A. Keith. 2026a. Codebook LLMs: Evaluating LLMs as measurement tools for political science concepts. Political Analysis, 34(2):188–204.
Andrew Halterman and Katherine A. Keith. 2026b. What is a protest anyway? codebook conceptualization is still a first-order concern in LLM-era classification. In Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 2043–2059, San Diego, California, United States. Association for Computational Linguistics.
Zixian He, Bharath Raahul Murugesan, Patrick Brandt, and Yibo Hu. 2026. When better codebooks are not enough: Predictive performance and behavioral reliability in LLM political event coding. Preprint, arXiv:2606.06781.
Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. 2022. LoRA: Low-rank adaptation of large language models. In International Conference on Learning Representations.
Pola Lehmann, Theres Matthieß, Nicolas Merz, Sven Regel, and Annika Werner. 2017. Manifesto corpus. version: 2017b. Technical report, WZB Berlin Social Science Center, Berlin.
Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. 2022. What makes good in-context examples for GPT-3? In Proceedings of Deep Learning Inside Out (DeeLIO 2022): The 3rd Workshop on Knowledge Extraction and Integration for Deep Learning Architectures, pages 100–114, Dublin, Ireland and Online. Association for Computational Linguistics.
Menglin Liu and Ge Shi. 2024. PoliPrompt: A high-performance cost-effective LLM-based text classification framework for political science. Preprint, arXiv:2409.01466v1. Version 1, 2 September 2024.
Aristides Milios, Siva Reddy, and Dzmitry Bahdanau. 2023. In-context learning for text classification with many labels. In Proceedings of the 1st GenBench Workshop on (Benchmarking) Generalisation in NLP, pages 173–184, Singapore. Association for Computational Linguistics.
Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannaneh Hajishirzi, and Luke Zettlemoyer. 2022. Rethinking the role of demonstrations: What makes in-context learning work? In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 11048–11064, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics.
Seyedali Mohammadi, Bhaskara Hanuma Vedula, Hemank Lamba, Edward Raff, Ponnurangam Kumaraguru, Francis Ferraro, and Manas Gaur. 2025. Do LLMs adhere to label definitions? examining their receptivity to external label definitions. In Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing, pages 32380–32393, Suzhou, China. Association for Computational Linguistics.
Nicholas Pangakis, Samuel Wolken, and Neil Fasching. 2023. Automated annotation with generative AI requires validation. Preprint, arXiv:2306.00176.
Petter Törnberg. 2024. Best practices for text annotation with large language models. Sociologica, 18(2):67–85.
Petter Törnberg. 2025. Large language models outperform expert coders and supervised classifiers at annotating political social media messages. Social Science Computer Review, 43(6):1181–1195.
Jerry Wei, Jason Wei, Yi Tay, Dustin Tran, Albert Weber, Yifeng Lu, Xinyun Chen, Hanxiao Liu,
Da Huang, Denny Zhou, and Tengyu Ma. 2023. Larger language models do in-context learning differently. Preprint, arXiv:2303.03846.
Caleb Ziems, William Held, Omar Shaikh, Jiaao Chen, Zhehao Zhang, and Diyi Yang. 2024. Can large language models transform computational social science? Computational Linguistics, 50(1):237–291.
A Implementation Details
Models. The retrieval analyses use Mistral-7B-Instruct-v0.2 and Llama-3.3-70B-Instruct. We also evaluate Llama-3.1-8B-Instruct and Gemma-7B-it under the three prompt conditions in Table 12. The fine-tuning audit uses Mistral-7B-Instruct-v0.2 and Llama-3.1-8B-Instruct. Additional zero-shot audit models are Llama-3-8B, Gemma-7B, and Llama-3.3-70B (Table 6). Because Llama-3-8B differs from Llama-3.1-8B, its zero-shot results are not a matched baseline for the adapters (Grattafiori et al., 2024).
Decoding and prompt assembly. For the retrieval analyses, all models use 4-bit (NF4) precision (Dettmers et al., 2023) and greedy decoding, with responses limited to 30 new tokens. The bootstrap intervals therefore capture variation across evaluation documents rather than variation from response sampling. Prompts contain a system message and a user message formatted with the model's chat template. Llama-3.3-70B retains a separate system turn; Mistral places the system message at the beginning of the user turn (Appendix F). The user message presents label information, preceding context (Manifesto only), source information, retrieved examples ordered by decreasing similarity, the document, and a final instruction to return only a label.
Parsing. The parser extracts the label following Label:. Responses that cannot be matched to an available label are recorded as Invalid. Table 13 reports these rates for free-text responses and compares predictive performance with generation restricted to valid labels.
B Audit Setup
Audit documents and label sets. After removing rows with missing labels, we select the first rows of each development file and use the same documents for every model, checkpoint, and rearrangement. The label distributions from first 1,000 rows for three datasets differ from the full development files by total variation distances of 0.000, 0.042, and
0.026, respectively. For the first 200 rows, used for Table 6, the corresponding distances are 0.052, 0.076, and 0.107. The main comparisons use 1,000 rows to obtain broader category coverage.
Rearrangements. Each rearrangement assigns every codebook entry to a different label, so no entry retains its original label. Definitions, clarifications, and codebook-provided examples remain together and unchanged; only the label attached to the entry changes. We generate ten independent rearrangements and use the same ten for every model and checkpoint.
Fine-tuning configuration. The six adapters are trained only on human-labeled training rows: 4,710 for CCC, 20,978 for BFRS, and 5,755 for Manifesto. Training uses cross-entropy loss, LoRA rank 8 with alpha equal to the rank, dropout 0.05, query and value projections, a learning rate of , one epoch with an effective batch size of 32, and 8-bit paged AdamW. All adapters use the same script and attention implementation. We evaluate base and fine-tuned models on the same 1,000 documents under the same ten rearrangements. Confidence intervals use 5,000 hierarchical paired-bootstrap resamples over rearrangements and documents, as described in the main text.
Performance under the original codebook. Fine-tuning improves weighted F1 under the original codebook in all six model-dataset combinations.
Additional zero-shot audit models. Table 6 extends the zero-shot audit to three additional models on the 200-document sample under one rearrangement.
C Retrieval Setup and Controls
Data accounting. Table 7 reports usable labeled rows and the training pools available for retrieval. Manifesto uses 49 distinct output labels. We exclude two unlabeled CCC development rows and retain the supplied human annotations without re-annotating the documents. Some identical training texts have conflicting labels: seven on Manifesto, forty on CCC, and five on BFRS.
Splits, leakage filtering, and codebook coverage. We select k on development data and hold it fixed for test evaluation. Exact-overlap filtering removes 23/1/69 training rows for Manifesto/CCC/BFRS
development evaluation and 17/0/48 for test evaluation. Table 15 evaluates additional similarity filtering and, for Manifesto, exclusion of examples from the query's own manifesto. The Manifesto 30-entry codebook contains the reference category for 92.9% of development and 93.6% of test documents. Replacing the 30-entry codebook with the full retained codebook significantly changes Mistral's F1 only in the development condition without examples (0.377 versus 0.416). CCC and BFRS prompts include all codebook entries. Figure 2 reports the development comparison used to select k.
All prompt conditions. Table 9 reports all six prompt conditions for both main models. The main-text headline table presents conditions 1, 2, 3, 5, and 6; the additional condition supplies label names with demonstrations. Figure 3 reports paired differences between prompt conditions. The two Manifesto comparisons that add codebook information use the full retained label set on both sides rather than the top-30 configuration in Table 9. Comparing codebook-only with demo-only prompting both removes codebook information and adds demonstrations. The instruction sentence also changes to describe the supplied information, so this contrast does not isolate a definition effect.
| Dataset | Outcome | Mistral-7B | Llama-3-8B | Gemma-7B | Llama-3.3-70B |
|---|---|---|---|---|---|
| CCC | Definition | 16.5 | 28.0 | 17.5 | 24.5 |
| Original | 56.0 | 45.5 | 29.0 | 57.0 | |
| Other | 27.5 | 26.5 | 53.5 | 18.5 | |
| Invalid | 0.0 | 0.0 | 0.0 | 0.0 | |
| BFRS | Definition | 6.0 | 18.0 | 4.0 | 24.5 |
| Original | 15.5 | 32.5 | 8.5 | 45.0 | |
| Other | 77.0 | 49.0 | 87.5 | 30.5 | |
| Invalid | 1.5 | 0.5 | 0.0 | 0.0 | |
| Manifesto | Definition | 3.0 | 7.0 | 2.5 | 0.0 |
| Original | 28.5 | 31.5 | 18.0 | 49.5 | |
| Other | 60.0 | 61.0 | 36.0 | 50.5 | |
| Invalid | 8.5 | 0.5 | 43.5 | 0.0 |
Table 6: Zero-shot audit outcomes for four models, as percentages of 200 documents under one rearrangement. Definition denotes agreement with the reassigned target; Original denotes agreement with the original human label; Other denotes another valid label; Invalid denotes an unparseable response.
| Manifesto | CCC | BFRS | |
|---|---|---|---|
| Document is aMedian words per document | sentence17 | article444 | report27 |
| Codebook entries | 142 | 8 | 12 |
| Labels ever used in the data | 55 | 5 | 12 |
| Labels scored | 49 | 5 | 12 |
| Train rows, usable | 5,755 | 4,710 | 20,978 |
| Dev rows, usable | 1,247 | 1,007 | 4,495 |
| Test rows, usable | 1,217 | 1,010 | 4,496 |
| Example pool, dev runs | 5,711 | 4,709 | 20,909 |
| Example pool, test runs | 5,717 | 4,710 | 20,930 |
Table 7: Dataset sizes and retrieval pools. Usable rows have human labels. Manifesto is scored on 49 retained output labels; CCC and BFRS use all observed labels. Retrieval pools contain usable training rows, restricted on Manifesto to those 49 labels, after removing texts also present in the evaluation split.
| Dataset | k=0 | k=3 | k=4 | k=5 | k=8 | k=10 | k=15 | k=20 |
|---|---|---|---|---|---|---|---|---|
| Manifesto | .416/.404 | .559*/.549 | .566/.557 | .566/.555 | .580/.551 | .568/.540 | .578/.542 | .579/.546 |
| CCC | .639/.658 | .654*/.672 | .650*/.679 | .662*/.649* | .671*/.687 | .691/.677 | .679/.685 | .679/.691 |
| BFRS | .545/.548 | .765*/.744* | .775*/.757* | .778*/.761* | .786*/.767* | .789/.769 | .792/.775 | .794/.774 |
Table 8: Values plotted in Figure 2
Global versus Class-wise at matched example counts. At matched example counts, Global retrieval significantly outperforms Class-wise retrieval on Manifesto and BFRS for both models and splits (Table 11). Holding the example count fixed shows that the advantage on Manifesto and BFRS is not explained by demonstration count, al-
though relevance and label composition still vary together.
Additional models. Table 12 evaluates three prompt conditions for Llama-3.1-8B and Gemma-7B alongside the two main models. Demo-only prompting produces higher F1 than label-only prompting for every model and dataset. Adding

Figure 2: Weighted F1 by the number of retrieved examples k for Mistral-7B with codebook information; k=0 supplies no examples. Dotted vertical lines mark the development-selected values used for test evaluation. Shading shows the 95% bootstrap interval for development F1 at the selected value. Beyond k=8, development F1 varies by at most 0.021 within each dataset.
| Condition | Manifesto dev/test | CCC dev/test | BFRS dev/test |
|---|---|---|---|
| Mistral-7B | |||
| 1 Label only | .394/.394 | .647/.665 | .441/.449 |
| 2 Codebook only | .416/.404 | .639/.658 | .545/.548 |
| 3 Global: demo only | .563/.555 | .696/.710 | .782/.778 |
| 4 Global: labels+demo | .518/.519 | .711/.703 | .764/.757 |
| 5 Global: codebook+demo | .580/.551 | .691/.677 | .794/.774 |
| 6 Class-wise: codebook+demo | .538/.513 | .667/.668 | .738/.719 |
| Llama-3.3-70B | |||
| 1 Label only | .465/.443 | .665/.664 | .591/.591 |
| 2 Codebook only | .495/.485 | .682/.652 | .707/.704 |
| 3 Global: demo only | .615/.610 | .680/.685 | .812/.805 |
| 4 Global: labels+demo | .611/.612 | .684/.689 | .813/.808 |
| 5 Global: codebook+demo | .583/.570 | .641/.639 | .813/.806 |
| 6 Class-wise: codebook+demo | .543/.527 | .644/.644 | .773/.767 |
Table 9: Development/test weighted F1 under the original mapping for all six prompt conditions. Conditions 3 to 5 use the selected k (8/10/20); condition 6 supplies two examples per represented category (98/10/24). Individual 95% confidence intervals are approximately ±0.03 on Manifesto and CCC and ±0.012 on BFRS. Paired bootstrap comparisons appear in Figure 3.
codebook information to demonstrations does not significantly improve performance on Manifesto or CCC.
Constrained decoding. Table 13 compares free-text generation with decoding restricted to valid labels. Across 48 recomputed prompt comparisons, no difference that is significant under free generation reverses direction, although six change statistical significance. For the larger model, adding codebook information to demo-only prompts still significantly lowers performance on the Manifesto and CCC test sets, but the development differences
are no longer significant. Constrained decoding can change responses that would otherwise produce valid labels, so its effect extends beyond preventing parsing failures.
Macro-F1. Table 14 reports macro-F1, giving each category equal weight. On CCC, codebook-only prompting exceeds codebook+demo prompting for both models. For Mistral, this reverses the ordering under weighted F1. The low retrieval coverage of rare categories in Appendix D helps explain why the two metrics give different assessments.
| Comparison, dataset | Dev [95% CI] | Test [95% CI] |
|---|---|---|
| Mistral-7B | ||
| 1→2: add codebook, no demos | ||
| Manifesto† | -.017 [-.045, +.010] | -.007 [-.034, +.019] |
| CCC | -.008 [-.035, +.019] | -.007 [-.035, +.020] |
| BFRS | +.104* [+.090, +.118] | +.100* [+.085, +.114] |
| 2→3: demos instead of codebook | ||
| Manifesto | +.147* [+.114, +.176] | +.151* [+.118, +.181] |
| CCC | +.057* [+.030, +.083] | +.052* [+.024, +.082] |
| BFRS | +.237* [+.221, +.252] | +.230* [+.214, +.245] |
| 3→4: add label list to demos | ||
| Manifesto | -.046* [-.066, -.024] | -.036* [-.058, -.015] |
| CCC | +.015* [+.000, +.032] | -.007 [-.023, +.010] |
| BFRS | -.018* [-.026, -.010] | -.020* [-.028, -.013] |
| 4→5: add codebook to labels+demos | ||
| Manifesto† | +.052* [+.030, +.072] | +.022* [+.002, +.043] |
| CCC | -.020* [-.040, -.001] | -.026* [-.044, -.006] |
| BFRS | +.030* [+.022, +.038] | +.017* [+.008, +.025] |
| Llama-3.3-70B | ||
| 1→2: add codebook, no demos | ||
| Manifesto† | +.016 [-.005, +.038] | +.029* [+.010, +.050] |
| CCC | +.017 [-.004, +.039] | -.013 [-.034, +.007] |
| BFRS | +.117* [+.104, +.130] | +.113* [+.100, +.127] |
| 2→3: demos instead of codebook | ||
| Manifesto | +.120* [+.088, +.147] | +.125* [+.095, +.154] |
| CCC | -.002 [-.036, +.029] | +.034* [+.000, +.068] |
| BFRS | +.105* [+.093, +.117] | +.100* [+.088, +.113] |
| 3→4: add label list to demos | ||
| Manifesto | -.004 [-.021, +.013] | +.002 [-.016, +.020] |
| CCC | +.004 [-.019, +.026] | +.004 [-.018, +.027] |
| BFRS | +.001 [-.005, +.007] | +.003 [-.003, +.009] |
| 4→5: add codebook to labels+demos | ||
| Manifesto† | -.019* [-.036, -.002] | -.031* [-.050, -.012] |
| CCC | -.043* [-.066, -.022] | -.051* [-.072, -.029] |
| BFRS | -.000 [-.007, +.006] | -.002 [-.009, +.005] |
Table 10: Values plotted in Figure 3: paired change in weighted F1 from the earlier to the later prompt condition, numbered as in Table 9, with 95% paired bootstrap intervals (2,000 resamples). * marks an interval excluding zero. † marks Manifesto comparisons in which the codebook side uses all entries, so both conditions show the same labels.

Figure 3: Paired differences in weighted F1 for four prompt comparisons. Circles show development-set results and squares test-set results; positive values favor the later condition. Conditions are numbered as in Table 9. The Manifesto comparisons that add codebook information use the same 49 output labels in both conditions.
| Manifesto dev/test | CCC dev/test | BFRS dev/test | |
|---|---|---|---|
| Examples in prompt | 98 | 10 | 24 |
| Mistral-7B | |||
| Class-wise | .538*/.513* | .667*/.668 | .738*/.719* |
| Global, same count | .567/.543 | .691/.677 | .794/.782 |
| Llama-3.3-70B | |||
| Class-wise | .543*/.527* | .644/.644 | .773*/.767* |
| Global, same count | .597/.582 | .641/.639 | .819/.808 |
Table 11: Class-wise Example-RAG against Global Example-RAG with the same number of examples; both prompts include codebook entries. Weighted F1, development/test. * marks a Class-wise score whose paired difference from Global has a 95% bootstrap interval excluding zero; every starred difference favors Global.
C.1 Example-Selection Controls
Random selection uses the same example count as nearest-neighbor retrieval; balanced random selection also distributes examples across categories. Similarity filtering excludes examples with query cosine similarity at or above 0.85 (changes at a 0.90 threshold are at most 0.005). Source filtering, available only for Manifesto, excludes all training examples from the query’s manifesto. Table 15 reports these controls. Random selection significantly lowers F1 in all twelve model–dataset–split comparisons. Balanced random selection also lowers F1 throughout Manifesto and BFRS, but CCC differences are not consistently significant or negative. Changes under the leakage filters are at most 0.008, except when excluding examples from the same manifesto. The larger decline under source filtering indicates that part of the retrieval gain depends on examples from the query’s source.
D Retrieval Coverage and the Contribution of the Language Model
At the selected , development neighborhoods contain an average of 4.09 distinct labels on Manifesto (of 49), 3.02 on BFRS (of 12), and 2.46 on CCC (of 5). The most frequent label accounts for 52.5%, 75.9%, and 70.0% of retrieved examples, respectively; test shares differ by at most 0.1 points. Retrieved labels thus concentrate on a small set of categories, although the model can output other
| Prompt | Manifesto dev/test | CCC dev/test | BFRS dev/test |
|---|---|---|---|
| Mistral-7B | |||
| Label only | .394/.394 | .647/.665 | .441/.449 |
| Global: demo only | .563/.555 | .696/.710 | .782/.778 |
| Global: codebook+demo | .580/.551 | .691/.677* | .794*/.774 |
| Llama-3.1-8B | |||
| Label only | .402/.378 | .618/.582 | .461/.462 |
| Global: demo only | .533/.533 | .665/.678 | .770/.770 |
| Global: codebook+demo | .489*/.484* | .658/.668 | .774/.764 |
| Gemma-7B | |||
| Label only | .263/.263 | .598/.619 | .224/.207 |
| Global: demo only | .582/.571 | .608/.620 | .777/.771 |
| Global: codebook+demo | .570/.550* | .589/.585* | .766*/.764 |
| Llama-3.3-70B | |||
| Label only | .465/.443 | .665/.664 | .591/.591 |
| Global: demo only | .615/.610 | .680/.685 | .812/.805 |
| Global: codebook+demo | .583*/.570* | .641*/.639* | .813/.806 |
Table 12: Three prompts on four models, weighted F1, development/test, . * marks a codebook+demo score that differs from the same model's demo-only score (95% paired bootstrap interval excludes zero). Models are Mistral-7B-Instruct-v0.2, Llama-3.1-8B-Instruct, Gemma-7B-it, and Llama-3.3-70B-Instruct.
| Manifesto dev/test | CCC dev/test | BFRS dev/test | |
|---|---|---|---|
| Free-text answers that fail to parse (%), Mistral | |||
| 1 Label only | 5.1/6.6 | 0.9/1.0 | 4.1/3.9 |
| 2 Codebook only | 6.0/5.6 | 0.8/0.9 | 5.1/4.7 |
| 3 Demo only | 15.9/16.4 | 2.8/1.3 | 3.5/3.8 |
| 4 Labels+demo | 3.9/4.7 | 0.5/0.0 | 1.4/1.3 |
| 5 Codebook+demo | 3.8/2.9 | 0.3/0.2 | 0.6/0.6 |
| Constrained minus free, weighted F1, Mistral | |||
| 1 Label only | -.010*/-.016* | -.003/-.003 | +.004*/+.002 |
| 2 Codebook only | +.003/.000 | +.006*/-.004* | -.006*/-.006* |
| 3 Demo only | -.005/-.002 | +.009*/.000 | +.002/+.003 |
| 4 Labels+demo | -.006/-.008* | +.003/-.004* | .000/.000 |
| 5 Codebook+demo | -.001/-.005* | +.001/-.001 | .000/.000 |
| Constrained minus free, weighted F1, Llama-3.3-70B | |||
| 1 Label only | .000/+.006 | -.002/-.002 | .000/.000 |
| 2 Codebook only | +.003/+.009 | -.019*/-.028* | .000/.000 |
| 3 Demo only | -.002/-.001 | +.022*/+.026* | .000/.000 |
| 4 Labels+demo | +.002/-.007 | +.018*/+.026* | .000/-.001 |
| 5 Codebook+demo | +.014*/+.010 | +.040*/+.029* | .000/.000 |
Table 13: Constrained decoding against free text on the same documents. Top: share of free-text answers from which no valid label can be read; constrained decoding makes this zero. Middle and bottom: weighted F1 with decoding restricted to valid labels minus weighted F1 with free text. * marks a difference whose 95% paired bootstrap interval excludes zero. Conditions are numbered as in Table 9.
| Manifesto dev/test | CCC dev/test | BFRS dev/test | |
|---|---|---|---|
| Mistral-7B | |||
| Codebook only | .318/.283 | .382/.437 | .453/.438 |
| Demo only | .439/.432 | .357/.472 | .724/.706 |
| Codebook+demo | .457/.396 | .343/.430 | .732/.696 |
| Llama-3.3-70B | |||
| Codebook only | .387/.346 | .462/.480 | .667/.650 |
| Demo only | .526/.498 | .343/.451 | .768/.756 |
| Codebook+demo | .496/.442 | .309/.411 | .770/.759 |
| Direct kNN vote | .420/.390 | .306/.381 | .679/.671 |
Table 14: Macro-F1, development/test, giving equal weight to each category. Demo only and codebook+demo are the Global conditions. The direct kNN vote uses the same retrieved examples as the Global conditions.
| Dataset, model | Nearest | Random | Balanced random | Remove sim. ≥ .85 | Remove same source |
|---|---|---|---|---|---|
| Manifesto, Mistral | .580/.551 | .432*/.396* | .414*/.382* | .575*/.549* | .518*/.483* |
| CCC, Mistral | .691/.677 | .602*/.615* | .626*/.659 | .685/.680 | — |
| BFRS, Mistral | .794/.774 | .642*/.635* | .611*/.623* | .789*/.769* | — |
| Manifesto, 70B | .583/.570 | .485*/.490* | .482*/.481* | .581/.568 | .543*/.524* |
| CCC, 70B | .641/.639 | .606*/.610* | .638/.646 | .637/.634 | — |
| BFRS, 70B | .813/.806 | .735*/.732* | .704*/.703* | .806*/.804 | — |
Table 15: Development/test weighted F1 for example-selection controls with codebook information. Stars mark paired differences from nearest-neighbor retrieval whose bootstrap confidence intervals exclude zero.
labels. The reference label appears in the neighborhood for 84.1/83.5% of Manifesto, 94.1/95.8% of CCC, and 97.1/97.0% of BFRS development/test documents. Coverage is lower for rare categories: it is 66% for Manifesto development documents in the rarest third of categories and 12% for CCC DEMONSTRATION documents. This uneven coverage helps explain differences between weighted F1 and macro-F1.
Table 17 compares the Global codebook+demo prompt with the direct kNN vote in development subsets. The vote matches or exceeds both models when retrieved labels are unanimous. Both models have higher accuracy when neighborhoods contain at least four labels or the two leading labels have similar summed similarity. These descriptive comparisons locate the LLM’s additional predictive value in neighborhoods where labels compete; they do not establish a causal mechanism.
E Paired Changes to Codebook and Example Labels
The paired experiment uses the full retrieval development and test sets, fixed retrieved texts and order, and the selected example counts (8/10/20). Manifesto uses the 30-entry codebook from the corresponding original prompt; CCC and BFRS use their full codebooks. Table 1 defines the conditions. Reassigned demos supplies reassigned demonstrations with a label list and no definitions; for Manifesto, this list includes all 49 label names, whereas codebook prompts show 30 entries. The contrast between Reassigned demos and Demo conflict therefore changes the complete prompt, including the available label information. Table 19 separately reports switch rates for a demo-only prompt without a label list and for Demo conflict. A neutral-name control replaces familiar category names with identifiers under Definition conflict.
Weighted F1 uses the original human label as the target for Original, Demo conflict, and Reassigned demos, and the reassigned target for Definition
| Model | Dataset | Split | LLM | kNN vote | Difference [95% CI] |
|---|---|---|---|---|---|
| Mistral-7B | Manifesto | dev | .580 | .538 | +.042* [+.012, +.071] |
| test | .551 | .515 | +.037* [+.009, +.068] | ||
| CCC | dev | .691 | .639 | +.053* [+.028, +.078] | |
| test | .677 | .649 | +.029* [+.001, +.054] | ||
| BFRS | dev | .794 | .765 | +.029* [+.018, +.040] | |
| test | .774 | .760 | +.015* [+.005, +.025] | ||
| Llama-3.3-70B | Manifesto | dev | .583 | .538 | +.045* [+.017, +.074] |
| test | .570 | .515 | +.056* [+.027, +.087] | ||
| CCC | dev | .641 | .639 | +.002 [-.027, +.030] | |
| test | .639 | .649 | -.010 [-.041, +.018] | ||
| BFRS | dev | .813 | .765 | +.048* [+.037, +.058] | |
| test | .806 | .760 | +.046* [+.036, +.056] |
Table 16: Values plotted in Figure 1.
| Dataset, model | Unanimous LLM / vote | ≥ 4 labels LLM / vote | Closest support LLM / vote |
|---|---|---|---|
| Manifesto, Mistral | 83.1 / 93.8 | 48.5 / 41.9 | 47.6 / 28.9 |
| Manifesto, 70B | 89.2 / 93.8 | 50.7 / 41.9 | 49.2 / 28.9 |
| CCC, Mistral | 79.4 / 79.4 | 71.2 / 61.0 | 66.7 / 52.4 |
| CCC, 70B | 79.4 / 79.4 | 69.5 / 61.0 | 59.5 / 52.4 |
| BFRS, Mistral | 96.9 / 97.7 | 66.8 / 61.9 | 58.4 / 49.3 |
| BFRS, 70B | 96.9 / 97.7 | 71.4 / 61.9 | 63.4 / 49.3 |
Table 17: Development-set accuracy (%) of the Global codebook+demo prompt and of the direct kNN vote within retrieved-example subsets. Closest support is the quarter of documents with the smallest difference in summed similarity between the two leading labels. These are descriptive subsets without subgroup significance tests.
conflict, Reassigned definitions, Aligned, and the neutral-name control. Documents whose human label belongs to the swapped pair account for about 18%, 87%, and 51% of the Manifesto, CCC, and BFRS development sets. These shares differ from the switch-rate denominator in Table 19, which selects documents by the model's prediction before the swap.
| Condition | Manifesto | CCC | BFRS | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Mistral dev | test | 70B dev | test | Mistral dev | test | 70B dev | test | Mistral dev | test | 70B dev | test | |
| Original codebook | ||||||||||||
| Original | .580 | .551 | .583 | .570 | .691 | .677 | .641 | .639 | .794 | .774 | .813 | .806 |
| Demo conflict | .491 | .466 | .565 | .543 | .511 | .515 | .557 | .566 | .476 | .455 | .430 | .430 |
| Reassigned codebook | ||||||||||||
| Reassigned definitions | .349 | .325 | .443 | .420 | .334 | .349 | .498 | .470 | .255 | .245 | .553 | .562 |
| Definition conflict | .452 | .415 | .472 | .433 | .224 | .221 | .292 | .279 | .380 | .370 | .399 | .392 |
| Aligned | .539 | .529 | .584 | .563 | .570 | .567 | .605 | .597 | .752 | .739 | .801 | .793 |
| Def. conflict, neutral names | .454 | .416 | .575 | .538 | .482 | .480 | .485 | .454 | .404 | .400 | .422 | .418 |
| Label list, no codebook | ||||||||||||
| Original demos | .518 | .519 | .611 | .612 | .711 | .703 | .684 | .689 | .764 | .757 | .813 | .808 |
| Reassigned demos | .457 | .439 | .549 | .538 | .455 | .488 | .589 | .594 | .414 | .407 | .403 | .402 |
Table 18: Development/test weighted F1 under the two-label reassignment. Conditions follow Table 1; neutral names replaces familiar category names under Definition conflict. Original and Demo conflict are scored against original human labels; reassigned-codebook conditions are scored against the reassigned target. Label-list conditions are scored against original human labels, and swapping their demonstration labels significantly lowers performance except for the 70B Manifesto comparisons. Aligned significantly exceeds Definition conflict in all twelve comparisons and falls significantly below Original except for the two 70B Manifesto comparisons. The table extends the five conditions in Table 5 with development results and additional controls.
| Prompt | Manifesto dev/test | CCC dev/test | BFRS dev/test |
|---|---|---|---|
| Mistral, swapped demos only | 44/45 | 66/64 | 70/70 |
| Mistral, codebook + swapped demos (Demo conflict) | 23/26 | 44/44 | 64/65 |
| Llama-3.3-70B, swapped demos only | 67/71 | 66/69 | 91/89 |
| Llama-3.3-70B, codebook + swapped demos (Demo conflict) | 9/9 | 23/20 | 80/79 |
Table 19: Development/test switch rates after the pairwise label swap (%). The denominator contains documents predicted as either swapped label before the intervention; the numerator counts predictions that move to the paired label. Swapped demos only supplies demonstrations without a label list or codebook. Demo conflict supplies the original codebook with swapped demonstrations. Weighted-F1 losses for Manifesto, CCC, and BFRS are .125/.127, .316/.326, and .364/.374 for Mistral and .133/.149, .272/.314, and .413/.407 for the 70B under swapped demos only. Corresponding losses with the codebook are .089/.086, .180/.162, .318/.319 and .018/.027, .083/.072, .384/.376; every loss is statistically significant.
| Dataset, model | Original codebook | Reassigned codebook | ||
|---|---|---|---|---|
| Original | Demo conflict | Definition conflict | Aligned | |
| Manifesto, Mistral | .580/.551 | .267/.263 | .022/.021 | .512/.485 |
| CCC, Mistral | .691/.677 | .452/.451 | .028/.023 | .501/.497 |
| BFRS, Mistral | .794/.774 | .119/.119 | .022/.025 | .705/.704 |
| Manifesto, 70B | .583/.570 | .461/.447 | .185/.190 | .574/.536 |
| CCC, 70B | .641/.639 | .644/.626 | .040/.027 | .601/.584 |
| BFRS, 70B | .813/.806 | .199/.200 | .021/.023 | .748/.745 |
Table 20: Development/test weighted F1 when every codebook entry receives a different label. Original repeats the unchanged Global codebook+demo scores. Mistral scores average five reassignments; the 70B uses one.
F Prompts
Listing 1 reproduces a retrieval prompt with the lengthy codebook entries summarized. Listing 2 shows how the six prompt conditions differ. The listing text preserves the wording used in the experiment, including grammatical errors.
[SYSTEM]
Instructions: You're an expert political scientist classifying statements from political parties' manifestos into categories. Carefully read the definitions below, read the sentence from the manifesto, and write the single Label that best match the story. Do not write anything else except the Label in all caps. It's very important that you use only the provided Labels.
Task Type: single-label multi-class
[USER]
Categories:
<< 30 category blocks, not reproduced here. Each block gives Category, Aggregation1, Label, Definition and, where the codebook has them, Clarification and Negative Clarification. They are the 30 entries most similar to the document, most similar first; MARKET_REGULATION, the correct label, is the 6th. >>
To provide some context for your coding, here's the previous passage: "This will be a growing economy where everyone benefits - not just the richest 1%. Investment and planning will provide opportunities for everybody to have a well-paid job and a good work-life balance.".
The following is an excerpt from a political party in United Kingdom..
Here are some labeled examples from this codebook:
Example 1:
Text: Plaid Cymru wants a successful economy for Wales, where everybody can maximise their potential.
Label: ECONOMIC_GROWTH_POSITIVE
Example 2:
Text: Plaid Cymru wants to get more people in Wales into work, with better pay and conditions.
Label: LABOUR_GROUP_POSITIVE
Example 3:
Text: Plaid Cymru believes that everybody should pay a fair share of tax so that we in Wales can all share excellent, world-class public services.
Label: EQUALITY_POSITIVE
Example 4:
Text: So that wealth is shared out more fairly within the UK, and to ensure that Wales receives its fair share of public investment, Plaid Cymru will introduce an Economic Fairness Bill to rebalance the wealth of the UK.
Label: MARKET_REGULATION
Example 5:
Text: Plaid Cymru believes in our people, and we want to give them the best chances in life.
Label: EQUALITY_POSITIVE
Example 6:
Text: Plaid Cymru wants a Wales where everybody can get involved.
Label: CIVIC_MINDEDNESS_POSITIVE
Example 7:
Text: Plaid Cymru wants all of our children and young people to reach their full potential.
Label: CIVIC_MINDEDNESS_POSITIVE
Example 8:
Text: Plaid Cymru will stand up for the needs of pensioners.
Label: WELFARE_POSITIVE
Document: As the economy improves, Plaid Cymru believes that everyone should benefit.
Write the name of the Label that fits best, with no other text. It's very important that you use only the provided labels. For example, "Label: FOREIGN_SPECIAL_POSITIVE", "Label: CONTROLLED_ECONOMY", etc.
Listing 1: Global codebook+demo prompt (condition 5) for the first Manifesto development sentence, with k=8 examples and 30 category entries. The experimental wording is preserved except that the 30 category blocks are summarized between « and », and long lines are wrapped. [SYSTEM] and [USER] identify messages formatted with each model's chat template. The eight examples appear in decreasing similarity order, selected from 5,711 training sentences. They contain six distinct labels; the reference label, MARKET_REGULATION, appears once, at rank four. Mistral instead predicted ECONOMIC_GROWTH_POSITIVE, the label of the nearest example.
All six conditions send the same query. Conditions 3, 4 and 5 also send the same eight examples. <CATS> = the 30 category blocks, <EX> = the eight examples, <context> = the previous-passage line, <source> = the "The following is an excerpt ..." line, and <reminder> = the closing "Write the name of the Label ..." line, all exactly as in Listing 1. Order in every prompt: label information, context, source, examples, query, reminder.
(1) LABEL ONLY [SYSTEM] ... Carefully read the valid labels below, ... [USER] Valid labels: WELFARE_POSITIVE, ENVIRONMENTALISM_POSITIVE, EQUALITY_POSITIVE, TECHNOLOGY_AND_INFRASTRUCTURE, EDUCATION_POSITIVE, LAW_AND_ORDER_POSITIVE, LAW_AND_ORDER_POSITIVE, DEMOCRACY, ... << full retained label list >> <context> <source> Document: <query> <reminder>
(2) CODEBOOK ONLY [SYSTEM] ... Carefully read the definitions below, ... [USER] Categories: Category: free market economy Aggregation1: Economy Label: FREE_MARKET_ECONOMY Definition: Favourable mentions of the free market and free market capitalism as an economic model. Clarification: May include favourable references to: · Laissez-faire economy; ... <CATS: the other 29 blocks> <context> <source> Document: <query> <reminder>
(3) GLOBAL: DEMO ONLY [SYSTEM] ... Carefully read the labeled examples below, ... [USER] << No label list and no definitions. Label names appear only on the examples, and as the two format examples in <reminder>. >> <context> <source> Here are some labeled examples from this codebook: <EX: 8 examples, by overall similarity> Document: <query> <reminder>
(4) GLOBAL: LABELS + DEMO [SYSTEM] ... Carefully read the valid labels below, ... [USER] Valid labels: WELFARE_POSITIVE, ENVIRONMENTALISM_POSITIVE, ... << full retained label list, as in (1) >> <context> <source> Here are some labeled examples from this codebook: <EX: the same 8 examples as (3)> Document: <query> <reminder>
(5) GLOBAL: CODEBOOK + DEMO (= Listing 1) [SYSTEM] ... Carefully read the definitions below, ... [USER] Categories: <CATS: 30 blocks, as in (2)> <context> <source> Here are some labeled examples from this codebook: <EX: the same 8 examples as (3)> Document: <query> <reminder>
(6) CLASS-WISE: CODEBOOK + DEMO [SYSTEM] ... Carefully read the definitions below, ... [USER] Categories: <CATS: 30 blocks, as in (2)> <context> <source> Here are some labeled examples from this codebook: <2 most similar examples for each of the 49 labels in the pool: 98 in total, most similar first, however dissimilar> Document: <query> <reminder>
Listing 2: All six prompt conditions for the same document; blocks shared with Listing 1 are named rather than repeated. Between conditions only the label information and the one instruction sentence that names it change, and conditions 3, 4 and 5 share the same eight examples. Condition 3 never lists the valid labels: the only label names it shows are those on its examples and the two format examples in the closing reminder. The label list in conditions 1 and 4 is not de-duplicated, so the two labels with two codebook entries each appear twice.