Zero-Shot Detection of LLM -Generated Text using Token Cohesiveness (2024)

Abstract: The increasing capability and widespread usage of large language models (LLMs) highlight the desirability of automatic detection of LLM-generated text. Zero-shot detectors, due to their training-free nature, have received considerable attention and notable success. In this paper, we identify a new feature, token cohesiveness, that is useful for zero-shot detection, and we demonstrate that LLM-generated text tends to exhibit higher token cohesiveness than human-written text. Based on this observation, we devise TOCSIN, a generic dual-channel detection paradigm that uses token cohesiveness as a plug-and-play module to improve existing zero-shot detectors. To calculate token cohesiveness, TOCSIN only requires a few rounds of random token deletion and semantic difference measurement, making it particularly suitable for a practical black-box setting where the source model used for generation is not accessible. Extensive experiments with four state-of-the-art base detectors on various datasets, source models, and evaluation settings demonstrate the effectiveness and generality of the proposed approach. Code available at: https://github.com/Shixuan-Ma/TOCSIN.

## introduction the past few years have witnessed tremendous advances in large language models (llms). these models such as chatgpt @xcite , palm @xcite , @xcite can now generate text of supreme quality, demonstrating exceptional performance in various fields like question answering, news reporting, and story writing. the increasing capability of llms to produce human-like text at high efficiency, however, also raises concerns about their misuse for malicious purposes, e.g., phishing @xcite , disinformation @xcite , and academic dishonesty @xcite . the effective detection figure 1 : histograms of token cohesiveness distributions for 500 human-written and 500 llm-generated articles. human-written articles are sampled from xsum @xcite , and llm-generated articles are produced by prompting four source models with the first 30 tokens of each human-written article. the calculation of token cohesiveness will be detailed in section 3.2. llm-generated text detection is typically formulated as a binary classification task, i.e., to classify if a piece of text is generated by a particular source llm or written by human @xcite . current solutions roughly fall into two categories: supervised classifiers and zero-shot classifiers. supervised classifiers are trained from labeled data and thus may overfit to their specific training domains @xcite . zero-shot classifiers, in contrast, are entirely training-free, making them less prone to domain-specific degradation and typically generalizing better @xcite . most existing zero-shot detectors are developed based on the generation probabilities (or their variations) of the source model, assuming that llmgenerated text aligns better with these probabilities @xcite . this paper takes a different tack and introduces a fundamentally new feature, token cohesiveness, which the input text x is fed into the upper channel to calculate token cohesiveness u(x), and the lower channel to produce raw prediction v(x). the two scores are then combined into w(x), and if the combination exceeds a predefined threshold , the text x is categorized as llm-generated. given the discriminative power of the new feature and its distinctiveness from existing detectors, we propose tocsin, a novel paradigm that leverages token cohesiveness to enhance zero-shot detection of llm-generated text. tocsin is a dual-channel detector, with one channel equipped with an existing zero-shot detector, and the other channel a token cohesiveness calculation module. given a piece of text to be detected, we create multiple copies, with each copy randomly removing a specific proportion of tokens from the input text. we calculate the average semantic difference, or more precisely, the average negative bartscore @xcite between the input text and these copies as the token cohesiveness score. meanwhile, we feed the input text into an existing zero-shot detector to produce a raw prediction score. after that, we combine the two scores and perform thresholding on the combination to make the final decision. the overall procedure is sketched in figure 2 . as an enhancement to existing zero-shot detectors, tocsin enjoys several merits. (1) general applicability: the dual-channel solution of toc-sin is quite generic, allowing token cohesiveness to be used as a plug-and-play module in a variety of detectors. (2) low additional time cost: toc-sin keeps the existing detector channel unchanged, and the additional time cost mainly comes from token cohesiveness calculation, which only involves several rounds of random token deletion and bart-score computation, and is highly time efficient. (3) low additional space cost: the only additional space cost comes from loading bart @xcite (or more precisely, bart-base), which is relatively small compared to those scoring models used in existing zero-shot detectors. to rigorously evaluate the effectiveness and generality of tocsin, we apply it to four current stateof-the-art zero-shot detectors, likelihood @xcite , logrank @xcite , lrr @xcite and fast-detectgpt @xcite , and conduct extensive experiments on four diversified datasets, with llm-generated passages produced by eight different source models ranging from gpt-2 @xcite to gpt-4 (ope-nai, 2023) and gemini @xcite . experimental results demonstrate consistent and meaningful improvements over the four detectors in both white-box and black-box settings. our main contributions in this paper are threefold: (1) unveiling and validating a new hypothesis that llm-generated text exhibits higher token cohesiveness than human-written text, (2) proposing a novel and generic framework that uses token cohesiveness to improve zero-shot detection of llm-generated text, and (3) achieving new best detection accuracy compared to existing zero-shot detectors. ## related work the increasingly powerful llms @xcite @xcite @xcite , though demonstrating excellent performance on various language-related tasks, raise numerous ethical concerns, drawing extensive attention to automatic detection of llm-generated text @xcite . llm-generated text detection is typically formulated as a binary classification task, with current solutions roughly categorized into supervised classifiers and zero-shot classifiers. supervised classifiers are those trained with statistical features @xcite @xcite or neural representations @xcite @xcite @xcite to discriminate llm-generated and humanwritten text, wherein a popular trend is to directly fine-tune a pre-trained language model like bert @xcite or roberta @xcite for the classification task @xcite @xcite . these supervised classifiers, though achieving excellent performance on their training domains, require periodic retraining to adapt to new llms, and often exhibit a tendency to overfit their training data @xcite . zero-shot classifiers are entirely training-free and often show better generalization ability. their key ideas are to extract various statistical features, e.g., likelihood @xcite , perplexity @xcite , normalized log-rank perturbation @xcite , probability and conditional probability curvatures @xcite , and perform thresholding on these features to discern llm-generated and human-written text. such features can be collected from the source llms themselves (the white-box setting) or from surrogate models (the black-box setting). in this paper, we propose a new feature called token cohesiveness to improve existing zero-shot detectors. the computation of the new feature does not rely on the source llms, making it particularly suitable for the black-box setting. recently there emerge some black-box zero-shot detectors based on llm rewriting @xcite . the idea is to rewrite a passage using another llm, typically chatgpt, and then assess the similarity or overlap between the original and recomposed text. passages with larger similarity or overlap will be regarded as llm-generated. our approach similarly adheres to the principle of text reconstruction. but it considers only random token deletion and does not require additional api calls, thus is more efficient and economical. besides binary classification, some recent studies consider more challenging llm-generated text detection tasks, e.g., detecting mixtures of humanwritten and llm-modified text @xcite and tracing the origin of text generation @xcite . these topics are out of the scope of this paper and will be studied as future work. ## methodology this section presents tocsin, a novel paradigm to improve zero-shot detection of llm-generated text. below we formally define the task in section 3.1, then illustrate our key assumption in section 3.2, followed by the detailed approach in section 3.3. ## experiments this section evaluates the effectiveness of tocsin for zero-shot llm-generated text detection compared with prior state-of-the-arts, and also provides extensive additional analyses to better understand multiple facets of the proposed method. ## conclusion this paper introduces the concept of token cohesiveness and unveils that it can serve as a new criterion to discriminate llm-generated and humanwritten text. based on this new finding, we devise tocsin for zero-shot detection of llm-generated text. tocsin is a generic dual-channel detection paradigm that uses token cohesiveness as a plugand-play module to improve existing zero-shot detectors. as empirical evaluation, we apply toc-sin to four current state-of-the-art base detectors, and achieve meaningful improvements across four diversified datasets with passages generated from eight different source llms, demonstrating the effectiveness and generality of our approach.