LLMDet: A Large Language Models Detection Tool

Kangxi Wu, Liang Pang, Huawei Shen, Xueqi Cheng, Tat-Seng Chua

Introduction

As Large Language Models (LLMs) such as ChatGPT, LLaMA, and GPT-4 become increasingly integrated into daily digital interactions, the ability to distinguish between human-authored and machine-generated text has become a critical necessity. The proliferation of AI-generated content raises significant concerns regarding academic integrity, the spread of misinformation, and "data contamination"—a phenomenon where AI-generated text is inadvertently used to train future models, potentially degrading their quality.

Existing detection frameworks often suffer from three primary limitations. First, most are binary classifiers that fail to provide attribution, meaning they cannot identify which specific model generated a piece of text. Second, high-accuracy methods like DetectGPT require multiple queries to the source model, which is both computationally expensive and often impossible for proprietary, closed-source models. Finally, many current tools require substantial GPU resources, making them impractical for large-scale, real-time auditing.

LLMDet addresses these gaps by introducing a model-specific, secure, and highly efficient detection tool that can run on standard CPU hardware without requiring direct access to the target models during the detection phase.

Methodology: The Proxy Perplexity Framework

The core innovation of LLMDet is the concept of Proxy Perplexity. In traditional linguistics, perplexity measures how well a probability distribution or probability model predicts a sample. An LLM is typically "least surprised" (lower perplexity) by text it has generated itself. However, calculating true perplexity requires running the full, often massive, LLM architecture.

LLMDet bypasses this requirement through a two-phase process:

  1. Offline Dictionary Construction: The researchers generate extensive text samples from various LLMs to identify the most frequent n-grams (sequences of 2 to 4 words). They then record the next-token probability distributions for these specific n-grams directly from the source models. This creates a compact "fingerprint" of the model's internal logic.
  2. Online Text Detection: When a user submits text for analysis, LLMDet looks up the constituent n-grams in its pre-computed dictionaries to estimate a "proxy" perplexity for each supported model. These proxy values are then processed by a lightweight LightGBM classifier to determine the most likely source.
The detailed workflow of LLMDet, illustrating the transition from offline dictionary construction to online proxy perplexity estimation and result ranking.

To ensure efficiency, the authors implemented significant compression techniques. By selecting only the top-k most salient n-grams and converting probability values from Float64 to Float16, the storage requirement for a single model's dictionary was reduced from 22GB to just 0.5GB, with negligible impact on accuracy.

Experimental Setup and Datasets

The tool was evaluated using a comprehensive dataset comprising 32,000 samples per model. Prompts were sourced from Wikipedia (SQuAD) and news articles (Xsum), while human-authored benchmarks were pulled from the HC3 (Human ChatGPT Comparison Corpus). The machine-generated text spanned nine prominent models: GPT-2, OPT, UniLM, LLaMA, BART, T5, Bloom, and GPT-Neo.

Key Results and Performance

LLMDet demonstrates a superior balance of speed and attribution accuracy compared to existing state-of-the-art methods.

Accuracy and Attribution

LLMDet achieved an overall F1-Macro score of 88.14%. A standout feature is its precision in identifying human-authored text, which reached 98.54%. The tool also excels at model-specific attribution; for instance, it identifies LLaMA and BART with near-perfect accuracy (97-98%). While some overlap exists between models with similar architectures (like GPT-2 and OPT), the tool remains highly effective at distinguishing between different model families.

Confusion matrix demonstrating LLMDet's ability to accurately attribute text to specific source models or human authors.

Efficiency and Speed

One of the most significant advantages of LLMDet is its computational efficiency. Because it relies on dictionary lookups rather than full model inference, it is approximately 5x faster than "True-PPL" methods. Compared to query-based methods like DetectGPT, LLMDet is orders of magnitude faster, making it suitable for rapid, large-scale third-party auditing on consumer-grade hardware.

Conclusion and Future Work

LLMDet represents a significant step forward in the field of AI-generated text detection by providing a fast, extensible, and model-specific attribution tool. Its robustness to different "temperature" settings and its ability to run on CPUs make it a practical solution for real-world deployment.

Future iterations of the tool aim to expand language support beyond English and address the challenges of closed-source models (like GPT-4) by proposing an extensible interface for model owners. Additionally, the researchers plan to investigate the tool's resilience against sophisticated adversarial rewriting and paraphrasing techniques.

Summary updated

BibTeX
@inproceedings{wu2023llmdet,
  author = {Kangxi Wu and Liang Pang and Huawei Shen and Xueqi Cheng and Tat-Seng Chua},
  title = {{LLMDet: A Large Language Models Detection Tool}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.139},
}
Figure