Title: No Train, all Gain: Self-Supervised Gradients Improve Deep Frozen Representations
Venue: NeurIPS 2024
Accepted: yes
Keywords: self-supervised

gradients

computer vision

transformers

k-nearest neighbor

classification

in-context learning

clustering

retrieval
Abstract: This paper introduces FUNGI, **F**eatures from **UN**supervised **G**rad**I**ents, a method to enhance the features of transformer encoders by leveraging self-supervised gradients. Our method is simple: given any pretrained model, we first compute gradients from various self-supervised objectives for each input. These gradients are projected to a lower dimension and then concatenated with the model's output embedding. The resulting features are evaluated on k-nearest neighbor classification over 11 datasets from vision, 5 from natural language processing, and 2 from audio. Across backbones spanning various sizes and pretraining strategies, FUNGI features provide consistent performance improvements over the embeddings. We also show that using FUNGI features can benefit linear classification, clustering and image retrieval, and that they significantly improve the retrieval-based in-context scene understanding abilities of pretrained models, for example improving upon DINO by +17% for semantic segmentation - without any training. Code is available at https://github.com/WalterSimoncini/fungivision.

No Train, all Gain: Self-Supervised Gradients Improve Deep Frozen Representations

Abstract

This paper introduces FUNGI, F eatures from UN supervised G rad I ents, a method to enhance the features of transformer encoders by leveraging self-supervised gradients. Our method is simple: given any pretrained model, we first compute gradients from various self-supervised objectives for each input. These gradients are projected to a lower dimension and then concatenated with the model's output embedding. The resulting features are evaluated on k-nearest neighbor classification over 11 datasets from vision, 5 from natural language processing, and 2 from audio. Across backbones spanning various sizes and pretraining strategies, FUNGI features provide consistent performance improvements over the embeddings. We also show that using FUNGI features can benefit linear classification, clustering and image retrieval, and that they significantly improve the retrieval-based in-context scene understanding abilities of pretrained models, for example improving upon DINO by +17% for semantic segmentation - without any training. Code is available at https://github.com/WalterSimoncini/fungivision .

1 Introduction

The k-nearest neighbor algorithm (kNN) (Fix, 1985) is a fundamental non-parametric machine learning tool, and can be scaled to datasets with billion of examples thanks to advances in quantization (Jegou et al., 2010; Guo et al., 2020) and efficient GPU implementations (Johnson et al., 2019). This simple and versatile algorithm has shown potential in multiple applications well before deep neural networks became relevant (Efros & Leung, 1999; Hays & Efros, 2008; Torralba et al., 2008). Its recent applications include fast and robust image classification with Vision Transformers (Caron et al., 2021; Chen & He, 2021), unlabeled data selection (Yalniz et al., 2019), relevant text-retrieval (Lewis et al., 2020), and visual in-context learning (Balazevic et al., 2024), where a context of data samples with their annotations (e.g., a semantic segmentation map) are used to make dense predictions.

Devising powerful and expressive features for recognition and image understanding has a long history in computer vision. Feature engineering strategies range from simple local features (Lowe, 2004; Dalal & Triggs, 2005; Van De Sande et al., 2009) extracting gradient, boundary or color information, to various mid-level (Boureau et al., 2010) or global pooling (Oliva & Torralba, 2001; Sivic & Zisserman, 2003; Jégou et al., 2010) techniques. It is also possible to couple off-the-shelf pretrained backbones as feature extractors with such pooling strategies (Gong et al., 2014; Kulkarni et al., 2015; Gidaris et al., 2020) to improve performances. While these approaches demonstrate the utility of using a neural network's learned embedding space, they still require specific expertise and tuning for each backbone and task with only limited guidance from the data itself.

Project &

Concat

Gradient

Enhanced

Features

Database

