Factoring Out the Domain: Covariate Topic Models of Reasoning Traces for Transferable Hallucination Detection

When a language model is trained to reason on mathematics and then asked about films, chemistry, or code, two things transfer at once. One is the useful part: the habits of breaking a problem down and checking work. The other is the harmful part: a tendency to assert unsupported facts or invent tools with confidence. Detectors that flag these false outputs ("hallucinations") usually fail to make the same jump. They learn what wrong math looks like, word by word, and then perform near chance on trivia. This proposal treats each model's written reasoning as a corpus and fits a structural topic model to it. A structural topic model is a topic model whose topic mix and whose word choices are both allowed to depend on known document metadata. Here the metadata says which domain a trace came from and how its model was trained. That lets the analysis set aside how each domain phrases a reasoning move and keep only which moves a trace makes. The bet is that the move profile, read with domain vocabulary removed, is what hallucination-prone reasoning has in common across domains.

The payoff would be twofold. Practically, the result would be a black-box, single-pass, interpretable hallucination detector that is trained on math and works on open-domain question answering. That is the regime where activation probes are known to collapse, and where the best domain-transferable detector needs a 20-turn interrogation per query. Scientifically, the same fitted model gives a measurement instrument for a live contradiction. Mathematical reinforcement learning (RL) improves code and science while also amplifying fabrication. The topic model can ask whether these come from the same shift in reasoning behaviour or from separable ones.

Core Claim

We claim that, conditional on domain, the proportions of reasoning "moves" in a chain of thought predict hallucination in a way that transfers across domains. Example moves are a verification step, a hedge, an unsupported factual assertion, a restatement loop, and a tool or source invocation. The key ingredient is the topic-content covariate, the part of the model that lets each topic use domain-specific words. A plain topic model fit on mixed traces would mix "math verification" and "trivia verification" into different topics because they share no vocabulary. A classifier on those topics would then relearn the domain, just as linear probes do. With domain as a content covariate, one "verification" topic is estimated whose words shift by domain while its prevalence stays comparable. This is a text-level analogue of the split that HARP makes inside the network. HARP separates the unembedding layer, the output projection onto vocabulary, into a large semantic subspace and a small reasoning subspace, and shows the reasoning part carries a transferable hallucination signal. Our proposal does this separation on the visible text, with explicit metadata, and with no access to model weights.

Research Program

The motivating evidence comes from three papers. HaluEval shows hallucination rates vary strongly by topic. Beyond In-Domain Detection: SpikeScore shows supervised probes trained on one domain drop to roughly 0.5–0.6 AUROC elsewhere, because they latch onto domain-specific semantic features. Are Reasoning Models More Prone to Hallucination? identifies two failure modes tied to the training pipeline. In "flaw repetition" the model cycles through the same broken logic; in "think-answer mismatch" a sound trace ends in a contradictory answer. Both are behavioural patterns that should show up as unusual move mixtures.

The method comes from covariate-conditioned topic modelling. We use the structural topic model formulation, in which covariates set the prior over each document's topic proportions and shift each topic's word distribution. For richer, correlated metadata we use the factor-topic structure of the Cross-structural Factor-topic Model. That model compresses many covariates into a few latent factors that shape both topic prevalence and word choice, and it reports better held-out prediction than plain topic models, especially on small subsets. We draw on its inference machinery, not its text-analysis applications.

Concretely, we generate chain-of-thought traces from three model types on matched question sets. The first is a full-pipeline reasoning model. The second is a distilled reasoning model; DeepSeek-R1-Distill-Qwen-7B is the model The Reasoning Trap found most prone to fabrication. The third is a series of our own checkpoints, trained with GRPO (an RL method that scores groups of sampled answers against each other) on GSM8K, saved at increasing RL steps. Each trace is split into steps, and each step is one short document. A step is the right unit because ordinary topic models ignore word order, and this keeps them from blurring whole traces. The covariates are domain (content and prevalence), training regime and RL step (prevalence), relative position in the trace (prevalence, via a smooth curve), and, on training data only, the correctness of the final answer (prevalence).

We fit the model on math traces with labels and on traces from all domains without labels. Unlabeled target-domain text is used only to estimate how domain shifts the vocabulary, never to learn the labels. Detection then scores a new trace by comparing two posteriors over its step-topic proportions: one under the "correct" value of the label covariate and one under the "hallucinated" value, with the trace's domain held fixed. Because the move topics are labelled by their top words, every flag comes with a readable reason, such as "unusually many unverified factual assertions late in the trace, for a trivia question."

The same fit answers the scientific question. If the move topics whose prevalence rises with RL step are the same ones linked to hallucination on non-math domains, transfer and trap share one mechanism. If the benefit moves (decomposition, verification) and the harmful moves (confident assertion, invocation) are separate topics with separate RL trajectories, the trap is in principle separable. That would give a concrete target for selective mitigation, which the DPO fix in The Reasoning Trap lacked. DPO, or Direct Preference Optimization, trains a model to prefer chosen over rejected answers; in that paper it cut tool-use reward from 0.45 to 0.34.

