Founders

How to Audit an LLM's Theme Coding Against a Human Sample

Antonio Evans10 min read

A split-screen scene: on the left, a person at a desk with a printed codebook and a stack of highlighted documents, writing codes in a margin; on the right.
Key points

Key points

  1. 1Fix the coding unit and codebook before any model runs, because agreement numbers mean nothing if the definition of a code shifts between the human pass and the model pass.
  2. 2Draw a stratified random sample and have two humans code it independently, so you get a human-to-human agreement ceiling rather than a single reviewer's opinion.
  3. 3Report percent agreement and Cohen's kappa together, and judge the model against the human ceiling, not against a textbook threshold.
  4. 4Read disagreement through a confusion matrix and set a pre-registered trust threshold before you look at the full-corpus counts.

Start with the unit and the codebook

Most failed audits fail before a prompt is written. The team codes paragraphs by hand, runs the model over whole documents, then compares counts. Nothing lines up, and the disagreement you are staring at is a definitional error, not a model error.

Fix three things on paper. The coding unit is the smallest piece of text that can carry exactly one theme: a sentence, a turn in a transcript, a paragraph, a ticket. Write down what to do when a unit carries two themes, usually by splitting it or recording both. The codebook is a numbered list of themes, each with a one-line definition, one positive example from your data, and one near-miss that should not be coded. The decision rules cover edge cases: sarcasm, hypotheticals, secondhand reports, and the gap between "the customer wants pricing clarity" and "the customer wants a cheaper plan."

The discipline is borrowed from audience research, where the same problem is well understood. Interview guides are built to pull concrete past behavior out of a respondent rather than opinions about a hypothetical future, because concrete reports are far more consistent to interpret Richard von Kaufmann's discovery guide. Coding follows the same logic: a rule that points at observable text ("mentions a specific price, date or named tool") is reproducible, while a rule that points at a vibe ("seems frustrated") is not.

Two tests before you spend money on inference. First, the coverage test: take ten documents you know well and code every unit using only the codebook, and treat every unit that does not fit as a missing code or a bad boundary. Second, the mutual exclusivity test: for each pair of codes, write one sentence explaining how they differ, and merge the pair if you cannot.

A codebook of eight to fifteen codes with sharp boundaries beats a taxonomy of forty. Every extra code is another chance for the model and the human to choose differently for reasons unrelated to the data. Where teams want intensity rather than simple presence, magnitude coding adds a scaled meta-code (low, medium, high) on top of an existing code, which keeps richness without exploding the number of categories Delve's guide to magnitude coding.

Draw a stratified random sample you can defend

You cannot code everything by hand, and you should not try. You need a sample that supports a claim like "for documents of this type, the model's code assignment matches a trained human often enough to count."

Stratify on the variable most likely to change model behavior: length band, source channel, customer segment, language, or time period. Allocate roughly in proportion to each stratum's share of the corpus, with a floor so small but important strata still get a look. A workable starter budget for a corpus of several thousand documents is 60 to 120 units per stratum, enough to see gross drift and cheap enough to double-code.

Sample at the coding-unit level if your counts will be unit-level counts. If the final statistic is "percentage of documents mentioning theme X," then documents are the units and every document in the sample must be coded completely. Mixing the two is the most common source of a number that looks wrong later.

Keep traceability. Every sampled unit needs a stable identifier back to the source file, speaker, and line or timestamp, because you will revisit specific disagreements while writing decision rules. Affinity mapping workflows solve the same problem by tagging each note with a participant ID plus a timestamp so a theme can be traced to the exact quote GoTranscript's affinity mapping workflow.

DecisionRecommended defaultWhy it matters
Sampling frameAll documents that will appear in the final countsA sample drawn from a filtered subset cannot validate counts on the full set
Stratification keyOne variable, chosen for likely model driftMore keys fragment the sample below usable size
Units per stratum60 to 120, proportional with a floorEnough to see major drift; small enough to double-code
Blind codingHumans never see model output; model never sees human labelsPrevents anchoring in both directions
Held-out rowsReserve 30 percent untouched until the decisionStops quiet iteration against the same rows

Build the human baseline first

A model-human agreement figure is meaningless alone. If two trained reviewers agree on a theme 78 percent of the time, a model hitting 72 percent is near the practical ceiling. A model hitting 94 percent against a human ceiling of 78 percent is suspicious, and usually means the humans were sloppy or the prompt was tuned on the wrong rows.

So run the human baseline first. Two reviewers, independent, no discussion, no shared notes beyond the codebook. Then compute human-to-human agreement. Adjudicate disagreements with a third person or by consensus, and log every adjudication as a new decision rule. That log is the most valuable artifact of the exercise, because it names which codes are genuinely hard.

