Elephants Never Forget: Testing Language Models for Memorization of Tabular Data

Sebastian Bordt, Harsha Nori, Rich Caruana

TL;DR

This paper demonstrates that Large Language Models (LLMs) like GPT-4 have effectively "memorized" many popular tabular datasets used in machine learning benchmarks. By introducing a suite of statistical and prompting tests, the authors show that LLMs often contain verbatim or compressed representations of these datasets, leading to inflated and invalid performance evaluations on downstream tasks.

What Problem Does This Paper Address?

In the rush to apply LLMs to everything from healthcare to finance, researchers often overlook data contamination. Because LLMs are trained on massive crawls of the public internet, they have likely encountered the CSV files, Kaggle notebooks, and GitHub repositories that house common research datasets.

If a model has already seen the "test set" during its pre-training, its high performance on a task isn't a sign of reasoning or generalization—it's just a sign of a good memory. This paper tackles the challenge of detecting this contamination in tabular data, where the structured nature of the data allows for more precise testing than free-form text.

Methods

The authors propose a hierarchy of tests to distinguish between three types of contamination:

  1. Knowledge: Does the model know metadata (feature names, value ranges, delimiters)?
  2. Learning: Can the model reproduce the joint probability distribution (e.g., correlations between features) without necessarily knowing specific rows?
  3. Memorization: Can the model recite specific rows verbatim, especially those with high entropy or unique values?

To test these without "leaking" the data in the prompt, they use zero-knowledge prompting. They provide the model with few-shot examples from different datasets to establish the desired output format, then ask the model to generate samples from the target dataset using only its internal parametric memory.

They also introduce four specific memorization tests:

  • Header Test: Completing the first few rows of a canonical CSV.
  • Row Completion: Completing a random row given a prefix.
  • Feature Completion: Predicting a unique feature (like a Name or ID) given all other features in a row.
  • First Token Test: Predicting the very first value of a random row.

Datasets

The study evaluates GPT-3.5 and GPT-4 across a diverse set of 10 datasets:

  • Publicly Available (Likely Contaminated): Iris, Wine, Kaggle Titanic, OpenML Diabetes, Adult Income, California Housing, and Scikit-learn Diabetes.
  • Guarded/Private (Likely Clean): FICO HELIOCv1 (requires a usage agreement), Kaggle Spaceship Titanic (released in 2022, after the models' training cutoffs), and Pneumonia (a private healthcare dataset).

Key Insights and Ideas

  • The "Elephant" in the Room: GPT-4 is a much larger "elephant" than GPT-3.5. It consistently exhibits higher rates of verbatim memorization across almost all public datasets.
  • The head() Effect: Models are significantly better at remembering the first few rows of a dataset than random rows from the middle. The authors hypothesize this is because Python tutorials and Kaggle notebooks frequently call df.head(), making those specific rows appear much more often in the training corpus.
  • Learning vs. Memorization: Interestingly, for datasets like California Housing, the models can perfectly replicate the complex Pearson correlation coefficients of the features (Learning) even when they fail to reproduce specific rows verbatim (Memorization).
Figure 1: Conditional completion on Adult Income and FICO. We give the model all previous feature values in the dataset as prefix and ask it to complete the next value in the data. The figure depicts the fraction of correctly completed observations (i.e., an observation exists in the data with that prefix and completion) for three different methods: (1) completion with GPT-3.5, (2) completion with GPT-4, and (3) as a baseline, completion with a random draw from the feature’s marginal distribution (i.e., with a random sample from the values of the next column). If GPT-3.5 (green) or GPT-4 (blue) are able to complete rows with true values from the original dataset at a rate higher than the baseline (yellow), this is evidence that the LLMs have seen the data before and memorized parts of it. We show this for 8 different features on 2 datasets. The mean and 95% confidence intervals are shown.

Key Results

  • Verbatim Recitation: For the Kaggle Titanic dataset, GPT-4 achieved a staggering 98% accuracy on a few-shot classification task. The authors' tests confirmed this was almost entirely due to memorization; the model could perfectly complete names and IDs for specific rows.
  • Distributional Accuracy: In zero-knowledge sampling, the models produced data that closely matched the Pearson correlations of the original datasets for California Housing and Titanic, but failed to do so for the "clean" FICO and Pneumonia datasets.
  • Contamination Confirmation: Table 1 in the paper shows that nearly all popular public datasets (Iris, Wine, Titanic, etc.) triggered positive results for both "Knowledge" and "Memorization" tests. Conversely, the Spaceship Titanic and Pneumonia datasets showed no evidence of contamination.

Limitations and Future Work

The authors acknowledge that their tests rely on black-box API access. Because they cannot see the model's internal probability distributions (logprobs), they must rely on sampling, which might underrepresent the true extent of memorization.

Furthermore, the "power" of these tests is tied to prompting. It is possible a model has memorized a dataset but requires a very specific, "magic" prompt to reveal it. The authors have released an open-source tool to help the community continue testing for contamination in new models and datasets.

Summary updated

BibTeX
@inproceedings{bordt2023elephants,
  author = {Sebastian Bordt and Harsha Nori and Rich Caruana},
  title = {{Elephants Never Forget: Testing Language Models for Memorization of Tabular Data}},
  booktitle = {TRL @ NeurIPS},
  year = {2023},
  url = {https://openreview.net/forum?id=l1u7jA60wT},
}
Figure