Skip to main content
QUICK REVIEW

[Paper Review] ResMem: Learn what you can and memorize the rest

Zitong Yang, Michał Łukasik|arXiv (Cornell University)|Feb 3, 2023
Topic ModelingComputer Science3 citations
TL;DR

ResMem proposes a two-stage learning framework that enhances model generalization by explicitly memorizing residuals of a base neural network using a k-nearest neighbors (k-NN) regressor. By combining the base model's predictions with k-NN-fitted residuals, ResMem achieves lower test risk than the base model alone, demonstrating consistent accuracy gains across vision and NLP benchmarks, including +1.0% accuracy on ImageNet and +0.89% on C4 language modeling.

ABSTRACT

The impressive generalization performance of modern neural networks is attributed in part to their ability to implicitly memorize complex training patterns. Inspired by this, we explore a novel mechanism to improve model generalization via explicit memorization. Specifically, we propose the residual-memorization (ResMem) algorithm, a new method that augments an existing prediction model (e.g. a neural network) by fitting the model's residuals with a $k$-nearest neighbor based regressor. The final prediction is then the sum of the original model and the fitted residual regressor. By construction, ResMem can explicitly memorize the training labels. Empirically, we show that ResMem consistently improves the test set generalization of the original prediction model across various standard vision and natural language processing benchmarks. Theoretically, we formulate a stylized linear regression problem and rigorously show that ResMem results in a more favorable test risk over the base predictor.

Motivation & Objective

  • To improve model generalization in small or low-capacity neural networks by explicitly memorizing training residuals.
  • To explore whether explicit memorization via k-NN can outperform implicit memorization in large models, especially when training data is complex or massive.
  • To theoretically and empirically validate that combining a parametric model with a non-parametric k-NN component reduces test risk.
  • To understand the inductive bias of ResMem and how it enables learning of fine-grained details beyond the base model’s capacity.

Proposed method

  • Train a base deep neural network (f_DNN) on the training data to produce initial predictions.
  • Compute residuals as the difference between true labels and f_DNN’s predictions on the training set.
  • Fit a k-NN regressor on the training set using the residuals as targets, using L2 distance on the final layer features.
  • Combine predictions via f_ResMem(x) = f_DNN(x) + r_kNN(x), where r_kNN is the k-NN prediction on the residuals.
  • Use temperature scaling and weighted combination to tune the contribution of the k-NN component.
  • Apply the method to image classification (CIFAR-100, ImageNet) and autoregressive language modeling (C4) with T5 models.
Figure 3: Examples from CIFAR100 and C4 test set with the property that (i) $y^{\textsf{ResMem}}$ is correct; (ii) $y^{\textsf{DeepNet}}$ is wrong but close in meaning. We use red to denote the ResMem prediction and blue to denote DeepNet prediction. The DeepNet predictions capture coarse structure
Figure 3: Examples from CIFAR100 and C4 test set with the property that (i) $y^{\textsf{ResMem}}$ is correct; (ii) $y^{\textsf{DeepNet}}$ is wrong but close in meaning. We use red to denote the ResMem prediction and blue to denote DeepNet prediction. The DeepNet predictions capture coarse structure

Experimental results

Research questions

  • RQ1Can explicit memorization of residuals via k-NN improve generalization beyond what a base neural network can achieve?
  • RQ2Does ResMem reduce test risk more effectively than a standard neural network, especially in high-capacity or complex data regimes?
  • RQ3How does the two-stage learning process—coarse feature learning followed by fine-grained residual memorization—affect model performance?
  • RQ4What is the theoretical advantage of ResMem over a base linear model in terms of convergence rate and test risk?
  • RQ5How does ResMem compare to direct k-NN label memorization or knowledge distillation in terms of performance and inductive bias?

Key findings

  • On ImageNet, ResMem improved test accuracy by 1.0% on the smallest MobileNet-V2 (a=0.35) and 0.4% on the largest (a=1.3), demonstrating consistent gains across model sizes.
  • On the C4 language modeling benchmark, ResMem achieved 45.55% test accuracy, outperforming the best kNN-LM method (44.88%) by 0.67 percentage points.
  • For CIFAR-100 with ResNet-8, ResMem achieved 59.66% accuracy, surpassing the base network (56.46%) and pure k-NN label memorization (54.44%).
  • Theoretical analysis on a linear regression problem shows that ResMem’s test risk decreases to zero as sample size increases, while the base model’s risk converges to a non-zero constant.
  • Qualitative analysis confirms that the base model learns coarse structure, while the k-NN component captures fine-grained, instance-specific details not captured by the base model.
  • ResMem outperforms direct k-NN label memorization across all evaluated settings, indicating that residual-based memorization is more effective than raw label memorization.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.