                  How Contaminated Is Your Benchmark?
Measuring Dataset Leakage in Large Language Models with Kernel Divergence


                         Hyeong Kyu Choi ∗ 1 Maxim Khanov ∗ 1 Hongxin Wei 2 Yixuan Li 1


                         Abstract                                  1. Introduction
                                                                   When a large language model (LLM) performs remarkably
      Dataset contamination, where evaluation datasets             well on a benchmark, can we confidently attribute its success
      overlap with pre-training corpora, inflates                  to true generalization—or is it simply a reflection of what
      performance metrics and undermines the relia-                the model has already seen during pre-training? The reality
      bility of model evaluations. Measuring dataset               is, we often don’t know. Beneath the surface of those impres-
      contamination thus becomes essential to ensure               sive performance scores lies a critical vulnerability: dataset
      that performance evaluations genuinely reflect               contamination, a phenomenon where evaluation datasets
      a model’s ability to generalize to unseen data,              overlap with the pretraining data of the model (Golchin &
      rather than relying on memorized examples.                   Surdeanu, 2024). This overlap artificially inflates reported
      To address this problem, we propose Kernel                   performance metrics, obscures true generalization capabil-
      Divergence Score (KDS), a novel method that                  ities, and raises critical concerns about the reliability of
      evaluates dataset contamination by computing                 benchmark evaluations. This brings us to a pressing and
      the divergence between the kernel similarity                 underexplored question: How can we measure the degree
      matrix of sample embeddings, before and after                of dataset contamination?
      fine-tuning on the benchmark dataset. Leveraging             Addressing this question is crucial to ensuring that perfor-
      the insight that fine-tuning affects unseen                  mance evaluations genuinely reflect a model’s ability to
      samples more significantly than seen ones, KDS               generalize to unseen data, rather than benefiting from over-
      provides a reliable measure of contamination.                lap with pretraining data. To formalize the problem, we
      Through extensive experiments on controlled                  aim to develop a scoring function S : (D, M) → R, that
      contamination scenarios, KDS demonstrates a                  takes a benchmark dataset D as input and produces a score
      near-perfect correlation with contamination levels           indicative of its relative contamination level with respect
      and outperforms existing baselines. Additionally,            to the given model M. A higher score corresponds to a
      we perform comprehensive ablation studies                    greater contamination level. Such a score is valuable be-
      to analyze the impact of key design choices,                 cause researchers can use it to rank multiple benchmarks
      providing deeper insights into the components                and prioritize the less contaminated ones, enabling more
      and effectiveness of KDS. These ablations high-              informed comparisons and reliable evaluation. For the score
      light the importance of leveraging fine-grained              to be reliable, we argue that the scoring function must satisfy
      kernel-based information and confirm the relia-              two essential properties: monotonicity, which ensures that
      bility of the proposed framework across diverse              the score exhibits a positive correlation with the contami-
      datasets and settings. Code is released in https:            nation level, and consistency, which means that the score
      //github.com/deeplearning-wisc/                              remains stable across independently sampled subsets with
      kernel-divergence-score.                                     the same contamination rate.
                                                                   To measure dataset contamination, we introduce the Kernel
  *                     1                                          Divergence Score (KDS), which computes the divergence
   Equal contribution    Department of Computer Sciences,
University of Wisconsin–Madison, United States 2 Department        of the kernel similarity matrix of sample embeddings before
of Statistics and Data Science, Southern University of Sci-        and after fine-tuning on the benchmark dataset. By analyz-
ence and Technology, China. Correspondence to: Yixuan Li           ing changes in the kernel similarity matrix, KDS captures
<sharonli@cs.wisc.edu>.                                            how fine-tuning reshapes the embeddings for seen and un-
                                                                   seen data, providing a more holistic and nuanced perspective
Proceedings of the 42 st International Conference on Machine
Learning, Vancouver, Canada. PMLR 267, 2025. Copyright 2025        on dataset contamination. This approach is motivated by
by the author(s).                                                  the fact that fine-tuning has a more significant effect on the

                                                               1
                                                     Kernel Divergence Score




               Seen    Seen   Seen




                                                 Pre-trained LLM                            Fine-tuned LLM
               Seen   Unseen Unseen




        Kernel Divergence
                                        (                                      ,                                    )
                                               Kernel similarity matrix                  Kernel similarity matrix




Figure 1. Overview of the proposed Kernel Divergence Score (KDS) framework for measuring dataset contamination in large language
models. The process involves extracting sample embeddings from the model before and after fine-tuning on the benchmark dataset D,
computing the kernel similarity matrix for each stage, and measuring the divergence between the two matrices Φ(Z) and Φ(Z ′ ). By
capturing the changes of embeddings induced by fine-tuning, KDS provides a reliable and interpretable score to evaluate the level of
dataset contamination.


embeddings of unseen samples, which the model must adapt                  • We validate Kernel Divergence Score through extensive
to, while seen samples exhibit minimal changes due to prior                 experiments on controlled contamination scenarios, show-
exposure during pre-training. Furthermore, as the propor-                   ing strong performance over existing baselines.
tion of unseen samples increases, their cumulative effect on
the kernel divergence score becomes more pronounced. By                   • We perform comprehensive ablations to analyze the im-
evaluating these changes, KDS can provide a reliable and                    pact of various design choices. Further practical discus-
interpretable measure of dataset contamination, with scores                 sions are presented, providing deeper insights into our
that proportionally reflect the level of contamination.                     kernel-based approach.

To evaluate KDS, we perform extensive experiments, sys-
tematically controlling contamination ratios across multi-                2. Problem Statement
ple datasets. Our results demonstrate that KDS achieves
                                                                          2.1. Measuring Benchmark Contamination
near-perfect correlation with contamination levels, generally
outperforming existing baselines across multiple datasets.                The objective is to evaluate the relative degree to which
Additionally, we show that KDS is robust to design choices,               a benchmark evaluation dataset, D, has been exposed to
including kernel functions, kernel bandwidth, and the extrac-             the pre-training process of a given LLM, M. In modern
tion location of embeddings. Overall, KDS provides stable                 LLMs, the pre-training dataset is typically unavailable, mak-
scores across diverse scenarios, enabling researchers to re-              ing it difficult to directly assess the contamination level.
liably identify benchmarks based on contamination levels.                 Accordingly, we consider a generalized characterization of
We summarize our contributions as follows:                                the benchmark evaluation data, modeling it as a mixture of
                                                                          both seen and unseen data:
                                                                                                    seen    unseen
• We propose Kernel Divergence Score, a reliable dataset-                                      D = DM    ∪ DM
                                                                                                 seen                                 (1)
  level scoring function to measure benchmark contami-                                         |DM    |/|D| = λ,
  nation. To the best of our knowledge, we are the first
                                                                                   seen                                            unseen
  to leverage the fine-grained information of kernels for                 where DM      is the data seen during M’s pre-training, DM
  scoring contamination levels.                                           is the data not seen by M, and λ ∈ [0, 1] is an unknown

                                                                    2
                                                   Kernel Divergence Score

parameter indicating the fraction of seen data in D. Within          Our approach is motivated by the fact that fine-tuning af-
this framework, we aim to develop a dataset-level scoring            fects the embedding relationships involving unseen samples
function                                                             more significantly than those involving seen samples. For
                    S : (D, M) → R,                                  seen samples, the model has already been exposed to similar
which measures the relative level of contamination of dataset        data during pretraining, leading to minimal shifts in their
D with respect to model M. A larger score indicates more             embedding relationships. In contrast, unseen samples expe-
contamination and vice versa.                                        rience more pronounced changes, as the fine-tuning process
                                                                     adjusts the model to better align with the benchmark dataset.
