Quantifying Train-Evaluation Overlap with Nearest Neighbors

Gauri Kambhatla, Thuy Nguyen, Eunsol Choi

Abstract

Traditional NLP benchmarks often fail to distinguish between true logical generalization and sophisticated pattern matching. This paper introduces a nearest-neighbor approach to quantify semantic overlap between training and evaluation sets. By demonstrating that simple "copy-paste" baselines can rival fine-tuned models on certain datasets, the authors propose InsSim as a metric to identify genuinely challenging test cases.

Introduction

The primary goal of machine learning is generalization: the ability of a model to perform well on unseen data. However, if an evaluation set contains examples semantically similar to the training data, high performance may merely reflect a model's capacity for memorization rather than reasoning. While exact string matching is easily detected, semantic overlap—where the meaning or structure of a test instance mirrors a training example—is a more subtle and pervasive issue in modern NLP benchmarks.

Methodology: The Nearest Neighbor Baseline

To measure this overlap, the authors propose a non-parametric Nearest Neighbor Classifier. The process involves mapping all instances into a high-dimensional vector space using two types of embeddings:

  1. General Embeddings ($E_g$): Captured via models like SimCSE to represent broad semantic similarity.
  2. Task-Specific Embeddings ($E_t$): Derived from models (e.g., RoBERTa) fine-tuned on the specific task.

For any evaluation example, the classifier simply adopts the label of its single nearest neighbor in the training set based on cosine similarity. If this "dumb" baseline performs well, it indicates a high degree of train-evaluation overlap.

Examples of evaluation instances and their nearest training neighbors. Task-specific embeddings ($E_t$) often find neighbors that are functionally identical for the task, even if they differ on the surface.

Additionally, the authors introduce InsSim (Instance Similarity), a metric that averages the cosine similarity of the top $k=5$ nearest training neighbors. High InsSim scores identify "easy" instances that the model has likely encountered in similar forms during training.

Dataset Analysis

The study evaluates 11 NLP datasets, categorized by their collection methodology:

  • Synthetic (SYN): Template-generated (e.g., WinoGrande).
  • Crowd-sourced (CWD): Written by human workers (e.g., MNLI, SQuAD 2.0).
  • Artificial Labels (LAB): Real-world text with crowd-sourced labels (e.g., NQ).
  • User-generated (USE): Naturally occurring text and labels (e.g., SST-2, AG News, IMDb).

Key Results and Insights

The results reveal that natural, user-generated datasets exhibit significantly higher overlap than synthetic ones. In many cases, the Nearest Neighbor baseline is surprisingly competitive with state-of-the-art fine-tuned models.

Accuracy of Nearest Neighbor baselines ($E_g$ and $E_t$) compared to random guessing and full fine-tuning. On datasets like SST-2 and AG News, the $E_t$ baseline nearly matches full fine-tuning performance.

Functional Identity

Task-specific embeddings ($E_t$) consistently reveal higher overlap than general ones ($E_g$). This suggests that many test examples are "functionally identical" to training data within the context of the specific task, even if they appear distinct in a general semantic space. For instance, on the SST-2 sentiment dataset, the $E_t$ nearest-neighbor baseline achieves 95.07% accuracy, trailing a fully fine-tuned model (96.84%) by less than 2 points.

The Generalization Gap

The authors further partitioned evaluation sets into MATCH (where the nearest neighbor's label is correct) and MISMATCH (where it is not) subsets. On AG News, model performance plummeted from 98.37% on the MATCH subset to 69.47% on the MISMATCH subset. This 29-point gap underscores the extent to which reported accuracies rely on "familiar" data patterns.

Conclusion and Future Work

The findings suggest that many popular NLP benchmarks may be overestimating model intelligence by providing "easy" test cases that overlap with training data. The authors recommend that future benchmark creators utilize metrics like InsSim during the data-splitting phase to ensure test sets provide a rigorous challenge. While limited to English BERT-style models, this work provides a vital framework for auditing the integrity of machine learning evaluations.

Summary updated

BibTeX
@inproceedings{kambhatla2023quantifying,
  author = {Gauri Kambhatla and Thuy Nguyen and Eunsol Choi},
  title = {{Quantifying Train-Evaluation Overlap with Nearest Neighbors}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.183},
}
Figure