Abstract
Large Language Models (LLMs) are prone to verbatim memorization of training data, posing significant legal and privacy risks. This paper identifies a phenomenon termed "positional fragility," where a model's ability to recall training sequences is heavily dependent on the data's position within the training context window. By investigating the "offset effect"—the distance between the start of a sequence and the start of the context window—we demonstrate that memorization is not uniform. We show that shifting sensitive content away from the start of a sequence during pretraining can effectively suppress verbatim recall and mitigate text degeneration without degrading general model performance.
Introduction
The tendency of LLMs to "regurgitate" training data has become a central concern for developers, particularly regarding copyrighted material and private information. While post-hoc defenses like fine-tuning or unlearning exist, they are often fragile and easily bypassed. This research investigates a more fundamental property of LLM training: how the spatial arrangement of data within the context window influences long-term memorization.
Previous evaluations of memorization risk often assumed that recall is uniform across a sequence. However, real-world prompts rarely align perfectly with the beginning of a training document. This study explores how "positional offset"—the shift between the start of a training sequence and the start of a prompt—affects retrieval, and how this fragility can be leveraged as a proactive defense mechanism.
Methodology
To analyze these effects, we pretrained a series of LLaMA-style models ranging from 1B to 8B parameters on 83 billion tokens. The experimental framework utilized two distinct data configurations:
- Dense Gutenberg: A setup where the model is trained exclusively on 10,000 book sequences to observe extreme memorization behaviors.
- Sparse Gutenberg: A realistic scenario where "sensitive" book data constitutes only 2% of the corpus, mixed with high-quality educational content (Fineweb-Edu).
We introduced FM-Probes (Frequency-Varied Memorization Probe Buckets) to systematically measure recall across three variables: prefix length (the amount of context provided), offset (the starting point of the prefix relative to the training sequence), and repetition frequency (ranging from 1 to 128 exposures).
The Offset Effect and Positional Fragility
Our findings reveal that LLMs rely disproportionately on the initial tokens of a training sequence as "retrieval anchors." When a prompt aligns exactly with the start of the context window (zero offset), verbatim recall is at its peak. However, even a minor shift in the starting position causes recall performance to plummet.
In our 1B parameter model, Rouge-L scores—a metric for verbatim overlap—dropped from near 1.0 (perfect recall) at zero offset to a baseline of approximately 0.2 when the prefix was shifted by as few as 128 tokens. This suggests that the model's internal "search" mechanism for memorized content is highly sensitive to positional alignment.
The Prefix Paradox
Interestingly, we observed a "Prefix Paradox" at zero offset: shorter prefixes often triggered higher verbatim recall than longer ones, particularly in smaller models. This counterintuitive behavior suggests that longer contexts may introduce enough noise to disrupt the specific positional triggers required for memory retrieval.
Mitigation via Displacement
Building on the discovery of positional fragility, we tested a novel mitigation strategy called "Swapped Gutenberg." In this approach, the first 4,000 tokens of a training sequence are replaced with unrelated, non-sensitive text, effectively "burying" the sensitive content deeper in the context window.
This simple displacement strategy nearly eliminated extractable memorization. Even for sequences repeated 128 times, Rouge-L and LCCS (longest contiguous common substring) scores remained at baseline levels. Crucially, this reduction in memorization did not negatively impact the model's general linguistic capabilities or its performance on standard benchmarks.
Memorization and Text Degeneration
A significant insight from this study is the link between failed memory retrieval and text degeneration. When a model is prompted with an offset sequence that it has seen many times, it often fails to recall the verbatim text but also fails to generate coherent original content. Instead, it frequently falls into "thematic loops" or repetitive, low-quality output. This suggests that what is often diagnosed as a general "degeneration" issue in LLMs may actually be a symptom of the model attempting—and failing—to retrieve a specific memorized sequence due to positional misalignment.
Scaling and Training Dynamics
Our research also highlights the impact of model scale and training hyperparameters:
- Scaling: Larger models (8B) are significantly more efficient at memorizing data, requiring only 16 exposures to reach the same level of recall that a 1B model achieves after 64 exposures.
- Batch Size: Smaller batch sizes, which necessitate more frequent gradient updates, were found to modestly reduce memorization compared to larger batch sizes under the same compute budget.
Conclusion and Future Work
Positional fragility represents a significant shift in our understanding of how LLMs store and retrieve training data. By recognizing that memorization is anchored to specific positions, researchers can develop more effective pretraining filters and data-shuffling strategies to protect sensitive information.
Future research should investigate whether these findings hold true for "Fill-in-the-Middle" (FIM) training objectives commonly used in code generation models, and whether similar positional sensitivities exist in multimodal models for images and video. Additionally, while displacement is an effective empirical defense, further work is needed to provide formal guarantees against more sophisticated extraction attacks.
Summary updated