Detecting Machine Text When the Machine Is Quoting Humans

Current detectors of machine-written text rest on one observation: language models write in a narrower, more predictable way than people do. One strong recent detector turns this into one-class learning, a setup where a model sees only one kind of example during training and learns to flag anything that falls outside it. That detector trains only on machine text, draws a tight boundary around it, and treats human writing as the outlier. Retrieval-augmented generation (RAG) is a setting where this assumption should break. In RAG, the model fetches human-written documents and writes its answer from them, so much of the output is copied or lightly paraphrased human prose. We expect such text to look human to a compactness-based detector because, in part, it is human text. The same is true in reverse: a person summarizing an article also borrows the article's words. How much a text borrows from its source is a nuisance variable, and it is tangled with authorship in ways no existing detector accounts for.

We propose a one-class detector for grounded text that reads each response together with the passages it was written from. Its representation is trained adversarially so that it cannot predict how much the response copies from its sources or which document collection the sources came from. The detector's boundary around machine text then has to rest on what the writer added beyond the source, not on how much source text shows through. Put simply: judge authorship on the part of the response the writer contributed, and train the representation so that it is blind to the borrowing.

Core Claim

Two claims follow, and both can be tested. The diagnostic claim is that the intrinsic-dimension gap between human and machine text (about 9 versus about 7.5 in English, from Intrinsic Dimension Estimation for Robust Detection of AI-Generated Texts) shrinks as a response copies more from its retrieved context. If so, the machine-as-inlier detector of Human Texts Are Outliers, which reports 98.3% AUROC and 8.9% FPR95 on ungrounded DeepFake text, should miss more heavily grounded machine responses. That paper tested only ungrounded generations. It motivates this proposal and supplies its base method.

The constructive claim is that removing copy rate and source-collection identity from the detector's features restores detection on grounded text. It should also transfer to document collections the detector never saw. Neither tweaking the one-class loss nor adding more training data should achieve this.

How This Differs From the Closest Work

Three papers each cover two of our four directions. ConDA adapts a supervised RoBERTa detector from one generator to another. It aligns feature distributions with maximum mean discrepancy, a statistic that measures how far apart two sets of features are, and adds contrastive learning on synonym-perturbed text. It needs labeled human and machine text in the source domain and never sees retrieved context. Our method is one-class and conditioned on the source passages. Our adversary also removes a specific nuisance variable, copy rate, rather than aligning whole domains.

Auto-GDA adapts a small grounding verifier to new RAG domains using LLM-generated synthetic claims. It reports that feature-alignment domain adaptation "barely moved the needle" for natural-language-inference-based checking of whether a claim is supported. This result constrains our design, and we take it seriously. We think the likely reason is that entailment labels depend on the fine-grained relation between claim and passage, and aligning whole distributions erases that relation. We therefore do not align the task variable. We adversarially remove a variable we believe should be irrelevant to authorship. Whether this distinction holds is one of the things the experiments test.

Human Texts Are Outliers supplies the one-class formulation: DeepSVDD, which learns to map inlier examples into a small sphere in feature space, with machine text as the inlier. We keep that formulation and change what the encoder sees and what it is forbidden to encode.

The method borrows from two sources. The adversarial part is a gradient reversal layer: a domain-prediction head whose gradient is sign-flipped before it reaches the encoder, so the encoder is pushed to make that head fail. This is the approach of FAN-Net and Ren et al.. The idea of making pseudo-outliers by adding noise to features comes from SimpleNet. Two other papers explain why a single score over the whole response is risky. RAGTruth finds that unsupported content concentrates toward the end of responses. Beyond Checkmate finds that the middle of a document separates human from machine writing best. Together they suggest that the writer's own contribution is spread unevenly across a response.

Research Program

The first step is a measurement study. We need human and machine responses written from the same sources. RAGTruth provides this almost directly. Its question-answering portion uses MS MARCO passages, and MS MARCO also contains human-written answers. Its summarization portion uses CNN/Daily Mail articles, which come with human-written highlights. RAGTruth itself contains 17,790 responses from six LLMs over those same contexts. The Yelp data-to-text portion has no paired human text, so we use it only on the machine side.

For every response we compute a copy rate: the fraction of tokens inside n-gram spans shared with the retrieved passages, plus a semantic version based on sentence-embedding similarity to the closest source sentence. We then estimate persistent-homology intrinsic dimension within copy-rate bins, following Tulchinskii et al., and run the Zeng et al. detector in each bin. This step either confirms the compactness failure or kills the proposal early.

The detector itself works as follows. A cross-encoder reads the retrieved passages and the response together and produces features for the response. A DeepSVDD objective pulls machine responses toward a center. Following SimpleNet, noised copies of those features serve as pseudo-outliers, so the boundary does not become trivially loose. Two adversarial heads sit behind gradient reversal. One predicts the binned copy rate. The other predicts which source collection or task the passages came from.