A reliable scoring function is practically valuable because          By evaluating these changes using the Kernel Divergence
it allows us to identify datasets that are contaminated with         Score, we can provide a reliable and granular measure of
respect to model M. Hence, we now outline the desirable              dataset contamination.
properties that the scoring function S should satisfy.
                                                                     Kernel similarity matrix. A kernel similarity matrix cap-
                                                                     tures the relationships among data samples, providing fine-
2.2. Reliable Contamination Scores
                                                                     grained information on their distribution. Formally, let
In this section, we state two essential requirements for a           Z ∈ Rn×d represent the embeddings of n samples in the
reliable contamination scoring function: Monotonicity and            dataset D, where Zi ∈ R1×d is the normalized embedding
Consistency.                                                         of i-th sample extracted from the pre-trained LLM M. We
                                                                     define the kernel matrix Φ(Z) ∈ Rn×n based on the Radial
Requirement 1. (Monotonicity) If dataset D is more inde-
                                                                     Basis Function (RBF) kernel:
pendent of model M than dataset D′ , i.e., λ < λ′ , then
                  S(D, M) < S(D′ , M)                                               Φ(Z)i,j = exp(−γ||Zi − Zj ||22 ),
should hold with statistical significance. In other words, a
dataset with a smaller λ, the fraction of seen data, should          where Φ(Z)i,j is the kernel similarity between samples Zi
have accordingly a smaller contamination score S(D, M).              and Zj , and γ controls the kernel bandwidth. The kernel
                                                                     matrix captures the pairwise relationships between all sam-
Requirement 2. (Consistency) If datasets D and D′ both               ples in the dataset, with values ranging from 0 to 1. An
comprise of independently and identically distributed (i.i.d.)       entry close to 1 indicates high similarity (small distance),
samples from a distribution with the same contamination              while a value close to 0 indicates low similarity (large dis-
ratio λ,                                                             tance). The matrix Φ(Z) is both symmetric and positive
                 S(D, M) ≈ S(D′ , M)                                 semidefinite.
should hold with statistical significance.
                                                                     Leveraging the effect of fine-tuning. Our proposed Kernel
The Monotonicity requirement ensures that the scoring func-          Divergence Score is based on the kernel matrix before and
tion exhibits a positive correlation with the dataset’s con-         after fine-tuning. Formally, let Z ′ ∈ Rn×d represent the
tamination rate, even though the true contamination rate             embeddings after LoRA (Hu et al., 2022) fine-tuning on
is typically unknown in real-world scenarios. A scoring              dataset D, where Zi′ ∈ R1×d . Accordingly, we can derive
function satisfying this requirement enables reliable ranking        the kernel similarity matrix as:
of datasets for each model based on their contamination
scores. The Consistency requirement, on the other hand,                             Φ(Z ′ )i,j = exp(−γ||Zi′ − Zj′ ||22 ).                        (2)
ensures that the scores are robust to variations in the spe-
cific samples drawn from the same underlying distribution,           Then, we define Kernel Divergence as
under the same λ. This property ensures that the random-
ness induced from sampling does not substantially affect                                    n
                                                                                     1 X                 Φ(Z)i,j
the overall scoring.                                                                         Φ(Z)i,j log            ,                             (3)
                                                                                     E i,j=1             Φ(Z ′ )i,j

3. Method: Kernel Divergence Score                                                qP
                                                                     where E =         i,j Φ(Z)i,j is a normalizer. When γ = 1,
In this section, we present our method, Kernel Divergence
                                                                     our score in Eq. (3) can be equivalently written as
Score, which leverages information among samples within
the model’s embedding space to establish a more nuanced                   n
contamination scoring mechanism. In a nutshell, we as-               1 X
                                                                             exp(−||Zi − Zj ||22 )            ||Zi′ − Zj′ ||22 − ||Zi − Zj ||22 .
sess changes in the kernel matrix of sample embeddings               E i,j=1 |       {z         }
                                                                              (1) Soft gating for originally |                 {z              }
before and after fine-tuning, capturing how the relationships                    closely-related samples     (2) Change in distance before and after SFT
between samples evolve as a result of fine-tuning.                                                                                                (4)

                                                                 3
                                                       Kernel Divergence Score




Figure 2. Decomposition of the Kernel Divergence Score. Each component of the Kernel Divergence Score function is shown. Φ(·)
denotes the kernel similarity matrix, Z and Z ′ represent normalized sample embeddings before and after fine-tuning, and ⊙ is the
Hadamard product. Score and embeddings are based on Llama-3.1-8B-Instruct (Dubey et al., 2024). (Left) shows that the original kernel
similarity matrix before fine-tuning. Note, that diagonal values are zeroed for better visualization, because all diagonal values are 1 in
RBF kernels. (Middle) reveals that fine-tuning alters relationships among unseen samples more than those among seen samples. (Right)
Combining the two panels enhances the distinction between seen and unseen samples, thereby enabling a more reliable measurement of
contamination levels.


Interpretation of kernel divergence. This function quan-                 left panel illustrates the soft gate from Eq. (4), or the kernel
tifies how fine-tuning changes the pairwise distances be-                similarity matrix using the pre-trained embedding. The
tween samples, weighted by their original similarity. Specif-            middle panel captures the change of pairwise embedding
ically, the second term ||Zi′ −Zj′ ||22 −||Zi −Zj ||22 measures          distance after supervised fine-tuning, and the right panel
the absolute change in the squared Euclidean distance be-                shows the resulting element-wise score matrix after the
tween embedding pairs caused by fine-tuning. For unseen                  Hadamard product of the two. As hypothesized, the middle
samples, fine-tuning tends to create new meaningful relation-            panel suggests that relationships involving unseen samples
ships or significantly alter their embeddings, making their              are more significantly altered by fine-tuning. By multiplying
contribution to the score larger. The first exponential term             the soft gate (left panel), unseen sample pairs contribute
acts as a soft gating function, assigning a higher weight to             more to the overall score. Additional examples with varying
pairs of samples that were originally closer to each other. By           contamination rates are provided in Appendix B.
incorporating this term, the score prioritizes the impact of
fine-tuning on pairs that were initially similar, highlighting           4. Experiments
cases where fine-tuning induces significant changes in their
relationships. Overall, a larger fraction of unseen examples             In this section, we conduct a controlled experiment to verify
(or smaller λ) can elevate the kernel divergence more signif-            the reliability of our Kernel Divergence Score with respect
icantly. Because we want the scoring function S(D, M) to                 to the Monotonicity and Consistency requirements (c.f. Sec-
be positively correlated with the contamination rate λ, we               tion 2.2). For a comprehensive analysis, we also assess
define our final scoring function to be the negation of kernel           existing non-kernel-based scoring methods.
divergence:
                             n
                                                                         4.1. Experimental Setup
                  1 X                 Φ(Z)i,j
      S(D, M) = −         Φ(Z)i,j log            ,             (5)       Dataset and model. Our controlled experiment aims to
                  E i,j=1             Φ(Z ′ )i,j
                                                                         evaluate the extent to which each method satisfies the Mono-
                                                                         tonicity and Consistency requirements. For this purpose, we
which is expected to be larger as the contamination λ grows.
                                                                         utilize three popular pre-training data detection benchmarks,
Visual demonstration of score components. To provide a                   WikiMIA (Shi et al., 2023), BookMIA (Shi et al., 2023),
concrete understanding of the role of each component in our              and ArxivTection (Duarte et al., 2024), each comprising
Kernel Divergence Score (Eq. (3) or Eq. (4)), we present the             samples labeled as ‘seen’ or ‘unseen’. Among the models
kernel matrix for each component in Figure 2. We use n =                 compatible with the datasets, we select Mistral-7B-Instruct-
100 samples with a contamination rate λ = 0.4, meaning                   v0.2 (Jiang et al., 2023) for our main evaluation. We present
40% of the samples are seen during model pre-training. The               additional results for other model families in Section 6.

                                                                     4
                                                      Kernel Divergence Score


