Memorization vs. Generalization : Quantifying Data Leakage in NLP Performance Evaluation

Aparna Elangovan, Jiayuan He, Karin Verspoor

Abstract

This paper investigates the prevalence of "data leakage" in popular NLP benchmarks, where test examples closely resemble training data. By quantifying this overlap using n-gram similarity and stratifying evaluation across similarity intervals, the authors demonstrate that high model performance often stems from memorization rather than true generalization. The findings suggest that current evaluation practices may provide an inflated sense of progress, as models frequently fail when encountering truly novel data.

Introduction

In Natural Language Processing (NLP), "held-out" test sets are the gold standard for measuring a model's ability to generalize to unseen data. However, many public datasets contain a hidden flaw: significant overlap between training and test sets. This leakage allows models to achieve high scores by acting as "lookup tables," memorizing specific patterns or entities rather than learning underlying linguistic logic. This study aims to quantify this leakage and its impact on performance across various tasks.

Methodology

The researchers proposed a framework to measure data leakage using a bag-of-words approach. Similarity between test instances and the training set was calculated using cosine similarity of unigrams, bigrams, and trigrams. Based on these scores, test sets were stratified into four intervals (1I to 4I), ranging from low to high similarity. Standard BERT-based models were then evaluated across these strata to determine if performance remained stable or relied on data proximity.

Quantifying Data Leakage

Analysis across several benchmarks revealed substantial overlap. For instance, in the BC2GM (gene mention) dataset, over 70% of gene names in the test set were already present in the training data. This suggests that for Named Entity Recognition (NER), models may simply be learning a list of names rather than the context of what constitutes a "gene."

Table 2: Percentage of n-gram overlap between training and test sets across different datasets. High unigram overlap in NER tasks (e.g., BC2GM ann at 70.77%) indicates significant entity leakage.

Impact on Model Performance

The core finding of the study is that model performance is highly sensitive to the degree of leakage. When evaluated on stratified test sets, performance consistently plummeted as similarity to the training data decreased.

For example, in the SST2 sentiment analysis task, accuracy reached 96.8% for the highest similarity group (4I) but dropped to 85.0% for the lowest (1I). In the ChEMU NER task, the F1-score saw a nearly 10-point drop (96.7 to 85.6) when moving from the highest similarity instances to the second-highest.

Table 4: Model performance (Precision, Recall, F1, Accuracy) stratified by similarity intervals (1I-4I) compared to the full test set (F). Performance consistently declines as similarity to training data decreases.

Discussion and Conclusion

The results highlight an "external validity crisis" in NLP evaluation. The common practice of random splitting often places similar sentences from the same document into both training and test sets, artificially inflating scores. For the AIMed dataset, moving from a random split to a unique document-based split caused F-scores to drop by over 10 points across multiple architectures.

The authors conclude that the NLP community must move beyond reporting a single aggregate metric. Instead, adopting stratified evaluation—reporting performance across varying degrees of data novelty—is essential to distinguish between a model that has truly learned to "think" and one that has merely learned to remember.

Summary updated

BibTeX
@inproceedings{elangovan2021memorization,
  author = {Aparna Elangovan and Jiayuan He and Karin Verspoor},
  title = {{Memorization vs. Generalization : Quantifying Data Leakage in NLP Performance Evaluation}},
  booktitle = {EACL},
  year = {2021},
  doi = {10.18653/v1/2021.eacl-main.113},
}
Figure