{

FUNGI

We depart from this line of work and aim to attain strong representations without training and feature engineering, yet still exploiting information cues from data. In particular, we suggest to enhance the neural network's embeddings by incorporating FUNGI (Features from Unsupervised GradIents). FUNGI are obtained from self-supervised loss functions, as these do not require any human annotations and allow for a simple enhancement to embedding-only kNN. The losses are computed on top of pretrained backbones (with randomly initialized linear layers if needed), which permits our method to be 'plug-and-play' and benefit from the diverse set of pretraining objectives put forth by the community.

We explore gradients from various learning objectives, such as contrastive learning (Chen et al., 2020a) and self-distillation (Caron et al., 2021) thereby integrating complementary information that mitigates the weaknesses of individual losses. The gradients are obtained from late hidden layers, making them computationally cheap. Finally, these are projected to smaller dimensions, and concatenated with the neural network embeddings, to yield new inputs to the classic kNN algorithm.

Using kNN with FUNGI can be regarded as a non-parametric transfer learning approach: the gradient information encodes first-order learning signals that are specific to the downstream data, yet no parameters need to be updated. Despite this simplicity, we achieve consistent performance improvements across multiple models and benchmarks. Overall, our main contributions are summarized as follows:

We introduce FUNGI, a novel method that combines neural network features and gradients to enhance representations.

We demonstrate that the gradients from self-supervised losses have predictive abilities and offer complementary information to model embeddings.

We validate the generality and utility of our method by achieving consistent gains across 11 image, 5 text, and 2 audio classification benchmarks, plus 2 in-context image segmentation and 2 image retrieval tasks, utilizing a total of 20 backbones.

2 Related Work

Fast Adaptation There is a broad range of approaches to quickly adapt models to newly specified tasks and data. Inspired by early learning-to-learn work (Hochreiter et al., 2001), meta-learning methods (Finn et al., 2017; Nichol et al., 2018) learn to initialize the parameters of a learner such that it becomes faster to fine-tune with a small number of gradient steps and data. Alternative approaches leverage external memory modules to store relevant training samples to learn to match query examples (Santoro et al., 2016; Vinyals et al., 2016), learn to produce and compare class-based prototypes (Snell et al., 2017) or learn to generate the weights of a classifier (Gidaris & Komodakis, 2018) or even of an entire neural network (Bertinetto et al., 2016) from only a few labeled examples. The advent of Vision Transformers (Dosovitskiy et al., 2021) enable new parameter- and dataefficient strategies to adapt pretrained models through visual prompts (Jia et al., 2022) and in-context learning (Zhang et al., 2023). In contrast to this line of works, our method does not require specialized training and can be applied to any frozen pretrained backbone. FUNGI can also be related to test-time training (Sun et al., 2020; Hardt & Sun, 2024), where the parameters of a predictive model are

Emb.

KL

DINO

SimCLR

100.0

90.3

82.3

46.6

90.3

100.0

83.5

48.9

82.3

83.5

100.0

53.5

46.6

48.9

53.5

100.0

CKA (Flowers)

100.0

92.9

84.3

43.7

92.9

100.0

85.2

45.1

84.3

85.2

100.0

47.9

43.7

45.1

47.9

100.0

CKA (ESAT)

100.0

95.2

85.6

51.5

95.2

100.0

86.6

54.2

85.6

86.6

100.0

58.0

51.5

54.2

58.0

100.0

CKA

CKA (Cars)

Emb.

KL

DINO

SimCLR

Emb.

KL

DINO

SimCLR

56.9

60.4

64.0

68.0

60.4

61.4

65.4

70.2

64.0

65.4

65.3

70.2

68.0

70.2

70.2

67.0

Emb.

KL

DINO

SimCLR

90.7

92.0

93.2

94.4

92.0

91.6

94.1

94.6

93.2

94.1

93.1

94.5

94.4

94.6

94.5

93.6

Pair Acc. (ESAT)

Emb.

KL

DINO

SimCLR

32.3

33.2

36.8

37.8

33.2

32.7

37.0

38.7

36.8

37.0

35.8

38.6

37.8

38.7

38.6

34.9

Pair Acc. (Cars)

0

1

Emb.

Per-Class Accuracy Deltas (Flowers 102)

0.5

0.0

0.5

KL

0.5

0.0

0.5

DINO

0.5

0.0

0.5

SimCLR

Class Index

updated over test samples with a self-supervised objective to reduce the gap between the training and test distributions. While we also use self-supervised objectives and gradients, our approach does not update model parameters and is not limited to predictive models, as it can be applied to any task that can be solved with retrieval.

Self-Supervised Learning Objectives In recent years, self-supervised learning (SSL) has made tremendous progress in computer vision. SSL aims to learn good representations from unlabeled data by leveraging supervision from different signals in the data itself via pretext objectives, thus foregoing human supervision. Models pretrained with self-supervision are subsequently finetuned to downstream tasks of interest with few labeled samples. The crux of SSL is in the pretext learning objective. A wide and diverse collection of pretext objectives have been proposed in the community relying on contrastive learning (Chen et al., 2020a; He et al., 2020; Chen et al., 2020b), clustering (Caron et al., 2018; Asano et al., 2020; Caron et al., 2020), self-distillation (Caron et al., 2021; Grill et al., 2020; Chen & He, 2021; Gidaris et al., 2021), feature (Zhou et al., 2022; Assran et al., 2023) or input reconstruction (He et al., 2022).

We hypothesize that the gradients induced by these objectives encapsulate different information from the input data, and that this information can be combined to produce more information-rich representations. Here, we do not use self-supervision in the usual way, i.e. , to pretrain an encoder, but rather focus on pretext objectives and data augmentation strategies to compute representations from a frozen pretrained model.

Feature Engineering A long-standing research area for pattern recognition and image understanding before the advent of deep neural networks that brought the paradigm of end-to-end representation learning. In contrast, classic feature extraction methods are devised without labeled data and often from only a few data samples. They range from local features, such as SIFT (Lowe, 2004), HOG (Dalal & Triggs, 2005), to global pooling, such as GIST (Oliva & Torralba, 2001), Bag-ofVisual-Words (Sivic & Zisserman, 2003), Fisher vectors (Perronnin et al., 2010), VLAD (Jégou et al., 2010), selective match kernels (Tolias et al., 2013), etc. These pooling strategies can be easily plugged to intermediate or output neural network activations (Gong et al., 2014; Kulkarni et al., 2015; Gidaris et al., 2020), harnessing data-driven learned representations. Other modern examples of feature engineering include Head2Toe (Evci et al., 2022), which augments the model embeddings using intermediate activations, kNN-prompting (Xu et al., 2023), which uses the next token probabilities of a language model to perform few shot nearest neighbor classification and LOST (Siméoni et al., 2021) which uses patch features from self-supervised vision transformers for object localization. Closer to our line of work, Wei et al. (2022) shows that kernel regression using the empirical neural tangent kernel (eNTK), which corresponds to the model Jacobian, can achieve a performance similar to fine-tuning in vision, and Mu et al. (2020) shows that features obtained from the Jacobian of the top layers of a convolutional neural network can be used to enhance a linear classifier. In contrast, our method does not require any annotations and is computationally cheaper, as we only compute the gradient for a single layer rather than the full Jacobian.

(2) Compute Loss & Backpropagate

Attract

Repel

Fixed Negative Batch

(1) Patchify and Forward

(3) Extract

Per-Sample

Gradients

(4) Project

3 Gradients as Features

Gradients encode information on how the weights of a neural network should change to solve a given task. Thus, they contain information about the current state of the network and its relation to the data point(s) used to compute it. Therefore, we hypothesize that features from self-supervised gradients should perform better than the embeddings, as they are adapted to the dataset at hand. Empirically, the second row in Figure 2 shows this to be accurate, e.g., gradients from a SimCLR loss improve the accuracy of k-nearest neighbor classification by 10.1% on Flowers102.

If we plot the per-class accuracy distribution as in Figure 3, we notice that gradient features encode different information depending on the loss and that they can perform significantly worse on some classes, possibly because they are estimated using a single data point, and are thus dependent on the local loss curvature. These findings suggest that the information in embeddings and gradient features could be complementary. We show that this holds in the second row of Figure 2, as feature pairs perform better. Moreover, the first row of the figure suggests that more diverse feature pairs, as measured via their centered kernel alignment (CKA) (Kornblith et al., 2019) score, lead to better overall performance.

4 Method

Our method, FUNGI, enhances k-nearest neighbor search by incorporating features from unsupervised gradients. We extract gradients from self-supervised loss functions, project them to smaller dimensions, and concatenate them with neural network embeddings. The extraction of self-supervised gradients is illustrated in Figure 4, while Figure 1 shows how FUNGI features are constructed.

Definitions Throughout this section, we define L 2 normalization as z ′ = z/ || z || 2 , a vision backbone as f , a linear projection head as h and vectorization as vec ( · ) .

4.1 FUNGI: Features from Unsupervised Gradients

Gradients Extraction. Given an arbitrary vision backbone f , in our case a vision transformer (ViT) (Dosovitskiy et al., 2021), we attach a randomly initialized linear projection head h and obtain a latent representation z = h ( f ′ ( x )) of the input images, which we use to compute the loss for one of our self-supervised objectives. We then run backpropagation and extract the gradients with respect to the weights and biases of an arbitrary hidden linear layer within f . Unless specified otherwise, we use the attention output projection of the last transformer block as our gradient's source.

From Gradients to Retrieval-Friendly Features. Gradients are high dimensional and thus impractical for nearest-neighbor retrieval due to speed and storage considerations and the curse of dimensionality. To tackle these issues, we downsample the gradients to the dimensionality of original model embeddings d using the binary random projections method introduced by Achlioptas (2003). For this, we first vectorize the gradients by flattening them to a m -dimensional vector and then multiply them by a matrix R ∈ {-1 , 1 } d,m whose entries are the realizations of a Bernoulli random

variable with p = 0 . 5 . The gradient g β with respect to a loss L β is then defined as

Combining with Embeddings. To produce our FUNGI features ϕ , we concatenate one or more gradients to the model embeddings. As gradient magnitudes can vary widely across losses, and we want gradients to be equally considered as the embeddings, we L 2 -normalize each gradient, as well the embeddings and compute

where cat denotes concatenation. Finally, we reduce the dimensionality of these combined features via PCA to a d -dimensional vector. This allows the combination of multiple losses at iso-storage cost. Our final FUNGI features for a sample x are thus obtained as:

4.2 Self-Supervised Objectives

We consider losses representing three families of self-supervised objectives: DINO (Caron et al., 2021), SimCLR (Chen et al., 2020a) and a KL-divergence based loss inspired by the out-ofdistribution detection literature (Huang et al., 2021). In this section we briefly describe the objectives and our adjustments to them, and in Appendix B.6, we also briefly discuss clustering and masked image modeling-based losses.

DINO. DINO is a distillation and implicit clustering-based learning method. We use the standard DINO loss, which, given an image, enforces global and local crop correspondence between teacher and student models using a cross-entropy loss. In our case, both models share the same parameters, but have independent heads h s and h t for student and teacher respectively, thus we have z i = h i ( f ′ ( x )) , i ∈ { s, t } . The DINO objective can be expressed as:

SimCLR. SimCLR is a noise-contrastive method. Given a batch of images, SimCLR generates two views for each image and aims to minimize the distance between views belonging to the same image and maximize their distance to all other views. Instead, we generate a set of 49 overlapping patches for each image, which we call the positive set. This set is then contrasted against a fixed comparison batch of 49 × 256 negative examples. Our objective is the expectation of the pair-wise InfoNCE (Oord et al., 2018) loss for each pair of positive views. If we define the positive set of latent view representations as Z , where z i ∈ Z = h ′ ( f ( x i )) for a view x i , the comparison batch size as N and the temperature as τ , the L SimCLR objective is then defined as:

̸

✶ KL Divergence. The KL objective is calculated as the KL divergence between the softmaxed logits of the latents and a uniform distribution U :

̸

We hypothesize two reasons as for why this loss produces predictive gradients: first, it receives a non-augmented image, with a higher signal-to-noise ratio compared to other objectives, and second, if we assume that similar images ( e.g. , the ones that belong to the same class) produce similar activations, then maximizing their entropy by forcing the output distribution to match an uniform should produce similar intra-class gradients and help separability. This hypothesis is supported by the fact that while the KL gradients are discriminative, they have chance performance in other tasks, such as in-context scene understanding.

4.3 In-Context Scene Understanding

Balazevic et al. (2024) introduced a method for retrieval-based in-context scene understanding, where, for semantic segmentation, they first build a memory bank containing training image patches and their labels, and at test time, for each image patch, retrieve its nearest neighbors and use them to predict its

AR IN1K

ViT-S/16

DeIT

ViT-B/32

MoCov3

ViT-B/16

DeIT-III

ViT-B/16

DeIT

ViT-B/16

AR IN21K

ViT-S/16

AR IN21K

ViT-B/16

DINO

ViT-B/16

CLIP

ViT-B/16

AR IN21K

ViT-L/16

DINOv2

ViT-B/14

EVA CLIP

ViT-B/16

0.50

0.55

0.60

0.65

0.70

0.75

0.80

0.85

0.90

+3.5%

+5.8%

+2.6%

+4.0%

+4.9%

+1.9%

+2.9%

+1.9%

+4.0%

+1.8%

+2.0%

+1.0%

Full Dataset

AR IN1K

ViT-S/16

DeIT

ViT-B/32

MoCov3

ViT-B/16

DeIT-III

ViT-B/16

DeIT

ViT-B/16

AR IN21K

ViT-S/16

AR IN21K

ViT-B/16

DINO

ViT-B/16

CLIP

ViT-B/16

AR IN21K

ViT-L/16

DINOv2

ViT-B/14

EVA CLIP

ViT-B/16

0.25

0.30

0.35

0.40

0.45

0.50

0.55

0.60

+2.8%

+3.4%

+3.7%

+5.7%

+4.6%

+2.1%

+3.0%

+1.2%

+5.3%

+2.9%

+4.8%

+1.4%

Few Shot

Embeddings

FUNGI

label using an attention mechanism. Images are first resized to 512 × 512 , and then encoded as a set of 32 2 = 1024 patch features using a ViT with patch size 16.

We enhance the patch features using SimCLR gradients, obtained by contrasting the input patch tokens against their nearest neighbors from a support index built with ScaNN (Guo et al., 2020). We use the reproduction of this evaluation protocol by Pariza et al. (2024) to run our experiments.

5 Experiments

In this section, we evaluate the performance of FUNGI in k-nearest neighbor image, text and audio classification and retrieval-based in-context scene understanding. Further experiments, including image retrieval, clustering and linear probing, are provided in Appendix B.

5.1 Image Classification

Following Caron et al. (2021), we evaluate our FUNGI features using the task of kNN classification. To show the generalizability of our method, we evaluate our features across ViT backbones (Dosovitskiy et al., 2021) with varying model sizes and pretraining strategies, including both supervised and self-supervised methods.

We conduct our experiments on 11 diverse downstream datasets, described in Appendix D. Unless otherwise specified, we report the average accuracy across these datasets. We evaluate our features using the kNN implementation of scikit-learn (Pedregosa

2

3

4

5

6

7

8

9

10

Shots

0.2

0.3

0.4

0.5

0.6

0.7

0.8

Embeddings

KL + SimCLR Gradients

DINO

FUNGI

GT

DINO

FUNGI

GT

et al., 2011) with majority voting over 20 neighbors, for full dataset and few shot scenarios, the latter using five examples per class, to analyze the efficacy of our approach in low-data scenarios.

Our results, presented in Figure 6, show that FUNGI consistently improves the kNN performance of all ViT models, regardless of model size or pretraining strategy, both for the full dataset and in few shot scenarios. We further investigate data-efficient settings in Figure 5, where FUNGI shows a significant improvement when 3 to 6 shots are used, highlighting the potential of FUNGI in low-data regimes.

In Table 1, we show that, with some exceptions, FUNGI provides consistent improvements across datasets for two AugReg (Steiner et al., 2022) ViT-B/16 backbones, pretrained on IN1K and IN21K, with FUNGI providing better results on the former. We further discuss these results in Section 6.

Lastly, in Table 2 we show that performance improves as more gradients from different self-supervised objectives are used.

5.2 In-Context Scene Understanding

In this section, we assess the effectiveness of our approach in the task of retrieval-based semantic segmentation on Pascal VOC 2012 (Everingham et al., 2010) and ADE20K (Zhou et al., 2019,

2017). We use the trainaug and train splits to build the memory banks for Pascal VOC and ADE20K, respectively, and report the mean intersection over union (mIoU) on the validation set.

We apply FUNGI to DINO ViT-S/16 and ViT-B/16 models. Our results, presented in Table 3 and Table 7, demonstrate that FUNGI significantly enhances DINO's performance across all memory bank sizes, with the most substantial improvements observed in smaller memory banks for Pascal VOC. Qualitatively, FUNGI produces sharper and more complete segmentation masks, as shown in Figure 7. Notably, the DINO ViT-B/16 model, when enhanced with our FUNGI approach, achieves competitive results against the current state-of-the-art HummingBird model (Balazevic et al., 2024), with a difference of only 3.5% on Pascal VOC and 3.1% on ADE20K, without any training. This is a particularly promising result, as HummingBird employs a self-supervised pretraining strategy that is specialized for retrieval-based dense prediction tasks, which are the focus of our evaluation in this study.

In addition, we evaluate the efficacy of FUNGI in a data-efficient setup, and report the results in Table 4. Our findings indicate that our method outperforms DINO in this scenario, even when compared to end-to-end fine-tuning of DINO on the downstream task for Pascal VOC.

5.3 Other Modalities

Natural language. We evaluate FUNGI in the text domain using five datasets, described in Appendix D, and two transformer language models: BERT base uncased (Devlin et al., 2019) and T5-small (Raffel et al., 2020). We use the L KL and L SimCLR losses and obtain the SimCLR views by randomly deleting words with a 10% probability. The results are presented in Table 5 and show that FUNGI achieves improvements in the text domain. However, SimCLR gradients struggle with some datasets. Different data augmentation strategies, such as back-translation (Sennrich et al., 2016), or language-specific self-supervised losses, e.g. , masked language modeling (Devlin et al., 2019), may yield more discriminative gradients. We leave this investigation for future work. Furthermore, in Appendix B.5, we investigate the potential of FUNGI in language in-context learning.

Audio. We demonstrate gains for the audio modality in Table 12, where we improve the ESC-50 kNN classification accuracy from 42 . 8% to 47 . 0% and SpeechCommands from 27 . 4% to 29 . 9% with an SSAST backbone (Gong et al., 2022). Further details are provided in Appendix B.2.

5.4 Ablation Studies

Projection head. To compute our self-supervised losses, we first L 2 -normalize the model embeddings (except for SimCLR) and then project them using a randomly initialized linear head. We motivate this choice empirically by ablating these components, and the results in Table 6 show that this configuration produces the most predictive gradients for ImageNet-100.

1

2

3

4

5

6

7

8

9

10

11

12

Layer #

0.0

0.2

0.4

0.6

0.8

1.0

KL

1

2

3

4

5

6

7

8

9

10

11

12

Layer #

DINO

1

2

3

4

5

6

7

8

9

10

11

12

Layer #

SimCLR

embeddings

attn.qkv

attn.proj

mlp.fc1

mlp.fc2

.

Gradients source layer. Throughout the paper, we extract gradients from the self-attention output projection of the last transformer block. Intuitively, deeper layers provide more predictive features, and thus, their gradient should display the same behavior. This assumption is confirmed by our results in Figure 8, where, for all losses, deeper layers consistently produce more predictive gradients. Regarding the choice of layer within a transformer block, for shallower blocks, the second MLP layer is significantly more predictive, but the performance gap becomes insignificant as we move towards deeper blocks, favoring (by a small margin) the attention output projection, which is also more memory efficient, as it has fewer parameters compared to other layers.

6 Discussion and Conclusion

Broader impact. Our method improves the features used for the kNN algorithm. As such, it is a fundamental contribution to Machine Learning. Given the ubiquitous use of kNN, our method could have positive consequences, such as improving reliability and factuality in Retrieval Augmented Generation (RAG) systems, where Language Models are grounded in retrieved pieces of text before generating an answer. We do not foresee any direct negative consequence caused by our method.

Impact of pretraining dataset. Our method works with various backbones, model sizes, and pretraining strategies. However, we have observed that the benefits diminish as the size of the pretraining dataset increases: in Table 1, FUNGI provides a smaller relative improvements on a backbone pretrained with IN21K compared to one pretrained on IN1K, and similarly, in Table 16 the relative improvement over EVA-CLIP (Sun et al., 2023) is smaller compared to the improvement over CLIP (Radford et al., 2021), as they are pretrained on 2B and 400M text-image pairs respectively.

Computational efficiency. Computing FUNGI features introduces an overhead, which we measure in Table 27 by comparing the throughput of a DeIT ViT-B/16 when extracting gradients and embeddings. The DINO and SimCLR losses have the largest overhead, as they forward 12 and 49 views per image, respectively. As shown in Appendix C.1, this number can be reduced, at a performance cost. However, thanks to our dimensionality reduction, the speed of kNN retrieval is not impacted.

7 Conclusion

We have shown that gradients from self-supervised objectives have predictive abilities and encode complementary information to the model embeddings. Building on those findings, we introduced FUNGI , which effectively combines embeddings and gradients into powerful features for retrievalbased tasks. Specifically, we have shown that FUNGI enhance the performance of kNN-based image and text classification across models, pretraining strategies, and downstream datasets, both for full dataset and few shot setups. Moreover, we have shown that FUNGI significantly boost the performance of DINO features for retrieval-based semantic segmentation tasks.

Acknowledgements. We acknowledge the use of the Dutch national supercomputer Snellius to run the experiments presented in this paper. YMA thanks Tengda Han for the initial discussions on using self-supervised gradients for tasks other than learning. WS thanks the Amsterdam ELLIS Unit for their generous funding, which allowed him to visit the Valeo laboratory in Paris. The presentation of this paper at the conference was financially supported by the Amsterdam ELLIS Unit and Qualcomm.

References

Josh Achiam, Steven Adler, Sandhini Agarwal, Lama Ahmad, Ilge Akkaya, Florencia Leoni Aleman, Diogo Almeida, Janko Altenschmidt, Sam Altman, Shyamal Anadkat, et al. Gpt-4 technical report. arXiv preprint arXiv:2303.08774 , 2023. 19

Dimitris Achlioptas. Database-friendly random projections: Johnson-lindenstrauss with binary coins. JCSS , 2003. 4, 22

Yuki M. Asano, Christian Rupprecht, and Andrea Vedaldi. Self-labelling via simultaneous clustering and representation learning. In ICLR , 2020. 3

Mahmoud Assran, Quentin Duval, Ishan Misra, Piotr Bojanowski, Pascal Vincent, Michael Rabbat, Yann LeCun, and Nicolas Ballas. Self-supervised learning from images with a joint-embedding predictive architecture. In ICCV , 2023. 3

Ivana Balazevic, David Steiner, Nikhil Parthasarathy, Relja Arandjelovi´ c, and Olivier Henaff. Towards in-context scene understanding. NeurIPS , 2024. 1, 5, 7, 8, 17, 24

Francesco Barbieri, Jose Camacho-Collados, Francesco Ronzano, Luis Espinosa-Anke, Miguel Ballesteros, Valerio Basile, Viviana Patti, and Horacio Saggion. Semeval 2018 task 2: Multilingual emoji prediction. In IWSE , 2018. 25, 26

Francesco Barbieri, Jose Camacho-Collados, Luis Espinosa Anke, and Leonardo Neves. TweetEval: Unified benchmark and comparative evaluation for tweet classification. In EMNLP , 2020. 25, 26

Luca Bertinetto, João F Henriques, Jack Valmadre, Philip Torr, and Andrea Vedaldi. Learning feed-forward one-shot learners. In NeurIPS , 2016. 2

Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101-mining discriminative components with random forests. In ECCV , 2014. 25, 26

Y-Lan Boureau, Francis Bach, Yann LeCun, and Jean Ponce. Learning mid-level features for recognition. In CVPR , 2010. 1

Mathilde Caron, Piotr Bojanowski, Armand Joulin, and Matthijs Douze. Deep clustering for unsupervised learning of visual features. In ECCV , 2018. 3, 20, 21

Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning of visual features by contrasting cluster assignments. NeurIPS , 2020. 3

Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou, Julien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties in self-supervised vision transformers. In ICCV , 2021. 1, 2, 3, 5, 6, 26

Iñigo Casanueva, Tadas Temˇ cinas, Daniela Gerz, Matthew Henderson, and Ivan Vuli´ c. Efficient intent detection with dual sentence encoders. In NLP4ConvAI , 2020. 25, 26

Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In ICML , 2020a. 2, 3, 5

Xinlei Chen and Kaiming He. Exploring simple siamese representation learning. In CVPR , 2021. 1, 3

Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297 , 2020b. 3

Xinlei Chen, Saining Xie, and Kaiming He. An empirical study of training self-supervised vision transformers. In ICCV , 2021. 26

Mircea Cimpoi, Subhransu Maji, Iasonas Kokkinos, Sammy Mohamed, and Andrea Vedaldi. Describing textures in the wild. In CVPR , 2014. 25, 26

Navneet Dalal and Bill Triggs. Histograms of oriented gradients for human detection. In CVPR , 2005. 1, 3

Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In NACL , 2019. 8, 26

Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR , 2021. 2, 4, 6

Matthijs Douze, Alexandr Guzhva, Chengqi Deng, Jeff Johnson, Gergely Szilvasy, Pierre-Emmanuel Mazaré, Maria Lomeli, Lucas Hosseini, and Hervé Jégou. The faiss library. 2024. 19

Alexei A Efros and Thomas K Leung. Texture synthesis by non-parametric sampling. In ICCV , 1999. 1

Utku Evci, Vincent Dumoulin, Hugo Larochelle, and Michael C Mozer. Head2toe: Utilizing intermediate representations for better transfer learning. In ICML , 2022. 3

Everingham, L. Van Gool, C. K. I. Williams, J. Winn, and A. Zisserman. The pascal visual object classes (voc) challenge. IJCV , 2010. 7

Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In ICML , 2017. 2

Evelyn Fix. Discriminatory analysis: nonparametric discrimination, consistency properties . USAF school of Aviation Medicine, 1985. 1

Spyros Gidaris and Nikos Komodakis. Dynamic few-shot visual learning without forgetting. In CVPR , 2018. 2

Spyros Gidaris, Andrei Bursuc, Nikos Komodakis, Patrick Pérez, and Matthieu Cord. Learning representations by predicting bags of visual words. In CVPR , 2020. 1, 3

Spyros Gidaris, Andrei Bursuc, Gilles Puy, Nikos Komodakis, Matthieu Cord, and Patrick Pérez. Obow: Online bag-of-visual-words generation for self-supervised learning. In CVPR , 2021. 3

Yuan Gong, Yu-An Chung, and James Glass. AST: Audio Spectrogram Transformer. In Interspeech , 2021. 18, 19, 26

Yuan Gong, Cheng-I Lai, Yu-An Chung, and James Glass. Ssast: Self-supervised audio spectrogram transformer. In AAAI , 2022. 8, 18, 19, 26

Yunchao Gong, Liwei Wang, Ruiqi Guo, and Svetlana Lazebnik. Multi-scale orderless pooling of deep convolutional activation features. In ECCV , 2014. 1, 3

Jean-Bastien Grill, Florian Strub, Florent Altché, Corentin Tallec, Pierre Richemond, Elena Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Guo, Mohammad Gheshlaghi Azar, et al. Bootstrap your own latent-a new approach to self-supervised learning. In NeurIPS , 2020. 3

Antonio Gulli. Ag's corpus of news articles. http://groups.di.unipi.it/~gulli/AG_corpus_ of_news_articles.html , 2005. Accessed: 2020-05-21. 25, 26

Ruiqi Guo, Philip Sun, Erik Lindgren, Quan Geng, David Simcha, Felix Chern, and Sanjiv Kumar. Accelerating large-scale inference with anisotropic vector quantization. In ICML , 2020. 1, 6, 24

Moritz Hardt and Yu Sun. Test-time training on nearest neighbors for large language models. In ICLR , 2024. 2

James Hays and Alexei A Efros. Im2gps: estimating geographic information from a single image. In CVPR , 2008. 1

Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In CVPR , 2020. 3

Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollár, and Ross Girshick. Masked autoencoders are scalable vision learners. In CVPR , 2022. 3, 17, 26

Patrick Helber, Benjamin Bischke, Andreas Dengel, and Damian Borth. Eurosat: A novel dataset and deep learning benchmark for land use and land cover classification. JST-AEORS , 2019. 25, 26

Sepp Hochreiter, A Steven Younger, and Peter R Conwell. Learning to learn using gradient descent. In ICANN , 2001. 2

Rui Huang, Andrew Geng, and Yixuan Li. On the importance of gradients for detecting distributional shifts in the wild. NeurIPS , 2021. 5

Herve Jegou, Matthijs Douze, and Cordelia Schmid. Product quantization for nearest neighbor search. TPAMI , 2010. 1

Hervé Jégou, Matthijs Douze, Cordelia Schmid, and Patrick Pérez. Aggregating local descriptors into a compact image representation. In CVPR , 2010. 1, 3

Menglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, and Ser-Nam Lim. Visual prompt tuning. In ECCV , 2022. 2

Jeff Johnson, Matthijs Douze, and Hervé Jégou. Billion-scale similarity search with gpus. T-BD , 2019. 1, 19

Simon Kornblith, Mohammad Norouzi, Honglak Lee, and Geoffrey Hinton. Similarity of neural network representations revisited. In ICML , 2019. 4

Jonathan Krause, Jia Deng, Michael Stark, and Li Fei-Fei. Collecting a large-scale dataset of fine-grained cars. 2013. 25, 26

Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009. 25, 26

Harold W Kuhn. The hungarian method for the assignment problem. Naval research logistics quarterly , 1955. 19

Praveen Kulkarni, Joaquin Zepeda, Frederic Jurie, Patrick Perez, and Louis Chevallier. Hybrid multi-layer deep cnn/aggregator feature for image classification. In ICASSP , 2015. 1, 3

Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, et al. Retrieval-augmented generation for knowledge-intensive nlp tasks. In NeurIPS , 2020. 1

Ping Li, Trevor J Hastie, and Kenneth W Church. Very sparse random projections. In KDD , 2006. 22

Xin Li and Dan Roth. Learning question classifiers. In COLING , 2002. 25, 26

W Johnson J Lindenstrauss and J Johnson. Extensions of lipschitz maps into a hilbert space. Contemporary Mathematics , 1984. 21

Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. What makes good in-context examples for GPT-3? In DeeLIO , 2022. 19

Stuart Lloyd. Least squares quantization in pcm. T-IT , 1982. 19

David G Lowe. Distinctive image features from scale-invariant keypoints. IJCV , 2004. 1, 3

Julien Mairal. Cyanure: An open-source toolbox for empirical risk minimization for python, c++, and soon more. arXiv preprint arXiv:1912.08165 , 2019. 18

Maji, J. Kannala, E. Rahtu, M. Blaschko, and A. Vedaldi. Fine-grained visual classification of aircraft. Technical report, 2013. 25, 26

Fangzhou Mu, Yingyu Liang, and Yin Li. Gradients as features for deep representation learning. In ICLR , 2020. 3

Alex Nichol, Joshua Achiam, and John Schulman. On first-order meta-learning algorithms. arXiv preprint arXiv:1803.02999 , 2018. 2

Maria-Elena Nilsback and Andrew Zisserman. Automated flower classification over a large number of classes. In ICVGIP , 2008. 25, 26

Aude Oliva and Antonio Torralba. Modeling the shape of the scene: A holistic representation of the spatial envelope. IJCV , 2001. 1, 3

Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748 , 2018. 5

Maxime Oquab, Timothée Darcet, Théo Moutakanni, Huy Vo, Marc Szafraniec, Vasil Khalidov, Pierre Fernandez, Daniel Haziza, Francisco Massa, Alaaeldin El-Nouby, et al. Dinov2: Learning robust visual features without supervision. TMLR , 2023. 26

Valentinos Pariza, Mohammadreza Salehi, and Yuki Asano. Hummingbird evaluation for vision encoders, 4 2024. URL https://github.com/vpariza/open-hummingbird-eval . 6

Omkar M Parkhi, Andrea Vedaldi, Andrew Zisserman, and CV Jawahar. Cats and dogs. In CVPR , 2012. 25, 26

Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay. Scikit-learn: Machine learning in Python. JMLR , 2011. 6

Florent Perronnin, Jorge Sánchez, and Thomas Mensink. Improving the fisher kernel for large-scale image classification. In ECCV , 2010. 3

James Philbin, Ondrej Chum, Michael Isard, Josef Sivic, and Andrew Zisserman. Object retrieval with large vocabularies and fast spatial matching. In CVPR , 2007. 17, 19

James Philbin, Ondrej Chum, Michael Isard, Josef Sivic, and Andrew Zisserman. Lost in quantization: Improving particular object retrieval in large scale image databases. In CVPR , 2008. 17, 19

Karol J. Piczak. ESC: Dataset for Environmental Sound Classification. In ACMMM , 2015. 18, 25, 26

Filip Radenovi´ c, Ahmet Iscen, Giorgos Tolias, Yannis Avrithis, and Ondˇ rej Chum. Revisiting oxford and paris: Large-scale image retrieval benchmarking. In CVPR , 2018. 17

Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In ICML , 2021. 9, 17, 26

Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. JMLR , 2020. 8, 26

Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, et al. Imagenet large scale visual recognition challenge. IJCV , 2015. 25, 26

Adam Santoro, Sergey Bartunov, Matthew Botvinick, Daan Wierstra, and Timothy Lillicrap. Metalearning with memory-augmented neural networks. In ICML , 2016. 2

Rico Sennrich, Barry Haddow, and Alexandra Birch. Improving neural machine translation models with monolingual data. In ACL , 2016. 8

Oriane Siméoni, Gilles Puy, Huy V Vo, Simon Roburin, Spyros Gidaris, Andrei Bursuc, Patrick Pérez, Renaud Marlet, and Jean Ponce. Localizing objects with self-supervised transformers and no labels. In BMVC , 2021. 3

Sivic and Zisserman. Video google: A text retrieval approach to object matching in videos. In ICCV , 2003. 1, 3

Jake Snell, Kevin Swersky, and Richard Zemel. Prototypical networks for few-shot learning. NeurIPS , 30, 2017. 2

Richard Socher, Alex Perelygin, Jean Wu, Jason Chuang, Christopher D. Manning, Andrew Ng, and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In EMNLP , 2013. 25, 26

Andreas Steiner, Alexander Kolesnikov, Xiaohua Zhai, Ross Wightman, Jakob Uszkoreit, and Lucas Beyer. How to train your vit? data, augmentation, and regularization in vision transformers. In TMLR , 2022. 6, 7, 17, 20, 26

Quan Sun, Yuxin Fang, Ledell Wu, Xinlong Wang, and Yue Cao. Eva-clip: Improved training techniques for clip at scale. arXiv preprint arXiv:2303.15389 , 2023. 9, 17, 26

Yu Sun, Xiaolong Wang, Zhuang Liu, John Miller, Alexei Efros, and Moritz Hardt. Test-time training with self-supervision for generalization under distribution shifts. In ICML , 2020. 2

Giorgos Tolias, Yannis Avrithis, and Hervé Jégou. To aggregate or not to aggregate: Selective match kernels for image search. In ICCV , 2013. 3

Antonio Torralba, Rob Fergus, and William T Freeman. 80 million tiny images: A large data set for nonparametric object and scene recognition. TPAMI , 2008. 1

Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. In ICML , 2021. 26

Hugo Touvron, Matthieu Cord, and Hervé Jégou. Deit iii: Revenge of the vit. In ECCV , 2022. 17

Koen Van De Sande, Theo Gevers, and Cees Snoek. Evaluating color descriptors for object and scene recognition. TPAMI , 2009. 1

Oriol Vinyals, Charles Blundell, Timothy Lillicrap, Daan Wierstra, et al. Matching networks for one shot learning. NeurIPS , 2016. 2

Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie. The caltech-ucsd birds-200-2011 dataset. 2011. 25, 26

Pete Warden. Speech commands: A dataset for limited-vocabulary speech recognition. arXiv preprint arXiv:1804.03209 , 2018. 18, 25, 26

Alexander Wei, Wei Hu, and Jacob Steinhardt. More than a toy: Random matrix models predict how real-world neural representations generalize. In ICML , 2022. 3

Ross Wightman. Pytorch image models. https://github.com/rwightman/ pytorch-image-models , 2019. 6, 26

Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander M. Rush. Transformers: State-of-the-art natural language processing. In EMNLP , 2020. 26

Benfeng Xu, Quan Wang, Zhendong Mao, Yajuan Lyu, Qiaoqiao She, and Yongdong Zhang. k nn prompting: Beyond-context learning with calibration-free nearest neighbor inference. In ICLR , 2023. 3

I Zeki Yalniz, Hervé Jégou, Kan Chen, Manohar Paluri, and Dhruv Mahajan. Billion-scale semisupervised learning for image classification. arXiv preprint arXiv:1905.00546 , 2019. 1

Xiang Zhang, Junbo Jake Zhao, and Yann LeCun. Character-level convolutional networks for text classification. In NeurIPS , 2015. 25, 26

Yuanhan Zhang, Kaiyang Zhou, and Ziwei Liu. What makes good examples for visual in-context learning? In NeurIPS , 2023. 2

Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing through ADE20K dataset. In CVPR , 2017. 8

Bolei Zhou, Hang Zhao, Xavier Puig, Tete Xiao, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Semantic understanding of scenes through the ade20k dataset. IJCV , 2019. 7

Jinghao Zhou, Chen Wei, Huiyu Wang, Wei Shen, Cihang Xie, Alan Yuille, and Tao Kong. ibot: Image bert pre-training with online tokenizer. In ICLR , 2022. 3, 20

Appendix

Table of Contents

A Algorithm

Algorithm 1 provides pytorch-style pseudocode for the computation of L KL, the gradient extraction, and the computation of FUNGI features (without PCA).

Algorithm 1 PyTorch pseudocode for the KL FUNGI features.

B Additional Experimental Results

In this section we first illustrate additional results that solidify the findings discussed in the main paper, including the evaluation of FUNGI in image retrieval, k-nearest neighbor audio classification, linear classification and clustering and a brief investigation of the performance of gradients from clustering and masked image modeling self-supervised objectives.

In Table 8, we report the performance of embeddings and FUNGI features for some additional backbones, including CLIP and EVA-CLIP models, for which, as explained in the main text, we experience diminishing returns as the pretraining dataset size grows. Moreover, for both models, the SimCLR loss does not produce predictive gradients, which we hypothesize is due to models being saturated to a contrastive loss, as they use a similar objective for pretraining.

In Table 10, we report the mean accuracy and one standard deviation (computed via numpy.std ) across three seeds for a subset of our datasets, using a DeIT ViT-B/16 backbone, showing that the performance improvements of FUNGI are consistent across seeds.

In Figure 11 we evaluate the effectiveness of FUNGI across different ViT model sizes. The findings show that FUNGI improves the results for all three ViT models (ViT-S, ViT-B, and ViT-L), with the most significant improvements observed in the ViT-B model. In Table 9, we provide further evidence for the scalability of FUNGI by evaluating it on several ViT-L and ViT-H backbones.

In Table 7, we report the performance of FUNGI for in-context retrieval-based semantic segmentation on ADE20K, and show that our method outperforms DINO across all memory bank sizes and is competitive against HummingBird.

B.1 Image Retrieval

We evaluate the performance of FUNGI features in image retrieval using the revisited (Radenovi´ c et al., 2018) Oxford (Philbin et al., 2007) and Paris (Philbin et al., 2008) landmarks datasets. We report the mean average precision (mAP) for both the medium (M) and hard (H) splits.

For this task, we use FUNGI features built with DINO and KL gradients, as the SimCLR gradients did not result in good retrieval performance. The results displayed in Table 11 show that FUNGI features improve the retrieval abilities of all backbones, except for DINOv2. Our method is particularly effective when applied on CLIP backbones: on the Paris hard split, we improve by 12.4% and 7.2% for CLIP and EVA-CLIP, respectively.

B.2 Audio Classification

We evaluate FUNGI on the audio modality using SSAST (Gong et al., 2021, 2022), a self-supervised audio spectrogram transformer trained for audio and speech classification, as the backbone. We construct FUNGI features using KL and SimCLR gradients, and test their performance in k-nearest neighbor classification on ESC 50 (Piczak, 2015) and SpeechCommands V2 (Warden, 2018).

We use the same formulation as in the vision experiments for the L KL and L SimCLR objectives. However, for the latter, we obtain 16 views of the same clip by adding uniform noise following Gong et al. (2022). If we define the filter bank of an audio clip as c ∈ R h,w , the noise-augmented clip ˆ c is computed as:

Finally, ˆ c is shifted by a factor sampled from a discrete uniform distribution U ( -10 , 10) . The complete list of hyperparameters used for the audio classification experiments is reported in Table 13.

The results are reported in Table 12, and show that FUNGI features built using KL gradients yield promising results, improving by up to 4.2% on the baseline. On the other hand, using SimCLR gradients does not consistently yield improvements. It rather often causes a performance drop when combined with KL gradients. As with text classification, further research is needed to determine the optimal self-supervised objectives and data augmentation to extract predictive gradients.

B.3 Linear Classification of Image Features

We evaluate FUNGI features in logistic regression, using the implementation from the cyanure library (Mairal, 2019). We train each classifier for a maximum of 300 epochs (30 in the case of ImageNet-1K) using L 2 regularization. For each dataset and feature combination (i.e., embeddings, embeddings + ∇ KL, etc.), we pick the best regularization parameter between 5 linearly spaced values in the interval [5 × 10 -6 , 5 × 10 -4 ] using the validation set. For datasets without a validation set, we generate one using an 80/20 stratified split. The final model is trained using the entire training dataset.

We report the results in Table 15 and Table 16 and find that, in linear classification, FUNGI features are most effective for backbones pretrained using a supervised objective. In contrast, self-supervised backbones do not benefit as much. This is especially evident for DINO and DINOv2, where

FUNGI often yields worse results, especially in a few shot scenarios. Contrary to the k-nearest neighbor classification results, the best feature combination is backbone specific, and in Figure 9, we show that significant performance improvements can be achieved by picking the best feature combination for each backbone.

B.4 Clustering

We evaluate the performance of FUNGI features built with KL and DINO gradients in k-means clustering (Lloyd, 1982) of image features using faiss (Johnson et al., 2019; Douze et al., 2024). Given a dataset with C classes, we compute C clusters via k-means and match clusters to classes using the Hungarian algorithm (Kuhn, 1955). We then measure the average overlap between clusters and classes. The results in Table 14 show that, on average, FUNGI features built with KL and DINO gradients improve the overlap between clusters and classes. In particular, FUNGI can improve the clustering performance by up to 15.8% on Oxford-IIT Pets for a CLIP ViT-L/14 backbone.

B.5 Language In-Context Learning

Liu et al. (2022) has shown that selecting examples for in-context learning using retrieval outperforms a random baseline, and that using encoders fine-tuned on a task similar to the target one further improves performance. Thus, we hypothesize that using FUNGI features to retrieve in-context examples can improve performance, as they contain an adaptation signal to the task at hand. We test this hypothesis by measuring the in-context classification performance of GPT 4o mini (Achiam et al., 2023) using examples retrieved either using embeddings or FUNGI features built with KL and

AR IN1K

ViT-S/16

DeIT

ViT-B/32

AR IN21K

ViT-S/16

AR IN21K

ViT-B/16

DeIT-III

ViT-B/16

MoCov3

ViT-B/16

DeIT

ViT-B/16

DINO

ViT-B/16

CLIP

ViT-B/16

AR IN21K

ViT-L/16

EVA CLIP

ViT-B/16

DINOv2

ViT-B/14

0.65

0.70

0.75

0.80

0.85

0.90

0.95

1.00

+1.6%

+3.3%

+1.2%

+1.1%

+3.1%

+2.1%

+2.4%

+0.2%

+2.0%

+0.4%

+0.8%

+0.5%

Full Dataset

AR IN1K

ViT-S/16

DeIT

ViT-B/32

AR IN21K

ViT-S/16

AR IN21K

ViT-B/16

DeIT-III

ViT-B/16

MoCov3

ViT-B/16

DeIT

ViT-B/16

DINO

ViT-B/16

CLIP

ViT-B/16

AR IN21K

ViT-L/16

EVA CLIP

ViT-B/16

DINOv2

ViT-B/14

0.45

0.50

0.55

0.60

0.65

0.70

0.75

0.80

0.85

0.90

+1.6%

+3.0%

+1.6%

+2.2%

+1.9%

+1.1%

+2.5%

-0.5%

+4.1%

+1.2%

+0.9%

0.0%

Few Shot

Embeddings

FUNGI

SimCLR gradients using a BERT backbone. We retrieve the top 20 most similar training examples for each test sample and ask the model to predict its label using a prompt template similar to the one shown in Listing 1. For a fair evaluation, we set the model temperature to 0. The results listed in Table 17 show that examples retrieved using FUNGI features improve the in-context learning accuracy by up to 2.5% on banking-77.

☎

✆

B.6 Additional Self-Supervised Objectives

In this section, we study the performance of gradients obtained by two additional self-supervised objectives, DeepCluster (Caron et al., 2018) and iBOT (Zhou et al., 2022) in k-nearest neighbor classification on ImageNet-100 using a DeIT ViT-B/16 backbone. DeepCluster is a self-distillation and explicit clustering-based self-supervised method that alternates between clustering image features and training a model to predict cluster assignments. iBOT is an extension of DINO that combines image and patch-level objectives, the latter implemented as a latent-space masked image modeling (MIM) objective, where a learnable patch token replaces a subset of patches, and the model must reconstruct them.

The results are displayed in Figure 10, and show that the objectives used in this work achieve similar performances to the model embeddings, even surpassing them in the case of DINO. At the same time, iBOT and DeepCluster instead produce gradients with relatively poor predictive performance. For the former, a possible reason is that it incorporates a dense loss, whose gradients may not help to discriminate examples on the image level. Regarding DeepCluster, models pretrained using this strategy had worse performance in retrieval tasks compared to supervised pretraining (Caron et al., 2018), which may explain the poor retrieval abilities of its gradients.

B.7 Additional Ablations

DINO data augmentation and head. To maximize the signal-to-noise ratio, we only use local and global crops for the DINO data augmentation. We validate this choice empirically, and the results in Table 18 show that random crops produce more discriminative gradients compared to the standard data augmentation policy. Moreover, we also empirically validate the choice of using two independent heads for the DINO loss in Table 18, showing that this choice is beneficial for kNN classification.

Random Projections. In order to reduce the dimensionality of the gradients we use random projections, an unsupervised dimensionality reduction technique based on the lemma by Lindenstrauss

Deep

Cluster

DINO

KL

iBOT

(No MIM)

iBOT

(MIM)

SimCLR

0.80

0.82

0.84

0.86

0.88

0.90

0.92

0.94

Gradients Accuracy on ImageNet-100

features

ViT S

ViT B

ViT L

0.66

0.68

0.70

0.72

0.74

0.76

+1.93%

+2.95%

+1.87%

Embeddings

FUNGI

&Johnson (1984), which states that for a set of N d -dimensional points and a projection subspace of dimension k ≥ k 0 = O ( ϵ -2 log ( N )) there exist a mapping f : R d → R k that preserves euclidean distances with a distortion of at most ϵ ± 1 . This mapping can be either implemented as a Gaussian, binary (Achlioptas, 2003) or sparse (Li et al., 2006) projection. Our method uses a binary projection, as it's more memory-efficient than a Gaussian matrix, and in Table 19, we compare its performance to the other initializations. The results show that the initialization has little impact on downstream performance, favoring binary projections by a small margin.

PCA. We use Principal Component Analysis (PCA) to combine data from multiple losses at an iso-storage and retrieval speed cost. Given a dataset of FUNGI features, we fit the PCA on the training split and use it to transform training and test splits. Table 20 lists the PCA dimensionalities used for each model architecture and shows that they do not cause a decrease in performance but rather provide a minor improvement on average. Moreover, we compare PCA against binary, Gaussian, and sparse random projections in Table 21 and find that all random projection-based methods result in a drop in accuracy compared to the original features, while PCA consistently improves performance.

C Experimental Details

C.1 Vision Nearest Neighbor Classification Experimental Details

Hyperparameters. We use three losses to extract gradients from vision backbones: L KL , L DINO and L SimCLR. The parameters used for each loss are shown in Table 22. This set of parameters is used consistently across backbones and datasets. While L KL and L DINO are robust to the choice of hyperparameters, L SimCLR is particularly sensitive to the number of positive views, as shown in Figure 12, where performance increases in a logarithmic fashion as more positive views are used, at the cost of gradient extraction speed. While this behavior is consistent across datasets, it has the most significant impact in datasets with many classes, e.g., Flowers102.

SimCLR data augmentation and loss details. Given an image, we patchify it in 49 overlapping views as follows: we first resize the input image to (224 , 224) , and then extract 49 patches of size 112 × 112 , using a stride corresponding to 1 / 6 of the patch size. No other style or color augmentation is used. As the number of patches increases, so does the memory required to compute the loss and the gradients. This problem can be partially tackled by precomputing the negative batch, which in our experiments is picked randomly from the training dataset and kept constant for every input. Moreover, we can observe that the SimCLR loss is only defined for positive pairs, so we only need to compute the similarity of positive pairs to all other pairs, significantly reducing the size of the similarities matrix and memory usage.

4

9

16

25

36

49

Number of Patches

62

63

64

65

66

67

SimCLR Accuracy vs Number of Patches

4

9

16

25

36

49

Number of Patches

10

20

30

40

50

60

70

images/s

SimCLR Num Patches vs Images/s

Images/s

C.2 In-Context Scene Understanding Experimental Details

For the evaluation of the in-context scene understanding abilities of FUNGI features we closely replicate the setup described by Balazevic et al. (2024) for both the full and few shot setups, with two minor exceptions: (1) we use a single augmentation epoch for the full dataset evaluation and (2) we use an anisotropic quantization threshold of 0.2 for the nearest neighbor index, as this parameter was not specified in the paper. The full set of parameters for the evaluation, loss computation and data augmentation is reported in Table 23. As for data augmentation, we use the same policy of Balazevic et al. (2024), and apply each augmentation independently.

In order to construct FUNGI features for this task, we implement a SimCLR loss that contrasts patch tokens from an input image to their nearest neighbors retrieved from a supporting memory bank. In practice, we:

Construct a memory bank of image patches of the same size as the one used for evaluation and its nearest neighbor index with ScaNN (Guo et al., 2020) following the procedure by Balazevic et al. (2024). We call this our support index.

Then, for each image, we:

Resize it to 512 × 512 , compute its [CLS] and patch tokens and project them with a linear head. Excluding the [CLS] token, each image is mapped to 32 2 = 1024 features, as all our backbones use patches of size 16.

For each token, retrieve its two nearest neighbors from the support index and randomly drop 50% of them.

Compute the SimCLR loss, where the patch tokens constitute the positive set and the neighbors the negative batch. This allows us to compute a per-patch gradient.

Drop the [CLS] token, as it does not correspond to a real image patch.

Construct FUNGI features as in Equation 8, where f ( x ) maps an image to patches of dimension d , L 2 normalization is defined as z ′ = z/ || z || 2 and cat indicates concatenation.

C.3 Text Classification Experimental Details

The parameters used to extract gradients from text encoders for L KL and L SimCLR are shown in Table 24. The gradient source layer is always the attention output projection of the last transformer encoder block. We use the same parameters across backbones. No data augmentation is used for the L KL, while for L SimCLR the views are obtained by randomly deleting words independently, where each word has a 10% probability of being deleted.

Parameter

Random crop

p

Scale factor

Brightness jitter

Contrast jitter

p

Saturation jitter

Hue jitter

p

Max brightness

Max contrast

∆

Max saturation

∆

Value

1.0

[0

.

5

,

2

0.5

0.5

0.5

0.5

0.1

0.1

0.1

0.1

D Data and Models

We investigate the performance of our gradient-enhanced features on 11 image classification datasets, namely CIFAR 10 and CIFAR 100 (Krizhevsky et al., 2009), Oxford Flowers 102 (Nilsback & Zisserman, 2008), Food101 (Bossard et al., 2014), ImageNet-1K (Russakovsky et al., 2015), FGVC Aircraft (Maji et al., 2013), CUB 200-2011 (Wah et al., 2011), Oxford-IIT Pets (Parkhi et al., 2012), Stanford Cars (Krause et al., 2013), DTD Textures (Cimpoi et al., 2014) and EuroSAT (Helber et al., 2019), 5 text classification datasets: TREC (Li & Roth, 2002) in its coarse version, banking-77 (Casanueva et al., 2020), Stanford Sentiment Treebank (SST) (Socher et al., 2013) in its fine-grained version, AG news (Zhang et al., 2015; Gulli, 2005) and tweet eval (emoji) (Barbieri et al., 2018, 2020) and 2 audio classification datasets: ESC 50 (Piczak, 2015), an environmental sound classification dataset, and SpeechCommands V2 (Warden, 2018), a keyword spotting task, where the goal is to classify utterances into a predefined set of words. The datasets, their license and citations are also listed in Table 25.

We follow the evaluation protocol for each individual dataset and report the top-1 accuracy for CIFAR 10 and 100, Food101, ImageNet-1K, Stanford Cars, EuroSAT, DTD Textures, CUB 200-2011, TREC, banking-77, SST, AG news, tweet eval (emoji), ESC 50 and SpeechCommands V2, and the mean-per-class accuracy for Flowers102, FGVC Aircraft and Oxford-IIT Pets.

.

0]

∆

p

p

∆

We use the default splits defined by torchvision or the dataset authors where possible. As EuroSAT does not explicitly define a test split, we use an 80/20 stratified split as indicated by the dataset paper. We always report metrics on the test splits, with the exception of ImageNet, for which we use the validation split.

We evaluate FUNGI features across several architectures, pretraining strategies and model sizes. These are listed in Table 26, alongside their license, data type and citation.

E Compute Resources

The gradient features were extracted using a machine with a single NVIDIA A100 GPU with 40GB of VRAM. Considering the inference times listed in Table 27, replicating the k-nearest neighbor image classification results would require approximately 27 GPU hours per backbone using float16 , which we use throughout all our experiments. As we evaluate our method across 17 vision backbones, reproducing these results would require 459 GPU hours. As for the text and audio classification experiments, they require around 3 GPU hours per backbone, for a total of 9 hours. The extracted gradient features were reused for the linear probing and clustering experiments, the former requiring 168 hours on a machine with a single AMD EPYC 7H12 CPU and the latter requiring 18 hours on a machine with a single NVIDIA A100 GPU with 40GB of VRAM.

Finally, additional experiments such as image retrieval, in-context learning, and ablation studies required approximately 84 hours, while the preliminary experiments for this paper required a negligible amount of compute.

NeurIPS Paper Checklist

1. Claims

Question: Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope?

Answer: [Yes]

Justification: we analyze the predictive abilities of gradients and show that they are complementary the model embeddings in Section 3. We show that our method improves k-nearest neighbor classification for vision, text and audio in Sections 5.1 and 5.3. We evaluate FUNGI in linear probing in Appendix B.3, image retrieval in Appendix B.1 and visual in-context learning in Section 4.3.

2. Limitations

Question: Does the paper discuss the limitations of the work performed by the authors?

Answer: [Yes]

Justification: we discuss limitations concerning the backbone pretraining datasets and the computational efficiency in Section 6.

Guidelines:

3. Theory Assumptions and Proofs

Question: For each theoretical result, does the paper provide the full set of assumptions and a complete (and correct) proof?

Answer: [NA]

Justification: we do not provide any theoretical result in the paper.

4. Experimental Result Reproducibility

Question: Does the paper fully disclose all the information needed to reproduce the main experimental results of the paper to the extent that it affects the main claims and/or conclusions of the paper (regardless of whether the code and data are provided or not)?

Answer: [Yes]

Justification: we describe all our self-supervised objectives and data augmentation in Section 4. Additional details regarding the self-supervised objectives are described in Appendices C.1, C.2 and C.3. The complete set of hyperparameters used for all our experiments are listed in Table 22, Table 23 and Table 24. Furthermore, Appendix A contains pytorch-like pseudocode that illustrates how to perform gradient extraction for one of our objectives. Finally, we open sourced the code used to run our experiments at https://github.com/WalterSimoncini/no-train-all-gain .

5. Open access to data and code

Question: Does the paper provide open access to the data and code, with sufficient instructions to faithfully reproduce the main experimental results, as described in supplemental material?

Answer: [Yes]

Justification: we evaluate our method using only publicly available datasets and backbones, and we release the code to reproduce our experimental results at this URL https:// github.com/WalterSimoncini/no-train-all-gain . The code documentation and the supplementary materials contain all the information needed to replicate our experiments.

6. Experimental Setting/Details

Question: Does the paper specify all the training and test details (e.g., data splits, hyperparameters, how they were chosen, type of optimizer, etc.) necessary to understand the results?

Answer: [Yes]

Justification: to the best of our knowledge, we have provided all the necessary hyperparameters, dataset splits, and experimental details to fully reproduce our results.

7. Experiment Statistical Significance

Question: Does the paper report error bars suitably and correctly defined or other appropriate information about the statistical significance of the experiments?

Answer: [Yes]

Justification: In Table 10, we show that our method is consistent across three seeds by reporting the average performance and one standard deviation. The results support our claim that FUNGI features provide consistent improvements over the model embeddings. We calculate the standard deviation using numpy.std . We only report the standard deviation for this experiment, as computing it for all backbone and dataset combinations would require a significant amount of compute.

8. Experiments Compute Resources

Question: For each experiment, does the paper provide sufficient information on the computer resources (type of compute workers, memory, time of execution) needed to reproduce the experiments?

Answer: [Yes]

Justification: We fully disclose the hardware and the run time of all our experiments in appendix E.

9. Code Of Ethics

Question: Does the research conducted in the paper conform, in every respect, with the NeurIPS Code of Ethics https://neurips.cc/public/EthicsGuidelines ?

Answer: [Yes]

Justification: we have read the code of ethics and made sure that the paper conforms to it in every aspect.

10. Broader Impacts

Question: Does the paper discuss both potential positive societal impacts and negative societal impacts of the work performed?

Answer: [Yes]

Justification: in the main paper, we discuss potential broader impacts, but as we make a fundamental contribution to machine learning, we do not foresee any direct negative consequences from our method.

11. Safeguards

Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pretrained language models, image generators, or scraped datasets)?