Table 1. Monotonicity Evaluation. Correlation coefficients averaged across five different subsets are shown. SRCT on BookMIA and
ArxivTection are omitted due to excessive computation. On average, our Kernel Divergence Score demonstrates the best compliance with
the Monotonicity requirement.

                                               WikiMIA             BookMIA             ArxivTection           Average
 Methods                                 Spearman ↑ Pearson ↑ Spearman ↑ Pearson ↑ Spearman ↑ Pearson ↑ Spearman ↑ Pearson ↑
 Non-kernel-based Methods
 Zlib (Carlini et al., 2021)               0.968       0.960      -1.000      -0.997      0.997      0.918       0.322       0.294
 Zlib + FSD (Zhang et al., 2025)           0.976       0.966      -0.888      -0.895      0.941      0.947       0.343       0.339
 Perplexity (Li, 2023)                     0.933       0.929      0.964       0.967       1.000      0.997       0.966       0.964
 Perplexity + FSD (Zhang et al., 2025)     0.979       0.967      -0.777      -0.824      0.992      0.982       0.398       0.375
 Min-K% (Shi et al., 2023)                 0.893       0.899      0.998       0.992       1.000      0.998       0.964       0.964
 Min-K% + FSD (Zhang et al., 2025)         0.932       0.937      -0.526      -0.640      0.988      0.980       0.459       0.420
 Min-K%++ (Zhang et al., 2024b)            -0.790     -0.833      OOM         OOM         0.996      0.996       0.103       0.082
 Min-K%++ + FSD (Zhang et al., 2025)       -0.790     -0.834      OOM         OOM         0.754      0.809      -0.018      -0.013
 SRCT (Oren et al., 2024)                  0.080       0.073         -           -          -          -         0.080       0.073
 Kernel-based Method
 Kernel Divergence Score (Ours)            0.999      0.993       0.997       0.979       0.975      0.974       0.990      0.982



Baselines. We consider various baseline methods for com-               4.2. Experimental Results
prehensive evaluation. Specifically, we consider Zlib (Car-
                                                                       Kernel divergence score satisfies the monotonicity re-
lini et al., 2021), Perplexity Score (Li, 2023), Min-K% (Shi
                                                                       quirement. To evaluate compliance with the monotonicity
et al., 2023), Min-K%++ (Zhang et al., 2024b), Fine-tuned
                                                                       requirement, we analyze the correlation between scores and
Score Deviation (FSD; Zhang et al. (2025)), which evaluate
                                                                       contamination rates λ ∈ {0.0, 0.05, 0.10, . . . , 0.95, 1.0}.
the likelihood of exposure for every sample independently.
                                                                       The primary metric used is the Spearman correlation coeffi-
The overall contamination score of the dataset S(D, M)
                                                                       cient, which directly evaluates the monotonic relationship
is then quantified by averaging these instance-wise scores.
                                                                       between scores and contamination rates, ensuring align-
In addition, we consider the dataset-level approach that
                                                                       ment with the expected trend. Additionally, we compute
assesses the contamination of a dataset as a whole by exam-
                                                                       the Pearson correlation coefficient to provide insight into
ining statistical or distributional patterns that differentiate
                                                                       the linearity of the trends, with higher values indicating a
seen vs unseen datasets. This approach provides a more
                                                                       stronger linear pattern in the scores.
holistic view of contamination, capturing aggregate charac-
teristics that are not discernible at the individual example           In Table 1, we present the correlation coefficients for the
level. Specifically, we consider the Sharded Rank Compari-             three benchmark datasets. We keep the dataset size fixed
son Test (SRCT; Oren et al. (2024)), the latest dataset-level          while varying the contamination ratios. We observe that
detection method that identifies datasets showing significant          existing approaches often exhibit highly varying correlation
variability in likelihood values across different sample or-           and even reversed signs. For instance, in the BookMIA
derings. For each baseline, we adjusted their score sign so            dataset, our thorough evaluation across five random subsets
that higher scores indicate more contamination (i.e., bigger           consistently revealed negative correlation values for several
λ). We include the detailed definition of each baseline in             baseline methods. In contrast, KDS consistently achieves
Appendix A.2.                                                          a near-perfect correlation on all datasets. On average, it
                                                                       demonstrates the strongest compliance with the monotonic-
Experimental details. For each dataset, we evaluate scor-              ity requirement.
ing performances on different contamination rates. For in-
tegrity across experiments, we fix the data subset size to 700         Moreover, it is noteworthy that compared to FSD (Zhang
for WikiMIA and ArxivTection, and 4000 for BookMIA.                    et al., 2025) in Table 1, which also leverages fine-tuning in-
Then, we run each dataset five times for robust evaluation,            formation in detecting pre-training data, our method demon-
each with differently sampled subsets. For methods that                strates more consistent performance improvements. We
require fine-tuning (e.g our Kernel Divergence Score and               attribute this improvement to our KDS’s direct assessment
Fine-tuned Score Deviation (Zhang et al., 2025)), we train             of the structural information within model representations,
the model for 1 epoch using stochastic gradient descent                bypassing the reliance on intermediate scoring adjustments
with a batch size of 4. Furthermore, in determining the                in FSD methods. This direct approach allows our score to
bandwidth parameter γ in the RBF kernel (Eq. (2)), we                  effectively capture the intrinsic characteristics of the data,
utilize the median heuristic (Garreau et al., 2017). Further           leading to more reliable scoring.
implementation details are in Appendix A.

                                                                   5
                                                                  Kernel Divergence Score
