Skip to content

Black-Box Membership Inference via Word-Level Probability Estimation

Conference: EMNLP 2026
Paper: ACL Anthology
Code: https://github.com/niusj03/WPMIA
Area: LLM Safety
Keywords: Black-Box Membership Inference / Word-Level Probability Estimation / Local Kernel Smoothing / Contrastive Prefixes / Pretraining Data Detection

TL;DR

Addressing the fundamental challenge of auditing proprietary LLMs that expose only generated textual continuations without token-level logits, WPMIA estimates word-level generation probabilities via Monte Carlo sampling with local semantic kernel smoothing, aggregates them additively into sequence-level log-likelihoods, and contrasts member and non-member prefix interventions, achieving an average TPR@5%FPR of 42.0% across GPT-5-Chat, Gemini-2.5-Flash, and Claude-4.5-Haiku.

Background & Motivation

As the pretraining corpora of modern large language models continue to expand across trillions of tokens, web-crawled training sets inevitably ingest proprietary, copyrighted materials and sensitive personally identifiable information despite automated filtering. Auditing whether specific sensitive texts were memorized during training has become a crucial challenge for data copyright compliance, intellectual property protection, and AI safety. To conduct empirical privacy audits, pretraining data detectionโ€”primarily formulated as membership inference attacks (MIAs)โ€”aims to infer whether a candidate text was included in the target model's training distribution. Existing state-of-the-art MIA techniques (e.g., Min-K%, Min-K%++, and ReCaLL) rely on a gray-box threat model: they assume direct adversary access to the model's proprietary tokenizer and output token-level logits, allowing exact computation of sequence log-likelihoods or token-level probability perturbations along the autoregressive chain rule.

In practical enterprise deployment, however, leading proprietary commercial models (such as ChatGPT, Gemini, and Claude) are predominantly exposed via black-box subscription interfaces or cloud APIs. These APIs return only generated textual continuations, entirely concealing underlying vocabulary definitions, tokenization schemes, and per-token logit vectors. Consequently, gray-box MIA techniques are inapplicable. Recent heuristic black-box attempts attempt to circumvent this barrier using text-level surrogates. For example, SaMIA measures the ROUGE-N surface overlap between model continuations and reference suffixes; yet as autoregressive generation proceeds, continuations diverge and suffer from severe error accumulation and distribution shift. SimMIA samples next-word occurrences to compute word-level empirical frequencies or cosine similarities, but it averages raw word-level ratio scores directly across positions. Such word-level division is vulnerable to zero denominators and discards the additive mathematical structure of log-likelihoods, leading to unstable membership signals and suboptimal discrimination.

The central tension of black-box privacy auditing lies in reconstructing statistically sound, sequence-level likelihood estimators from discrete, sparse, and noisy textual outputs without access to internal model logits, while simultaneously mitigating baseline likelihood confounding caused by common language patterns. This paper addresses this challenge by shifting from heuristic surface scoring back to the fundamental definition of autoregressive likelihood: leveraging standard external tokenizers, smoothing discrete generation counts via continuous semantic embeddings, and performing contrastive prefix intervention strictly at the sequence level. Core idea: estimate word-level generation probabilities via Monte Carlo next-word sampling with local semantic kernel smoothing, aggregate them additively into sequence-level log-likelihoods to preserve autoregressive chain-rule structure, and amplify membership divergence via dual-path member and non-member contrastive prefixes.

Method

Overall Architecture

WPMIA is designed to perform membership inference against black-box autoregressive language models \(f_\theta\) accessible solely through prompt-and-continuation interfaces. Given a target text \(x\), an external standard word tokenizer, and reference prefix pools, WPMIA executes through four interconnected stages: 1. Word-Level Tokenization and Prefix Context Construction: The target text is split into a sequence of words \(x = (x_1, \dots, x_L)\) using an off-the-shelf word tokenizer. Three query contexts are constructed for each word position \(i\): unprefixed context \(c_i^0 = x_{<i}\), non-member-prefixed context \(c_i^{nm} = P_{nm} \oplus x_{<i}\), and member-prefixed context \(c_i^m = P_m \oplus x_{<i}\); 2. Monte Carlo Sampling and Local Semantic Kernel Smoothing: For each context \(c_i^q\), the target LLM is queried \(M\) times to sample the first generated continuation words. A dense embedding model measures the cosine similarity between candidate generations and the target word \(x_i\), smoothing the probability mass through an exponential temperature-scaled kernel; 3. Additive Sequence-Level Likelihood Aggregation: The smoothed word-level log-probabilities are averaged across all positions \(i \in [1, L]\) to construct unbiased sequence-level log-likelihood estimators \(\hat{LL}_0(x)\), \(\hat{LL}_{nm}(x)\), and \(\hat{LL}_m(x)\); 4. Contrastive Prefix Difference and Normalized Decision: The likelihood shift between non-member and member prefixes is contrasted and normalized by the unprefixed baseline likelihood, producing a scalar membership score \(S(\theta, x)\) that is thresholded for the binary membership verdict.

