Social scientists increasingly hand large language models a codebook and ask them to label thousands of documents. A codebook here means the written definitions of categories such as "this news article frames immigration as an economic issue." The standard evidence that this works is agreement with human coders on a public, already-annotated corpus. Those same corpora, their codebooks, and a decade of papers analyzing them are on the web. The next recommended step for better machine coders, pre-training further on disciplinary text, makes the problem worse, because a social-science domain corpus is exactly where those annotations and analyses concentrate. We propose to measure how much of a machine coder's agreement comes from remembering how specific documents were coded, and how much comes from reading the document in front of it. We also ask whether domain pre-training amplifies this memorization.
The approach combines two things. The first is a controlled experiment in which we continually pre-train a small open model on a social-science corpus while deliberately adding, or removing, the Media Frames Corpus in several forms. The second is a new style of test for qualitative coding: pairs of rewritten documents. In one rewrite the surface changes but the correct code stays the same. In the other the surface stays nearly the same but a trained human would now assign a different code. A coder that reads should follow the second edit. A coder that remembers will keep the old label. Because we control what the model saw, we can check whether this rewrite test detects contamination. Once validated, we can apply it to off-the-shelf models whose training data we cannot inspect.
Core Claim
We claim that agreement on public qualitative benchmarks overstates how well models code new material, and that continual pre-training on domain text widens this gap when the domain corpus contains the benchmark or the secondary literature about it. We further claim that a label-flip rewrite test separates reading from remembering more cleanly than the obvious alternative of scoring on fresh, post-cutoff documents. Fresh documents mix up two things: memorization, and ordinary shift to new topics and vocabulary.
Where This Sits
The qualitative-coding work motivates the question. Supporting Qualitative Analysis with Large Language Models: Combining Codebook with GPT-3 for Deductive Coding prompts GPT-3 with a codebook and reaches Cohen's kappa 0.61 on a semantic coding task. It reaches only 0.38 on a syntactic task, where human coders agree at 0.90. HICode: Hierarchical Inductive Coding with LLMs builds bottom-up themes and evaluates on the Media Frames Corpus among other datasets. Neither asks whether the model had seen the data. The corpus itself, The Media Frames Corpus: Annotations of Frames Across Issues, provides 15 issue-general framing dimensions over news articles on immigration, smoking, and same-sex marriage. It has been public for years, which makes it the natural test case.
The contamination work supplies the method and constrains the design. Investigating Data Contamination for Pre-training Language Models pre-trains GPT-2 models from scratch with three kinds of leaked data: raw evaluation text, text plus answers, or nothing. It finds three things. Leaked answers matter far more than leaked text. Gains follow a U-shape in the number of repetitions, peaking near 10. Standard n-gram filtering largely fails to remove the effect. We reuse its controlled design, but move it from general web pre-training and standard NLP tasks to domain continual pre-training and qualitative coding. We also add a form of leakage that paper does not consider: secondary literature that describes the codebook and example codings without containing the test items.
Three papers show that perturbed or fresh items expose memorized performance in math and logic:
- DyVal: Dynamic Evaluation of Large Language Models for Reasoning Tasks generates problems procedurally.
- ThinkBench: Dynamic Out-of-Distribution Evaluation for Robust LLM Reasoning alters problem scenarios and injects noise.
- LLM-as-an-Interviewer: Beyond Static Testing Through Dynamic LLM Evaluation perturbs questions across multiple turns.
All three rely on answers that can be checked automatically. Qualitative codes have no checker, so our rewrites must be validated by trained human coders. That cost is the price of moving dynamic evaluation into interpretive tasks.
The domain pre-training work frames the regime. FeynTune: large language models for high-energy theory continually pre-trains Llama-3.1-8B on physics abstracts. MonoCoder: Domain-Specific Code Language Model for HPC Codes and Tasks trains a code model from scratch and finds that generalist models rely on surface tokens such as variable names. It removes these through an anonymizing transformation. We treat MonoCoder's result as a hint that domain training can either reduce or increase surface shortcuts depending on what the corpus contains, and our experiment manipulates exactly that. A Comparative Study of PEFT Methods for Python Code Generation reports that domain pre-training predicts downstream performance better than the choice of lightweight fine-tuning method. That result is why domain pre-training is the regime worth auditing. It is also why lightweight fine-tuning appears here as a competitor rather than a replacement.
Research Program
Test sets. The first artifact is a rewrite test set built on the Media Frames Corpus primary-frame labels. For a held-out sample of roughly 600 annotated articles, we produce two rewrites each, drafted by a language model under tight instructions.
- Label-preserving rewrite. This changes named entities, dates, outlet style, and wording, and moves the article to a parallel policy issue where possible. It keeps the argument and therefore the primary frame. For example, an economic-cost argument about immigration becomes an economic-cost argument about a hypothetical labor policy.
- Label-flip rewrite. This keeps most sentences, entities, and dates verbatim but rewrites the central argument so the primary frame changes, for instance from Economic to Morality.
Two coders trained on the MFC codebook label every rewrite blind to its origin. We keep only items where they agree with each other and with the intended label, and we report their kappa. We also collect about 400 fresh, human-coded articles published after the base model's training cutoff, including one policy issue absent from MFC. This gives the conventional time-split comparison.
The central quantity is flip adherence. It is the fraction of label-flip items on which the model still outputs the original article's label:
$$A_{\text{flip}} = \frac{1}{N}\sum_{i=1}^{N} \mathbb{1}\left[\hat{y}(x_i^{\text{flip}}) = y_i^{\text{orig}}\right]$$
Here $x_i^{\text{flip}}$ is the $i$-th flipped document, $y_i^{\text{orig}}$ is the label of the unedited article, $\hat{y}$ is the model's prediction, and $N$ is the number of validated flip items. A reading coder should have low $A_{\text{flip}}$ even while scoring well on the originals. A remembering coder keeps a high $A_{\text{flip}}$.
Controlled pre-training. The second artifact is a set of continually pre-trained models. We start from one small open base model at roughly one billion parameters, a scale where the controlled contamination paper already found measurable effects. We continue pre-training for a fixed token budget on a social-science corpus. The corpus combines open news text with open-access communication-science and political-science papers. We run several arms:
- Clean. All MFC articles are removed by document match and fuzzy match, along with all papers that mention the corpus.
- Text-only. MFC article text is added.
- Ground-truth. Article text is added together with its frame label and the codebook.
- Secondary-literature. Only papers and tutorials that describe MFC and quote example codings are added, with no test articles.
- Filtered. The ground-truth corpus after a standard 13-gram decontamination filter.
Contaminant arms use repetition counts of 1, 10, and 20 to test whether the U-shape carries over. In every arm the contaminant tokens replace matched clean tokens, so total compute and token count are identical. We also keep the base model without continual pre-training as the generalist reference.
Coding runs. Every model codes every test item with the same codebook prompt and the same one-shot exemplar. The deductive-coding study found one shot gave most of the gain. We score primary-frame macro-F1 and Cohen's kappa against humans on four sets: originals, label-preserving rewrites, label-flip rewrites, and fresh articles. We also report $A_{\text{flip}}$.
Applying the test to released models. Once the controlled arms show which signal tracks contamination dose, we apply the rewrite test to widely used open instruction models in the 7–8B range. For these models we can only infer exposure. As a secondary and optional analysis, we check whether the low-dimensional activation concentration reported in A Narrowing Geometry in Contaminated Reasoning appears on memorized MFC items. That paper found such concentration for leaked math problems. We treat this as exploratory, not as part of the main claim.
Baselines
Naive reference. The do-nothing reference is the generalist base model, prompted with the codebook and one exemplar, without continual pre-training. It shows what a practitioner gets today. It is also the ceiling of what "reading" alone can deliver at this scale, unless domain training genuinely helps. The generalist base model's kappa on fresh articles is the number the clean domain model must beat for domain pre-training to have earned its cost.
Strongest method for coding quality. The strongest competitor on coding quality is the clean domain-pretrained model, which follows the recipe that FeynTune and MonoCoder recommend. Its purpose is fairness: it separates legitimate domain gains from contamination gains, because it uses the same budget and data minus the leaked material. The finding the proposal predicts is specific. Contaminated arms should beat the clean arm on originals, yet match or trail it on flip and fresh items. If the contaminated arms beat the clean arm everywhere, our claim fails.
We found no reported result on Lacuna for language-model primary-frame classification on the Media Frames Corpus. HICode's Frame numbers are not given in the file. The nearest reported deductive-coding figure is kappa 0.61 on a different, binary semantic task, from Supporting Qualitative Analysis with Large Language Models. The only MFC reliability numbers are the human span-agreement alphas of 0.08–0.23 in The Media Frames Corpus. We will therefore establish the reference numbers ourselves and not compare across papers.
Strongest method for detection. The strongest competitor for detecting contamination is the time-split: the drop from originals to fresh articles. This mirrors ThinkBench, which reports an average 24.9% accuracy drop on perturbed historical AIME items versus 11.8% on fresh AIME 2024 items across 16 models. The rewrite test beats the time-split if two conditions hold across the controlled arms. First, $A_{\text{flip}}$ rises with contamination dose. Second, the fresh-article drop fails to order the arms correctly, or also moves in the clean arm because of topic shift. We will report rank correlations with known dose for both signals.
Filtering baseline. The filtered arm tests whether the problem disappears with standard n-gram decontamination. Investigating Data Contamination for Pre-training Language Models found it does not for standard tasks. For general knowledge, that paper reports 24.3% versus 22.8% on MMLU for ground-truth-contaminated versus clean GPT-2 large at 10 repetitions.
Lightweight fine-tuning. A LoRA adapter trained on a few hundred human-coded non-test MFC articles, applied to the generalist base, is run with the same tuning budget as the continual pre-training arms.
Key ablation. The ablation that isolates our key ingredient is the secondary-literature arm. If papers about the codebook alone raise flip adherence, then decontaminating by test document is insufficient for domain corpora. That is the practical result this proposal most wants to establish or rule out.
Why not just…?
Why not just score coders on fresh, post-cutoff articles? This is the most serious alternative, and we run it. The weakness is that a drop on fresh articles has two causes: forgotten memorization, or new issues, vocabulary, and events that any honest coder finds harder. ThinkBench's own fresh set still shows an 11.8% average drop, a reminder that fresh items carry shift of their own. Label-flip pairs keep nearly all surface text fixed, so a wrong answer there points to the document's identity rather than its content. The controlled arms settle the question. If the fresh-article drop ranks contamination dose as well as $A_{\text{flip}}$ does, we will say the cheaper test suffices and recommend it.
Why not just n-gram filter the domain corpus before training? Prior controlled work found n-gram filtering largely ineffective against answer-bearing leakage. More importantly for our setting, filtering on test documents cannot touch the secondary literature: papers that quote codebook definitions and example codings in new words. The filtered arm and the secondary-literature arm directly measure how much inflation survives filtering.
Why not just skip domain pre-training and use a lightweight adapter on coded examples? An adapter trained on a few hundred codings sees far less leaked material, so it may be less contaminated. The PEFT comparison in code generation suggests it will also gain less real domain understanding. The adapter arm is run at matched budget, and its fresh-article and flip scores are compared with the clean domain model. If the adapter matches the clean domain model on fresh and flip items, practitioners should prefer it. We would report that as a finding against our own regime.
Why not just ask a strong model to judge whether the coding rationale is sound? A judge sees fluent justifications whether they were derived or recalled. The narrowing-geometry study shows contaminated models produce rationales that look like genuine reasoning, and the interviewer study documents verbosity bias and run-to-run variance in judges. Human-validated flip items avoid needing a judge at all.
Decisive Checks
The first decisive check is the dose-response table across the controlled arms. The proposal predicts two things. Original-item kappa should rise with contamination and repetitions. Flip adherence should rise in step, while clean-arm flip adherence stays low. If contaminated arms show high original scores but ordinary flip adherence, the memorization story for qualitative coding is wrong, and we will report that domain coders read rather than remember.
The second check is whether the secondary-literature arm alone raises flip adherence above the clean arm. If it does, then domain corpora carry leakage that test-document filtering cannot remove.
The third check is whether the fresh-article time-split orders the arms as well as the rewrite test does. That result decides which audit we recommend to practitioners who cannot see a model's training data.
The final step applies the validated audit to released open models coding MFC. It reports, per model, the gap between original-item agreement and flip-item agreement. These are the numbers a social scientist needs before trusting a public-benchmark kappa.
References
- Supporting Qualitative Analysis with Large Language Models: Combining Codebook with GPT-3 for Deductive Coding
- HICode: Hierarchical Inductive Coding with LLMs
- The Media Frames Corpus: Annotations of Frames Across Issues
- Does Data Contamination Make a Difference? Insights from Intentionally Contaminating Pre-training Data For Language Models
- DyVal: Dynamic Evaluation of Large Language Models for Reasoning Tasks
- ThinkBench: Dynamic Out-of-Distribution Evaluation for Robust LLM Reasoning
- LLM-as-an-Interviewer: Beyond Static Testing Through Dynamic LLM Evaluation
- FeynTune: large language models for high-energy theory
- MonoCoder: Domain-Specific Code Language Model for HPC Codes and Tasks
- A Comparative Study of PEFT Methods for Python Code Generation
- A Narrowing Geometry in Contaminated Reasoning