Kernel Divergence Score
                          1.0                                                   Table 2. Ablation study of KDS components. Correlation coef-
                                      WikiMIA                                   ficients are averaged across 5 independent runs evaluated on the
                                                                                WikiMIA dataset.
                          0.8
                                                                                    Methods                        Spearman ↑   Pearson ↑
                          0.6
                                                                                    Kernel Divergence Score          0.999        0.993
                                                                                    w/o (1) Soft Gating              0.998        0.990
                          0.4                                                       w/o (2) Fine-tuning              0.683        0.749
                                                                                    w/ Euclidean Distance Kernel     0.999        0.994
                          0.2                                                       w/ Cosine Similarity Kernel      0.998        0.990
                                                                                    w/ Dot-product Kernel            0.998        0.986
                          0.0   0.0     0.2     0.4   0.6   0.8       1.0
                                         Contamination Rates                     ||Zi′ − Zj′ ||22 − ||Zi − Zj ||22 as the contamination score.
                                                                                Conversely, ablating component (2) is equivalent to disre-
     Figure 3. Trend of Kernel Divergence Scores on WikiMIA. The
                                                                                garding the effects of supervised fine-tuning, relying solely
     score shows monotonic increase with respect to contamination rate,
                                                                                on the kernel similarity matrix Φ(Z) before fine-tuning,
     and the standard deviation over 5 runs is low.
                                                                                with the average kernel entry value serving as the contam-
                                                                                ination score. The results indicate that removing the soft
                                                                                gating mechanism (Component 1) leads to a marginal de-
     Kernel divergence score satisfies the consistency require-
                                                                                cline in performance. This suggests that while the gating
     ment. To verify the Consistency requirement, we test
                                                                                mechanism enhances the score’s reliability, the majority of
     whether our score remains stable across independently and
                                                                                the information is derived from the differential effects ob-
     identically distributed datasets sampled from the same dis-
                                                                                served before and after fine-tuning. Indeed, removing the
     tribution and with the same contamination rate λ. For each
                                                                                supervised fine-tuning component (Component 2) signifi-
     contamination rate λ ∈ {0.0, 0.05, 0.10, . . . , 0.95, 1.0}, we
                                                                                cantly degrades the performance, highlighting the critical
     create datasets by randomly sampling 5 independent subsets
                                                                                role of fine-tuning in amplifying the kernel’s ability to mea-
     from each dataset. Each subset complies with the mixing
                                                                                sure dataset contamination levels.
     rate λ, consisting of seen and unseen samples in proportions
     determined by λ. All datasets are fixed to the same size
                                                                                Our method is not sensitive to the choice of kernel func-
     to ensure comparability. In Figure 3, we observe that the
                                                                                tion. The Kernel Divergence Score employs the RBF
     kernel divergence score demonstrates relatively low stan-
                                                                                kernel to compute differences after supervised fine-tuning.
     dard deviations, indicating compliance with the Consistency
                                                                                However, an important question arises: how robust is the
     requirement. This shows that our method can produce sta-
                                                                                scoring performance to variations in the kernel function? To
     ble and reliable scores, independent of the specific random
                                                                                address this, we evaluate our method using alternative ker-
     subset used.
                                                                                nel functions, including Euclidean pairwise distance, cosine
                                                                                similarity, and dot-product similarity, as shown in Table 2
     5. Ablation Studies                                                        (bottom). For the Euclidean pairwise distance and cosine
                                                                                similarity kernels, we replace Φ(Z) in Eq. (5) with the
     In this section, we conduct an in-depth analysis to under-
                                                                                respective kernel computations. We add 1 to the cosine sim-
     stand various design choices of our kernel divergence score.
                                                                                ilarity kernel matrix to enforce non-negative entries. For the
     What’s the impact of fine-tuning on the score? As de-                      dot-product similarity kernel, we compute the mean squared
     scribed in Eq. (4), the Kernel Divergence Score comprises                  error of the kernel matrices before and after fine-tuning, as
     two key components: (1) the kernel similarity matrix Φ(Z),                 the kernel entries may take negative values, making them
     which serves as a soft gating mechanism, and (2) the change                incompatible with the logarithmic operation used in our
     in pairwise distance, which captures the effects of super-                 scoring function.
     vised fine-tuning. The roles of these two components are
                                                                                The results indicate that scoring performance remains con-
     qualitatively illustrated in the left and middle panels of Fig-
                                                                                sistent across different kernel functions. This suggests that
     ure 2. To further elucidate their individual contributions,
                                                                                the effectiveness of the Kernel Divergence Score lies in its
     we conducted an ablation study, with results summarized in
                                                                                ability to leverage structural information from kernel rep-
     Table 2 (top). The study evaluates the impact of removing
                                                                                resentations, rather than being dependent on the specific
     each component.
                                                                                choice of the kernel. These findings highlight the versatility
     Specifically, ablating component (1) involves omitting the                 of our kernel-based approach in measuring contamination
     soft gating mechanism, thereby utilizing the average of                    levels across diverse settings.

                                                                            6
                                                                Kernel Divergence Score


Table 3. Effect of different kernel bandwidths. Scoring perfor-                     Table 4. Effect of different training configurations. Scoring
mance metrics are retrieved and averaged over 5 independent runs.                   performance metrics are retrieved and averaged over 5 independent
                                                                                    runs. Values in parentheses are the standard deviation across runs.
        Kernel Bandwidth          Spearman ↑        Pearson ↑
                                                                                         Configuration              Spearman ↑       Pearson ↑
        γ = Median                    0.999            0.993
                                                                                         1 Epoch; Stochastic GD      0.999 (0.00)   0.993 (0.00)
        γ = 0.001                     0.999            0.994
                                                                                         1 Epoch; Batch GD           0.908 (0.18)   0.916 (0.13)
        γ = 0.01                      0.999            0.994
                                                                                         4 Epochs; Stochastic GD     0.983 (0.02)   0.643 (0.43)
        γ = 0.1                       0.999            0.994
                                                                                         4 Epochs; Batch GD          0.846 (0.15)   0.875 (0.08)
        γ = 1.0                       0.999            0.994
        γ = 10.0                      0.801            0.838

                                                                                    What’s the impact of embedding extraction location?
                                                                                    In our main experiments, we use the output embeddings
 1.0
            Spearman Corr.                                                          from the final layer of the LLM to compute KDS. To fur-
 0.8        Pearson Corr.                                                           ther analyze the impact of embedding location, we evaluate
                                                                                    the Spearman and Pearson correlation using embeddings
 0.6                                                                                extracted from different layers of the model, as shown in
 0.4                                                                                Figure 4 (top). Our results reveal that the strongest corre-
                                                                                    lation is observed in the latter layers, indicating that these
 0.2                                                                                layers contain the most information relevant to dataset con-
 0.0                                                                                tamination. This suggests that the latter layers of the LLM,
       1 2 3 4 5 6 7 8 9 1011121314151617181920212223242526272829303132
                               Layer Index                                          which are typically fine-tuned to align with specific tasks
                                                                                    or datasets, are more sensitive to the effects of contamina-
                                                                                    tion compared to earlier layers. These findings support the
Figure 4. Scoring performance across embedding location. Cor-                       selection of final layer embeddings for kernel computation,
relation coefficients from different layers are retrieved using                     as they provide an informative basis for assessing dataset
Mistral-7B-Instruct-v0.2 on WikiMIA.                                                contamination.

                                                                                    How does SFT configuration impact the performance?
How does the kernel bandwidth γ impact the perfor-
                                                                                    Table 4 presents the Spearman and Pearson correlation coef-
mance? In an RBF kernel, the bandwidth parameter γ
                                                                                    ficients for contamination scores under different SFT train-
controls the sharpness of the kernel’s entry distribution. In
                                                                                    ing configurations on the WikiMIA dataset. The configu-
our approach, we employed the median heuristic (Garreau
                                                                                    rations vary in terms of the optimization method (Stochas-
et al., 2017), which sets γ as the inverse of the median
                                                                                    tic Gradient Descent vs. Batch Gradient Descent) and the
pairwise distance. To examine the effect of γ on contam-
                                                                                    number of fine-tuning epochs (1 vs. 4). The results show
ination scoring, we evaluate different bandwidth values
                                                                                    that stochastic GD significantly outperforms batch GD, sug-
{0.001, 0.01, 0.1, 1.0, 10.0}, as shown in Table 3. The re-
                                                                                    gesting that the finer-grained updates introduced by SGD
sults indicate that scoring performance is largely invariant
                                                                                    enhance the sensitivity of the Kernel Divergence Score to
to the choice of γ. This behavior is expected, considering
                                                                                    dataset contamination. On the other hand, increasing the
that Eq. (4) with arbitrary γ is
                                                                                    number of fine-tuning epochs does not necessarily improve
                 n
                                                                                    scoring performance. This may be attributed to the repeated
           1 X                                                                      exposure of the model to the same samples during training,
                   γ exp(−ui,j )γ              u′i,j − ui,j ,             (6)
           E i,j=1 |     {z     }                                                   which could obscure the distinction between seen and un-
                      monotonicity preserved                                        seen samples. Overall, training with one epoch using SGD
                                                                                    leads to the best performance.
