NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

$k$NNProxy: Efficient Training-Free Proxy Alignment for Black-Box Zero-Shot LLM-Generated Text Detection

Kahim Wong, Kemou Li, Haiwei Wu, Jiantao ZhouarXiv 2026

TL;DR

The authors introduce $k$NNProxy, a training-free and query-efficient framework that aligns an off-the-shelf proxy LLM with an unknown black-box source LLM to improve AI text detection. By repurposing $k$-nearest neighbor retrieval as a non-parametric domain adapter, it achieves state-of-the-art zero-shot detection performance without costly fine-tuning or live API dependencies.

What Problem Does This Paper Address?

Zero-shot LLM-generated text (LGT) detectors are highly popular because they don't require training a task-specific binary classifier. Instead, they use an open-source "proxy" LLM (like Falcon or GPT-Neo) to compute the likelihood of a text sequence; if the text aligns closely with the proxy's probability patterns, it's flagged as AI-generated.

However, this approach assumes the proxy LLM behaves similarly to the actual, often unknown "source" LLM (e.g., GPT-4 or Claude) that generated the text. In practice, this alignment gap causes zero-shot detectors to fail under domain shifts or when facing advanced commercial models.

Prior attempts to fix this "proxy-source gap" either require computationally heavy supervised fine-tuning (like DALD) or continuous, query-intensive API calls at test time (like Glimpse). These methods are expensive, fragile to silent commercial API updates, and brittle when encountering out-of-domain (OOD) text.

Fig. 2. Illustration of proxy alignment. Fixed-proxy detectors (e.g., Fast- DetectGPT [20], Binoculars [21], Lastde [22]) rely on an off-the-shelf proxy LLM, while proxy alignment narrows the proxy–source gap using queried data. Prior methods align the proxy either by fine-tuning on queried outputs (DALD [27]) or by streaming API returns (Glimpse [28]). Our kNNProxy instead augments a fixed proxy with a datastore built from a fixed query budget, avoiding fine-tuning and repeated API calls while improving detection.

Methods

Instead of modifying the proxy LLM's weights or querying an API for every single token during inference, $k$NNProxy uses a retrieval-augmented approach:

  1. Offline Datastore Construction: The authors build a lightweight, static datastore from a text corpus reflective of the target source LLM. Using the fixed proxy LLM, local context windows are converted into vector keys, paired with the actual next token as the value.
  2. Retrieval-Induced Interpolation: During inference, for each token in a suspicious text, $k$NNProxy queries the datastore to find the $k$-nearest context neighbors. It computes a retrieval-based token probability distribution and blends (interpolates) it with the proxy LLM's native output distribution.
  3. Mixture of Proxies (MoP): To handle domain shift, the authors extend the framework into an ensemble of domain-specific datastores. A lightweight router analyzes the input text and dispatches it to the most topically compatible datastore expert.
  4. Theory-Driven Adaptation & Tail Clipping: The authors derive a theoretical error bound to dynamically adjust the number of neighbors ($k$) and the interpolation weight ($\lambda$) token-by-token. Additionally, they introduce a lower-tail clipping strategy to prevent extreme low-likelihood outlier tokens from skewing the final detection score.
The overall architecture of the $k$NNProxy pipeline and its token-level alignment mechanism.

Datasets

The method was evaluated on two comprehensive benchmarks:

  • Mix8: A unified suite compiled from Glimpse and DNA-DetectLLM datasets. It covers 4 domains (arXiv, XSum, WritingPrompts, PubMedQA) and features text from 8 proprietary source LLMs, including GPT-4 Turbo, Claude-3.7 Sonnet, and Gemini-2.0 Flash.
  • DetectRL: A benchmark designed to test robustness against adversarial attacks (paraphrasing, prompt-based alterations, and token perturbations) across 4 domains and 4 source LLMs.

Key Insights and Ideas

  • Retrieval for Discrimination, Not Generation: While $k$NN language models traditionally use retrieval to make text generation more factual, $k$NNProxy flips this mechanism to calibrate detection-time likelihood patterns.
  • Fixing the Tail Outliers: The authors observed that zero-shot detectors suffer from extreme low-likelihood token outliers—pathological spikes where the proxy model is simply confused by a token, degrading classification accuracy. Introducing a simple lower-bound clipping threshold dramatically stabilizes detection.
Per-token log-likelihood distributions showing how low-likelihood outliers degrade separability, and how tail clipping resolves it.

Key Results

  • State-of-the-Art Accuracy: On the Mix8 benchmark, $k$NNProxy paired with the Binoculars detector achieved an exceptional average AUROC of 0.990, outperforming the previous state-of-the-art alignment method (Glimpse at 0.930) and unaligned baselines.
  • OOD and Adversarial Robustness: Under severe out-of-domain multi-LLM settings on DetectRL, $k$NNProxy boosted the F1 score of the Fast-DetectGPT detector from a baseline of 0.332 to 0.783 (a 135.84% relative improvement).
  • Source Attribution Utility: Beyond binary AI vs. Human detection, the framework proved highly effective at closed-set source attribution (identifying which specific LLM wrote the text), achieving an average accuracy of 0.84 across four major model families.

Limitations and Future Work

  • Corpus Dependency: $k$NNProxy relies on the availability of a target-reflective corpus to build its offline datastore. If no text samples from a new proprietary model are available, constructing an effective datastore becomes challenging.
  • Source Confusion: In source attribution tasks, the model occasionally confuses outputs from Claude with Llama-2 or PaLM-2, as these models share highly similar underlying readability statistics. Future work could explore finer-grained features to better separate closely related model families.

Summary updated

BibTeX
@misc{wong2026k,
  author = {Kahim Wong and Kemou Li and Haiwei Wu and Jiantao Zhou},
  title = {{$k$NNProxy: Efficient Training-Free Proxy Alignment for Black-Box Zero-Shot LLM-Generated Text Detection}},
  year = {2026},
  eprint = {2604.02008},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.02008},
}
Figure