Large language models may verbatim complete text not explicitly trained onLanguage Models May Verbatim Complete Text They Were Not Explicitly Trained On
After deleting n-gram members and retraining, 1.6B still completes 0.4007 of the deleted sequences verbatim.
- Privacy, copyright, and security often rely on completion tests to determine whether text was in training, yet ground truth often uses n-gram overlap. The authors ask: when the training data does not contain the target n-gram, can the model still complete it verbatim.
- Pretrain GPT-2 architecture models on FineWeb-Edu, delete windows sharing n-grams with completed sequences, then retrain from scratch. Then use chunking, token dropout, and case flipping to construct a fine-tuning set with no n-gram overlap with unseen targets.
- For 1.6B, k=50, the residual proportion under exact filtering is 0.4007, and 0.0109 at n=5 (Table 10). Adversarial fine-tuning pushes edit similarity above 90% under multiple configurations; small-block chunking mostly cannot complete the target.
- The authors say they failed to forge outputs under natural data, and leave forging and more transformations for future work, while noting that retraining-based forgetting does not necessarily prevent generation. Fine-tuning repetition counts and judge consistency are not reported in the paper.
- Evaluated models
- GPT-2 architecture models trained from scratch (350M, 774M, 1.6B, 2.8B; Mbase/Mfilter)Gemma-2Qwen-2.5
- Benchmarks
- FineWeb-EduLylesKarpathyWillowTaylor SwiftAppleHarry Potter Paraphrase
- Metrics
- lingering fractionexact completionedit similaritynormalized Levenshtein distance
Researchers found that large language models may verbatim complete text that was not explicitly trained on, and common n-gram-based membership inference can be bypassed. The paper removes all completed training samples and retrains the model from scratch, finding that exact duplicates, near-duplicates, and even short overlapping fragments can exhibit this phenomenon, indicating that it is difficult to select a single usable n value to define membership. The authors accordingly design an adversarial dataset where, for any reasonably chosen n, the target sequence can be completed without appearing in the training data. The authors argue this highlights the inadequacy of n-gram membership inference, as the membership definition does not account for auxiliary information available to the training algorithm.
Paper analysis
What problem does this paper attempt to solve?
The n-gram membership definition can be bypassed: models can complete verbatim text that does not contain its n-grams.
Is n-gram overlap sufficient as ground truth for training membership, and will completion tests still succeed when the n-gram is absent.
- Use case: The authors argue that privacy, copyright, and security all require determining whether a piece of text was used in training, so membership determination needs to be robust. Questions raised in the introduction include whether information from training text is leaked, whether training occurred on copyrighted text, and whether text later labeled harmful was truly forgotten.
- Existing definition: The authors say the most common ground truth is n-gram overlap: equality of all n-grams for all n means verbatim identical, and majority equality at some n means approximately identical (Lee et al., 2021). Examples include GPT-4's 50-character substring overlap and Llama-3's 8-gram token overlap.
- Authors' question: Long sequences have high entropy due to length and are unlikely to be generated by chance; if a model still generates them verbatim, people intuitively think they are in the training set. The authors ask: can a model still generate a sequence when the training data never contained some n-gram of that sequence.
- Answer in this paper: The authors report the answer is yes. n-gram membership is just a threshold that varies with n, and this threshold can be gamed. They use deletion followed by retraining from scratch to find residual completions, and use adversarial datasets to force models to complete n-gram non-members.
- Test object: Completion tests use a prefix prompt and check whether the suffix is generated. The authors say this paper only studies such tests and treats them as black-box membership tests; extraction additionally requires proving that the completion is a training set member.
What related research exists?
Related work focuses on n-gram membership definitions, membership inference, and completion and extraction.
n-gram membership definitions and deduplication
- Technical reports and contamination detection: Anil et al. (2023), Gemini Team et al. (2023; 2024), Gemma Team et al. (2024a;b), Touvron et al. (2023), Dubey et al. (2024), etc., define membership using n-gram or substring overlap. GPT-4 considers 50-character substring overlap (Achiam et al., 2023), Llama-3 considers 8-gram token overlap (Dubey et al., 2024). Contamination work also often uses n-grams (Sainz et al., 2023; Jiang et al., 2024; Dekoninck et al., 2024; Singh et al., 2024).
- Deduplication: Lee et al. (2021) use suffix arrays for exact substring matching; Broder (1997) and Mou (2023) use MinHash or locality-sensitive hashing for approximate matching. The authors say the popularity of n-gram definitions reflects a practical balance between precision and simplicity, and use this as the limitation this paper points out.
Membership inference
- Sample-level MIA: Shokri et al. (2017) introduced membership inference; subsequent work includes vision-oriented attacks and sample-level MIA for LLMs (Zarifzadeh et al., 2023; Shi et al., 2023; Mattern et al., 2023; Li et al., 2023).
- Critiques cited in the paper: Duan et al. (2024) argue that membership in natural language can itself be ambiguous; Das et al. (2024) report distribution shift in existing MIA testbeds; Kong et al. (2023) attack MIA using gradient space. Meeus et al. (2024) and Zhang et al. (2024b) discuss the difficulty of post-hoc membership inference and that MIA cannot prove a model was trained on your data.
- Dataset-level tests: Maini et al. (2021; 2024) and Kandpal et al. (2023) strengthen membership signals using multiple related samples; Golchin & Surdeanu (2023), Oren et al. (2023) do contamination testing. The authors say this paper focuses on sequence-level, completion-based tests because they care about model-generated text.
Completion, memorization, and related methods
- Extraction and memorization: Carlini et al. (2019; 2021; 2022b) and Nasr et al. (2023) study training data completion and extraction; Ippolito et al. (2022) give an approximate memorization definition. Without training set access, completions are usually checked against auxiliary databases as a proxy confirmation of membership.
- Mitigation and poisoning: Hans et al. (2024)'s goldfish loss omits loss on roughly every nth token during training to mitigate verbatim memorization. Concurrent work Panaitescu-Liess et al. (2024) uses similar chunking, treating copyrighted material as poisoning data.
- Unlearning and forging: Bourtoule et al. (2021), Cooper et al. (2024) treat retraining from scratch after removing forgotten data as the gold baseline for machine unlearning. Thudi et al. (2022) study forging the same step's gradient using another minibatch.
Baselines and data
- Comparisons: The paper does not introduce external attack methods as baselines. Comparisons are filtering at different n, and three generalization proxies: off-the-shelf GPT-2-XL, counterfactual model Mcf trained on pretraining shards disjoint from Dbase, and few-shot judgments from Gemini 1.5 Pro.
- Data: Pretraining uses FineWeb-Edu.
The authors frame this paper around the failure mode of "membership definition and membership test mismatch," and say the limitation comes from definitions not accounting for auxiliary information accessible to the training algorithm, not just which distance is chosen when comparing two sequences.
How does the paper address this problem?
First delete windows by n-gram and retrain, then use non-overlapping transformations for fine-tuning to force completion.
Overall there are two counterfactuals: retraining from scratch after removing n-gram members, and fine-tuning with only n-gram non-members added. The authors call the latter an adversarial construction against the n-gram definition.
How membership and completion are defined
- n-gram member: the set of n-grams of a token sequence x is denoted n-grams(x). Definition 3.1 specifies that x is a member if there exists g ∈ n−grams(x) and g appears in the n-grams of any training sequence, and otherwise it is an n-gram non-member. The authors say this is stricter than "matching many n-grams", so it overestimates members and underestimates non-members. n=|x| is the verbatim membership of Carlini et al. (2022b).
- Completion: write x as prefix p followed by suffix s. The experiments fix |p|=|s|=|x|/2. Exact completion (Definition 3.2) is M(p)=s under greedy decoding. r-similar (Definition 3.3) requires lev(M(p), s)/max(|M(p)|, |s|) ≤ 1−r. Case-insensitive completion (Definition 3.4) is equality after lowercasing character by character.
- Difference from extraction: the authors say extractable means both completable and provably a training set member. Figure 2 draws extraction as the intersection of membership and completion. This paper studies non-member completion.
Retraining from scratch after removing members
- Four-step procedure: first pretrain Mbase from scratch on Dbase; then take the first k tokens of each training document, collect length-k sequences that can be exactly completed, obtaining Dmem; then scan Dbase with a sliding window of length |x|, deleting any window that shares any n-gram with x; finally train Mfilter from scratch on the filtered data. Deleted sequences that can still be exactly completed are called lingering sequences, denoted Dlinger.
- Filter strength: n=|x| deletes only windows identical to x verbatim; the smaller n is, the more partial matches also trigger deletion, so filtering is stronger. Appendix Definition A.1 writes this as n-gram filtering over a filter set F.
- Training setup: the model is the GPT-2 architecture, trained with LLM.c. Data is 33.6B tokens randomly drawn from FineWeb-Edu. The default is k=50, i.e. 25 each for prefix and suffix; Appendix also does k=100. 1.6B roughly corresponds to Chinchilla optimal, and the authors cite Hoffmann et al. (2022) for about 20 tokens/parameter. Training is 32000 steps, total batch 1,048,576 tokens, maximum learning rate 6e-4, cosine decay, warmup 700 steps. Unless stated otherwise, main results report 1.6B.
Forcing completion with non-members
- Construction principle: apply a noisy transformation f to an unseen target x so that x̃=f(x) still retains information about x but has no n-gram overlap with x. The authors hypothesize that after training on x̃ with different randomness, the model should be able to recover x, similar to a denoising autoencoder.
- Three transformations: chunking cuts x into overlapping token segments and fills the remaining positions with random tokens from the vocabulary, with parameters chunk size c and overlap l. Token dropout replaces tokens at interval d, with d≤n, thereby avoiding n-gram overlap; the deterministic version guarantees x is not a d-gram member, and the randomized version guarantees it with high probability. Case flipping flips English letters with probability p, then re-tokenizes; p=0.5 has maximum variance. Appendix B.4 gives Algorithms 1 to 4.
- Combination and training: tokens not dropped can also undergo case flipping. The authors say these transformations resemble excerpting, dropping words, dropping punctuation and dropping case, and the goal is not to find the most covert transformation but to see feasibility. Fine-tuned models are Gemma-2 and Qwen-2.5, scale 0.5B to 9B; next-token prediction, batch 32, constant learning rate 10^{-5}. N=2,000 entries are constructed per target, and most settings have fewer than 1,000.
- Target texts: the three main-experiment passages are each about 1,000 characters, about 250 tokens under the Gemma-2 tokenizer: Lyles, Karpathy, Willow. The authors say they have relatively recent time cutoffs, so they would not enter the Gemma-2 training set, and are extremely unlikely to appear in the Qwen-2.5 training set. Appendix also has Taylor Swift, Apple, and a Harry Potter passage rewritten by GPT-4o. The introduction says the experiments force the model to complete six target passages.
Relation to goldfish loss
- Data-only change: the authors say token dropout is related to Hans et al. (2024) but is entirely on the data side and does not change the loss. Subsequent tokens still attend to the replaced random tokens, which the authors think makes the learning task harder. Because of BPE, even with d>2 and most tokens retained, the original text becomes hard for humans to recognize.
What experiments did the paper conduct?
1.6B exact filtering residual ratio 0.4007; at n=5 it is 0.0109.
Experimental setup
- Pretrained models: GPT-2 architecture. Main text writes {350M, 774M, 1.6B, 2.8B}, Figure 3 x-axis includes 350M; Table 1 and Table 8 write 304M, 774M, 1.6B, 2.8B. Whether these are the same configuration is not stated in the paper. Main report is 1.6B.
- Data and Dmem: FineWeb-Edu, Dbase is 33.6B random tokens. Dmem comes from the first k tokens of each training document. |Dmem| in Table 1 is 76,648, 116,270, 151,598, 175,813, corresponding to 304M through 2.8B in the table.
- Filtering: k=50 with n=5, 10, 20, 50; k=100 with n=10, 20, 50, 100. n=|x| is exact filtering.
- Fine-tuned models and texts: Figures include Gemma-2 2B, Gemma-2 9B, Qwen-2.5 0.5B, 1.5B, 7B. Targets are Lyles, Karpathy, Willow; appendix additionally has Taylor Swift, Apple, and a Harry Potter rewrite.
- Metrics and evaluation: Exact completion uses greedy decoding. Residual proportion is |Dlinger|/|Dmem|. §5.5 treats edit similarity >90% as successful completion. Generalization proxies use off-the-shelf GPT-2-XL, Mcf on disjoint shards, and Gemini 1.5 Pro few-shot judgments on whether it is pattern continuation; prompts are in Appendix A.10.
- Repetitions: 1.6B is pretrained from scratch 5 times each for n=10, 20, 50. The paper does not report the number of fine-tuning repetitions.
Main results
Per Table 10, k=50, cells are |Dlinger|/|Dmem|.
Swipe horizontally to read the table
Model n=5 n=10 n=20 n=50 (exact) 304M 0.0175 0.0402 0.0978 0.4793 774M 0.0132 0.0300 0.0916 0.4013 1.6B 0.0109 0.0259 0.0796 0.4007 2.8B 0.0099 0.0247 0.0869 0.4068 - Authors' summary: Merely deleting sequences from pretraining data does not always prevent LLMs from regenerating them, and this occurs at all scales. Figure 1 summarizes exact filtering and stronger approximate filtering as about 40% and about 1%.
- Stronger filtering: Smaller n gives lower residual proportions, but residuals remain at n=5. The authors say they found no creative generalization: residuals are either still members under another membership definition, or lack complexity, e.g., patterns or counts.
- Main text vs. table: The abstract says 40% can still be completed verbatim under experimental conditions. This is close to 0.4007 for 1.6B, n=50 in Table 10; 304M's exact filtering proportion is higher at 0.4793.
Nearest neighbors and proxy metrics for lingering sequences
- Nearest-neighbor search: For randomly sampled lingering sequences, find Levenshtein distance <20 token 的邻居。作者称所查询的序列都能找到近重复,而这些副本以某种方式避开了 n-gram 检测。因代价,只对随机子集做了搜索;论文未报告查询条数。Figure 8 给出若干例子。
- 代理指标:Fig 5 为 1.6B。横轴是 Lingering Fraction (%),纵轴是 Generalization Proxy Metric (%),图例为 GPT-2-XL、反事实重训和 Gemini 1.5 Pro。作者称三个代理都支持人工检查:更强过滤使残留转向可泛化模式。纯文本转换未保留各点数值,此处不转写。
- 近似残留:Table 14 把编辑距离放宽。1.6B、k=50、距离阈值 10 时,n=5 的比例为 0.0217,n=50 为 0.6105。作者称强过滤下这类近似残留相对少,弱过滤下比例增加更多。
对抗微调迫使补全
- 能否成功:Figure 6 分四块:Lyles 上的分块、Karpathy 上的 token dropout、Willow 上的大小写翻转,以及 Willow 上的 dropout 加翻转。作者报告多种配置的编辑相似度 >90%, while Dft has no n-gram overlap with the target.
- Method differences: With chunking at c=25, models mostly cannot complete; only some models succeed at c=100. The effect of overlap l, the authors say, is empirically small (Appendix B.5.1). With token dropout at interval 2, i.e., 50% token dropout, Qwen-2.5 0.5B can also complete verbatim. Case flipping is largely effective. After combination, smaller models succeed less often but can still complete verbatim.
- Scale and steps: The authors say that under the same configuration, larger models complete more easily. The example in Fig 7 is Qwen-2.5 7B, Willow, gap=4, flip=0.9; the authors say success may require only a few gradient steps; the main text gives no unified number of steps for success. Appendix B.6 also reports induced completion for three other texts, where chunking on Apple remains weak.
Other ablations and analyses
- Five retrainings (Table 16, 1.6B, k=50): n=50 residual proportion mean 0.4108±0.0145, n=10 is 0.0269±0.0005, n=20 is 0.0793±0.0028; n=5 only once, proportion 0.0109.
- Five-way intersection (Table 17): n=50 is 34,185 (0.2255 of |Dmem|), n=10 is 2,666 (0.0176). The authors say the sets overlap little across runs, but the intersection tends toward a core set as the number of runs increases.
- Retained tokens (Table 2, k=50): n=5 is 0.6905, n=10 is 0.9838, n=20 is 0.9938, n=50 is 0.9995.
- k=100, 1.6B: Table 11 writes n=100 residual proportion 0.4007; Table 15 at edit distance 0, n=100 writes 0.4335. The two tables are inconsistent.
- Appendix B.5.4: With case flipping alone, Gemma-2 tends to be higher than Qwen-2.5; after combining with dropout, the authors say Qwen-2.5 is overall better, with no specific explanation.
- Negative results: n=5 still cannot eliminate all residuals; the authors say there is no evidence of creative generalization up to 2.8B; small-block chunking mostly fails; Section 6 says no forges of model outputs were obtained using natural data.
What are some points that can be further explored?
The authors leave forging and more transformations for future work, and remind that retraining-based forgetting does not necessarily prevent generation.
Limitations and future directions noted by the authors
- Forging: Section 6 states that readers familiar with forging (Thudi et al., 2022) will see connections to this paper. The authors say experiments did not obtain forges of model outputs using "natural" data, and consider this a valuable future direction for characterizing when completion can serve as membership evidence.
- New similarities: Section 6 states that membership definitions and tests should incorporate new similarity measures. The authors also write that membership inference should consider membership concepts beyond single sequences, and data units could be sets of sequences grouped by similarity.
- Unlearning is insufficient to suppress outputs: Section 6 states that the widely accepted gold baseline for machine unlearning is retraining from scratch after removing target data; this paper does exactly that counterfactual, yet excluded sequences can still be generated verbatim. The authors caution that unlearning alone may not always prevent generation of sequences of interest, i.e., output suppression.
- More transformations: Appendix B.2 states that changing punctuation, synonym substitution, visually similar Unicode, etc., can also break contiguous n-grams in token space. The authors leave a fuller exploration to future work.
- Model family differences: Appendix B.5.4 states that after combined perturbations, the relative performance of the two model families changes. The authors say they have no specific explanation and leave it to future work.
Experimental coverage
- Pretrained models are GPT-2 architecture at four scales, data is 33.6B tokens of FineWeb-Edu; main experiments use k=50, appendix has k=100. Filtering values are in Table 10 and appendix Table 11.
- 1.6B is pretrained 5 times each for n=10, 20, 50; Appendix A.9 states n=5 was not repeated due to compute.
- Models in fine-tuning figures are Gemma-2 2B, 9B and Qwen-2.5 0.5B, 1.5B, 7B. Target texts total 6 segments, each with up to 2,000 constructed examples, batch 32, learning rate 10^{-5}.
- Completion uses greedy decoding, with the main setting of half prefix and half suffix. Proxies include off-the-shelf GPT-2-XL, Mcf on disjoint shards, and Gemini 1.5 Pro. Nearest-neighbor search is only on randomly sampled lingering sequences, with threshold edit distance <20.
- The paper does not report the number of fine-tuning repetitions, nor agreement numbers between Gemini 1.5 Pro judgments and human checks.
Summarize the main content of the paper
n-gram non-members can still be completed verbatim; the residual proportion after exact filtering at 1.6B is 0.4007.
The authors study whether a model completing a text verbatim means it can be deemed a training set member by n-gram overlap. The conclusion points to no. Completion tests use a prefix to check the suffix, and the authors treat this as a black-box membership test; n-gram membership counts as membership if just one n-gram is shared.
- Delete then retrain: Train GPT-2 architecture models from scratch on 33.6B tokens of FineWeb-Edu, collect sequences that can be completed exactly, delete windows by n-gram, then train from scratch again. For 1.6B, k=50, the residual ratio for exact filtering at n=50 is 0.4007, and at n=5 it is 0.0109 (Table 10). For 304M the exact filtering ratio is 0.4793.
- Where residuals come from: The authors say they found no creative generalization. Sampled residual sequences can find near-duplicates in the original data with edit distance <20, but these copies avoid the n-gram detection used. Stronger filtering makes residuals more like counts, lists, and other continuable patterns.
- Adversarial fine-tuning: For six unseen targets, construct fine-tuning sets with no n-gram overlap using chunking, token dropout, and case flipping. The authors report edit similarity above 90% across multiple configurations. With dropout interval 2, Qwen-2.5 0.5B can also complete verbatim; chunking with block size 25 mostly fails. The authors say larger models succeed more easily under the same configuration.
- Authors' explanation: The authors think the reason is not a poorly chosen comparison distance, but that the membership definition does not account for auxiliary information accessible to the training algorithm. Constructing the (n−1)-gram itself presupposes knowing the entire segment x.
- Implications given by the authors: Developers should report train-test metrics beyond n-gram overlap. The forgetting baseline of removing data and retraining does not necessarily prevent the model from regenerating target sequences. The authors also say attempts to forge model outputs with natural data were unsuccessful.