where ui,j = ||Zi − Zj ||22 and u′i,j = ||Zi′ − Zj′ ||22 . The
effect of γ is limited to a constant multiplicative factor on                       6. Discussions
the overall scores, and to a power factor that controls the
sharpness of the soft gate. This does not influence their                           Temporal shift problems of MIA benchmarks. Recent
relative trends across varying contamination rates. This                            studies have expressed concerns regarding the temporal
invariance underscores the robustness of our Kernel Diver-                          shift issues in existing Membership Inference Attack (MIA)
gence Score to the choice of bandwidth parameter. However,                          benchmarks (Duan et al., 2024; Das et al., 2024; Maini et al.,
setting an excessively large value (e.g. γ = 10.0) may cause                        2024). Notably, datasets such as WikiMIA, BookMIA, and
numerical errors and degrade scoring performance.                                   ArxivTection have been identified as susceptible to temporal

                                                                                7
                                                     Kernel Divergence Score


                                      Table 5. Baseline comparison on PILE data subsets.

    Methods                            Wikipedia PhilPapers Enron HackeerNews Pile CC StackExchange Average
    Zlib                                  0.861        1.000     1.000          -0.956         -0.782           0.990            0.352
    Zlib + FSD                            1.000        0.991     0.999           0.323          0.894           0.999            0.868
    Perplexity                           -0.886        0.999     0.999          -0.999         -0.251           0.999            0.144
    Perplexity + FSD                      1.000        0.990     0.999           0.118          0.908           1.000            0.836
    Min-K%                               -0.645        0.996     1.000          -0.955          0.690           0.999            0.348
    Min-K% + FSD                          0.997        0.952     0.997          0.421           0.908           1.000            0.879
    Min-K%++                             -0.482        0.960     -0.842         0.561          0.514            0.697            0.235
    Min-K%++ + FSD                       -0.536        0.994     -0.770         0.705          -0.358           0.210            0.041
    Kernel Divergence Score (Ours)       0.891         0.982     1.000          0.897           0.895           1.000            0.944



Table 6. Evaluation on benchmarks with IID setup. We evaluate        Table 7. Evaluation using various models. We evaluate the Mono-
the monotonicity of our kernel divergence score on six subsets       tonicity on the WikiMIA dataset.
from the Pile dataset (Gao et al., 2020).
                                                                      Model                                            Spearman ↑ Pearson ↑
        Data Subset       Spearman ↑       Pearson ↑                  Mistral-7B-Instruct-v0.2 (Jiang et al., 2023)      0.999      0.996
                                                                      Llama-3.1-8B-Instruct (Dubey et al., 2024)         0.982      0.952
        Wikipedia             0.891          0.922
                                                                      Phi-3-small-128k-instruct (Abdin et al., 2024)     0.892      0.890
        PhilPapers            0.982          0.974
        Enron                 1.000          0.965
        HackerNews            0.897          0.920
        Pile-CC               0.895          0.908                   method reliably scores contamination levels without relying
        StackExchange         1.000          0.998                   on temporal shifts.
        Average               0.944          0.948
                                                                     Extension to various model families. We extend our eval-
                                                                     uation to diverse models to demonstrate the versatility of
                                                                     our approach. As presented in Table 7, our approach con-
cues, which can inadvertently simplify the membership in-
                                                                     sistently exhibits near-perfect correlation values across all
ference task. This simplification arises because models can
                                                                     models tested. These findings underscore the robustness and
exploit temporal information to distinguish between seen
                                                                     applicability of our method across diverse model families.
versus unseen data, leading to a potential overestimation of
detection performance.
                                                                     Computational cost. Our kernel divergence score in-
To ensure the robustness of our approach and mitigate po-            volves a fine-tuning step to obtain two kernel matrices, fol-
tential biases introduced by temporal shifts, we conducted           lowed by the computation of our scoring function. Given a
evaluations using 500 samples from six subsets of the Pile           dataset with N samples, the fine-tuning step operates with
dataset (Gao et al., 2020). The subsets include text data from       a time complexity of O(c1 · N ), where c1 is a constant in-
various sources, including expository proses (Wikipedia),            fluenced by factors such as average sample length, batch
academic papers (PhilPapers), emails (Enron), news arti-             size, and model dimension. The computation of the KDS
cles (HackerNews), web-scraped data (Pile-CC), and user-             score has complexity O(c2 · N 2 ), due to the quadratic na-
contributed questions and answers (StackExchange). For               ture of kernel matrix operations. In practice, the latency
each subset, the ‘train’ set is regarded as seen data, while         overhead caused by scoring is minimal, as these operations
the ‘val’ set serves as unseen data. We mix these two sets ac-       are highly optimized through vectorized computations. As
cording to varying contamination rates to assess our model’s         demonstrated in Table 8, the latency measured in seconds
performance under different conditions. This methodology             for each dataset confirms the efficiency and scalability of
provides a rigorous assessment, ensuring that our model              our approach.
does not exploit temporal cues. In Table 5, we provide
the baseline comparison results evaluated on the PILE data           7. Related Works
subsets. On average, our Kernel Divergence Score (KDS)
achieves the highest Spearman correlation coefficient. More-         Data contamination (Magar & Schwartz, 2022; Xu et al.,
over, as presented in Table 6, both the Spearman and Pearson         2024; Balloccu et al., 2024; Dekoninck et al., 2024), also
correlation coefficients are near 1.0, averaging at 0.944 and        known as benchmark leakage, poses a significant challenge
0.948, respectively. These findings demonstrate that our             in the evaluation of LLMs (Zhou et al., 2023; Duan et al.,

                                                                 8
                                                      Kernel Divergence Score

                                                                       capabilities. This contributes to a more rigorous bench-
Table 8. Computational cost. We report the computation time in
                                                                       marking process, fostering fair and meaningful comparisons
seconds, measured on a single RTX H200 GPU.
                                                                       across different models and architectures. Furthermore, the
     Dataset       Size (N )   Fine-tuning      Scoring                insights gained from this work can inform better practices
     Complexity                 O(c1 · N )     O(c2 · N 2 )
                                                                       for dataset curation. This not only reduces the risk of in-
                                                                       flated performance results but also enhances the utility of
     WikiMIA         700           39s          0.0008s
     WikiMIA         350           23s          0.0006s
                                                                       benchmarks as tools for guiding research and development.
     BookMIA        4000           555s         0.0013s
     BookMIA        2000           294s         0.0012s                Limitations and Future Work
     BookMIA        1000           114s         0.0011s
                                                                       In this work, we introduced the Kernel Divergence Score
                                                                       as a method to reliably measure dataset contamination lev-
2024). To mitigate this problem, one line of research focuses          els. Compared to sample-wise scoring methods, our kernel
on “decontaminating” datasets by introducing controlled                divergence score leverages kernels that require quadratic
perturbations to reduce overlap with evaluation (Yang et al.,          computation. As shown in Table 8, kernel computation
2023). Another line explores methods for detecting contami-            itself is not a significant burden in practice. However, it
nated datasets or identifying samples seen during LLM train-           can become a bottleneck in terms of time and space as
ing. Membership inference attack (MIA) techniques (Shokri              dataset size increases substantially. To mitigate this compu-
et al., 2017; Truex et al., 2019) have been employed to clas-          tational challenge, we can reduce the amount of computation
sify individual data as seen or unseen (Yeom et al., 2018;             by adopting local kernel approaches (Segata & Blanzieri,
Salem et al., 2019; Mattern et al., 2023), with many recent            2010), and by sequentially computing and accumulating
studies specifically targeting LLMs for pre-training data              the kernel entries to avoid out-of-memory errors. Another
detection (Carlini et al., 2021; Shi et al., 2023; Zhang et al.,       promising direction for future research is the application
2024b; Xie et al., 2024; Li, 2023; Ye et al., 2024). In ad-            of Positive-Unlabeled (PU) learning (Elkan & Noto, 2008),
dition, set-level detection methods have been introduced               which focuses on constructing classifiers using only positive
to identify contamination at a broader dataset level (Oren             and unlabeled data. In the context of dataset contamination
et al., 2024; Zhang et al., 2024a; Golchin & Surdeanu, 2024).          detection, PU learning could help in estimating the distribu-
Building on this foundation, our work introduced a novel ap-           tion of contaminated data when only a subset of positive (i.e.,
proach, Kernel Divergence Score, to scoring contamination              contaminated) examples is available. Additionally, explor-
levels using information derived from embedding kernel                 ing kernel calibration methods may enhance the robustness
similarity matrices. An expanded literature review of MIA is           of KDS across different models. By investigating these di-
in Appendix F.                                                         rections, future work can aim to develop a more universally
                                                                       applicable contamination scoring mechanism, thereby im-
                                                                       proving the reliability and comparability of contamination