Training uses machine text only. Human text is used only at evaluation, which keeps the setup honestly one-class. With $c$ the sphere center, $z$ the response features, $\ell_{\text{copy}}$ and $\ell_{\text{dom}}$ the adversaries' cross-entropy losses, and $\lambda$ a weight, the encoder minimizes

$$\mathbb{E}\,\|z-c\|^2 \;+\; \mathcal{L}_{\text{noise}} \;-\; \lambda\,(\ell_{\text{copy}}+\ell_{\text{dom}}),$$

while the adversary heads minimize their own losses. Here $\mathcal{L}_{\text{noise}}$ is the loss of a small classifier that separates real features from noised ones. A variant scores only sentences whose copy rate falls below a threshold. This tests whether the adversary is doing anything beyond explicit masking.

Baselines

The naive reference point is the Zeng et al. detector trained on ungrounded machine text and applied unchanged to RAG responses. Its reported numbers are 98.3% AUROC and 8.9% FPR95 on DeepFake, and "up to 95.2%" AUROC on unseen LLMs, from Human Texts Are Outliers. This is the strongest existing one-class detector in the file. We re-run it with the same backbone as our detector, so the comparison isolates retrieval conditioning and the adversaries. Beating it means a higher AUROC and a lower FPR95 on paired human responses, most importantly in the top copy-rate tercile.

The same detector retrained on RAG-generated machine text from the training tasks is the most important competitor, because it asks whether more relevant data is all that is needed. It gets identical data and the same tuning budget, a fixed number of hyperparameter trials each. We count our method as beating it only if the gap holds on the held-out task.

ConDA, which reports AUROC "near 0.99" across TuringBench generator pairs, is the strongest domain-adaptation competitor. We run it with labeled source human and machine text and unlabeled target text. This gives it more supervision than we use, and we report it as such.

Zero-shot scoring comes in two forms. The first is plain log-rank as in DetectLLM. The second is a context-conditioned log-rank that scores the response given the retrieved passages. That second variant is a strong training-free way to discount copied text, and we treat it as a serious threat.

For RAG machine-text detection specifically, no reported result found on Lacuna for detecting authorship of grounded responses. RAGTruth's reported figures (78.7% response-level F1 for a fine-tuned Llama-2-13B) concern hallucination, not authorship, and are not comparable.

The ablations remove the copy-rate adversary, remove the source-collection adversary, replace adversarial removal with explicit masking of copied spans, and drop the retrieved context from the encoder's input.

Why not just…?

Why not just generate RAG text in the target domain and retrain the one-class detector? Because machine text is the inlier class, target-domain inliers are cheap to produce, and this is a real threat. The trouble is that the detector would still be free to use copy rate as evidence. Human writers quoting sources also score high on it, and deployed RAG systems vary how much they copy with different prompts and retrievers. The decisive test trains on one copy-rate regime and tests on another: extractive prompts versus abstractive prompts over the same contexts. If augmentation matches us there, the adversary is unnecessary and we will report that.

Why not just mask copied n-grams before scoring? This is the simplest fix and may work well enough. It misses paraphrased borrowing, which grows as generators are prompted to rephrase. The masking ablation, split by lexical versus semantic copy rate, settles whether the learned invariance adds anything.

Why not just fine-tune a supervised binary classifier on grounded human and machine pairs? Paired human grounded text exists for only a few tasks. Supervised detectors also collapse under domain shift: RoBERTa loses 66% Macro F1 when moving from ArXiv to IDMGSP abstracts in Exploring the Limitations of Detecting Machine-Generated Text. We include this classifier under leave-one-task-out evaluation to measure that collapse on grounded text.

Why not just use context-conditioned likelihood? Conditioning on the passages already makes copied tokens cheap to predict, so the remaining surprise should reflect the writer's contribution. However, likelihood scores are fragile to paraphrasing: F1 falls from 0.99 to 0.04 in MGTBench. Binoculars also shows a length bias. We therefore run all methods under DIPPER-style paraphrasing as well as on clean text.

Proposed Experiments

The primary protocol is leave-one-task-out across RAGTruth question answering, summarization, and data-to-text. Human-side evaluation covers the first two, using MS MARCO answers and CNN/Daily Mail highlights. Metrics are AUROC, FPR95, and accuracy at 1% false-positive rate, reported per copy-rate tercile and per generator, with Llama-2-7B held out as an unseen generator.

We add three sanity checks. First, the detector should keep performance near Zeng et al. on ungrounded DeepFake and TuringBench text, so that the fix does not break the standard case. Second, the adversaries should actually fail at their jobs: we train fresh probes on the frozen features and expect them to predict copy rate and source collection at chance. Third, the "tail effect" check tests whether scoring only the final third of a response is more or less informative than scoring the middle.

The proposal is decisively supported only if three things hold together. The naive detector's false-negative rate must rise with copy rate. Our method must flatten that curve on the held-out task. The masking and augmentation baselines must fail to flatten it equally.