The guidelines literature is blunt here. When an LLM replaces human judgment in tasks such as coding interview transcripts, the replacement must be justified and grounded in inter-model and model-to-human agreement, and high agreement between models can reflect shared model bias rather than valid annotation, so a human-validated sample is still required LLM Guidelines for Software Engineering. That is exactly why the human baseline comes first: it is the only reference that is not itself a model.

The same source describes a useful loop for stabilizing the human reference: put objects in groups small enough to judge in one to three hours, have two or three experts judge the first group together while writing decision rules, then cycle through independent rating, agreement calculation, discussion of disagreements, and rule updates until the target agreement is reached and held for two or three consecutive groups LLM Guidelines for Software Engineering. A compressed version on 40 units takes an afternoon and saves a week of arguing about model output.

Measure agreement with two numbers

Percent agreement is the plain share of units where two coders chose the same code. It is intuitive and it is flattering when one code dominates. If 85 percent of units are uncoded and the rest carry four themes, two coders choosing "uncoded" almost every time will score above 80 percent agreement while agreeing on almost nothing that matters.

Cohen's kappa corrects for that. It exists precisely because percent agreement cannot account for agreement that would occur by chance, and it ranges from -1 to +1, where 0 means chance-level agreement and 1 means perfect agreement McHugh's overview of the kappa statistic. Kappa is defined for two raters, so it fits the human-human and human-model comparisons here; Fleiss' kappa extends to more than two raters and uses a different calculation, so the two should never be compared directly Quirkos on inter-rater reliability.

Two traps. Kappa collapses when one category dominates, which is normal in theme coding where most units carry no theme. And kappa is sensitive to the number of categories and to sample size, so two decimal places on a small sample implies precision you do not have Quirkos on inter-rater reliability. Round to one decimal place or report a confidence interval.

A compact worked example on 100 sampled units, five codes plus "none."

PairPercent agreementKappaReading
Human A vs Human B84 percent0.71The practical ceiling for this codebook
Human baseline vs Model76 percent0.58Real but imperfect; inspect where
Model vs Model, two runs91 percent0.83Stable, so the drift is systematic, not noise

Three things this tells you that a single accuracy number would not. The human ceiling is 0.71, so the model at 0.58 is 0.13 below it, not 0.13 below perfection. The model is consistent with itself, so the error is a rule mismatch you can name. And the per-theme errors may be large and offsetting even when totals look close, which is why the confusion matrix comes next.

If the inference side needs to run a large sample in one pass with a fixed prompt and stored labels, Quanta Inference exposes text, image, video, audio and embedding models through one OpenAI-compatible API key, which keeps the model call reproducible Quanta Inference.

Diagnose drift with a confusion matrix

Aggregate agreement hides the only thing you can act on: which codes the model over-applies and which it misses. A confusion matrix with human labels on one axis and model labels on the other shows that at a glance.

Read it in three passes. The diagonal shows codes the model gets right almost always, and those are safe to count. Off-diagonal cells with mass show boundary problems, for example the model assigning "pricing confusion" where the human assigned "onboarding friction"; the fix is a sharper decision rule and one or two examples in the prompt, not a new model. Row and column totals reveal prevalence bias: a code whose column total far exceeds its row total is over-applied, and the reverse means it is missed.

Two drift patterns have different fixes. Boundary drift is systematic confusion between adjacent codes and often costs little in totals because errors offset. Prevalence drift is a bias toward or against a whole category, and it moves your headline percentages, so it is the dangerous one.

Sort each disagreement into one of four buckets and count them: definitional (the codebook was ambiguous), unit-level (the split was wrong), contextual (the human used outside knowledge the model lacked), or genuine model error (the text clearly supports one label). In most first audits, the first two buckets hold the majority, which is a finding about your codebook, not your model.

One check that earns its keep: send the same sample through the model twice with an identical prompt. High self-agreement with low human agreement means the model is confidently wrong, and repeating the prompt will not save you. Low self-agreement means the prompt is underspecified or the unit boundaries are unstable.

Pre-register a threshold and a decision rule

Decide in writing, before computing agreement, what counts as good enough. This separates an audit from a vibe check and prevents interpreting results into existence after the fact. Interview practice teaches the same lesson: interviewers drift off track and cannot see it themselves, which is why an observer scores the session against explicit criteria rather than impressions Rob Fitzpatrick on rehearsing interviews.

A rule that works in practice has three parts. First, a floor on human-to-human agreement: if two reviewers land below about 0.6 kappa, stop and fix the codebook, because there is nothing to validate against yet. Second, a model-to-human condition expressed relative to the ceiling, for example model kappa within 0.10 of human kappa and percent agreement within 8 points. Third, a per-theme condition: any theme where the model's recall against the human baseline falls below a set level is flagged not countable and shifts to manual coding, even if the overall numbers pass.