Answer: [NA]

Justification:

12. Licenses for existing assets

Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected?

Answer: [Yes]

Justification: we properly cite all models, datasets, and code implementations used to run our experiments. A summary of all models and datasets used in the paper are available in Table 26 and Table 25, along with their license and citation. We made sure to adhere to the usage guidelines and license of each individual asset.

13. New Assets

Question: Are new assets introduced in the paper well documented and is the documentation provided alongside the assets?

Answer: [Yes]

Justification: we release two new assets: (a) the code to replicate our experimental results, available at https://github.com/WalterSimoncini/no-train-all-gain and (b) a library to extract FUNGI features from ViT backbones, available at https://github.com/ WalterSimoncini/fungivision . Both repositories include proper documentation and are released under the MIT license.

14. Crowdsourcing and Research with Human Subjects

Question: For crowdsourcing experiments and research with human subjects, does the paper include the full text of instructions given to participants and screenshots, if applicable, as well as details about compensation (if any)?

Answer: [NA]

Justification:

15. Institutional Review Board (IRB) Approvals or Equivalent for Research with Human Subjects

Question: Does the paper describe potential risks incurred by study participants, whether such risks were disclosed to the subjects, and whether Institutional Review Board (IRB) approvals (or an equivalent approval/review based on the requirements of your country or institution) were obtained?