Baselines

The naive reference point is a detector that uses only trace length and simple lexical markers. These include the hedge and "wait"/recheck counts that Self-Braking Tuning uses to measure overthinking, plus the model's mean token log-probability. It gets the same math training data and a logistic regression. If our detector does not beat it cross-domain, the topic model adds nothing.

The ablation that isolates our key ingredient is the identical pipeline with the domain content covariate removed: the same step documents, topic count, label covariate, and classifier. A further variant replaces the joint model with an off-the-shelf unsupervised topic model plus a downstream classifier. The topic count is tuned on a held-out math split for all variants, never on target domains. Our claim requires the full model to beat the no-content-covariate version on target domains while matching it on math.

The strongest black-box competitor for domain transfer is SpikeScore. It drives the model through a 20-turn pressure dialogue and scores the largest second-order jump in uncertainty. It reports cross-domain AUROC of roughly 0.78–0.79. Note that SpikeScore uses activation-derived uncertainty, so it is not strictly black-box. We run it on the same models and the same math-to-target splits, and we report the compute used. Beating it means matching or exceeding its AUROC on at least the open-domain question-answering targets at roughly one-twentieth of the generation cost. Matching it at that cost would itself count as a result.

The strongest white-box competitor is HARP. It reports 92.8% AUROC on TriviaQA for Qwen and 92.9% for LLaMA in-domain, and near-identical transfer from TriviaQA to NQ Open. It has no reported math-to-trivia transfer number on Lacuna, so we run it ourselves under our splits. We do not expect to beat its in-domain number with text alone. The question is the math-to-other-domain gap.

The strongest structure-based method is the Flow Score of Hallucination Detection from Structural Reasoning Model. It turns reasoning into a dependency graph and has an LLM judge check each step against its parents. It reports 76.59% average precision (AP) on MATH, 13.8 points over non-graph baselines, and 83.08% AP on HumanEval. Self-consistency sampling scored about 25% AP on HumanEval in the same paper. We compare in AP on those two benchmarks with judge calls counted.

Why not just…?

Why not just train a linear probe on hidden states? Because cross-domain is exactly where probes fail: SpikeScore documents near-random 0.5–0.6 AUROC for probes moved off their training domain. Our experiments include such a probe trained on math traces to confirm this on our splits. If it does not fail on our splits, our motivation weakens and we will say so.

Why not just use HARP's reasoning subspace, which already strips out semantics? This is the real threat. HARP's split may achieve inside the network what our content covariate does in text, and do it better. Our proposal is only worth it if one of two things holds. Either it is competitive cross-domain without weights, which covers closed APIs, or its interpretable move topics explain failures that HARP's subspace cannot name. We run HARP under identical math-to-target transfer. If HARP wins by a wide margin and our topics add nothing as extra features to it, we report the instrument purely as an analysis tool, not a detector.

Why not just ask an LLM judge to tag reasoning moves, or use Flow Score? Judge-based tagging and graph verification spend one model call per step, and Flow Score misfires when steps rely on unstated common-sense premises. Our topic model is fit once and scores new traces with a cheap posterior calculation. We compare accuracy per unit of compute against Flow Score. We also add a judge-tagged move-count baseline: an LLM labels each step with a move type, and a classifier uses the counts. If that baseline beats us, the value of the probabilistic covariate model is in doubt.

Why not just count hedges and "wait" tokens? If simple markers capture the move profile, the topic model is unnecessary. This is the naive baseline above, and the ablation is designed so that a marker-only win would be visible.

Proposed Experiments and Decisive Checks

We train detectors on MATH and GSM8K traces and test on TriviaQA, SimpleQA, TruthfulQA, HaluEval2, HumanEval, and GPQA-Diamond. Labels are final-answer correctness against gold answers. For HaluEval2 we use its provided hallucination labels. AUROC is the primary metric, with AP where Flow Score comparisons require it. Each model is reported separately, with bootstrap confidence intervals.

The first decisive check is the content-covariate ablation. The gap between the full model and the no-content-covariate model should be near zero in-domain and clearly positive out-of-domain. If the gap is flat everywhere, the core claim is false.

The second check is the RL-trajectory analysis on our GSM8K GRPO checkpoints. We also score each checkpoint on SimpleToolHalluBench's no-tool-available queries, where no suitable tool exists, and on HumanEval. We then test whether the prevalence trajectories of "benefit" topics and "fabrication" topics separate. Their correlations with HumanEval gains and with tool-hallucination rates respectively should differ. If one topic tracks both, the trap and the transfer are inseparable at this level of description. That would be a useful negative result for anyone hoping to keep the gains and drop the fabrication.

The third check targets the think-answer mismatches catalogued in Are Reasoning Models More Prone to Hallucination? We hand-label a sample to test whether our detector catches them. These are cases where the trace looks sound and only its final step disagrees, so we specifically test whether the position-in-trace covariate is what flags them.