%%{init: {'flowchart': {'rankSpacing': 24, 'nodeSpacing': 28, 'padding': 6, 'wrappingWidth': 400}}}%%
flowchart TD
    A["Target Text Sequence & Prefix Context Construction"] --> B["Local Semantic Kernel Probability Estimation<br/>M Monte Carlo first-word samples + cosine exponential smoothing"]
    B --> C["Additive Sequence-Level Likelihood Aggregation<br/>Log-space cumulative averaging preserving chain-rule structure"]
    C --> D["Contrastive Prefix Difference Amplification<br/>Dual-path prefix intervention + baseline normalization"]
    D --> E["Scalar Threshold Decision I[S(ฮธ, x) > ฮบ]"]

Key Designs

1. Local Semantic Kernel Probability Estimation: Discrete Sparsity -> Continuous Cosine Exponential Smoothing -> Robust Word-Level Probability Mass
Under strict black-box constraints, an adversary cannot inspect output multinomial distributions over vocabulary tokens and must approximate next-token generation from empirical sampling. With a modest query budget \(M\) (e.g., 10 to 100 queries) and extensive LLM vocabularies, exact string matching \(K_{em}(x_i, \hat{x}) = \mathbb{I}[x_i = \hat{x}]\) yields severe zero-probability sparsity: semantically identical words, morphological variants, or subtle punctuation divergences receive zero weight, destabilizing probability estimates. WPMIA resolves this by introducing a pretrained dense embedding function \(e(\cdot)\) (specifically all-MiniLM-L6-v2) to map words into a continuous representation space. The similarity between target word \(x_i\) and the first word \(\hat{x}_{i,j}^{c_i}\) of the \(j\)-th sampled continuation is mapped through a local exponential kernel with temperature parameter \(\tau\): $\(K_\tau(x_i, \hat{x}) = \exp\left( \frac{\cos(e(x_i), e(\hat{x})) - 1}{\tau} \right)\)$ The kernel assigns decaying weights to semantically related words as cosine distance increases, providing local smoothing that suppresses sampling variance. To maintain numerical stability on the log scale, a small constant \(\epsilon = 10^{-8}\) is added, yielding the robust word-level log-probability estimator \(\hat{b}_\ell(x_i|c_i) = \log\left(\epsilon + \frac{1}{M}\sum_{j=1}^M K_\tau(x_i, \hat{x}_{i,j}^{c_i})\right)\).

2. Additive Sequence-Level Likelihood Aggregation: Unstable Word-Level Ratios -> Sequence-Level Averaging -> Mathematical Preservation of Chain-Rule Likelihoods
Prior black-box methods like SimMIA compute relative prefix scores at each individual word position before averaging across the sequence: \(\frac{1}{L} \sum_{i=1}^L \frac{s(x_i | c_i^{nm})}{s(x_i | c_i^0)}\). This local ratio formulation suffers from severe numerical instability because empirical probabilities in the denominator often collapse toward zero, causing unbounded outliers. Moreover, normalizing per-word scores invalidates the additive decomposition of autoregressive log-likelihoods under the probability chain rule. WPMIA enforces a clear architectural separation between word-level probability estimation and sequence-level score formulation. Word-level estimates are maintained strictly as log-probabilities \(\hat{b}_\ell(x_i | c_i^q)\) and aggregated additively into sequence-level log-likelihoods: $\(\hat{LL}_q(x) = \frac{1}{L} \sum_{i=1}^L \hat{b}_\ell(x_i | c_i^q), \quad q \in \{0, nm, m\}\)$ By computing relative contrast only after sequence-wide aggregation, WPMIA completely eliminates zero-division singularities and yields an estimator whose mathematical behavior mirrors gray-box average log-likelihood.