8. Conclusion                                                          assessments across various machine learning models and
In this work, we addressed the critical issue of dataset con-          datasets.
tamination in LLM by introducing the Kernel Divergence
Score. By capturing fine-tuning-induced shifts in sample               Acknowledgement
embeddings, KDS provides a robust and interpretable mea-
sure of contamination. Extensive experiments on controlled             The authors would like to thank Shawn Im and Seongheon
scenarios demonstrated the effectiveness of KDS in sat-                Park for their valuable comments on the manuscript.
isfying key properties like monotonicity and consistency,              Hyeong Kyu Choi, Maxim Khanov, and Yixuan Li are sup-
outperforming existing baselines. This work paves the way              ported in part by the AFOSR Young Investigator Program
for more reliable benchmark evaluations, fostering better              under award number FA9550-23-1-0184, National Science
dataset curation practices in LLM research.                            Foundation under awards IIS-2237037 and IIS-2331669,
                                                                       Office of Naval Research under grant number N00014-23-
                                                                       1-2643, Schmidt Sciences Foundation, and Alfred P. Sloan
Impact Statement                                                       Fellowship.
The broader impact of this work lies in its potential to sig-
nificantly improve the reliability, transparency, and fairness
of large language model evaluation. By enabling the identi-
fication and quantification of contaminated datasets, our ap-
proach ensures that reported performance metrics are more
trustworthy and reflective of a model’s true generalization

                                                                   9
                                                       Kernel Divergence Score

References                                                                 Hu, E. J., Wallis, P., Allen-Zhu, Z., Li, Y., Wang, S., Wang, L.,
                                                                             Chen, W., et al. Lora: Low-rank adaptation of large language
Abdin, M., Aneja, J., Awadalla, H., Awadallah, A., Awan, A. A.,              models. In International Conference on Learning Representa-
  Bach, N., Bahree, A., Bakhtiari, A., Bao, J., Behl, H., et al.             tions, 2021.
  Phi-3 technical report: A highly capable language model locally
  on your phone. arXiv preprint arXiv:2404.14219, 2024.                    Hu, E. J., Shen, Y., Wallis, P., Allen-Zhu, Z., Li, Y., Wang, S.,
                                                                             Wang, L., Chen, W., et al. Lora: Low-rank adaptation of large
Balloccu, S., Schmidtová, P., Lango, M., and Dušek, O. Leak,               language models. ICLR, 1(2):3, 2022.
  cheat, repeat: Data contamination and evaluation malpractices
  in closed-source llms. In Proceedings of the 18th Conference             Jiang, A. Q., Sablayrolles, A., Mensch, A., Bamford, C., Chaplot,
  of the European Chapter of the Association for Computational                D. S., Casas, D. d. l., Bressand, F., Lengyel, G., Lample, G.,
  Linguistics (Volume 1: Long Papers), pp. 67–93, 2024.                       Saulnier, L., et al. Mistral 7b. arXiv preprint arXiv:2310.06825,
                                                                              2023.
Carlini, N., Tramer, F., Wallace, E., Jagielski, M., Herbert-Voss,
  A., Lee, K., Roberts, A., Brown, T., Song, D., Erlingsson, U.,           Li, Y. Estimating contamination via perplexity: Quantifying
  et al. Extracting training data from large language models. In              memorisation in language model evaluation. arXiv preprint
  30th USENIX Security Symposium (USENIX Security 21), pp.                    arXiv:2309.10677, 2023.
  2633–2650, 2021.
                                                                           Liu, G., Wang, C., Peng, K., Huang, H., Li, Y., and Cheng, W.
Carlini, N., Chien, S., Nasr, M., Song, S., Terzis, A., and Tramer,          Socinf: Membership inference attacks on social media health
  F. Membership inference attacks from first principles. In 2022             data with machine learning. IEEE Transactions on Computa-
  IEEE Symposium on Security and Privacy (SP), pp. 1897–1914.                tional Social Systems, 6(5):907–921, 2019.
  IEEE, 2022.
                                                                           Liu, G., Xu, T., Zhang, R., Wang, Z., Wang, C., and Liu, L.
Das, D., Zhang, J., and Tramèr, F. Blind baselines beat member-             Gradient-leaks: Enabling black-box membership inference at-
  ship inference attacks for foundation models. arXiv preprint               tacks against machine learning models. IEEE Transactions on
  arXiv:2406.16201, 2024.                                                    Information Forensics and Security, 2023.

Dekoninck, J., Müller, M., and Vechev, M. Constat: Performance-           Magar, I. and Schwartz, R. Data contamination: From memoriza-
  based contamination detection in large language models. Ad-                tion to exploitation. In Proceedings of the 60th Annual Meeting
  vances in Neural Information Processing Systems, 37:92420–                 of the Association for Computational Linguistics (Volume 2:
  92464, 2024.                                                              Short Papers), pp. 157–165, 2022.

Duan, M., Suri, A., Mireshghallah, N., Min, S., Shi, W., Zettle-           Maini, P., Jia, H., Papernot, N., and Dziedzic, A. Llm dataset
  moyer, L., Tsvetkov, Y., Choi, Y., Evans, D., and Hajishirzi,             inference: Did you train on my dataset? arXiv preprint
  H. Do membership inference attacks work on large language                 arXiv:2406.06443, 2024.
  models? arXiv preprint arXiv:2402.07841, 2024.
                                                                           Mattern, J., Mireshghallah, F., Jin, Z., Schoelkopf, B., Sachan, M.,
Duarte, A. V., Zhao, X., Oliveira, A. L., and Li, L. DE-COP:                 and Berg-Kirkpatrick, T. Membership inference attacks against
  Detecting copyrighted content in language models training data.            language models via neighbourhood comparison. In Findings
  In Proceedings of the 41st International Conference on Machine             of the Association for Computational Linguistics: ACL 2023,
  Learning, volume 235, pp. 11940–11956, 2024.                               pp. 11330–11343, 2023.

                                                                           Meeus, M., Shilov, I., Jain, S., Faysse, M., Rei, M., and de Mon-
Dubey, A., Jauhri, A., Pandey, A., Kadian, A., Al-Dahle, A.,                tjoye, Y.-A. Sok: Membership inference attacks on llms
  Letman, A., Mathur, A., Schelten, A., Yang, A., Fan, A., et al.           are rushing nowhere (and how to fix it). arXiv preprint
  The llama 3 herd of models. arXiv preprint arXiv:2407.21783,              arXiv:2406.17975, 2024.
  2024.
                                                                           Oren, Y., Meister, N., Chatterji, N. S., Ladhak, F., and Hashimoto,
Elkan, C. and Noto, K. Learning classifiers from only positive               T. Proving test set contamination in black-box language models.
  and unlabeled data. In Proceedings of the 14th ACM SIGKDD                  In The Twelfth International Conference on Learning Represen-
  international conference on Knowledge discovery and data                   tations, 2024.
  mining, pp. 213–220, 2008.
                                                                           Salem, A., Zhang, Y., Humbert, M., Berrang, P., Fritz, M., and
Gao, L., Biderman, S., Black, S., Golding, L., Hoppe, T., Foster,            Backes, M. Ml-leaks: Model and data independent membership
  C., Phang, J., He, H., Thite, A., Nabeshima, N., et al. The pile:          inference attacks and defenses on machine learning models. In
  An 800gb dataset of diverse text for language modeling. arXiv              Proceedings 2019 Network and Distributed System Security
  preprint arXiv:2101.00027, 2020.                                           Symposium. Internet Society, 2019.

