ExaGPT: Example-Based Machine-Generated Text Detection for Human Interpretability

Ryuto Koike, Masahiro Kaneko, Ayana Niwa, Preslav Nakov, Naoaki Okazaki

TL;DR

ExaGPT is a novel, interpretable LLM text detector that mimics the human decision-making process by segmenting text and retrieving similar human-written or AI-generated examples from a datastore. By providing concrete, semantically similar text spans as evidence, it helps users intuitively verify a text's origin while outperforming existing interpretable detectors by up to 37% accuracy at a strict 1% false positive rate.

What Problem Does This Paper Address?

As Large Language Models (LLMs) become ubiquitous, distinguishing machine-generated text from human-written text has become crucial to prevent academic cheating and the spread of fake news. However, false positives carry severe consequences, such as ruining a student's academic reputation or causing a writer to lose their job.

Because no detector is 100% perfect, tools must provide interpretable evidence so users can judge the reliability of a prediction. Existing interpretable detectors rely on abstract technical metrics like token-level log-probabilities or complex perturbation scores, which are completely disconnected from how humans naturally evaluate text. When humans suspect a text is AI-generated, they intuitively look for familiar phrases or stylistic overlaps. The authors introduce ExaGPT to bridge this gap by aligning machine explanation with human intuition.

Concept of identifying text origin via similar spans

Methods

ExaGPT operates in two primary phases: Span Scoring and Span Selection.

  1. Span Scoring via $k$-NN Search: Given a target text, the system extracts potential $n$-gram spans. Each span is embedded into a vector space using a standard BERT model. ExaGPT then performs a $k$-nearest neighbor ($k$-NN) search via FAISS against a pre-computed datastore containing both human-written and LLM-generated texts. For each target span, it computes:
  2. A Length score ($L$): The number of tokens.
  3. A Reliability score ($R$): The mean cosine similarity of the top-$k$ neighbors, indicating how frequently similar phrases appear in the datastore.
  4. A Prediction score ($P$): The ratio of LLM-generated text labels among the retrieved neighbors.
  5. Span Selection via Dynamic Programming: To make the final output readable, ExaGPT uses dynamic programming to segment the text into a sequence of optimal, non-overlapping spans. The optimization function balances long span lengths and high reliability scores using a tuning parameter $\alpha$: $$S = \alpha \cdot L_{std} + (1 - \alpha) \cdot R_{std}$$

The overall text is classified as LLM-generated if the mean prediction score ($P_{overall}$) across all selected spans exceeds a specific threshold.

Overview of the ExaGPT workflow

Datasets

The authors evaluated ExaGPT using the English subset of the M4 dataset, a large-scale text detection benchmark. The dataset includes 3,000 pairs of human and machine-generated texts across:

  • Four domains: Wikipedia, Reddit, WikiHow, and arXiv.
  • Three generators: ChatGPT, GPT-4 (closed-source), and Dolly-v2 (open-source).

Each domain/generator combination was split into 2,000 pairs for training (used as the datastore), 500 for validation, and 500 for testing.

Key Insights and Ideas

  • Semantic Similarity Trumps Exact Matches: Unlike prior work (like DNA-GPT) that relies strictly on exact $n$-gram overlaps, ExaGPT leverages dense embeddings to find semantically similar phrases. This captures stylistic and structural AI signatures even when the exact wording differs.
  • Reliability Drives Performance: Analysis of the hyperparameter $\alpha$ showed that smaller values of $\alpha$ (which place more weight on the reliability score $R$ rather than span length $L$) yield better detection performance. Selecting target spans that closely match the datastore is key to accuracy.
  • Intuitive UI Empowers Users: By highlighting text spans in red (human-leaning), blue (LLM-leaning), or green (neutral) and providing a hover-tooltip with the exact retrieved source examples, ExaGPT allows users to quickly verify why a text was flagged.
ExaGPT User Interface Tooltip Example

Key Results

  • Superior Human Interpretability: In a human evaluation study, participants were asked to judge whether a detector's decision was correct based on its provided evidence. Humans achieved 61.5% accuracy using ExaGPT's evidence, significantly higher than baseline methods like RoBERTa with SHAP (47.9%), LR-GLTR (57.3%), and DNA-GPT (53.1%).
  • Massive Performance Gains at Low FPR: In real-world deployment, minimizing false positives is critical. At a fixed 1% False Positive Rate (FPR), ExaGPT outperformed baseline interpretable detectors by up to +37.0 accuracy points (e.g., scoring 96.0% accuracy on ChatGPT-generated WikiHow texts compared to RoBERTa's 50.0%).
  • Robustness to Paraphrasing: When texts were heavily rewritten using the DIPPER paraphraser, ExaGPT maintained moderately high detection performance, generally outperforming its closest competitor, LR-GLTR.
  • Computational Efficiency: While dense retrieval can be expensive, the authors demonstrated that using FAISS with Product Quantization (IVFPQ) and reducing the datastore size to 500 pairs cut GPU memory usage by 87% and latency by 90% with only a minor drop in AUROC (from 99.5 to 97.8).

Limitations and Future Work

  • User Study Scope: The human evaluation relied on four annotators who all had NLP backgrounds. The authors acknowledge that future work needs to validate whether these interpretability benefits extend to a broader, non-technical user population (e.g., classroom teachers).
  • Datastore Dependence: ExaGPT's performance naturally degrades when evaluating text from an unknown domain or a generator not represented in its datastore. While creating a mixed-source ("ALL") datastore mitigates this drop, optimizing datastore configurations for open-world deployment remains an open challenge.

Summary updated

BibTeX
@inproceedings{koike2026exagpt,
  author = {Ryuto Koike and Masahiro Kaneko and Ayana Niwa and Preslav Nakov and Naoaki Okazaki},
  title = {{ExaGPT: Example-Based Machine-Generated Text Detection for Human Interpretability}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.findings-acl.380},
}
Figure