LLMD et: A Third Party Large Language Models Generated Text Detection Tool (2023)

Abstract: Generated texts from large language models (LLMs) are remarkably close to high-quality human-authored text, raising concerns about their potential misuse in spreading false information and academic misconduct. Consequently, there is an urgent need for a highly practical detection tool capable of accurately identifying the source of a given text. However, existing detection tools typically rely on access to LLMs and can only differentiate between machine-generated and human-authored text, failing to meet the requirements of fine-grained tracing, intermediary judgment, and rapid detection. Therefore, we propose LLMDet, a model-specific, secure, efficient, and extendable detection tool, that can source text from specific LLMs, such as GPT-2, OPT, LLaMA, and others. In LLMDet, we record the next-token probabilities of salient n-grams as features to calculate proxy perplexity for each LLM. By jointly analyzing the proxy perplexities of LLMs, we can determine the source of the generated text. Experimental results show that LLMDet yields impressive detection performance while ensuring speed and security, achieving 98.54% precision and about \times 5.0 faster for recognizing human-authored text. Additionally, LLMDet can effortlessly extend its detection capabilities to a new open-source model. We will provide an open-source tool at https://github.com/TrustedLLM/LLMDet .

## introduction recently, the emergence of chatgpt 1 has heralded a "cambrian explosion" for generative large language models (llms). @xcite , bard 2 , palm-2 @xcite , and other llms from internet companies are currently flourishing, while open-source communities are witnessing a proliferation of open-source models like llama @xcite , opt @xcite , chatglm @xcite . these models are capable of generating coherent, fluent, and meaningful text. however, the formidable text generation capabilities of generative language models have also raised concerns about their potential misuse in domains such as phishing, spreading false information, and academic fraud. additionally, with the application of products like chatgpt, the future abundance of machine-generated text data has the potential to contaminate genuine humangenerated data @xcite , altering the data ecosystem of the real world. accordingly, the study of practical content generation detection tools has attracted widespread attention from the community. recently, the primary focus of research is on approaching the text detection problem as a binary classification task to distinguish machine-generated text and humanauthored text, making it hard to assign responsibility to a specific model or its provider. nevertheless, watermarking @xcite methods necessitate altering the text generation process, leading to a compromise in the quality of the generated content. techniques like gpt-zero foot_0 , detect-gpt @xcite , and the classifier in openai (openai, 2023) require access to the deployed model, thereby resulting in high cost and intractability for third parties. thus, a practical llm detection tool should possess the following capabilities, which are also the objectives of our method: specificity: merely focusing on identifying human and machinegenerated text is insufficient for duty attribution. there is a pressing need for the ability to recognize the specific model responsible for generating the text. safety: ensuring model security and mitigating potential risks require a detection method that does not require accessing model parameters. this need is particularly urgent for commercial mod-els. efficiency: with the increasing demand for detection and the exponential growth of models, it is crucial to develop detection algorithms that have low resource and low latency requirements. extendibility: the detection tool should inherently possess the capacity to seamlessly accommodate emerging model paradigms. this capability plays a pivotal role in refining the detection ecosystem and effectively addressing the ever-expanding variety of llms. guided by the aforementioned capabilities, we propose a pragmatic third-party detection method called llmdet. our approach is inspired by the observation that perplexity serves as a reliable signal for distinguishing the source of generated text, a finding that has been validated in previous work @xcite @xcite . however, directly calculating perplexity requires access to llms, which compromises both safety and efficiency. in llmdet, we address this challenge by capturing the next token probabilities of prominent n-gram in texts as priors. this enables us to efficiently compute a proxy perplexity for each llm. by comprehensively analyzing the proxy perplexities of llms, we can accurately trace the specific language model responsible for generating the text. notably, our method eliminates the need to access the model at the detection end, ensuring the security of parameters in large-scale models. it also offers the potential for seamless integration with emerging open-source models, as well as proprietary models under appropriate licensing. these factors contribute to the widespread adoption of our approach. llmdet exhibits outstanding overall detection performance, with an f1-macro score of 88.14% and near-perfect results for r@2, indicating that highly ranked predictions cover the correct labels for the majority of instances. particularly notable is its exceptional discriminative ability in human text, llama-generated text, and bart-generated text. in terms of detection efficiency, llmdet significantly outperforms other similar methods such as fine-tuned roberta, gpt-zero foot_1 , detect-gpt @xcite , and true-ppl with respect to speed. and, it has very low resource requirements, as text detection can be accomplished solely on a cpu, enabling easy accessibility for a wider range of users. additionally, when tested on perturbated text data, llmdet produces satisfac- ## related work the existing methods for detecting generated text can be broadly categorized into two types: blackbox and white-box detection @xcite . ## motivation a practical llms detection method should possess the characteristics of being specific, secure, efficient, and extensible, which serve as the intention for developing our third-party detection tool. specificity: the field of llms constantly evolves, indicating that a sole focus on identifying human and machine-generated text is insufficient to meet detection requirements. from the perspective of copyright protection for works generated by artificial intelligence @xcite , an ideal detection tool should be capable of identifying the specific language model responsible for generating the text, thereby exerting a lasting impact on intellectual property rights protection. safety: the majority of existing detection methods require accessing or modifying model parameters, which is deemed unacceptable for commercial models. once the model is loaded, it represents a financial loss for the owner and can also expose the model to potential attacks @xcite . hence, considering the security of the model, it is desirable to minimize the need for model loading during the detection process. efficiency: with the growing number of users utilizing large-scale models, the future of text detection is poised for exponential expansion in terms of demand and user base. for instance, in the realm of education, there is a significant need for text detection to combat cheating and plagiarism @xcite , despite often constrained hardware conditions. this poses a formidable challenge to existing detection methods. hence, the pursuit of rapid and resource-efficient approaches has become a pivotal direction in developing efficient detection algorithms. extendibility: as for multi-model generated text detection approaches, it is crucial to seamlessly adapt to emerging model paradigms and extend detection capabilities to new models. this is because an excellent detection tool is not static but needs to keep up with technological advancements and continuously enhance its own detection ecosystem to address the challenges posed by new models. ## llmdet combining the aforementioned motivations, we introduce llmdet, a text detection tool capable of identifying the sources from which the text was generated, such as human, llama, opt, or others. the overall framework of the system is illustrated in figure 1 and consists of two main components: dictionary construction (see § 4.1) and text detection (see § 4.2). the construction of the dictionary is performed offline by us or provided by the model owner, ensuring its independence from external systems. this ensures the fulfillment of the four characteristics proposed for our detection tool in § 3. the text detection component can be distributed to tool users, allowing third-party detection without requiring the possession of the model. for the specific algorithm, please refer to appendix a. ## experiments we conduct experiments based on proxy perplexity and true perplexity according to the methods proposed in § 4. by comparing the performance of the text detectors based on fine-tuned roberta, proxy perplexity, and ture perplexity, we find that our proposed method outperforms existing methods in terms of detection efficiency, security, and scalability while ensuring the performance of the detector. ## analysis in this section, we conduct several additional experiments to facilitate a more comprehensive analysis of llmdet. firstly, we verify the detection robustness of llmdet. subsequently, we investigate the impact of n-gram in dictionary construction on the detection performance of llmdet. finally, we explore the influence of the top-k of the next token samples in dictionary construction on the detection performance of llmdet. ## conclusions and future work in the era dominated by machine-generated text, there is a growing need for an efficient and secure detection tool. however, existing detection methods typically require interaction with language models, which inherently compromises speed and security. our proposed detection tool, llmdet, overcomes these limitations by leveraging premined prior probability information to compute proxy perplexity, ensuring both speed and secu-rity in the detection process. additionally, our method enables text tracking, allowing for the identification of the underlying language model from which the text originates. importantly, our detection tool can be continuously enhanced by expanding to new open-source llms, enabling ongoing improvements. in the future, we aim to further refine our detection tool. firstly, we will improve the dictionaries used to compute proxy perplexity, thereby enhancing the detection performance. secondly, for closed-source models, we are unable to build their corresponding dictionaries. to mitigate it to some extent, we have considered two possible approaches: furthermore, the distillation method is a valuable avenue for future exploration. we will certainly consider it in our future research endeavors.