Answer: [NA]

Justification:

Peer reviews:
{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper presents an unsupervised method to enhance the representations of pretrained models. The authors observe that gradient features from various self-supervised objectives are helpful to enhance k-nearest neighbor (KNN) retrieval. The proposed method, FUNGI, combines the embeddings of a pretrained model with gradients from different self-supervised objectives, followed with dimensionality reduction from PCA. Experiments on Image classification, semantic segmentation and text classification show the effectiveness of proposed algorithm.\n\nSTRENGTHS:\nThis paper is well written and eazy to follow, with nice charaterization of background and related works. The algorithm is well motivated. The plots and tables are also well-structured with clear information. The idea to combine the gradient features from multiple objective is simple and effective. The proposed algorithm is evaluated on different pretrained models and different tasks.\n\nWEAKNESSES:\n1. My biggest concern is that the evaluation of proposed method is limited to nearest neighbor retrieval (though I agree that this task is important). As a method of feature engineering, it'd be good to test the performance of (few-shot) linear prob or K-Means clustering.\n\n2. Lack of analysis on random projection. For example, [6] uses random Gaussian matrix to project the gradient features to low-dim and shows that it perseves inner-product with high probability. In FUNGI, the projection matrix is sampled in {-1, 1} by Bernoulli random variables. What properties would it have?\n\n3. Some related works are not covered. There've been a number of works using gradient as features for downstream tasks, for example [1-3]. It'd be good to metion them and discuss the intuition why gradient could be used as features for KNN retrieval. The same also holds for the analysis on self-supervised learning objectives, for example [6].\n\n[1] Gradients as Features for Deep Representation Learning, ICLR 2020.\n\n[2] More than a toy: Random matrix models predict how real-world neural representations generalize. ICML 2022. \n\n[3] Head2Toe: Utilizing Intermediate Representations for Better Transfer Learning. ICML 2022.\n\n[4] A Kernel-Based View of Language Model Fine-Tuning. ICML 2023.\n\n[5] Trak: Attributing model behavior at scale. ICML 2023.\n\n[6] Learning by Reconstruction Produces Uninformative Features For Perception. 2024\n\nQUESTIONS:\n1. What's the dimension of the gradient feature? What's the time cost of random projection and PCA?\n\n2. What's the advantage of random projection with matrix sampled from {-1, 1}, compared to random Gaussian matrix? \n\n3. For text classification, nearest neightbors are used to select examples for in-context learning [1]. Would FUNGI be helpful in this process?\n\n\n[1] What makes good in-context examples for gpt-3? ACL 2022.\n\nLIMITATIONS:\nThe author have discussed some of the limtations in the paper. For others, please refer to \"Weakness\"", "TITLE": "Official Review", "RECOMMENDATION": 8, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2024-07-10"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThe paper proposes a simple method named FUNGI - Features from Unsupervised Gradients, to improve the representations of Vision Transformers (ViTs). Specifically, FUNGI uses gradients from self-supervised objectives to augment the embeddings from pre-trained models. FUNGI involves three straightforward steps - (i) compute gradients at a specific layer for selected self-supervised objectives (ii) project the gradients to a lower dimension (iii) concatenate these projected features with the model’s embeddings for kNN-based classification. Extensive experiments across various datasets, pre-trained models, and tasks demonstrate the effectiveness of the proposed approach.\n\nSTRENGTHS:\n- **Presentation**: The paper is presented well and well-structured overall. The use of gradients for feature enhancement in ViTs is motivated well through simple analytical experiments. All the experimental setups have been clearly explained and the results are presented well, covering a wide range of pre-trained models and datasets.\n \n- **Simplicity**: The proposed method is simple and easy to understand and implement. Moreover, the authors have provided the PyTorch pseudocode in the supplementary, which makes it easier to replicate the results of the proposed method.\n\n- **Results**: The results from Fig. 5, Tables 1, 2, 3, and 5 demonstrate the effectiveness of FUNGI across various datasets, pre-trained models, and tasks (visual and text-based). Given that the improvements come with no training, they are noteworthy.\n\nWEAKNESSES:\n- **Missing backbones**: While the authors have presented results on a comprehensive list of backbones, a few recent backbones are missing, which are listed below:\n    - Touvron, Hugo, Matthieu Cord, and Hervé Jégou. \"Deit iii: Revenge of the vit.\" ECCV 2022.\n    - Vasu, Pavan Kumar Anasosalu, et al. \"Mobileclip: Fast image-text models through multi-modal reinforced training.\" CVPR 2024.\n\n- **Scalability**: There is no discussion on how FUNGI scales with larger ViT models. All the analyses are performed with ViT-B and ViT-S. The authors should also demonstrate the scalability of FUNGI with larger ViT models across the various pre-training schemes that they have presented results on for ViT-B and ViT-S.\n\nQUESTIONS:\n1. Does FUNGI also work for CNNs and CNN-ViT hybrid architectures? For example, MobileCLIP mentioned above consists of convolutional layers and attention-based layers. Would FUNGI work for CNNs such as CLIP ResNet-50 and CNN-ViT hybrids such as MobileCLIP?\n\n2. Since FUNGI is a generic gradient-based method, does it extend beyond classification tasks? Would FUNGI work for generative models such as LLMs, VLMs such as Llava, and BLIP? The application of FUNGI to any such model would greatly improve the impact of the work.\n\nLIMITATIONS:\nThe authors have adequately addressed the limitations of the work.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2024-07-14"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\n- The draft introduces a feature enhancement technique called FUNGI (Features from Unsupervised GradIents) for vision transformers. - \n- The core idea is to leverage the un/self-supervised loss gradients at an arbitrary hidden layer within a vision backbone (the default option being the attention output projection of the last transformer block) to enhance the feature embeddings\n- These gradients, along with the pre-trained embeddings, are shown to achieve higher accuracy in kNN classification across various datasets and transformer backbones.\n- Comprehensive experimentation evaluated this technique in three activities (image classification, in-context scene understanding, and text classification). Consistent gains in accuracy are reported across model backbones, tasks/datasets, learning scenarios, etc.\n\nSTRENGTHS:\n1. The core contribution is to show that gradients w.r.t. self-supervised objectives have complementary information to the pre-trained model embeddings. This information can be combined to achieve better performance. In my opinion, this can be claimed to be a novel representation. \n\nIt is well-known that pretraining on self-supervised objectives results in moderately powerful features. Contrary to this notion, the draft presents a method to enrich the trained embeddings with more information from multiple such self-supervision objectives. However, the clever thing the draft does is to avoid costly fine-tuning by concatenating the (one-step) gradients for the learned embeddings toward the self-supervision tasks.\n\n2. The authors have introduced a \"generic\" technique to enhance the performance of the kNN classifier built on top of a transformer backbone.\n3. The experimental evaluation of the proposed technique is sound, with several backbones, various unsupervised objectives, different tasks/datasets, ablations, initial verifications (Figures 2 & 3), etc.\n\nWEAKNESSES:\n1. Although complementary information is extracted as gradients, it is computationally demanding - it requires one (partial) backpropagation for each self-supervision objective, total backpropagation operations are linear with respect to the number of objectives, the added linear projection head (h), and finally, the dimensionality reduction to match the dimension of the embedding. One may opine that the additional cost is not worth performance gains (poor returns). Overall, the gains may not be significant to be deployed in practice.\n\n2. The draft provides no sound reasoning regarding the performance enhancement resulting from the self-supervised gradients. Section 3 (figures 2 & 3) empirically proves that these gradients complement the embeddings but doesn't discuss how/why.\n\nQUESTIONS:\n1. It would be interesting to understand (if not already) the role of the pre-trained embedding. In other words, can a half-trained or untrained (random) embedding also extract discriminative information from the self-supervised objectives similar to the pre-trained one? Authors may clarify this.\n\n2. Authors may clarify the second weakness mentioned in the above section.\n\nLIMITATIONS:\nThe authors addressed the limitations and potential societal impact of the proposed work.", "TITLE": "Official Review", "RECOMMENDATION": 4, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 2, "DATE": "2024-07-18"}