3. Contrastive Prefix Difference Amplification: Confounded Base Likelihood -> Dual-Path Prefix Shift -> Maximal Member-Nonmember Distribution Separation
Evaluating texts solely using the unprefixed log-likelihood \(\hat{LL}_0(x)\) conflates intrinsic linguistic simplicity with true training-data memorization: common syntax, stock phrases, and generic knowledge naturally exhibit high likelihood regardless of membership. WPMIA exploits in-context prefix conditioning as a test-time intervention to expose training-set memorization. By prepending a concatenation of \(T\) non-member examples (\(P_{nm}\)) or member examples (\(P_m\)) to the context, WPMIA induces distinct likelihood shifts. Non-member prefixes inject out-of-distribution context that sharply degrades the conditional likelihood of member texts while exerting milder effects on non-member texts. Member prefixes conversely introduce asymmetric contextual reinforcement. WPMIA combines both shifts into a normalized contrastive membership score: $\(S(\theta, x) = \frac{\hat{LL}_{nm}(x) - \hat{LL}_m(x)}{\hat{LL}_0(x)}\)$ Normalizing the contrastive margin by the unprefixed baseline likelihood \(\hat{LL}_0(x)\) calibrates for sample-specific intrinsic complexity, driving maximal divergence between member and non-member score distributions.

Probability Estimation and Membership Decision Protocol

To implement black-box querying on proprietary commercial APIs without generating unnecessary continuation tokens, WPMIA employs an explicit system prompt: "Return ONLY the single next token from the text. It can be punctuation or one whole word. No spaces, no quotes, no extra text.", with user input formatted as "Text so far: [PREFIX]".

The end-to-end evaluation protocol operates as follows: 1. Tokenization: The input sequence is segmented using NLTK WordPunct tokenizer. In specialized symbolic domains (such as the DM Mathematics subset of MIMIR), exact string matching is automatically applied for numeric tokens to avoid semantic distortion from embedding geometry. 2. Three-Way Sampling: Across each position \(i \in [1, L]\) and condition \(q \in \{0, nm, m\}\), context \(c_i^q\) is submitted to \(f_\theta\) across \(M\) parallel Monte Carlo sampling queries. Default sampling size is \(M = 100\) and \(T = 7\) for open-source benchmarks (\(T = 10\) for MIMIR), and scaled to \(M = 10\) and \(T = 7\) for proprietary APIs to maintain practical economic feasibility. 3. Hyperparameter Configuration: Kernel smoothing utilizes all-MiniLM-L6-v2 embeddings with default temperature \(\tau = 0.2\) (\(\tau = 0.1\) for WikiMIA-25) and numerical offset \(\epsilon = 10^{-8}\). 4. Decision Boundary: Sweeping threshold \(\kappa\) over evaluation scores generates ROC curves, evaluating area under the curve (AUC) alongside true positive rate at 5% false positive rate (TPR@5%FPR) via \(\mathcal{A}(\theta, x) = \mathbb{I}[S(\theta, x) > \kappa]\).

Key Experimental Results

Main Results

WPMIA was evaluated across three established benchmarks: WikiMIA (lengths 32, 64, and 128 across four open-source models), MIMIR (seven distinct domains across Pythia-dedup scaling variants from 160M to 6.9B), and WikiMIA-25 (evaluating modern open-source models alongside leading commercial proprietary LLMs). Baselines include black-box methods (PETAL, SaMIA, SimMIA*, SimMIA) and gray-box reference baselines (Loss, Reference, Zlib, Min-K%, ReCaLL).

The following table summarizes performance on WikiMIA (averaged across lengths 32, 64, 128) and WikiMIA-25 across modern open-source and proprietary models:

Benchmark / Model Threat Model PETAL (AUC / TPR@5%) SaMIA (AUC / TPR@5%) SimMIA* (AUC / TPR@5%) SimMIA (AUC / TPR@5%) WPMIA (Ours) (AUC / TPR@5%)
WikiMIA Len 32 (Avg) Black-box 63.8 / 14.6 57.5 / 8.7 78.5 / 24.9 72.4 / 16.0 84.8 / 35.2
WikiMIA Len 64 (Avg) Black-box 62.1 / 13.4 64.1 / 10.4 79.7 / 26.6 72.9 / 14.7 84.5 / 40.8
WikiMIA Len 128 (Avg) Black-box 66.5 / 20.0 65.6 / 10.8 79.0 / 20.1 70.9 / 11.8 81.7 / 38.0
WikiMIA-25 (Pythia-6.9B) Black-box 72.2 / 30.1 57.8 / 8.8 88.1 / 37.2 88.8 / 47.8 89.0 / 56.6
WikiMIA-25 (Qwen3-8B-Base) Black-box 62.8 / 18.6 50.3 / 2.7 63.2 / 2.7 63.0 / 6.2 65.9 / 23.0
WikiMIA-25 (Claude-4.5-Haiku) Commercial Black-box - / - 62.6 / 8.0 65.7 / 6.2 60.5 / 6.2 66.3 / 22.1
WikiMIA-25 (Gemini-2.5-Flash) Commercial Black-box 67.1 / 23.9 57.0 / 15.0 75.7 / 30.2 74.1 / 28.5 78.2 / 36.5
WikiMIA-25 (GPT-5-Chat) Commercial Black-box 78.0 / 35.4 65.7 / 13.3 90.6 / 73.3 83.3 / 37.2 91.0 / 67.3

Note: SimMIA denotes exact matching frequency scoring (Eq. 12), while SimMIA uses cosine embedding similarity (Eq. 13). Proprietary models were evaluated under an efficient \(M=10\) sampling budget.*

On proprietary commercial LLMs, WPMIA achieves TPR@5%FPR of 22.1% on Claude-4.5-Haiku, 36.5% on Gemini-2.5-Flash, and 67.3% on GPT-5-Chat, averaging 42.0% across the three models and establishing an effective standard for strict black-box auditing.

Ablation Study

The authors conducted comprehensive component-wise ablations, prefix corruption analyses, and token-budget-matched comparisons on WikiMIA using Pythia-6.9B.

1. Sequence-Level Aggregation vs. Word-Level Normalization and Prefix Conditioning (AUC):

Configuration Aggregation Level Formulation Len 32 AUC Len 64 AUC Len 128 AUC
Unprefixed Baseline (No Prefix) Sequence-level additive \(S_0 = \hat{LL}_0(x)\) 58.8 55.4 62.0
+ Non-Member Prefix (+NP) Word-level normalization Eq. (10) form 52.0 46.9 54.7
+ Non-Member Prefix (+NP) Sequence-level additive \(S_{nm} = \hat{LL}_{nm}(x) / \hat{LL}_0(x)\) 75.5 77.2 76.2
+ Member Contrast Prefix (+MP) Word-level normalization Eq. (10) form 51.4 48.8 48.8
+ Member Contrast Prefix (+MP) Sequence-level additive \(S_{ctr} = (\hat{LL}_{nm}(x) - \hat{LL}_m(x)) / \hat{LL}_0(x)\) 84.8 86.5 84.7

2. Prefix Robustness, Distribution Shifts, and Budget-Matched Comparisons (Len 32):

Condition / Comparison Construction Details Mislabeled Ratio AUC TPR@5%FPR Notes
Clean Standard WikiMIA pools (\(T=7\)) 0 / 14 84.78 27.89 Gold-standard benchmark reference
Noisy-light 1 swapped prefix per pool 2 / 14 79.76 15.79 Mild drop (-5.0 AUC)
Noisy-heavy 3 swapped prefixes per pool 6 / 14 48.73 6.05 Collapses toward random guessing
Fully shuffled Random repartitioning of pools 8 / 14 48.14 5.08 Signal destroyed
GitHub OOD Domain-mismatched code prefixes N/A 56.54 8.11 Domain shift degrades contrast
Synthetic GPT-4o generated proxy prefixes N/A 75.27 14.84 Viable zero-prior auditing alternative
Low Budget (~6.3k Tokens) WPMIA (\(M=20\)) vs SimMIA (\(M=30\)) N/A 81.25 vs 69.99 28.68 vs 11.58 Outperforms baseline at identical token cost
High Budget (~21.1k Tokens) WPMIA (\(M=67\)) vs SimMIA (\(M=100\)) N/A 84.59 vs 71.24 27.11 vs 12.63 Demonstrates superior sample scaling