Then declare what happens on each outcome. Pass: count the corpus and report the model numbers with agreement figures and sample size beside them. Partial: count only the themes that passed, label the rest as manually coded, and report both. Fail: do not report model theme frequencies at all; use the model for triage and retrieval and code the full set by hand.

Two guardrails keep the rule honest. Keep the held-out rows untouched until the decision is made, and log the prompt and codebook version next to the agreement result so a later change cannot be presented as if it had been tested. The guidelines for replacing human judgment are explicit that the justification, the measurement instrument, and the agreement evidence all have to be reported, not asserted LLM Guidelines for Software Engineering.

Worked example and failure modes

Take 4,000 support conversations and six friction themes. Stratify by channel (chat, email) and customer tier (three levels), giving six strata, allocated proportionally with a floor of 50, which lands at 180 sampled conversations. Two reviewers code each conversation for all six themes, independent and blind, and human-human kappa comes out at 0.69 with 83 percent agreement. The adjudication log produces four new rules about conversations that name a competitor.

Run the model on the same 180 conversations with a prompt containing the codebook, the four rules, and one example per code. Model-to-human kappa is 0.61 and percent agreement 77 percent, within 0.10 of the ceiling, so the aggregate passes. But the per-theme breakdown shows over-applied "pricing confusion" and under-applied "integration limits," and those two fail. You count the four passing themes across all 4,000 conversations and manually code the two flagged themes by using the model as a retrieval filter that surfaces candidates for a human to confirm. The reported result is four automated percentages with agreement figures and sample size, plus two manual percentages. That is a defensible synthesis.

Common failure modes, briefly:

  • Coding whole documents when the statistic is per-unit, or the reverse. Fix the unit at design time.
  • One human coder, which produces a model-versus-opinion comparison with no ceiling.
  • Humans shown model output first, which inflates agreement and destroys the baseline.
  • Tuning the prompt on the rows later reported as agreement evidence.
  • A single accuracy figure with no base rate; a theme mentioned in 3 of 5 units and 3 of 50 are not the same finding Skimle's guide to quantifying qualitative data.
  • Treating high inter-model agreement as validation, when it can simply mean shared bias LLM Guidelines for Software Engineering.
  • Confusing reliability with accuracy: two coders can agree consistently and both be wrong Quirkos on inter-rater reliability.
FAQ

FAQ

How many documents do I need to double-code?

For a first audit, 60 to 120 units per stratum is a practical range, adjusted for how variable the theme prevalence is across strata. You need enough rows per stratum to see a large drift in your most important theme, and few enough to code twice in a day with two reviewers. If a stratum carries your headline claim, push it toward the top of the range.

Should I use Cohen's kappa or percent agreement?

Both, always, side by side. Percent agreement is easy to interpret but inflated by chance and by a dominant category, while kappa corrects for chance and drops sharply when one code dominates McHugh's overview of the kappa statistic. Report both, plus per-theme figures, because a good aggregate can hide a bad theme.

What if my two human coders agree poorly?

Treat that as a codebook defect, not a model problem, and stop. Rewrite the ambiguous codes, add decision rules from the disagreement log, and recode a fresh group. The iteration loop of independent rating, agreement calculation, discussion, and rule update exists for exactly this LLM Guidelines for Software Engineering. Do not compare the model until the humans clear a floor you set in advance.

Can I skip the human baseline if I validate against a second model?

No, not for count-based claims. Agreement between two models can reflect shared training data and shared bias rather than correct interpretation, which is why a human-validated sample is recommended even when inter-model agreement looks strong LLM Guidelines for Software Engineering. A second model is a useful stability check, not a substitute for a human reference.

What do I report alongside the final counts?

Report the coding unit and codebook version, the sampling design and per-stratum sample size, human-human and model-human percent agreement and kappa, the per-theme flags, and the pre-registered threshold the result was judged against. Anyone reading the counts should see how much of the number is measurement and how much is interpretation.

Sources

Sources

  1. Customer Discovery Done Well - Medium
  2. What is Magnitude Coding in Qualitative Analysis? A Guide
  3. Affinity Mapping From Transcripts: How to Go From Quotes ...
  4. Use Human Validation for LLM Outputs
  5. Interrater reliability: the kappa statistic - PMC - NIH
  6. Should you use inter-rater reliability in qualitative coding?
  7. The Mom Test AI can't run your customer interviews (but ... - YouTube
  8. How to quantify qualitative data: 5 techniques, mixed ...
About the author

About the author

Antonio Evans
Antonio Evans

Antonio Evans is the founder of Quanta Intelligence and a fractional CTO who builds HIPAA-ready AI systems for health and life-science companies. Before that he was technical co-founder of FriendsEAT for twenty years, CEO of Socialdraft, and a data engineer at IBM. Antonio lives with his dog Santino in Lisbon, Portugal.

All articles