Garreau, D., Jitkrittum, W., and Kanagawa, M. Large sample anal-           Segata, N. and Blanzieri, E. Fast and scalable local kernel ma-
  ysis of the median heuristic. arXiv preprint arXiv:1707.07269,             chines. Journal of Machine Learning Research, 11(6), 2010.
  2017.
                                                                           Shi, W., Ajith, A., Xia, M., Huang, Y., Liu, D., Blevins, T., Chen,
Golchin, S. and Surdeanu, M. Time travel in llms: Tracing data               D., and Zettlemoyer, L. Detecting pretraining data from large
  contamination in large language models. In The Twelfth Inter-              language models. In The Twelfth International Conference on
  national Conference on Learning Representations, 2024.                     Learning Representations, 2023.

                                                                      10
                                                        Kernel Divergence Score

Shokri, R., Stronati, M., Song, C., and Shmatikov, V. Membership
  inference attacks against machine learning models. In 2017
  IEEE symposium on security and privacy (SP), pp. 3–18. IEEE,
  2017.

Truex, S., Liu, L., Gursoy, M. E., Yu, L., and Wei, W. Demystifying
  membership inference attacks in machine learning as a service.
  IEEE transactions on services computing, 14(6):2073–2089,
  2019.

Xie, R., Wang, J., Huang, R., Zhang, M., Ge, R., Pei, J., Gong,
  N., and Dhingra, B. Recall: Membership inference via relative
  conditional log-likelihoods. In Proceedings of the 2024 Confer-
  ence on Empirical Methods in Natural Language Processing,
  pp. 8671–8689, 2024.

Xu, C., Guan, S., Greene, D., Kechadi, M., et al. Benchmark
  data contamination of large language models: A survey. arXiv
  preprint arXiv:2406.04244, 2024.

Yang, S., Chiang, W.-L., Zheng, L., Gonzalez, J. E., and Stoica,
  I. Rethinking benchmark and contamination for language mod-
  els with rephrased samples. arXiv preprint arXiv:2311.04850,
  2023.

Ye, W., Hu, J., Li, L., Wang, H., Chen, G., and Zhao, J. Data
  contamination calibration for black-box llms. arXiv preprint
  arXiv:2405.11930, 2024.

Yeom, S., Giacomelli, I., Fredrikson, M., and Jha, S. Privacy risk
  in machine learning: Analyzing the connection to overfitting.
  In 2018 IEEE 31st computer security foundations symposium
  (CSF), pp. 268–282. IEEE, 2018.
Zhang, H., Lin, Y., and Wan, X. Pacost: Paired confidence signifi-
  cance testing for benchmark contamination detection in large
  language models. In Findings of the Association for Computa-
  tional Linguistics: EMNLP 2024, pp. 1794–1809, 2024a.

Zhang, H., Zhang, S., Jing, B., and Wei, H. Fine-tuning can help
  detect pretraining data from large language models. In ICLR,
  2025.

Zhang, J., Sun, J., Yeats, E., Ouyang, Y., Kuo, M., Zhang, J., Yang,
  H. F., and Li, H. Min-k%++: Improved baseline for detecting
  pre-training data from large language models. arXiv preprint
  arXiv:2404.02936, 2024b.

Zhou, K., Zhu, Y., Chen, Z., Chen, W., Zhao, W. X., Chen, X., Lin,
  Y., Wen, J.-R., and Han, J. Don’t make your llm an evaluation
  benchmark cheater. arXiv preprint arXiv:2311.01964, 2023.




                                                                       11
                                                  Kernel Divergence Score


Appendix

Contents

A Further Experimental Details                                                                                            12
   A.1 Implementation Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .     12
   A.2 Baseline Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   12


B Kernel Decomposition Plots Across Contamination Rates                                                                   13


C Consistency Requirement Compliance in Detail                                                                            15


D Role of the Normalization Factor                                                                                        15


E Histogram of Change in Embedding Distances                                                                              16


F Extended Literature Review                                                                                              16



A. Further Experimental Details
In this section, we append further experimental details and provide formal definitions of the baselines evaluated in the
manuscript.

A.1. Implementation Details
For supervised fine-tuning, we utilize Low-rank Adaptation (Hu et al., 2021). In Table 9, we disclose detailed LoRA
configurations and other training hyperparameters used for supervised fine-tuning.


                            Table 9. Supervised Fine-tuning Configurations and Hyperparameters.

                            Hyperparameter             WikiMIA       BookMIA        ArxivTection
                            LoRA Dimension                                  8
                            LoRA α                                         32
                            LoRA Dropout                                   0.1
                            LoRA Target Modules              query, value projection layers
                            SGD Learning Rate                           0.0001
                            Batch GD Learning Rate                        0.01
                            Batch Size                                      4
                            Dataset Size                  700           4000            700



A.2. Baseline Definitions
Here, we provide formal definitions for each baseline compared in Table 1.

                                                            12
                                                     Kernel Divergence Score

Definition 1. (Zlib Score) is the negated ratio of the log perplexity and the zlib compression size:
                                                n      1
                                                          P
                                            1 X − |Ti | xj ∈Ti log Pθ (xj |x<j )
                                          −                                         ,                                           (7)
                                            n i=1           Zlib(xi ).size

where Ti is the set of tokens from sample i. (Carlini et al., 2021)
Definition 2. (Perplexity Score) is the negated average perplexity across samples:
                                              n                              
                                           1X           1 X
                                         −       exp −       log Pθ (xj |x<j ) ,                                                (8)
                                           n i=1       |Ti |
                                                                 xj ∈Ti

where Ti is the set of tokens from sample i. (Li, 2023)
Definition 3. (Min-K% Score) is the negated mean probability from bottom-k% tokens averaged across samples:
                                                            n
                                                     1     X   X
                                             −                   log Pθ (xj |x<j ),                                             (9)
                                                 n · |Ki | i=1
                                                             xj ∈Ki


where Ki is the set of bottom-k% tokens from sample i. (Shi et al., 2023)
Definition 4. (Min-K%++ Score) is the negated mean normalized probability from bottom-k% tokens averaged across
samples:
                                                n  X log Pθ (xj |x<j ) − µx<j
                                         1     X
                                   −                                          ,                            (10)
                                     n · |Ki | i=1             σx<j
                                                        xj ∈Ki

where Ki is the set of bottom-k% tokens from sample i, µx<j = Ez∼p(·|x<j ) [log p(z|x<j )] is the expected log probability
                                              q
over the vocabulary of the model, and σx<j = Ez∼p(·|x<j ) [(log p(z|x<j ) − µx<j )2 ] is the standard deviation. (Zhang
et al., 2024b)
Following the general guideline from Shi et al. (2023), we take the bottom 20% tokens for the Min-K% Score and Min-K%++
Score.
Definition 5. (Fine-tuned Score Deviation) is the difference of scores before and after supervised fine-tuning, averaged
across samples:
                                                 n
                                              1X
                                                    S(xi ; θ) − S(xi ; θ′ ),                                         (11)
                                              n i=1

where xi is the i-th sample in the dataset, S(·; ·) is an existing scoring function (e.g., Min-K% or Perplexity Score), and
θ, θ′ are models before and after fine-tuning, respectively. (Zhang et al., 2025)
Definition 6. (Sharded Rank Comparison Test) is the difference between the log likelihood of the canonical dataset sample
ordering from the mean over shuffled sample orderings, averaged across dataset shards:
                                     r                                                 
                                   1X             (k)          1 X          (k)
                                         log P ([xi ]ni=1 ) −      log P ([xσ(i) ]ni=1 ) ,                                    (12)
                                   r                          |S|
                                     k=1                              σ∈S

                                                                               (k)
where r is the number of shards, S is the set of sample permutations, and [xi ]ni=1 is the sequence of samples x1 , x2 , . . . , xn
in k-th shard of the dataset. (Oren et al., 2024)

