Manuscript Offprint

arXiv:2608.22179

Token-Level Likelihood-Array Regression for Membership Inference and AI-Generated Text Detection

Jiajun Sun, Zhanrui Cai

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Membership inference asks whether a text was used to train a language model, whereas AI-generated text detection asks whether it was generated by a language model rather than written by a human. Existing likelihood-based methods typically compress token-level probabilities into a few prespecified scores, most often using only probabilities conditioned on the full preceding context. We propose likelihood-array regression (LAR), which evaluates each target token under nested left-context windows and organizes the resulting likelihood-derived features into a structured array. After aligning arrays across texts of different lengths, LAR learns how detection information varies with context scale, token position, and likelihood features. LAR-1 aggregates learned contributions from individual aligned cells, while LAR-2 adds second-order features formed from pairs of evaluations of the same target token across context lengths. For within-path quadratic model, we establish matching minimax lower and upper bounds, characterize errors from finite-dimensional approximation and random squared projections, and derive conditions under which an oracle spectral sieve attains the minimax rate. Across multiple scoring language models, LAR substantially improves membership inference and AI-generated text detection over likelihood-based baselines. The analyses further show that shorter-context likelihoods contain information beyond conventional full-context probabilities, while second-order features provide additional gains for membership inference.

Keywords: AI-generated text detection; membership inference; likelihood array; structured covariates

1 Introduction

We consider two related problems in auditing language models. The first is membership inference, which asks whether a given text was included in the training data of a particular language model. This question is central to privacy and copyright audits. For example, a publisher may seek to determine whether its proprietary articles were used to train a model, as highlighted by The New York Times' ongoing lawsuit against OpenAI and Microsoft (The New York Times Company, 2023). The second is AI-generated text detection, which asks whether a text was produced by a language model rather than written by a human. This question arises in authorship verification, academic publishing, and the identification of model-generated passages in mixed-content documents. Although the two problems concern different relationships between a text and a language model, both can be formulated as binary classification tasks based on conditional token probabilities. In membership inference, the label indicates whether the text was used to train the model; in AI-generated text detection, it indicates whether the text was written by a human or generated by AI.

Existing likelihood-based approaches to these two detection tasks generally reduce token-level probabilities to one or a few scalar summaries. For membership inference, commonly used summaries rely on calibrated losses, lower-tail token likelihoods, or adjustments for token rarity; for AI-generated text detection, they rely on token ranks, likelihood curvature, comparisons across models, or adaptive witness functions (Carlini et al., 2021; Shi et al., 2024; Mitchell et al., 2023; Hans et al., 2024; Zhou et al., 2025). Most of these methods are built from the standard next-token log-probability sequence ℓfull(t)=log⁡pθ(xt∣x1,…,xt−1)\ell_{\text{full}}(t) = \log p_{\theta}(x_t \mid x_1, \ldots, x_{t-1}), where each token is evaluated conditional on the entire preceding sequence. More recent methods incorporate specific forms of context dependence by introducing external prefixes, computing perplexities over subsequences, or contrasting predictions with and without context (Xie et al., 2024; Chang et al., 2025; Sun et al., 2026). Nevertheless, they ultimately aggregate the resulting likelihood information into a small number of prespecified scores. An alternative approach is to fine-tune a language model as a detector using a large labeled corpus (Zhou et al., 2026). Adapting such detectors to a new audited model or application domain generally requires additional labeled data and extra model fine-tuning. Existing approaches therefore leave open a broader statistical question: how should likelihood information that varies jointly with context length and token position be represented and modeled for these two detection tasks?

Addressing this question involves three major statistical challenges. First, evaluating the tokens in each document under multiple lengths of preceding context produces a likelihood representation whose dimensions vary with document length. Such a representation must place documents of different lengths on a common domain while preserving information about both token position and context length. Second, token probabilities contain not only signals relevant to the detection label but also substantial nuisance variation arising from token rarity, baseline predictability, topic, writing style, document length, and model calibration. Third, the context lengths, document regions, and likelihood patterns that are informative for detection are not known in advance. Learning these relationships without imposing structural assumptions would require estimating a high-dimensional function from a relatively small labeled sample.