comments: SUMMARY:
The paper introduces an approach to augment the feature representations from ViTs, by utilizing the gradients from self-supervised losses. The gradients from the attention output projection of the last transformer block is extracted and projected into the output embedding space using random-projections and PCA to compute FUNGI. Exhaustive experimental evaluation across vision and NLP datasets brings out the efficacy of the approach.

STRENGTHS:
+ Novel methodology
+ Simple approach
+ Exhaustive experimental analysis

WEAKNESSES:
- The method to generate features from unsupervised gradients seems very empirical. Any theoretical backing for the good results would further improve the paper.

QUESTIONS:
- Intuitively, the proposed approach "encodes first-order learning signals that are specific to the downstream data" (line 46). If we use task specific loss functions, instead of self-supervised loss, would it further help with the adaptation of the latent representation towards the downstream task?
- How much is the method dependent on the PCA that is performed to reduce the dimensionality (line 141)? Would there be any other alternative to try?
- FUNGI has been found effective is augmenting features used for k-NN based classification and scene understanding task. Can FUNGI features be consumed by downstream discriminative classifiers that are trained with softmax?
- Would be good to clarify whether the reported numbers are the mean of multiple runs.

LIMITATIONS:
NA
TITLE: Official Review
SOUNDNESS_CORRECTNESS: 3
DATE: 2024-07-23