ASK-NN: An Asymmetric Nearest-Neighbor Test that detects Distribution Drifts in Natural Language
Summary
ASK-NN is an asymmetric nearest-neighbor test for detecting distribution drifts between reference and query samples, with applications to LLM hallucination detection and artificial-text detection. It is computationally efficient, has theoretical guarantees, and performs competitively against baselines on synthetic and real-world benchmarks.
View Cached Full Text
Cached at: 07/20/26, 09:30 AM
# ASK-NN: An Asymmetric Nearest-Neighbor Test that detects Distribution Drifts in Natural Language
Source: [https://arxiv.org/html/2607.15607](https://arxiv.org/html/2607.15607)
###### Abstract
Hallucinations and artificial text in LLM\-generated outputs often appear as distributional deviations between prompt and response hidden\-state distributions\. Since prompts or retrieved contexts typically serve as reference samples and responses as query samples, with major differences in length, these asymmetries motivate the use of change test statistics that treat the two samples differently\. We consider an asymmetric two\-sample test ASK\-NN based on the directed k\-nearest\-neighbor \(k\-NN\) graph\. Our statistic counts reference points whose nearest neighbor in the pooled sample is also a reference point\. Under the permutation null, it admits an exact finite\-sample conditional mean and variance; we further establish asymptotic normality and consistency under fixed alternatives\. ASK\-NN is computationally effective and easy to implement\. Empirically, it is competitive with kernel and graph\-based baselines on synthetic benchmarks, artificial\-text detection, and LLM hallucination detection from token\-level hidden states\.111Code is available at: https://anonymous\.4open\.science/r/asymmetrical\-multivariate\-two\-sample\-test\-21F0/
Machine Learning, ICML
## 1Introduction
Large language models \(LLMs\) are increasingly deployed in various applications with extended usage in decision\-support pipelines\[Liuet al\.,[2024](https://arxiv.org/html/2607.15607#bib.bib8)\]\. Due to limited memory and information constraints in the training data end date, they are often complemented with retrieval\-augmented generation \(RAG\) systems\[Lewiset al\.,[2020](https://arxiv.org/html/2607.15607#bib.bib9), Fanet al\.,[2024](https://arxiv.org/html/2607.15607#bib.bib10)\], where the model is expected to produce responses*faithful*to the evidence\. A core obstacle to reliability is*hallucination*: the model may generate statements that are unsupported by, or contradict, the given context\[Zhanget al\.,[2025](https://arxiv.org/html/2607.15607#bib.bib7)\]\.
Detection approaches emphasize that hallucinations in RAG can be exposed by measuring the*mismatch*between the context and the generation using internal model signals\[Riccoet al\.,[2025](https://arxiv.org/html/2607.15607#bib.bib6)\]\. For example, probabilistic distances between prompt and response hidden\-state distributions \(e\.g\., MMD with dependence\-aware resampling\) provide a training\-free score that increases under hallucination, and can be made comparable across variable\-length sequences via p\-values computed from an estimated null distribution\[Oblovatnyet al\.,[2025](https://arxiv.org/html/2607.15607#bib.bib26)\]\. Another line of work analyzes attention\-map structure\[Chuanget al\.,[2024](https://arxiv.org/html/2607.15607#bib.bib5)\]and reports that certain attention heads exhibit robust hallucination signatures across datasets, which can be summarized by a topological divergence on attention\-induced graphs\[Bazarovaet al\.,[2025](https://arxiv.org/html/2607.15607#bib.bib28)\]\.
While these methods account for diverse patterns encountered by an LLM, they mostly ignore the internal structure for most tasks\. One typically has a*reference*distribution \(e\.g\., embeddings of retrieved evidence or a trusted prompt\) and a*query*distribution \(embeddings of the generated response\)\. Crucially, the operational goal is often*asymmetric*: we would like to tightly control false alarms when the response is well grounded in the reference, while remaining sensitive to deviations that, e\.g\., indicate hallucination\. Asymmetry also arises when the length of the prompt and the generated response can be significantly different, making most approaches inefficient in the presence of a large context\. This asymmetry is not fully captured by classical symmetric two\-sample tests, which treat both samples interchangeably\.
In this paper, we formalize hallucination detection and the artificial text detection problem as an asymmetric two\-sample testing problem and develop a nearest\-neighbor \(NN\) graph test tailored to this regime\. Nearest\-neighbor methods are attractive in high dimensions because they avoid density estimation and rely only on local geometry\. The classical nonparametric NN coincidence test of Henze counts how often a point and its NN belong to the same sample across both groups, and is symmetric by design with provable strong statistical properties\[Henze,[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]\. We propose and analyze a one\-sided variant that counts NN coincidences*only within the reference sample*\. This yields a statistic that \(i\) aligns with the reference\-vs\-query structure of hallucination detection, \(ii\) admits an exact finite\-sample conditional mean and variance under the permutation null \(given the pooled locations\), and \(iii\) retains asymptotic normality and consistency properties analogous to the symmetric case\.
Our work adopts a*reference\-sided*counting rule, focusing only on within\-reference NN coincidences\. This asymmetric construction better matches operational settings such as hallucination detection, where one sample plays the role of an anchor distribution, and yields a statistic with tractable conditional moments and analogous large\-sample behavior\. Our theoretical analysis closely follows the framework ofHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\], while adapting the statistic, null moments, asymptotic calibration, and consistency argument to the asymmetric one\-sided setting\. We further demonstrate how such asymmetric tests can be applied to real\-world LLM generation problems using hidden\-state representations\.
Our contributions are as follows:
- •An asymmetric two\-sample statistic ASK\-NN\.We introduce an asymmetric two\-sample statistic ASK\-NN based on within\-reference coincidences in the k\-NN graph, motivated by reference\-query settings where one sample provides an anchor distribution\.
- •Established theoretical properties for ASK\-NN\.For ASK\-NN statistic, we derive exact conditional mean and variance under the permutation null and obtain an asymptotically normal calibration\. Our theoretical contributions continue with characterization of the limiting separation functional under fixed alternatives and show that it is minimized if and only if the two distributions coincide, implying consistency of the resulting test\.
- •Competitive empirical performance of ASK\-NN\.We evaluate the method on synthetic Gaussian benchmarks, artificial\-text detection, and LLM hallucination detection, showing competitive performance against MMD, Sinkhorn, Hotelling’sT2T^\{2\}, and symmetric k\-NN baselines\.
## 2Related works
#### Graph\-based and nearest\-neighbor tests\.
Graph\-based tests form a class of nonparametric two\-sample tests\. They rely only on the geometric structure of the pooled sample, rather than on a parametric model for the underlying distributions\. In particular, they construct a graph on pooled observations, for example using nearest\-neighbor graphs or minimum spanning trees \(MSTs\), and measure how frequently edges connect points from the same sample\. Among the well\-known examples are the Friedman–Rafsky test, based on the MST\[Friedman and Rafsky,[1979](https://arxiv.org/html/2607.15607#bib.bib2)\], as well as nearest\-neighbor tests, such as the Henze nearest\-neighbor coincidence test\[Henze,[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]\. The latter counts the number of nearest\-neighbor pairs within the samples symmetrically across both samples and establishes asymptotic normality under the null hypothesis and consistency under alternative hypotheses\.
#### Two\-sample testing and kernel methods\.
The two\-sample problem has a long history, with modern nonparametric methods including kernel\-based tests and graph\-based tests\. Maximum Mean Discrepancy \(MMD\) is a widely used kernel two\-sample statistic with strong theoretical guarantees and practical performance\[Grettonet al\.,[2012](https://arxiv.org/html/2607.15607#bib.bib20)\]\. For dependent data, wild\-bootstrap variants provide valid calibration for degenerate kernel tests\[Chwialkowskiet al\.,[2014](https://arxiv.org/html/2607.15607#bib.bib23)\]\. Connectivity between two samples is also explored in\[Friedman and Rafsky,[1979](https://arxiv.org/html/2607.15607#bib.bib2), Henze and Penrose,[1999](https://arxiv.org/html/2607.15607#bib.bib1)\], where the authors consider the number of edges in the minimum spanning tree connecting nodes from different samples\. Similar ideas appear in works\[Barannikovet al\.,[2021](https://arxiv.org/html/2607.15607#bib.bib4)\], but from a topological perspective, while with proved statistical properties\[Mironenkoet al\.,[2026](https://arxiv.org/html/2607.15607#bib.bib3)\]\. These methods are directly relevant to token\-sequence embeddings in LLMs, where strong local dependence violates i\.i\.d\. assumptions\.
#### Hallucination detection via internal signals\.
A growing body of work detects hallucinations without external knowledge by extracting model\-internal uncertainty or consistency cues, e\.g\., self\-consistency over multiple generations\[Farquharet al\.,[2024](https://arxiv.org/html/2607.15607#bib.bib12)\], entropy\-based confidence\[Fadeevaet al\.,[2024](https://arxiv.org/html/2607.15607#bib.bib18)\], and probes over hidden states\[Skyet al\.,[2024](https://arxiv.org/html/2607.15607#bib.bib17)\]\. In RAG, a particularly effective principle is to directly quantify the relationship between the provided context and the generated response\[Eset al\.,[2024](https://arxiv.org/html/2607.15607#bib.bib21)\]\. One approach measures probabilistic distances between prompt and response hidden\-state distributions and uses dependence\-aware resampling \(e\.g\., wild bootstrap\) to compute calibrated p\-values, yielding length\-normalized hallucination scores\[Oblovatnyet al\.,[2025](https://arxiv.org/html/2607.15607#bib.bib26)\]\. In parallel, TOHA analyzes graphs induced by attention matrices and uses an asymmetric topological divergence between prompt and response subgraphs, reporting that a small subset of attention heads yields stable hallucination signatures across datasets and models\[Bazarovaet al\.,[2025](https://arxiv.org/html/2607.15607#bib.bib28)\]\.
#### Artificial\-text detection\.
Machine\-generated text \(MGT\) detection aims to distinguish human\-written texts from outputs of large language models\. This task has become increasingly challenging because modern LLMs generate fluent, high\-quality text, making the distributional differences between human and generated writing subtle\.
Existing methods include metric\-based detectors based on language\-model statistics such as likelihood, entropy, rank or perturbation\-based scores\[Gehrmannet al\.,[2019](https://arxiv.org/html/2607.15607#bib.bib13), Mitchellet al\.,[2023](https://arxiv.org/html/2607.15607#bib.bib14)\], model\-based classifiers trained to separate human and generated examples\[Guoet al\.,[2023](https://arxiv.org/html/2607.15607#bib.bib15)\], and distributional approaches that explicitly view detection through the lens of statistical two\-sample problem\. In particular, recent work uses MMD\-based criteria not only to measure discrepancies between human\-written and machine\-generated texts, but also to optimize detectors that are sensitive to such distributional differences\[Zhanget al\.,[2024](https://arxiv.org/html/2607.15607#bib.bib16)\]\.
We use this domain as a source of real\-world data, where human\-written and LLM\-generated texts form two closely related distributions, providing a useful benchmark for evaluating the sensitivity of our two\-sample statistic\.
## 3Methods
### 3\.1Hypothesis testing problem
LetX1,…,Xn1,Y1,…,Yn2X\_\{1\},\\ldots,X\_\{n\_\{1\}\},Y\_\{1\},\\ldots,Y\_\{n\_\{2\}\}be independentℝd\\mathbb\{R\}^\{d\}\-valued random vectors with the dimensiond≥1d\\geq 1\. Throughout the paper, theXX\-sample is treated as the reference sample and theYY\-sample as the query or potentially shifted sample\. The distribution ofXiX\_\{i\}has an unknown probability density functionf\(x\)f\(x\), andYiY\_\{i\}has an unknown probability density functiong\(x\)g\(x\)\. We consider the two\-sample testing problemH0:f≡gH\_\{0\}:f\\equiv gagainstH1:f≢gH\_\{1\}:f\\not\\equiv g\.
### 3\.2Nearest\-neighbour based statistic
Let
Zi=\{Xi,1≤i≤n1,Yi−n1,n1\+1≤i≤n,Z\_\{i\}=\\begin\{cases\}X\_\{i\},&1\\leq i\\leq n\_\{1\},\\\\ Y\_\{i\-n\_\{1\}\},&n\_\{1\}\+1\\leq i\\leq n,\\end\{cases\}wheren=n1\+n2n=n\_\{1\}\+n\_\{2\}\. Then, for the pooled sample\{Zi\}\\\{Z\_\{i\}\\\}, we defineNr\(Zi\)N\_\{r\}\(Z\_\{i\}\)to be therr\-th nearest neighbor ofZiZ\_\{i\}in the full sample, andA\(Zi\)=I\(1≤i≤n1\)A\(Z\_\{i\}\)=I\(1\\leq i\\leq n\_\{1\}\)is the indicator of the first group of points\.
The statistic ASK\-NN to be studied is:
Tn=∑i=1n∑r=1kA\(Zi\)A\(Nr\(Zi\)\)\.T\_\{n\}=\\sum\_\{i=1\}^\{n\}\\sum\_\{r=1\}^\{k\}A\(Z\_\{i\}\)A\(N\_\{r\}\(Z\_\{i\}\)\)\.\(1\)Thus,TnT\_\{n\}counts the number of reference points whosekknearest neighbors in the pooled sample are also reference points, as it equals∑i=1n1∑r=1kA\(Nr\(Zi\)\)\\sum\_\{i=1\}^\{n\_\{1\}\}\\sum\_\{r=1\}^\{k\}A\(N\_\{r\}\(Z\_\{i\}\)\)\. Our goal is to examine the properties ofTnT\_\{n\}and compare them with those of the version proposed by HenzeTnfull=∑i=1n∑r=1kA\(Zi\)A\(Nr\(Zi\)\)\+\(1−A\(Zi\)\)\(1−A\(Nr\(Zi\)\)\)T^\{\\mathrm\{full\}\}\_\{n\}=\\sum\_\{i=1\}^\{n\}\\sum\_\{r=1\}^\{k\}A\(Z\_\{i\}\)A\(N\_\{r\}\(Z\_\{i\}\)\)\+\(1\-A\(Z\_\{i\}\)\)\(1\-A\(N\_\{r\}\(Z\_\{i\}\)\)\)\. We will show thatTnT\_\{n\}has properties that are largely similar to those of the original, while requiring a smaller amount of computation, as evident from Table[1](https://arxiv.org/html/2607.15607#S3.T1)forn1≪nn\_\{1\}\\ll n\.
MethodTimeMST\-based test \(Henze et al\., 1999\)O\(n2d\)O\(n^\{2\}d\)MMD\[Grettonet al\.,[2012](https://arxiv.org/html/2607.15607#bib.bib20)\]O\(n2d\)O\(n^\{2\}d\)MTopDiv\[Mironenkoet al\.,[2026](https://arxiv.org/html/2607.15607#bib.bib3)\]O\(n2\(d\+logn\)\)O\(n^\{2\}\(d\+\\log n\)\)TnfullT\_\{n\}^\{\\mathrm\{full\}\}\[Henze,[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]O\(n\(k\+nd\)\)O\(n\(k\+nd\)\)TnT\_\{n\}\(ours\)O\(n1\(k\+nd\)\)O\(n\_\{1\}\(k\+nd\)\)Table 1:Computational costs for different nonparametric two\-sample statistics\.
### 3\.3Distribution underH0H\_\{0\}
IfH0H\_\{0\}holds, we can represent the random sequenceZ1,…,ZnZ\_\{1\},\\ldots,Z\_\{n\}using the permutation distribution, similarly toHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]\.Z1,…,ZnZ\_\{1\},\\ldots,Z\_\{n\}are i\.i\.d randomdd\-dimensional vectors\. Additional random variablesUn1,…,UnnU\_\{n1\},\\ldots,U\_\{nn\}have distribution:
ℙ\(Unj=uj;1≤j≤n\)==\{\(nn1\)−1,if∑i=1nI\(ui=1\)=n1,0,otherwise\.,\\mathbb\{P\}\(U\_\{nj\}=u\_\{j\};1\\leq j\\leq n\)=\\\\ =\\begin\{cases\}\\binom\{n\}\{n\_\{1\}\}^\{\-1\},&\\text\{if\}\\sum\_\{i=1\}^\{n\}I\(u\_\{i\}=1\)=n\_\{1\},\\\\ 0,&\\text\{otherwise\}\.\\end\{cases\},whereuj∈\{1,2\}u\_\{j\}\\in\\\{1,2\\\}are all possible values ofUnjU\_\{nj\}\. These variables represent the sample type ofZjZ\_\{j\}:XXorYY\-type correspondingly\. For1≤i≠j≤n,1≤r≤k1\\leq i\\neq j\\leq n,1\\leq r\\leq kwe introduce events
Aij\(r\)=\[Zj=Nr\(Zi\)\],A\_\{ij\}^\{\(r\)\}=\[Z\_\{j\}=N\_\{r\}\(Z\_\{i\}\)\],Bj=\[Unj=1\]\.B\_\{j\}=\[U\_\{nj\}=1\]\.
Here we study only one sample type \(Unj=1U\_\{nj\}=1\), therefore, the test becomes asymmetric\.
UnderH0H\_\{0\},TnT\_\{n\}defined in \([1](https://arxiv.org/html/2607.15607#S3.E1)\) has the same distribution as
T~n=∑i,j=1n∑r=1kI\(Bi\)I\(Bj\)I\(Aij\(r\)\)\.\\tilde\{T\}\_\{n\}=\\sum\_\{i,j=1\}^\{n\}\\sum\_\{r=1\}^\{k\}I\\left\(B\_\{i\}\\right\)I\\left\(B\_\{j\}\\right\)I\\left\(A\_\{ij\}^\{\(r\)\}\\right\)\.GivenZi=ziZ\_\{i\}=z\_\{i\}we denote:
aij\(r\)=aij\(r\)\(z1,…,zn\)=I\(Aij\(r\)\|Z1=z1,…,Zn=zn\)\.a\_\{ij\}^\{\(r\)\}=a\_\{ij\}^\{\(r\)\}\(z\_\{1\},\\ldots,z\_\{n\}\)=I\(A\_\{ij\}^\{\(r\)\}\|Z\_\{1\}=z\_\{1\},\\ldots,Z\_\{n\}=z\_\{n\}\)\.aij\+=∑r=1kaij\(r\)\(aij\+∈\{0,1\}\)a\_\{ij\}^\{\+\}=\\sum\_\{r=1\}^\{k\}a\_\{ij\}^\{\(r\)\}\\quad\(a\_\{ij\}^\{\+\}\\in\\\{0,1\\\}\)Allaij\+a\_\{ij\}^\{\+\}together form an adjacency matrix of the k\-nearest\-neighbour graph on pointsz1,…,znz\_\{1\},\\ldots,z\_\{n\}\.
Ln=∑i,j=1naij\+I\(Bi\)I\(Bj\)\.L\_\{n\}=\\sum\_\{i,j=1\}^\{n\}a\_\{ij\}^\{\+\}I\(B\_\{i\}\)I\(B\_\{j\}\)\.
For convenience, letdj\(k\)=∑i=1naij\+d\_\{j\}^\{\(k\)\}=\\sum\_\{i=1\}^\{n\}a\_\{ij\}^\{\+\},cn\(k\)=1nk∑j=1n\(dj−k\)2c\_\{n\}^\{\(k\)\}=\\frac\{1\}\{nk\}\\sum\_\{j=1\}^\{n\}\\left\(d\_\{j\}\-k\\right\)^\{2\},vn\(k\)=1nk∑i,j=1naij\+aji\+v\_\{n\}^\{\(k\)\}=\\frac\{1\}\{nk\}\\sum\_\{i,j=1\}^\{n\}a\_\{ij\}^\{\+\}a\_\{ji\}^\{\+\}\(same notation is used in\[Henze,[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]\)\. Now we can formulate the one\-sided analog of Proposition 2\.1 from\[Henze,[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]:
###### Proposition 3\.1\.
For the random variableLnL\_\{n\}it holds that
𝔼\[Ln\]=kn1\(n1−1\)n−1,\\mathbb\{E\}\[L\_\{n\}\]=k\\frac\{n\_\{1\}\(n\_\{1\}\-1\)\}\{n\-1\},\(2\)𝕍\[Ln\]=kn1\(n1−1\)n2\(n−1\)\(n−2\)\(n−3\)××\(\(n1−2\)cn\(k\)\+\(n2−1\)\(1\+vn\(k\)−2kn−1\)\)\.\\mathbb\{V\}\[L\_\{n\}\]=k\\frac\{n\_\{1\}\(n\_\{1\}\-1\)n\_\{2\}\}\{\(n\-1\)\(n\-2\)\(n\-3\)\}\\times\\\\ \\times\\left\(\(n\_\{1\}\-2\)c\_\{n\}^\{\(k\)\}\+\(n\_\{2\}\-1\)\\left\(1\+v\_\{n\}^\{\(k\)\}\-\\frac\{2k\}\{n\-1\}\\right\)\\right\)\.\(3\)
###### Proof\.
For the proof, we turn to the work\[Bloemena,[1964](https://arxiv.org/html/2607.15607#bib.bib19)\]\. Lettingmij=aij\+\+aji\+,Q=∑i,j=1nmijI\(Bi\)I\(Bj\)m\_\{ij\}=a\_\{ij\}^\{\+\}\+a\_\{ji\}^\{\+\},Q=\\sum\_\{i,j=1\}^\{n\}m\_\{ij\}I\(B\_\{i\}\)I\(B\_\{j\}\), we haveLn=12QL\_\{n\}=\\frac\{1\}\{2\}Q\. The variableQQ\(xWx\_\{W\}orxBx\_\{B\}\) was studied by Bloemena \(see def\. \(1\.1\.5\)\) and the assertion follows from \(3\.3\.1\) and \(3\.3\.8\), observing that, in their notation,mi\+=k\+di\(k\)m\_\{i\+\}=k\+d\_\{i\}^\{\(k\)\},m\+\+=2nkm\_\{\+\+\}=2nk,∑i=1n\(mi\+−\(1/n\)m\+\+\)2=nkcn\\sum\_\{i=1\}^\{n\}\(m\_\{i\+\}\-\(1/n\)m\_\{\+\+\}\)^\{2\}=nkc\_\{n\}and∑i,j=1nmij2=2nk\(1\+vn\)\\sum\_\{i,j=1\}^\{n\}m\_\{ij\}^\{2\}=2nk\(1\+v\_\{n\}\)\. So, we obtain the desired results by straightforwardly calculating the mean and variance in question\. ∎
Now we derive a new asymptotic distribution underH0H\_\{0\}\.
###### Proposition 3\.2\.
Ifn→∞n\\rightarrow\\inftywithn1/n→τ,0<τ<1n\_\{1\}/n\\rightarrow\\tau,0<\\tau<1, then
𝕍\(n−1/2Tn~\|Z1,…,Zn\)→Pfσ2\(τ,d,\|\.\|\),\\mathbb\{V\}\\left\(n^\{\-1/2\}\\tilde\{T\_\{n\}\}\|Z\_\{1\},\\ldots,Z\_\{n\}\\right\)\\rightarrow\_\{P\_\{f\}\}\\sigma^\{2\}\(\\tau,d,\|\.\|\),where
σ2\(τ,d,\|\.\|\)=kτ2\(1−τ\)\(τc∞\(k\)\+\(1−τ\)\(1\+v∞\(k\)\)\),\\sigma^\{2\}\(\\tau,d,\|\.\|\)=k\\tau^\{2\}\(1\-\\tau\)\\left\(\\tau c\_\{\\infty\}^\{\(k\)\}\+\(1\-\\tau\)\(1\+v\_\{\\infty\}^\{\(k\)\}\)\\right\),v∞\(k\)v\_\{\\infty\}^\{\(k\)\}andc∞\(k\)c\_\{\\infty\}^\{\(k\)\}are defined in Propositions 3\.1, 3\.2 inHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]\.
###### Proof\.
The result follows immediately taking to the limit \([3](https://arxiv.org/html/2607.15607#S3.E3)\), using Propositions 3\.1, 3\.2 inHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]aboutc∞\(k\)c\_\{\\infty\}^\{\(k\)\}andv∞\(k\)v\_\{\\infty\}^\{\(k\)\}\. ∎
Then, using the fact above \(or using Theorem 4\.1\.1 fromBloemena \[[1964](https://arxiv.org/html/2607.15607#bib.bib19)\]with notations given in the proof of Prop\.[3\.1](https://arxiv.org/html/2607.15607#S3.Thmprop1)\), we obtain the next result:
###### Theorem 3\.1\.
Ifn→∞n\\rightarrow\\inftywithn1/n→τ,0<τ<1n\_\{1\}/n\\rightarrow\\tau,0<\\tau<1, then
n−1/2\(Tn−kn1\(n1−1\)n−1\)→𝒟f𝒩\(0,σ2\(τ,d,\|\.\|\)\),n^\{\-1/2\}\\left\(T\_\{n\}\-k\\frac\{n\_\{1\}\(n\_\{1\}\-1\)\}\{n\-1\}\\right\)\\rightarrow\_\{\\mathcal\{D\}\_\{f\}\}\\mathcal\{N\}\\left\(0,\\sigma^\{2\}\(\\tau,d,\|\.\|\)\\right\),lim𝕍\(n−1/2Tn\)=σ2\(τ,d,\|\.\|\)\.\\lim\\mathbb\{V\}\\left\(n^\{\-1/2\}T\_\{n\}\\right\)=\\sigma^\{2\}\(\\tau,d,\|\.\|\)\.
The result above delivers the distribution ofTnT\_\{n\}underH0H\_\{0\}\. It allows us to derive the p\-values forTnT\_\{n\}given its asymptotical normality and analytical expressions for its mean and variance\.
### 3\.4Consistency
Now we turn our attention to a one\-sided analog of Theorem 4\.1 fromHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]that describes what happens iff≠gf\\neq g\.
###### Theorem 3\.2\.
Ifn→∞n\\rightarrow\\inftywithn1/n→τ,0<τ<1n\_\{1\}/n\\rightarrow\\tau,0<\\tau<1, then
1nkTn→Pf,gD~\(f,g,τ\),\\frac\{1\}\{nk\}T\_\{n\}\\rightarrow\_\{P\_\{f,g\}\}\\tilde\{D\}\(f,g,\\tau\),where
D~\(f,g,τ\)=∫τ2f2\(x\)τf\(x\)\+\(1−τ\)g\(x\)𝑑x\.\\tilde\{D\}\(f,g,\\tau\)=\\int\\frac\{\\tau^\{2\}f^\{2\}\(x\)\}\{\\tau f\(x\)\+\(1\-\\tau\)g\(x\)\}dx\.
###### Proof\.
Using the notationIj\(r\)I\_\{j\}\(r\)\(definition \(1\.3\) fromHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]\), the result follows from Lemma 4\.2 fromHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]and the fact that
lim𝔼\[I1\(1\)I2\(1\)\|X1=x1,X2=x2\]==∏j=12τf\(xj\)τf\(xj\)\+\(1−τ\)g\(xj\)\.\\lim\\mathbb\{E\}\\left\[I\_\{1\}\(1\)I\_\{2\}\(1\)\|X\_\{1\}=x\_\{1\},X\_\{2\}=x\_\{2\}\\right\]=\\\\ =\\prod\_\{j=1\}^\{2\}\\frac\{\\tau f\(x\_\{j\}\)\}\{\\tau f\(x\_\{j\}\)\+\(1\-\\tau\)g\(x\_\{j\}\)\}\.
which is given inHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]to prove Theorem 4\.1\. ∎
Now we prove a special case of inequality for this asymmetric separation measureD~\\tilde\{D\}:
###### Proposition 3\.3\.
Letf,gf,gbe probability density functions onℝd\\mathbb\{R\}^\{d\}, and let0<τ<10<\\tau<1\. Then
D~\(f,g,τ\)≥τ2\.\\tilde\{D\}\(f,g,\\tau\)\\geq\\tau^\{2\}\.Equality holds, if and only if, the probability measures corresponding toffandggcoincide\.
###### Proof\.
Let us note that
D~\(f,g,τ\)−D~\(g,f,1−τ\)==∫τ2f2\(x\)−\(1−τ\)2g2\(x\)τf\(x\)\+\(1−τ\)g\(x\)𝑑x==∫\(τf\(x\)−\(1−τ\)g\(x\)\)𝑑x==τ−\(1−τ\)=2τ−1\\tilde\{D\}\(f,g,\\tau\)\-\\tilde\{D\}\(g,f,1\-\\tau\)=\\\\ =\\int\\frac\{\\tau^\{2\}f^\{2\}\(x\)\-\(1\-\\tau\)^\{2\}g^\{2\}\(x\)\}\{\\tau f\(x\)\+\(1\-\\tau\)g\(x\)\}dx=\\\\ =\\int\\left\(\\tau f\(x\)\-\(1\-\\tau\)g\(x\)\\right\)dx=\\\\ =\\tau\-\(1\-\\tau\)=2\\tau\-1and
D~\(f,g,τ\)\+D~\(g,f,1−τ\)=D\(f,g,τ\),\\tilde\{D\}\(f,g,\\tau\)\+\\tilde\{D\}\(g,f,1\-\\tau\)=D\(f,g,\\tau\),whereD\(f,g,τ\)D\(f,g,\\tau\)is given in statement of Theorem 4\.1 fromHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]\. Therefore:
D~\(f,g,τ\)=D\(f,g,τ\)\+2τ−12\.\\tilde\{D\}\(f,g,\\tau\)=\\frac\{D\(f,g,\\tau\)\+2\\tau\-1\}\{2\}\.Following Proposition 4\.3 fromHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]we have:
D\(f,g,τ\)≥τ2\+\(1−τ\)2⇔D~\(f,g,τ\)≥τ2D\(f,g,\\tau\)\\geq\\tau^\{2\}\+\(1\-\\tau\)^\{2\}\\Leftrightarrow\\tilde\{D\}\(f,g,\\tau\)\\geq\\tau^\{2\}and equality holds if, and only if,ffandggcoincide\. ∎
After that the statistical test is defined similarly \(see Theorem 4\.4 fromHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]\), aside from different formulas form\(n1,n2\)m\(n\_\{1\},n\_\{2\}\)andUn1,n2U\_\{n\_\{1\},n\_\{2\}\}:
m\(n1,n2\)=n1\(n1−1\)n−1,m\(n\_\{1\},n\_\{2\}\)=\\frac\{n\_\{1\}\(n\_\{1\}\-1\)\}\{n\-1\},Un1,n2=kn1\(n1−1\)n2\(n−1\)\(n−2\)\(n−3\)××\(\(n1−2\)Cn\+\(n2−1\)\(1\+Vn−2kn−1\)\)≤≤kn1\(n1−1\)n2\(n−1\)\(n−2\)\(n−3\)××\(\(n1−2\)\(𝒞\+1\)2\+2\(n2−1\)\)=O𝒫f,g\(n\),U\_\{n\_\{1\},n\_\{2\}\}=k\\frac\{n\_\{1\}\(n\_\{1\}\-1\)n\_\{2\}\}\{\(n\-1\)\(n\-2\)\(n\-3\)\}\\times\\\\ \\times\\left\(\(n\_\{1\}\-2\)C\_\{n\}\+\(n\_\{2\}\-1\)\\left\(1\+V\_\{n\}\-\\frac\{2k\}\{n\-1\}\\right\)\\right\)\\leq\\\\ \\leq k\\frac\{n\_\{1\}\(n\_\{1\}\-1\)n\_\{2\}\}\{\(n\-1\)\(n\-2\)\(n\-3\)\}\\times\\\\ \\times\\left\(\(n\_\{1\}\-2\)\(\\mathcal\{C\}\+1\)^\{2\}\+2\(n\_\{2\}\-1\)\\right\)=O\_\{\\mathcal\{P\}\_\{f,g\}\}\(n\),
whereCnC\_\{n\},VnV\_\{n\},𝒞\\mathcal\{C\}are defined in \(3\.1\), \(3\.2\), \(2\.5\) fromHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\], respectively\. Using this we can derive \(4\.8\) fromHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]\. The last inequality in the proof of Theorem 4\.4 fromHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]now follows from Theorem[3\.2](https://arxiv.org/html/2607.15607#S3.Thmtheorem2), \(4\.8\) fromHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\], Proposition[3\.3](https://arxiv.org/html/2607.15607#S3.Thmprop3)and the fact that, asn→∞,n1/n→τn\\rightarrow\\infty,n\_\{1\}/n\\rightarrow\\tau,
lim\(n−1m\(n1,n2\)\)=τ2\.\\lim\\left\(n^\{\-1\}m\(n\_\{1\},n\_\{2\}\)\\right\)=\\tau^\{2\}\.
The proposed test is defined similarly as in Remark 5\.1 fromHenze \[[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]:
## 4Experiments
### 4\.1Baselines and evaluation protocol
#### Baselines\.
We compare the proposed testASK\-NNagainst representative baselines from several families of two\-sample tests: Hotelling’sT2T^\{2\}test \(t\-test\) as a classical parametric mean\-based test; the original Henze’s 1\-NN graph symmetry test \(Symmetric\)\[Henze,[1988](https://arxiv.org/html/2607.15607#bib.bib11)\]; the unbiased Maximum Mean Discrepancy with RBF\-kernel, label shuffling and median bandwidth heuristic \(MMDuB\\mathrm\{MMD\}\_\{u\}B\) as a kernel\-based two\-sample test\[Schrabet al\.,[2023](https://arxiv.org/html/2607.15607#bib.bib29)\]; and Sinkhorn Divergency \(SD\) as the entropy\-regularized optimal transport version\[Genevayet al\.,[2018](https://arxiv.org/html/2607.15607#bib.bib30)\]\. For the SD baseline, we use a small entropic regularization coefficient to stabilize the computation and compute the statistic efficiently via Sinkhorn iterations, while preserving a close approximation to the unregularized OT distance\. For theMMDuB\\mathrm\{MMD\}\_\{u\}B,SDandt\-testbaselines, p\-values are obtained by the same label\-shuffling procedure\[Good,[2005](https://arxiv.org/html/2607.15607#bib.bib31)\]\.
#### Monte Carlo evaluation\.
For each configuration, we estimate power as the empirical rejection rate overRRindependent Monte Carlo repetitions at the significance levelα=0\.05\\alpha=0\.05\. Error bars indicate normal\-approximation95%95\\%Monte Carlo confidence intervals,
p^±1\.96p^\(1−p^\)R,\\hat\{p\}\\pm 1\.96\\sqrt\{\\frac\{\\hat\{p\}\(1\-\\hat\{p\}\)\}\{R\}\},wherep^\\hat\{p\}is the empirical rejection rate andRRis the number of repetitions\.
### 4\.2Computational complexity
#### Implementation details\.
To study practical computational scaling, we benchmark all methods on synthetic Gaussian inputs\. For each configuration, we generate two samples of sizeNNin dimensionddand measure wall\-clock runtime of the statistic computational only, excluding data generation\. We consider dimensionsd∈\{128,1024\}d\\in\\\{128,1024\\\}and vary the total sample size from512512to3276832768on a powers\-of\-two grid\. Experiments are performed on an NVIDIA A100 GPU after 10 warm\-up iterations\. Runtime is reported as the median over repeated 20 executions\.
#### Results\.
Figure[1](https://arxiv.org/html/2607.15607#S4.F1)presents the observed runtime scaling of the proposed ASK\-NN statistic and competing baseline statistics\.ASK\-NNexhibits substantially slower runtime growth than the kernel\-basedMMDuMMD\_\{u\}statistic and theSDbaseline\. Moreover, ASK\-NN remains applicable at larger sample sizes than these baselines, which become memory\-limited earlier due to their higher memory requirements\.
Compared with the symmetric nearest\-neighbor statistic, ASK\-NN shows similar scaling behavior, with slightly lower runtime than this baseline\. Hotelling’sT2T^\{2\}test exhibits nearly constant runtime in the explored regime, likely because its computation is dominated by fixed GPU overheads rather than arithmetic cost\.
Overall, these experiments suggest that nearest\-neighbor\-based two\-sample statistics offer better practical scalability than kernel\-based alternatives, while ASK\-NN preserves this advantage and remains computationally competitive with the symmetric nearest\-neighbor baseline\.
Figure 1:Observed wall\-clock runtime scaling of the proposed ASK\-NN statistic and baseline two\-sample statistics on an NVIDIA A100 GPU for dimensionsd=128d=128\(Left\) andd=1024d=1024\(Right\)\. Runtime is measured only for statistic computation, excluding data generation\. Both axes use logarithmic scales\. Missing points correspond to configurations that exceeded the available GPU memory\.
### 4\.3Synthetic data
#### Gaussian benchmarks\.
Similar toGrettonet al\.\[[2012](https://arxiv.org/html/2607.15607#bib.bib20)\], we evaluate all tests on two high\-dimensional Gaussian two\-sample problems\. In the mean\-shift setting, we sampleX∼𝒩\(0,Id\)X\\sim\\mathcal\{N\}\(0,I\_\{d\}\)andY∼𝒩\(μδ,Id\)Y\\sim\\mathcal\{N\}\(\\mu\_\{\\delta\},I\_\{d\}\), whereμδ=δ𝟏d/d\\mu\_\{\\delta\}=\\delta\\mathbf\{1\}\_\{d\}/\\sqrt\{d\}\. This choice keeps the Euclidean norm of the mean difference fixed,‖μδ‖2=δ\\\|\\mu\_\{\\delta\}\\\|\_\{2\}=\\delta, independently of the dimensiondd\. In the scale\-shift setting, we sampleX∼𝒩\(0,Id\)X\\sim\\mathcal\{N\}\(0,I\_\{d\}\)andY∼𝒩\(0,σ2Id\)Y\\sim\\mathcal\{N\}\(0,\\sigma^\{2\}I\_\{d\}\), whereσ\\sigmacontrols the variance difference\. We evaluate dimensions ranging from22to25002500\. For the mean\-shift experiments, we use 20 logarithmically spaced values ofδ\\deltain\[0\.05,50\]\[0\.05,50\]\. For the scale\-shift experiments, we use 20 logarithmically spaced values ofσ\\sigmain\[1,10\]\[1,10\]\. For each configuration, we estimate power as the fraction of repetitions in which the null hypothesis is rejected at levelα=0\.05\\alpha=0\.05\. In all experiments, we drawn1=n2=250n\_\{1\}=n\_\{2\}=250samples from each distribution\.
#### Results\.
Figure[2](https://arxiv.org/html/2607.15607#S4.F2)demonstrates empirical power under the mean\-shift and variance\-shift alternatives\. In the mean\-shift setting, MMD and Hotelling’sT2T^\{2\}test achieve the highest rejection rates\. This is consistent with the structure of the alternative: Hotelling’sT2T^\{2\}test directly targets differences in means, while MMD with a characteristic RBF\-kernel is sensitive to the induced difference between the two Gaussian distributions\. The proposed ASK\-NN does not outperform the considered baselines in this setting, but attains nontrivial empirical power, confirming that the statistic remains sensitive to mean\-shift alternatives\.
In the variance\-shift setting, the ranking changes substantially: the proposed asymmetric test achieves the strongest performance among all considered methods and remains highly powerful across the full range of dimensions\. MMD is the closest competitor and also performs robustly, whereas the Sinkhorn divergence baseline is substantially weaker in higher dimensions\. Henze’s original symmetric 1\-NN graph test loses power almost completely, highlighting the advantage of the proposed asymmetric construction for detecting variance changes in high dimensions\.


Figure 2:Empirical power on synthetic Gaussian two\-sample benchmarks at a given significance levelα=0\.05\\alpha=0\.05\.Top: Gaussians having the same variance and different means\.Bottom: Gaussians having the same mean and different variances\.
### 4\.4Real problem of Artificial text detection
#### Experimental setup\.
We further evaluate the proposed test on artificial\-text detection datasets\. We use the RAID dataset\[Duganet al\.,[2024](https://arxiv.org/html/2607.15607#bib.bib34)\]and consider the subset corresponding to GPT\-4 generations in the abstracts domain\. For each sample size, we draw two independent samples of texts: one from the human\-written subset and one from the GPT\-4\-generated subset\. Texts are embedded using the multilingual\-e5\-large sentence encoder\[Wanget al\.,[2024](https://arxiv.org/html/2607.15607#bib.bib35)\], and the resulting embedding samples are compared using the considered two\-sample tests\. This setup evaluates whether the tests can detect the distributional difference between human\-written and machine\-generated texts in a semantic embedding space\.
Since the original asymptotic calibration of the proposed statistic is not sufficiently well\-calibrated in this setting, we also evaluate a label\-shuffling variant of our test, denotedAsymmetric \(LS\), wherepp\-values are obtained by permuting labels in the pooled sample\.
#### Results\.
Figure[3](https://arxiv.org/html/2607.15607#S4.F3)reports Type II and Type I errors across sample sizes\. The results show that human\-written and GPT\-4\-generated texts are well separated in the multilingual\-e5\-large embedding space, with most criteria achieving low Type II error at moderate sample sizes\.
The proposed asymmetric statistic is also sensitive to this distributional difference and reaches low Type II error as the sample size increases\. However, the original version requires careful calibration in this setting, as its Type I error may deviate from the nominal significance level on real text embeddings\. To address this issue, we additionally evaluate a label\-shuffling calibration of our approach \(ASK\-NN \(LS\)\)\. As the results show, this variant keeps Type I error close to the nominal level across the considered sample sizes, while retaining strong power\.
The comparison between the original and label\-shuffling variants indicates that the main challenge in this setting is calibration rather than lack of signal: our proposed statistic captures the human\-vs\-generated difference, while resampling provides reliable Type I error control\.
Figure 3:Type II error and Type I error on the RAID artificial\-text detection dataset as a function of sample size\. The label\-shuffling version of the proposed asymmetric statistic maintains Type I error close to the nominal level while retaining strong power\.
### 4\.5Real problem of LLM Hallucination Detection
#### Experimental setup\.
We evaluate the proposed test in an applied hallucination detection task following the experimental protocol ofOblovatnyet al\.\[[2025](https://arxiv.org/html/2607.15607#bib.bib26)\]\. The task is motivated by RAG, in which hallucinated responses are expected to exhibit weaker or structurally different relationships with the provided context\. Motivated by this, each prompt\-response pair is represented by the token\-level hidden states of an LLM, and hallucination detection is formulated as a two\-sample problem comparing the hidden\-state distributions of prompt and response tokens\. For a prompt\-response pairS=\(P,R\)S=\(P,R\), token\-level LLM hidden states define two empirical samples,XP=\{hiP\}i=1mX\_\{P\}=\\\{h\_\{i\}^\{P\}\\\}\_\{i=1\}^\{m\}andYR=\{hjR\}j=1nY\_\{R\}=\\\{h\_\{j\}^\{R\}\\\}\_\{j=1\}^\{n\}, corresponding to prompt and response tokens\. We compute the proposed asymmetric graph\-based statistic for the prompt and response hidden\-state samples \(XP,YRX\_\{P\},Y\_\{R\}\) and use it as a hallucination score\.
We evaluate our approach and the baselines on a subset of the benchmark considered byOblovatnyet al\.\[[2025](https://arxiv.org/html/2607.15607#bib.bib26)\]: long\-form QA dataset MS MARCO and summarization CNN/DM \+ Recent News from RAGTruth\[Niuet al\.,[2024](https://arxiv.org/html/2607.15607#bib.bib32)\], and conversational QA benchmark CoQA\[Reddyet al\.,[2019](https://arxiv.org/html/2607.15607#bib.bib33)\], using two open\-source LLMs: Mistral\-7B\-Instruct\-v0\.1 and LLaMA\-2\-7B\-chat\.
#### Results\.
Table[2](https://arxiv.org/html/2607.15607#S4.T2)shows ROC\-AUC scores for hallucination detection on three datasets and two LLMs\. The proposed asymmetric statistic achieves the best or second\-best result in five out of six settings\. For Mistral\-7B, it matches the best performance on MS MARCO and CNN/DM \+ Recent News, achieving ROC\-AUC scores of0\.720\.72and0\.620\.62, respectively, and remains close to the strongest method on CoQA\. For LLaMA\-2\-7B, the proposed method obtains the best results on MS MARCO and CoQA, and is second\-best on CNN/DM \+ Recent News\.
Compared to the MMD\-based criterion, our approach improves performance on most datasets and model backbones, suggesting that the proposed statistic captures prompt\-response mismatch in hidden\-state space more effectively in this application\. The gains are particularly clear for LLaMA\-2\-7B, where the proposed method outperforms MMD on all three datasets\. Overall, these results indicate that our approach transfers well to a practical hallucination detection scenario, beyond the controlled synthetic alternatives considered above\.
Table 2:ROC AUC \(↑\\uparrow\) of different statistical criteria in the task of hallucination detection for two LLMs\. The best results for each model are highlighted inbold, and the second best areunderlined\.MethodMS MARCOCNN/DM \+Recent NewsCoQAMistral\-7BMMDuBMMD\_\{u\}B0\.69¯±0\.03\\underline\{0\.69\}\\pm 0\.030\.60¯±0\.05\\underline\{0\.60\}\\pm 0\.050\.73±0\.03\\mathbf\{0\.73\}\\pm 0\.03SD0\.58±0\.03\{0\.58\}\\pm 0\.030\.49±0\.05\{0\.49\}\\pm 0\.050\.62±0\.07\{0\.62\}\\pm 0\.07t\-test0\.61±0\.02\{0\.61\}\\pm 0\.020\.59±0\.07\{0\.59\}\\pm 0\.070\.57±0\.07\{0\.57\}\\pm 0\.07Symmetric0\.72±0\.03\\mathbf\{0\.72\}\\pm 0\.030\.62±0\.04\\mathbf\{0\.62\}\\pm 0\.040\.70¯±0\.06\\underline\{0\.70\}\\pm 0\.06ASK\-NN \(ours\)0\.72±0\.03\\mathbf\{0\.72\}\\pm 0\.030\.62±0\.03\\mathbf\{0\.62\}\\pm 0\.030\.69±0\.07\{0\.69\}\\pm 0\.07LLaMA\-2\-7BMMDuBMMD\_\{u\}B0\.64±0\.03\{0\.64\}\\pm 0\.030\.53±0\.03\{0\.53\}\\pm 0\.030\.68±0\.04\{0\.68\}\\pm 0\.04SD0\.51±0\.02\{0\.51\}\\pm 0\.020\.47±0\.03\{0\.47\}\\pm 0\.030\.75¯±0\.03\\underline\{0\.75\}\\pm 0\.03t\-test0\.60±0\.05\{0\.60\}\\pm 0\.050\.51±0\.02\{0\.51\}\\pm 0\.020\.72±0\.06\{0\.72\}\\pm 0\.06Symmetric0\.65¯±0\.03\\underline\{0\.65\}\\pm 0\.030\.55±0\.02\\mathbf\{0\.55\}\\pm 0\.020\.75¯±0\.04\\underline\{0\.75\}\\pm 0\.04ASK\-NN \(ours\)0\.66±0\.02\\mathbf\{0\.66\}\\pm 0\.020\.54¯±0\.02\\underline\{0\.54\}\\pm 0\.020\.78±0\.03\\mathbf\{0\.78\}\\pm 0\.03
## 5Conclusion
We introduced an asymmetric multivariate two\-sample test based on directed 1\-nearest\-neighbor coincidences\. Unlike symmetric graph\-based tests, the proposed statistic treats one sample as a reference distribution and measures how its local neighborhood structure changes when a query sample is introduced\. We derived exact finite\-sample conditional moments under the permutation null, established asymptotic normality, and proved consistency under fixed alternatives\.
Experiments on synthetic benchmarks, artificial\-text detection, and LLM hallucination detection show that the proposed statistic is not only theoretically tractable and meaningful on controlled Gaussian alternatives, but also remains competitive on real embedding\-based tasks\.
Several directions remain open\. First, the asymptotic calibration can be inaccurate for real hidden\-state embeddings, where dependence, anisotropy, and high dimensionality are substantial; permutation or block\-resampling calibration may provide more robust alternatives\. Second, extending the theory to dependent token\-level samples and high\-dimensional regimes would make the method better aligned with LLM applications and improve hallucination detection in practical RAG systems\.
## References
- S\. Barannikov, I\. Trofimov, G\. Sotnikov, E\. Trimbach, A\. Korotin, A\. Filippov, and E\. Burnaev \(2021\)Manifold topology divergence: a framework for comparing data manifolds\.\.Advances in neural information processing systems34,pp\. 7294–7305\.Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px2.p1.1)\.
- A\. Bazarova, A\. Yugay, A\. Shulga, A\. Ermilova, A\. Volodichev, K\. Polev, J\. Belikova, R\. Parchiev, D\. Simakov, M\. Savchenko, A\. Savchenko, S\. Barannikov, and A\. Zaytsev \(2025\)Hallucination detection in LLMs via topological divergence on attention graphs\.arXiv preprint arXiv:2504\.10063\.External Links:[Link](https://arxiv.org/abs/2504.10063)Cited by:[§1](https://arxiv.org/html/2607.15607#S1.p2.1),[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px3.p1.1)\.
- A\. R\. Bloemena \(1964\)Sampling from a graph\.Mathematical Centre Tracts, Vol\.2,Mathematisch Centrum,Amsterdam\.Cited by:[§3\.3](https://arxiv.org/html/2607.15607#S3.SS3.2.p1.9),[§3\.3](https://arxiv.org/html/2607.15607#S3.SS3.p6.1)\.
- Y\. Chuang, L\. Qiu, C\. Hsieh, R\. Krishna, Y\. Kim, and J\. Glass \(2024\)Lookback lens: detecting and mitigating contextual hallucinations in large language models using only attention maps\.InProceedings of the 2024 Conference on Empirical Methods in Natural Language Processing,pp\. 1419–1436\.Cited by:[§1](https://arxiv.org/html/2607.15607#S1.p2.1)\.
- K\. Chwialkowski, D\. Sejdinovic, and A\. Gretton \(2014\)A wild bootstrap for degenerate kernel tests\.InAdvances in Neural Information Processing Systems \(NeurIPS\),External Links:[Link](https://arxiv.org/abs/1408.5404)Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px2.p1.1)\.
- L\. Dugan, A\. Hwang, F\. Trhlík, A\. Zhu, J\. M\. Ludan, H\. Xu, D\. Ippolito, and C\. Callison\-Burch \(2024\)RAID: a shared benchmark for robust evaluation of machine\-generated text detectors\.InProceedings of the 62nd Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\),Bangkok, Thailand,pp\. 12463–12492\.External Links:[Link](https://aclanthology.org/2024.acl-long.674)Cited by:[§4\.4](https://arxiv.org/html/2607.15607#S4.SS4.SSS0.Px1.p1.1)\.
- S\. Es, J\. James, L\. E\. Anke, and S\. Schockaert \(2024\)RAGAs: automated evaluation of retrieval augmented generation\.InProceedings of the 18th Conference of the European Chapter of the Association for Computational Linguistics: System Demonstrations,pp\. 150–158\.Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px3.p1.1)\.
- E\. Fadeeva, A\. Rubashevskii, A\. Shelmanov, S\. Petrakov, H\. Li, H\. Mubarak, E\. Tsymbalov, G\. Kuzmin, A\. Panchenko, T\. Baldwin,et al\.\(2024\)Fact\-checking the output of large language models via token\-level uncertainty quantification\.InFindings of the Association for Computational Linguistics: ACL 2024,pp\. 9367–9385\.Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px3.p1.1)\.
- W\. Fan, Y\. Ding, L\. Ning, S\. Wang, H\. Li, D\. Yin, T\. Chua, and Q\. Li \(2024\)A survey on RAG meeting LLMs: towards retrieval\-augmented large language models\.InProceedings of the 30th ACM SIGKDD conference on knowledge discovery and data mining,pp\. 6491–6501\.Cited by:[§1](https://arxiv.org/html/2607.15607#S1.p1.1)\.
- S\. Farquhar, J\. Kossen, L\. Kuhn, and Y\. Gal \(2024\)Detecting hallucinations in large language models using semantic entropy\.Nature630\(8017\),pp\. 625–630\.Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px3.p1.1)\.
- J\. H\. Friedman and L\. C\. Rafsky \(1979\)Multivariate generalizations of the wald\-wolfowitz and smirnov two\-sample tests\.The Annals of statistics,pp\. 697–717\.Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px1.p1.1),[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px2.p1.1)\.
- S\. Gehrmann, H\. Strobelt, and A\. M\. Rush \(2019\)Gltr: statistical detection and visualization of generated text\.InProceedings of the 57th annual meeting of the association for computational linguistics: system demonstrations,pp\. 111–116\.Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px4.p2.1)\.
- A\. Genevay, G\. Peyré, and M\. Cuturi \(2018\)Learning generative models with sinkhorn divergences\.InProceedings of the Twenty\-First International Conference on Artificial Intelligence and Statistics,A\. Storkey and F\. Perez\-Cruz \(Eds\.\),Proceedings of Machine Learning Research, Vol\.84,pp\. 1608–1617\.Cited by:[§4\.1](https://arxiv.org/html/2607.15607#S4.SS1.SSS0.Px1.p1.3)\.
- P\. I\. Good \(2005\)Permutation, parametric, and bootstrap tests of hypotheses\.3 edition,Springer\.Cited by:[§4\.1](https://arxiv.org/html/2607.15607#S4.SS1.SSS0.Px1.p1.3)\.
- A\. Gretton, K\. M\. Borgwardt, M\. J\. Rasch, B\. Schölkopf, and A\. Smola \(2012\)A kernel two\-sample test\.The journal of machine learning research13\(1\),pp\. 723–773\.Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px2.p1.1),[Table 1](https://arxiv.org/html/2607.15607#S3.T1.2.2.2),[§4\.3](https://arxiv.org/html/2607.15607#S4.SS3.SSS0.Px1.p1.16)\.
- B\. Guo, X\. Zhang, Z\. Wang, M\. Jiang, J\. Nie, Y\. Ding, J\. Yue, and Y\. Wu \(2023\)How close is chatgpt to human experts? comparison corpus, evaluation, and detection\.arXiv preprint arXiv:2301\.07597\.Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px4.p2.1)\.
- N\. Henze and M\. D\. Penrose \(1999\)On the multivariate runs test\.Annals of statistics,pp\. 290–298\.Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px2.p1.1)\.
- N\. Henze \(1988\)A multivariate two\-sample test based on the number of nearest neighbor type coincidences\.The Annals of Statistics,pp\. 772–783\.Cited by:[§1](https://arxiv.org/html/2607.15607#S1.p4.1),[§1](https://arxiv.org/html/2607.15607#S1.p5.1),[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px1.p1.1),[§3\.3](https://arxiv.org/html/2607.15607#S3.SS3.3.p1.2),[§3\.3](https://arxiv.org/html/2607.15607#S3.SS3.p1.5),[§3\.3](https://arxiv.org/html/2607.15607#S3.SS3.p4.3),[§3\.4](https://arxiv.org/html/2607.15607#S3.SS4.1.p1.1),[§3\.4](https://arxiv.org/html/2607.15607#S3.SS4.2.p2.1),[§3\.4](https://arxiv.org/html/2607.15607#S3.SS4.3.p1.2),[§3\.4](https://arxiv.org/html/2607.15607#S3.SS4.3.p1.7),[§3\.4](https://arxiv.org/html/2607.15607#S3.SS4.p1.1),[§3\.4](https://arxiv.org/html/2607.15607#S3.SS4.p3.2),[§3\.4](https://arxiv.org/html/2607.15607#S3.SS4.p4.4),[§3\.4](https://arxiv.org/html/2607.15607#S3.SS4.p5.1),[Table 1](https://arxiv.org/html/2607.15607#S3.T1.4.4.1),[Proposition 3\.2](https://arxiv.org/html/2607.15607#S3.Thmprop2.p1.4),[§4\.1](https://arxiv.org/html/2607.15607#S4.SS1.SSS0.Px1.p1.3)\.
- P\. Lewis, E\. Perez, A\. Piktus, F\. Petroni, V\. Karpukhin, N\. Goyal, H\. Küttler, M\. Lewis, W\. Yih, T\. Rocktäschel,et al\.\(2020\)Retrieval\-augmented generation for knowledge\-intensive NLP tasks\.Advances in neural information processing systems33,pp\. 9459–9474\.Cited by:[§1](https://arxiv.org/html/2607.15607#S1.p1.1)\.
- A\. Liu, B\. Feng, B\. Xue, B\. Wang, B\. Wu, C\. Lu, C\. Zhao, C\. Deng, C\. Zhang, C\. Ruan,et al\.\(2024\)Deepseek\-v3 technical report\.arXiv preprint arXiv:2412\.19437\.Cited by:[§1](https://arxiv.org/html/2607.15607#S1.p1.1)\.
- A\. Mironenko, E\. Burnaev, and S\. Barannikov \(2026\)The density of cross\-persistence diagrams and its applications\.IEEE Access\.Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px2.p1.1),[Table 1](https://arxiv.org/html/2607.15607#S3.T1.3.3.2)\.
- E\. Mitchell, Y\. Lee, A\. Khazatsky, C\. D\. Manning, and C\. Finn \(2023\)Detectgpt: zero\-shot machine\-generated text detection using probability curvature\.InInternational conference on machine learning,pp\. 24950–24962\.Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px4.p2.1)\.
- C\. Niu, Y\. Wu, J\. Zhu, S\. Xu, K\. Shum, R\. Zhong, J\. Song, and T\. Zhang \(2024\)Ragtruth: a hallucination corpus for developing trustworthy retrieval\-augmented language models\.InProceedings of the 62nd Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\),pp\. 10862–10878\.Cited by:[§4\.5](https://arxiv.org/html/2607.15607#S4.SS5.SSS0.Px1.p2.1)\.
- R\. Oblovatny, A\. Kuleshova, K\. Polev, and A\. Zaytsev \(2025\)Probabilistic distances\-based hallucination detection in llms with rag\.arXiv preprint arXiv:2506\.09886\.Cited by:[§1](https://arxiv.org/html/2607.15607#S1.p2.1),[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px3.p1.1),[§4\.5](https://arxiv.org/html/2607.15607#S4.SS5.SSS0.Px1.p1.4),[§4\.5](https://arxiv.org/html/2607.15607#S4.SS5.SSS0.Px1.p2.1)\.
- S\. Reddy, D\. Chen, and C\. D\. Manning \(2019\)Coqa: a conversational question answering challenge\.Transactions of the Association for Computational Linguistics7,pp\. 249–266\.Cited by:[§4\.5](https://arxiv.org/html/2607.15607#S4.SS5.SSS0.Px1.p2.1)\.
- E\. Ricco, L\. Cima, and R\. Di Pietro \(2025\)Hallucination detection: a probabilistic framework using embeddings distance analysis\.arXiv preprint arXiv:2502\.08663\.Cited by:[§1](https://arxiv.org/html/2607.15607#S1.p2.1)\.
- A\. Schrab, I\. Kim, M\. Albert, B\. Laurent, B\. Guedj, and A\. Gretton \(2023\)MMD aggregated two\-sample test\.Journal of Machine Learning Research24\(194\),pp\. 1–81\.External Links:[Link](http://jmlr.org/papers/v24/21-1289.html)Cited by:[§4\.1](https://arxiv.org/html/2607.15607#S4.SS1.SSS0.Px1.p1.3)\.
- C\. Sky, B\. Van Durme, J\. Eisner, and C\. Kedzie \(2024\)Do androids know they’re only dreaming of electric sheep?\.InFindings of the Association for Computational Linguistics: ACL 2024,pp\. 4401–4420\.Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px3.p1.1)\.
- L\. Wang, N\. Yang, X\. Huang, L\. Yang, R\. Majumder, and F\. Wei \(2024\)Multilingual e5 text embeddings: a technical report\.arXiv preprint arXiv:2402\.05672\.Cited by:[§4\.4](https://arxiv.org/html/2607.15607#S4.SS4.SSS0.Px1.p1.1)\.
- S\. Zhang, Y\. Song, J\. Yang, Y\. Li, B\. Han, and M\. Tan \(2024\)Detecting machine\-generated texts by multi\-population aware optimization for maximum mean discrepancy\.InInternational Conference on Learning Representations \(ICLR\),Cited by:[§2](https://arxiv.org/html/2607.15607#S2.SS0.SSS0.Px4.p2.1)\.
- Y\. Zhang, Y\. Li, L\. Cui, D\. Cai, L\. Liu, T\. Fu, X\. Huang, E\. Zhao, Y\. Zhang, Y\. Chen,et al\.\(2025\)Siren’s song in the AI ocean: a survey on hallucination in large language models\.Computational Linguistics51\(4\),pp\. 1373–1418\.Cited by:[§1](https://arxiv.org/html/2607.15607#S1.p1.1)\.Similar Articles
Hitting a Moving Target: Test-Time Adaptation for AI Text Detection under Continual Distribution Shift
This paper proposes a test-time adaptation approach using semi-supervised learning for AI text detection that adapts to continual distribution shifts from new LLMs, adversarial humanization, and temporal drift, outperforming state-of-the-art supervised detectors.
Attention-Discounted Adaptive Sampler for Masked Diffusion Language Models
This paper introduces ADAS, a training-free reranking rule for parallel masked diffusion decoding that uses attention to discount tokens that strongly attend to uncertain positions, improving low-NFE performance on reasoning and code tasks with minimal runtime overhead.
Drift Happens: An Empirical Study of Neural Architecture Robustness to Temporal Distribution Shift
This paper presents an empirical study comparing how different neural architectures (MLPs, CNNs, RNNs, pretrained transformers) degrade under temporal distribution shift across image and text domains, finding that models exploiting localized features degrade fastest while pretrained encoders drift more gradually.
Detecting Neural Network Failures through Spectral Analysis of Internal Activations
This paper identifies spectral drift in internal activations of neural networks during misclassifications and introduces Self-Detecting Neural Networks (SDNN) that monitors spectral dynamics to detect failures, achieving 79% AUROC on CIFAR-10, outperforming confidence-based methods by 25-30 percentage points.
Attention Drift: What Autoregressive Speculative Decoding Models Learn
This paper identifies 'attention drift' in autoregressive speculative decoding models, where drafters' attention shifts from the prompt to their own generated tokens. The authors propose architectural changes, such as post-norm and RMSNorm, which improve acceptance rates and robustness across various benchmarks.