In this paper, we propose token-level likelihood-array regression (LAR), a regression framework for both applications. LAR represents the conditional token probabilities obtained from a fixed scoring language model as a structured, variable-length array and models the conditional log odds of the binary label through functionals of this array. To construct the array, the scoring model evaluates each target token under a sequence of nested left-context windows. Each resulting cell is indexed by the amount of preceding context and the token's relative position in the document, and is augmented with several features derived from the model's predictive distribution. We align these cells on a common domain so that documents of different lengths can be analyzed within a single model. LAR-1 learns how the location and likelihood-derived features of each cell contribute to the class log odds and averages these contributions across context lengths and target tokens. LAR-2 adds within-path second-order features formed from pairs of evaluations of the same target token; these include both same-context quadratic terms and products across different context lengths. Basis expansions and random squared projections provide finite-dimensional approximations of the two models, which are then estimated by ridge logistic regression.

We provide both empirical and theoretical support for the proposed framework. Most notably, across five scoring models in each application, LAR attains mean held-out AUCs of 0.914–0.983 for membership inference and 0.985–0.996 for AI-generated text detection, substantially outperforming existing likelihood-based procedures. Restricted-array analyses further show that likelihoods computed from shorter preceding contexts contain information beyond conventional full-context likelihoods, while the within-path second-order augmentation yields additional gains primarily for membership inference. On the theoretical side, for the proposed within-path quadratic model, we establish matching minimax lower and upper prediction bounds at the rate {log⁡(en)/n}ν/(ν+1)\{\log(en)/n\}^{\nu/(\nu+1)} under product-form covariance decay. We further decompose the prediction error of finite-dimensional estimators into approximation, regularization, estimation, and squared-projection components, identify resolution conditions under which an oracle spectral sieve attains the minimax rate, and connect prediction error to AUC convergence.

The remainder of the paper is organized as follows. Section 2 reviews likelihood-based detection methods and regression with structured covariates. Section 3 constructs the likelihood-array representation and introduces the LAR models and estimators. Section 4 establishes the minimax prediction bounds, finite-resolution guarantees, and implications for AUC. Section 5 presents the numerical studies, and Section 6 discusses the scope and limitations of the proposed framework.

References (32)

  • A simple yet efficient ensemble approach for AI-generated text detection
  • Fast-DetectGPT: Efficient zero-shot detection of machine-generated text via conditional probability curvature
  • Pythia: A suite for analyzing large language models across training and scaling
  • Extracting training data from large language models
  • Context-aware membership inference attacks against pre-trained large language models
  • Ranking and empirical minimization of U-statistics
  • The Pile: An 800GB Dataset of Diverse Text for Language Modeling
  • GLTR: Statistical detection and visualization of generated text
  • How close is ChatGPT to human experts? comparison corpus, evaluation, and detection (opens arXiv in a new tab)
  • Spotting LLMs with binoculars: Zero-shot detection of machine-generated text
  • Automatic detection of generated text is easiest when humans are fooled
  • Low-rank tensor estimation via riemannian gauss-newton: Statistical optimality and second-order convergence
  • Membership inference attacks against language models via neighbourhood comparison
  • DetectGPT: Zero-shot machine-generated text detection using probability curvature
  • Functional regression
  • Functional Data Analysis
  • Detecting pretraining data from large language models
  • Release strategies and the social impacts of language models (opens arXiv in a new tab)
  • DetectLLM: Leveraging log rank information for zero-shot detection of machine-generated text
  • Likelihood ratio test for membership inference in large language models
  • Model card for Falcon-7B
  • Complaint, The New York Times Company v
  • Llama 2: Open Foundation and Fine-Tuned Chat Models
  • Ghostbuster: Detecting text ghostwritten by large language models
  • ReCaLL: Membership inference via relative conditional log-likelihoods
  • DNA-GPT: Divergent N-gram analysis for training-free detection of GPT-generated text
  • Data contamination calibration for black-box LLMs
  • Fine-tuning can help detect pretraining data from large language models
  • Min-k%++: Improved baseline for detecting pre-training data from large language models
  • Regularized matrix regression
  • AdaDetectGPT: Adaptive detection of LLM-generated text with statistical guarantees
  • Detecting LLM-generated text with performance guarantees (opens arXiv in a new tab)