B. Kernel Decomposition Plots Across Contamination Rates
In this section, we extend Figure 2 by providing visualization of kernel components at contamination λ = {0.2, 0.4, 0.6, 0.8}.
In all cases, the pattern shown in kernels is consistent with our explanation in Section 3.



                                                                 13
                    Kernel Divergence Score




Figure 5. Decomposition of the Kernel Divergence Score - full list.




                                14
                                                   Kernel Divergence Score

C. Consistency Requirement Compliance in Detail
To assess the adherence of each baseline to the Consistency requirement, we calculate the Mean Absolute Percentage
Error (MAPE) over five independent runs.
                                                           5
                                                        1 X St − S̄
                                              MAPE =                 ,
                                                        5 t=1    S̄

where St represents the score from the t-th run, and S̄ denotes the mean score across all five runs. This metric is then
averaged across all contamination rates. The results, presented in Table 10, indicate that our Kernel Divergence Score
achieves the lowest MAPE among non-FSD-based methods, highlighting its superior consistency. FSD-based scores
generally have lower average MAPE, but they often fail to meet monotonicity requirements (Table 1).

Table 10. Consistency Requirement in terms of average MAPE. The average Mean Absolute Percentage Error (MAPE) over 5
independent runs is calculated. Among non-FSD baselines, our Kernel Divergence Score achieves the lowest average MAPE.

                          Methods                    WikiMIA BookMIA ArxivTection Average
                          Non-FSD-based Scores
                          Zlib                         0.1300        0.1144      0.5199      0.2548
                          Perplexity Score             0.1786        0.1974      0.1892      0.1884
                          Min-K%                       0.1966        0.2519      0.1882      0.2122
                          Min-K%++                     0.3281        0.1115      0.3268      0.2554
                          FSD-based Scores
                          Zlib + FSD                   0.1421        0.1460      0.2191      0.1691
                          Perplexity Score + FSD       0.1587        0.1653      0.2490      0.1910
                          Min-K% + FSD                 0.2936        OOM         0.2616      0.2776
                          Min-K%++ + FSD               0.2914        OOM         0.2652      0.2783
                          Kernel Divergence Score      0.1427        0.1500      0.2527      0.1818



D. Role of the Normalization Factor
Recall that in our Kernel Divergence Score, we define the normalizer E as the square root of the sum of entries in the kernel
matrix. We employ this square-root normalizer because, despite the second-order nature of Eq. (4), the sum of kernel entries
reveals a linear relationship with varying data subset sizes, as shown in Figure 6. A linear fit to the data yields an R2 value
of 0.9766, confirming the linearity of this relationship. Therefore, to mitigate the influence of dataset size and prevent
over-penalizing the score scale, we utilize the square-root normalizer.




      Figure 6. Sum of kernel entries by data subset size. The data subsets are randomly sampled from the WikiMIA dataset.


                                                                15
                                                                          Kernel Divergence Score

E. Histogram of Change in Embedding Distances
In Figure 7, we present histograms of the change in embedding distances before and after fine-tuning. We compare three
pair types: seen-seen, seen-unseen, and unseen-unseen. The figure reveals that unseen-unseen pairs exhibit more significant
shifts, with distances increasing more after fine-tuning overall. This suggests that representations of unseen samples tend to
spread farther apart, highlighting and confirmaing our intuition on the distributional shift induced by the fine-tuning process.




                                             Seen-Seen                                   Seen-Unseen                                   Unseen-Unseen
              80000
              70000
              60000
              50000
      Count




              40000
              30000
              20000
              10000
                 0
                                 0                    0         0     x           0                   0         0     x           0                   0         0     x
                      x < -0.1                x < 0.0.00 x < 0.1 0.10     x < -0.1            x < 0.0.00 x < 0.1 0.10     x < -0.1            x < 0.0.00 x < 0.1 0.10
                                     -0.10         0                                  -0.10        0                                  -0.10        0



                                                    Figure 7. Histogram on the values of embedding distance change.



F. Extended Literature Review
Here, we provide a more descriptive review of previous works on membership inference attack (MIA) (Shokri et al., 2017;
Truex et al., 2019), as it is related to the objective of our work in quantifying leakage (i.e., contamination) in datasets (Magar
& Schwartz, 2022; Xu et al., 2024; Balloccu et al., 2024).

Early MIA approaches. Membership inference attacks aim to determine whether a specific data sample was part of
a model’s training dataset. Early approaches primarily utilized metrics derived from model outputs to achieve this. For
instance, Salem et al. (2019) employed output entropy as a distinguishing factor, observing that models often exhibit lower
entropy (i.e., higher confidence) for training samples compared to non-training ones. Similarly, Liu et al. (2019) focused on
the model’s confidence scores, noting that higher confidence levels could indicate a sample’s presence in the training set, and
Carlini et al. (2022) proposed a likelihood ratio-based approach. Beyond output-based metrics, researchers have explored
the impact of training dynamics on MIAs. Yeom et al. (2018) investigated the use of loss values, finding that models tend
to produce lower loss for training samples, making loss a viable metric for membership inference. Additionally, Liu et al.
(2023) introduced a gradient-based approach, leveraging the observation that the gradients of training samples differ from
those of non-training samples, thereby serving as an effective indicator for membership inference.

Challenges of MIA on Large Language Models. While MIAs have been effective against traditional machine learning
models, applying them to large language models (LLMs) presents unique challenges. Recent studies have highlighted the
difficulty of performing MIAs on LLMs. For instance, Duan et al. (2024) found that MIAs often barely outperform random
guessing when applied to LLMs. This limited success is primarily due to the vast scale of LLM training datasets and the
relatively brief exposure of each sample during training–typically only one epoch–resulting in minimal memorization of
individual data points. Additionally, the inherent overlap of n-grams between seen and unseen text samples complicates
the distinction between seen and unseen data. This overlap creates a fuzzy boundary, making it challenging for MIAs
to accurately infer membership. Furthermore, Meeus et al. (2024) identified that distribution shifts between collected
member and non-member datasets can lead to misleading MIA performance evaluations. They demonstrated that significant
distribution shifts might cause high MIA performance, not due to actual memorization by the model, but because of these
shifts. When controlling for such shifts, MIA performance often drops to near-random levels.

                                                                                              16
                                                    Kernel Divergence Score

MIA on Large Language Models. Despite challenges, numerous studies have endeavored to apply membership inference
attacks (MIA) for large language models (LLMs). Building on classical appraoches (Yeom et al., 2018; Carlini et al.,
2022), researchers have introduced a range of innovative approaches tailored to LLMs. Perplexity-based methods have
been utilized, as demonstrated by Li (2023) and Carlini et al. (2021), who leveraged perplexity as a key metric to infer
membership. Similarly, likelihood-based strategies have been explored, with Shi et al. (2023) and Zhang et al. (2024b)
employing likelihood scores to distinguish between seen and unseen samples effectively. Other studies have extended
traditional metric-based approaches to the LLM domain (Duan et al., 2024; Xie et al., 2024; Zhang et al., 2024b; Mattern
et al., 2023; Ye et al., 2024), while Zhang et al. (2025) further expanded the scope by investigating the influence of fine-tuning
on various membership-related scores. In addition to individual sample-level techniques, set-level detection methods have
been introduced to identify contamination across broader datasets. For example, Oren et al. (2024), Zhang et al. (2024a), and
Golchin & Surdeanu (2024) enabled a more holistic assessment of dataset contamination. Building on these foundations,
our work introduced the Kernel Divergence Score, a novel method for evaluating contamination levels. This approach
capitalizes on the differential effect of fine-tuning on embedding kernel similarity matrices, offering a unique perspective on
contamination detection and addressing key limitations of existing methods.




                                                               17