Key Findings

  • Sequence-level aggregation is essential to prevent mathematical collapse: Ablation results demonstrate that normalizing scores at the individual word level (+NP and +MP word) severely degrades performance below the unprefixed baseline (plunging from 55.4 to 46.9 and 48.8 at length 64). Dividing discrete probabilities introduces severe outlier noise; aggregating in log space prior to contrastive comparison preserves structural validity.
  • Contrastive prefix conditioning provides cumulative amplification: Progressing from unprefixed likelihood (AUC 55.4) to non-member conditioning (AUC 77.2) and full dual-prefix contrast (AUC 86.5) demonstrates the complementary utility of directional likelihood perturbations.
  • Superior efficiency under matched token budgets: Under identical generated token budgets (~21.1k tokens), WPMIA (\(M=67\)) attains 84.59 AUC, outperforming SimMIA (\(M=100\), 71.24 AUC) by 13.35 points, confirming that kernel smoothing extracts richer evidence from fewer generations.
  • Synthetic prefixes enable realistic unprivileged audits: Even without access to verified training splits, synthetic proxy prefixes generated via external models achieve 75.27 AUC, proving practical utility for external auditors lacking training data access.

Highlights & Insights

  • Principled statistical approximation replaces empirical heuristics: By reformulating black-box next-word continuations as empirical estimates of underlying autoregressive likelihoods, WPMIA bridges the gap between gray-box statistical MIAs and black-box threat models.
  • Continuous kernel smoothing mitigates discrete vocabulary sparsity: Applying an exponential kernel over dense sentence embeddings allows semantically related generations to contribute fractional probability mass to target tokens, maintaining stable estimates even under low sampling regimes (\(M=10\)).
  • Agnostic to model tokenization and internal architecture: WPMIA requires only standard whitespace/punctuation word tokenization, making it resilient to diverse BPE/WordPiece implementations across commercial providers.

Limitations & Future Work

  • Sampling query overhead and API costs: Evaluating a sequence of length \(L\) across three prefix conditions requires approximately \(Q \approx 3ML\) API requests. While \(M=10\) provides effective performance, auditing long documents on commercial APIs remains computationally and financially non-trivial (e.g., evaluating 240 samples on GPT-5-Chat required 241,492 requests and $266.80 USD). Future research should explore adaptive early-stopping and variance-reduction techniques to reduce query volume.
  • Monolingual evaluation: The current empirical study is confined to English benchmarks and embeddings. Extension to morphologically rich or non-segmented languages (such as Chinese or Arabic) may require language-specific tokenizers and calibrated multilingual embedding models.
  • vs. Gray-Box MIAs (Min-K% / Min-K%++ / ReCaLL): Gray-box methods require full access to output logits to identify low-probability outlier tokens or compute conditional logit differences. WPMIA demonstrates that the contrastive likelihood dynamics observed in ReCaLL can be faithfully recovered under strict black-box conditions via Monte Carlo smoothing.
  • vs. Black-Box Baselines (SaMIA / SimMIA / PETAL): SaMIA relies on multi-token continuation overlap (ROUGE), suffering from compounding autoregressive drift. SimMIA computes word-level ratio scores directly, breaking log-likelihood additivity and inducing division instabilities. WPMIA resolves both issues by isolating single-token sampling, applying continuous kernel smoothing, and aggregating additively prior to contrast.

Rating

  • Novelty: โญโญโญโญโญ First principled framework to reconstruct sequence-level log-likelihood estimators and contrastive prefix shifts under strict black-box API access.
  • Experimental Thoroughness: โญโญโญโญโญ Comprehensive evaluation across WikiMIA, MIMIR, and WikiMIA-25, spanning open-source architectures (Pythia, OPT, LLaMA, GPT-NeoX, Qwen3) and commercial frontier models (GPT-5-Chat, Gemini-2.5-Flash, Claude-4.5-Haiku) with budget-matched comparisons.
  • Writing Quality: โญโญโญโญโญ Mathematically clear formulation, well-structured ablation narrative, and precise empirical documentation.
  • Value: โญโญโญโญโญ Establishes a practical, highly capable foundation for regulatory privacy compliance and copyright verification against proprietary commercial LLMs.