NUDGE: Lightweight Non-Parametric Fine-Tuning of Embeddings for Retrieval

## Abstract

Abstract k k -Nearest Neighbor search on dense vector embeddings ( k k -NN retrieval) from pre-trained embedding models is the predominant retrieval method for text and images, as well as Retrieval-Augmented Generation (RAG) pipelines. In practice, application developers often fine-tune the embeddings to improve their accuracy on the dataset and query workload in hand. Existing approaches either fine-tune the pre-trained model itself or, more efficiently, but at the cost of accuracy, train adaptor models to transform the output of the pre-trained model. We present NUDGE, a family of novel non-parametric embedding fine-tuning approaches that
are significantly more accurate and efficient than both sets of existing approaches. NUDGE directly modifies the embeddings of data records to maximize the accuracy of k k -NN retrieval. We present a thorough theoretical and experimental study of NUDGE’s non-parametric approach. We show that even though the underlying problem is NP-Hard,
constrained variations can be solved efficiently. These constraints
additionally ensure that the changes to the embeddings are modest, avoiding large distortions to the semantics learned during pre-training. In experiments across five pre-trained models and nine standard text and image retrieval datasets, NUDGE runs in minutes and often improves NDCG@10 by more than 10% over existing fine-tuning methods. On average, NUDGE provides 3.3 × \times and 4.3 × \times higher increase in accuracy and runs 200 × \times and 3 × \times faster, respectively, over fine-tuning the pre-trained model and training adaptors . 1 1 1 Code available at https://github.com/szeighami/nudge .

## 1 Introduction

$k$-Nearest Neighbor search on dense vector embeddings ($k$-NN retrieval) from pre-trained embedding models is the de-facto standard for text and image retrieval, as well as in Retrieval-Augmented Generation (RAG) pipelines. (Lewis et al., ; Li et al., ; Gao et al., ; Patil et al., ; Du et al., ; Liu et al., ). Given $n$ data records (e.g., text chunks or images), $k$-NN retrieval embeds them using a pre-trained model as $d$-dimensional vectors in $\mathcal{R}^{d}$. To answer a query, it similarly embeds the query in $\mathcal{R}^{d}$ and retrieves the top-$k$ data records whose embeddings have the highest cosine similarity (or inner product) with the query embedding. By simply performing a top-$k$ look-up (often through vector databases), the simplicity and efficiency of $k$-NN retrieval has made it increasingly popular and often preferred to other retrieval paradigms, e.g., late interaction (Khattab & Zaharia, ; Santhanam et al., ) or generative retrieval (Tay et al., ; Wang et al., ). However, the out-of-the-box pre-trained model is often not sufficiently accurate on the dataset or queries in hand, and typically fine-tuning is used to improve the accuracy.

There are two standard approaches to fine-tuning embeddings: fine-tuning the pre-trained models directly (referred to henceforth as PTFT) or training adaptor models on top of the pre-trained models (Zhao et al., ; Zhou et al., ; Aarsen, ; Suvansh Sanjeev, ; LlamaIndex, ). PTFT can be more accurate but comes with practical challenges: it (1) requires access to the model parameters and must rely on third-party APIs for closed-source models (^2^22E.g., OpenAI currently does not provide an interface for fine-tuning embedding model (OpenAI, ).), (2) is computationally expensive, and (3) incurs further hosting and maintenance costs for deployment of the fine-tuned model. An alternative is to learn an Adaptor, $\hat{g}_{\theta}$, a transformation of the output of the (frozen) pre-trained model, $\hat{f}$, so that the function $\hat{g}_{\theta}\circ\hat{f}$ generates accurate data and/or query embeddings. Training $\hat{g}_{\theta}$ can be done model-agnostically, that is, with only black-box access to the pre-trained model, addressing (1). Moreover, Adaptors are typically small models, such as linear models (LlamaIndex, ), addressing (2), and lowering the associated costs in (3). Nonetheless, experimental results show, at best, modest accuracy gains from using Adaptors. We, therefore, lack a fine-tuning approach for $k$-NN retrieval that is simultaneously effective, efficient, and easy-to-use.

Figure: Figure 1: NUDGEs change embeddings within a constrained region to maximize similarity with training queries. Data embeddings are colored based on queries for which they are the ground-truth answers.
Refer to caption: x1.png

We present NUDGE, a family of approaches to non-parametrically fine-tune embeddings efficiently. NUDGE methods (or NUDGEs) are surprisingly effective, model-agnostic, and incur no additional deployment cost. NUDGEs take a novel non-parametric view of embedding fine-tuning: they view the embeddings themselves as parameters of the $k$-NN retrieval algorithm and directly modify the embeddings of data records to maximize the accuracy of $k$-NN retrieval. Although we show that the underlying optimization problem is NP-Hard in general, and can lead to overfitting if data embeddings are allowed to change arbitrarily, NUDGEs efficiently solve constrained variations of this problem formulated to avoid overfitting. As shown in Fig. 1, NUDGEs change each data embedding to maximize the similarity between the data embedding and the training queries to which the data record is a correct answer, while constraining how and by how much the embedding can change. Intuitively, the constraints allow for enough modifications to the embeddings to improve accuracy on the dataset in hand while avoiding large distortion that would offset the semantics learned during pre-training. Fig. 1 shows an example of the constrained region used, where new embeddings are constrained to be normalized (i.e., to fall on the unit ball), and the magnitude of changes to the embeddings to be bounded. NUDGEs solve the constrained optimization problems in closed form, presenting simple and effective update formulae for embedding fine-tuning.

NUDGE’s non-parametric formulation contrasts with the parametric approaches adopted by PTFT and Adaptors that increase the similarity between query and answer pairs through contrastive-type losses (Zhao et al., ). Through constrained non-parametric optimization, NUDGEs instead make bounded local changes to each individual data embedding. On the other hand, PTFT and Adaptors make potentially large global changes to the embedding function that modify the embeddings of all possible data and queries. However, learning modifications that generalize across all data and queries is difficult from the typically small training sets available during fine-tuning. Instead, models end up overfitting to the training set. Besides accuracy gains, the non-parametric formulation allows for efficient closed-form solutions to the optimization problem. NUDGEs use computation equivalent (up to a log factor) to a single training and validation iteration of Adaptors.

We present a thorough experimental evaluation, showing that NUDGEs significantly outperform Adaptors and PTFT on standard text retrieval datasets from BEIR (Thakur et al., ) and KILT (Petroni et al., )
and image retrieval datasets COCO (Lin et al., ) and Flickr (Young et al., ). NUDGEs improve common metrics such as Recall@$10$ and NDCG@$10$ by up to 16.0% more than both PTFT and Adaptors and 24.4% over no fine-tuning. Across 9 different datasets and 5 different embedding models NUDGEs consistently outperform PTFT and Adaptors, often providing 10% more increase in NDGC@10. NUDGEs avoid performance degradation on out-of-distribution queries that affect parametric approaches, ensuring that the significant accuracy gains for in-distribution queries do not come at the expense of out-of-distribution queries.
Moreover, NUDGEs are model-agnostic and can be used with any (potentially closed-source) embedding model. Overall, NUDGEs are trained in minutes on datasets with millions of records, and the fine-tuned embeddings can be used directly without any additional model inference cost, providing significant accuracy boosts almost “for free”.

Contributions and Overview. To summarize, our contributions are as follows.

- •
We formalize the notion of non-parametric embedding fine-tuning and show that the underlying unconstrained non-parametric optimization problem is NP-Hard
(Sec. 3.1).
- •
We present NUDGE-M and NUDGE-N, two methods that optimally solve constrained variations of the problem (Sec. 3.2).
NUDGE-M updates data embeddings to maximize the similarity between the embeddings of queries and their ground-truth data records subject to a bound on the magnitude of change to the embeddings.
NUDGE-N adopts a similar approach, but additionally constrains the embeddings to be normalized.
- •
We show NUDGE variants consistently outperform parametric fine-tuning methods with thorough experiments on 5 embedding models and 9 standard retrieval datasets (Sec. 4).

## 2 Preliminaries

Notation. We use bar $\bar{}$ on top of letters to denote raw data/queries that are not embedded. We use boldface capital letters to denote matrices (mostly used to represent embeddings), e.g., ${\bm{X}}\in\mathcal{R}^{r\times s}$ is an $r\times s$ matrix, and use ${\bm{X}}_{i}$ to refer to the $i$-th row of the matrix, which is a vector, ${\bm{X}}_{i}\in\mathcal{R}^{s}$. $\|{\bm{x}}\|$ refers to the L2 norm of a vector ${\bm{x}}$, and $\|{\bm{X}}\|$ refers to the vector of row-wise norms, $(\|{\bm{X}}_{1}\|,...,\|{\bm{X}}_{r}\|)$. We use $[s]$ to refer to the set $\{1,2,...,s\}$.

$k$-Nearest Neighbor Retrieval. Given a dataset, $\bar{D}$ of $n$ records (e.g., text chunks or images), $k$-NN retrieval first embeds the data records using an embedding model, $\mathcal{E}_{D}$, to generate an embedding matrix ${\bm{D}}\in\mathcal{R}^{n\times d}$ where $d$ is the embedding dimensionality. The $i$-th row, ${\bm{D}}_{i}$, of ${\bm{D}}$ is the embedding of the $i$-th record, $\bar{D}_{i}$, that is, ${\bm{D}}_{i}=\mathcal{E}_{D}(\bar{D}_{i})$. To answer a query $\bar{q}$, $k$-NN retrieval first embeds the query using an embedding model, $\mathcal{E}_{Q}$ (often $\mathcal{E}_{Q}$ and $\mathcal{E}_{D}$ are the same, but can be different, especially in a multi-modal setting) to obtain ${\bm{q}}=\mathcal{E}_{Q}(\bar{q})$. $k$-NN retrieval then returns the top-$k$ records in $\bar{D}$ whose embeddings have the highest similarity to ${\bm{q}}$, measured by either the inner product or cosine similarity, i.e., the $k$ records $\bar{D}_{{i}_{1}},...,\bar{D}_{{i}_{k}}$ that correspond to the $k$ highest values in the set $\{{\bm{D}}_{1}\cdot{\bm{q}},...,{\bm{D}}_{n}\cdot{\bm{q}}\}$ when using the inner product similarity metric. By default, we use the inner product, which can be applied to normalized embeddings to obtain cosine similarity.

Ground-Truth Answers. Queries can require retrieving multiple data records, and each data record can have a different degree of relevance to the query. For simplicity, here, we present our results in the setting where a query, $\bar{q}$, requires retrieving a single ground-truth data record. We refer to the ground-truth data record for a query, $\bar{q}$, as the ground-truth answer to the query and often refer to the data record with its index $y$, $y\in[n]$. Extensions to multiple ground-truth data records (each with potentially different degrees of relevance to the query) is straightforward and presented in Appx. D.

Fine-Tuning. Fine-tuning aims to improve retrieval accuracy for the dataset $\bar{D}$ through optimizing embeddings. We let ${\bm{D}}^{*}\in\mathcal{R}^{n\times d}$ denote the fine-tuned data embeddings obtained after fine-tuning, where ${\bm{D}}^{*}_{i}\in\mathcal{R}^{d}$ is the fine-tuned embedding for the $i$-th data record. We consider a supervised setting where a query set with corresponding ground-truth answers is available, consisting of the query set, $\bar{Q}$, and a set, $Y$, of ground-truth answers, where $Y_{j}$ is the index of the ground-truth answer for the $j$-th query, $\bar{q}_{j}$. We split this set into two, a training set $\bar{Q}^{T},Y^{T}$ and a validation set $\bar{Q}^{V},Y^{V}$, with $n_{T}$ and $n_{V}$ queries, respectively. Let ${\bm{Q}}^{T}\in\mathcal{R}^{n_{T}\times d}$ and ${\bm{Q}}^{V}\in\mathcal{R}^{n_{V}\times d}$ be matrices containing embeddings for training and validation queries. The training set can be collected over time from user interactions with the system, by collecting labels, or by generating synthetic training data using LLMs (e.g., LlamaIndex (); Meng et al. ()).

## 3 Non-Parametric Embedding Fine-Tuning

Our NUDGE approach views embeddings as parameters of the $k$-NN retrieval algorithm, optimizing the embeddings directly to improve retrieval accuracy. In Sec. 3.1, we formalize the notion of non-parametric embedding fine-tuning by stating two optimization problems, one directly maximizing a retrieval accuracy metric and one maximizing similarity between queries and their ground-truth answers. Maximizing accuracy is the final goal, but similarity is a simpler surrogate to optimize in practice. Nonetheless, we show that the former is NP-hard and the latter is unbounded (i.e., the objective can be improved indefinitely). Moreover, since both optimization problems allow embeddings to arbitrarily change (i.e., are unconstrained), directly solving either problem can lead to overfitting. In Sec. 3.2, we present NUDGE, a family of approaches that solve a combination of constrained variations of the two optimization problems to address generalization and efficiency challenges.

### 3.1 Unconstrained Non-Parametric Embedding Fine-Tuning Problems

Let ${\bm{\Delta}}\in\mathcal{R}^{n\times d}$ be the modification to be learned to the embeddings, so that its $i$-th row, ${\bm{\Delta}}_{i}$, is the modification to ${\bm{D}}_{i}$. That is, after fine-tuning, the final embedding is ${\bm{D}}^{*}={\bm{D}}+{\bm{\Delta}}$. We use ${\bm{Q}}$ and $Y$ to refer to a generic query embedding matrix with corresponding ground-truth answers containing $N$ queries. ${\bm{Q}}$ and $Y$ can respectively be either ${\bm{Q}}^{T}$ and $Y^{T}$ or ${\bm{Q}}^{V}$ and $Y^{V}$.

MaxA-EFT. Maximum Accuracy Embedding Fine-Tuning Problem, MaxA-EFT, is the problem of finding ${\bm{\Delta}}$ to fine-tune data embeddings that maximizes the number of queries in ${\bm{Q}}$ answered correctly, formalized as follows. For a query embedding matrix ${\bm{Q}}$ with ground-truth answers $Y$, let $\mathcal{I}_{i}({\bm{\Delta}})$, for $i\in[N]$, be the indicator variable denoting if the $i$-th query is answered correctly after fine-tuning with ${\bm{\Delta}}$. Formally, $\mathcal{I}_{i}({\bm{\Delta}})=1$ if the following holds, and zero otherwise

$$ $\displaystyle{\bm{Q}}_{i}\cdot({\bm{D}}_{Y_{i}}+{\bm{\Delta}}_{Y_{i}})>{\bm{Q}}_{i}\cdot({\bm{D}}_{j}+{\bm{\Delta}}_{j}),\quad\forall j\in[n]\setminus Y_{i}.$ (1) $$

###### Problem 1 (MaxA-EFT) .

MaxA-EFT is the problem of finding ${\bm{\Delta}}$ to maximize the number of queries answered correctly after fine-tuning with ${\bm{\Delta}}$, i.e., ${\arg\max}_{{\bm{\Delta}}\in\mathcal{R}^{n\times d}}\sum_{i\in[N]}\mathcal{I}_{i}({\bm{\Delta}}).$

###### Theorem 1 .

MaxA-EFT is NP-Hard.

Theorem 1 is proved by reduction from the Maximum Feasible Linear Subsystem problem as studied in  Amaldi & Kann (), see Appx. B.1. Apart from the NP-hardness, MaxA-EFT allows data embeddings to be arbitrarily changed by ${\bm{\Delta}}$. This can distort the semantics captured in ${\bm{D}}$ by the pre-trained model, and lead to poor generalization to queries outside of ${\bm{Q}}$.

MaxS-EFT. An alternative formulation is Maximum Similarity Embedding Fine-Tuning Problem,

$$ $\displaystyle\underset{{\bm{\Delta}}\in\mathcal{R}^{n\times d}}{\arg\max}\sum_{i\in[N]}{\bm{Q}}_{i}\cdot({\bm{D}}_{Y_{i}}+{\bm{\Delta}}_{Y_{i}}),$ (2) $$

referred to as MaxS-EFT. Here, we change data embeddings to maximize the similarity between queries and ground-truth answers,
a standard optimization objective (e.g., Henderson et al. (), SentenceTransformers ()). However, the non-parametric formulation makes Eq. 2 an unconstrained optimization problem with a linear objective, so the problem is unbounded and has no optimal solution. Moreover, setting ${\bm{\Delta}}_{Y_{i}}$ so that ${\bm{Q}}_{i}\cdot{\bm{\Delta}}_{Y_{i}}>0$ and increasing the magnitude of ${\bm{\Delta}}_{Y_{i}}$ arbitrarily improves the objective, yielding trivial solutions with poor generalization to unseen queries.

###### Problem 1 (MaxA-EFT) .

###### Theorem 1 .

### 3.2 NUDGE Approaches

Because of the potential for overfitting and the computational challenges due to NP-hardness, we do not solve either MaxA-EFT or MaxS-EFT directly. Instead, we introduce NUDGE, a family of approaches that solve constrained variations of MaxA-EFT and MaxS-EFT, designed to avoid overfitting, while being efficient. We discuss two main approaches, NUDGE-M and NUDGE-N, in Secs. 3.2.1 and 3.2.2 and present other practical extensions in Appx. C.

#### 3.2.1 NUDGE-M: NUDGE with Bounded Magnitude

NUDGE-M solves MaxS-EFT on the training set, but with the added constraint $\|{\bm{\Delta}}_{i}\|\leq\gamma$, $\forall i\in[n]$, for a scalar $\gamma\geq 0$. $\gamma$ controls how much each embedding can change during fine-tuning. NUDGE-M sets $\gamma$ by solving MaxA-EFT on the validation set. Intuitively, this (1) changes data embeddings to maximize the similarity between embeddings and queries on the training set, (2) ensures that the magnitude of the changes to the embeddings is bounded to avoid overfitting, and (3) decides how much the embeddings are allowed to change by maximizing validation accuracy. NUDGE-M provides a closed-form solution to do this. We provide an overview of the solution here and leave the details and formal proofs to Appx. B.2.

Optimization Formulation. Define MaxS-M($\gamma$), for a scalar $\gamma\geq 0$, as the set of optimal solutions to the following constrained version of MaxS-EFT with bounded magnitude:

$$ $\displaystyle\texttt{MaxS-M}(\gamma)=\operatorname*{arg\,max}$ $\displaystyle\sum_{i\in[n_{T}]}{\bm{Q}}^{T}_{i}\cdot({\bm{D}}_{Y_{i}^{T}}+{\bm{\Delta}}_{Y_{i}^{T}})$ s.t. $\displaystyle\;\,{\bm{\Delta}}\in\mathcal{R}^{n\times d},\|{\bm{\Delta}}_{i}\|\leq\gamma\quad\forall i\in[n].$ $$

A ${\bm{\Delta}}\in\texttt{MaxS-M}(\gamma)$ changes data embeddings by at most $\gamma$ while maximizing the similarity between training queries and their ground-truth answer. We set $\gamma$ to maximize the validation accuracy after fine-tuning with ${\bm{\Delta}}\in\texttt{MaxS-M}(\gamma)$:

$$ $\displaystyle\max$ $\displaystyle\sum_{i\in[n_{V}]}\mathcal{I}_{i}^{V}({\bm{\Delta}})$ s.t. $\displaystyle{\bm{\Delta}}\in\texttt{MaxS-M}(\gamma),\gamma\geq 0.$ $$

$\mathcal{I}_{i}^{V}({\bm{\Delta}})$ denotes $\mathcal{I}_{i}$ (see Eq. 1) on the validation set ${\bm{Q}}^{V},Y^{V}$, so $\sum_{i\in[n_{V}]}\mathcal{I}_{i}^{V}({\bm{\Delta}})$ is the validation accuracy after fine-tuning with ${\bm{\Delta}}$. This problem is referred to as Bi-level Maximization with bounded Magnitude, BiMax-M. We denote the optimal solution to BiMax-M by ${\bm{\Delta}}^{M}$.

NUDGE-M. NUDGE-M is an algorithm that optimally solves BiMax-M:

###### Theorem 2 .

There exists an algorithm, referred to as NUDGE-M, that optimally solves BiMax-M in $O(n_{V}(nd+\log n_{V})+n_{T}d)$. Specifically, NUDGE-M sets ${\bm{\Delta}}^{M}$ as

$$ $\displaystyle{\bm{\Delta}}_{i}^{M}=\gamma^{*}\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|},\quad\text{where}\;\;{\bm{G}}_{i}=\sum_{j\in[n_{T}]}\mathds{I}[i=Y_{j}^{T}]{\bm{Q}}^{T}_{j},\quad\forall i\in[n],$ (3) $$

and $\mathds{I}$ is the indicator function with a predicate argument, for an optimally chosen scalar $\gamma^{*}$.

Eq. 3 presents the simple update rule used by NUDGE-M to fine-tune data embeddings, using which the fine-tuned embeddings are computed as ${\bm{D}}^{*}={\bm{D}}+{\bm{\Delta}}^{M}$. Observe that ${\bm{G}}_{i}$ is the sum of query embeddings whose ground-truth answer is ${\bm{D}}_{i}$, so that data embeddings are moved towards the queries for which they are the ground-truth answers. We also note that $O(n_{T}d)$ is the complexity of a single iteration over training data, and $O(n_{V}nd)$ is the complexity of calculating validation accuracy once. Thus, ignoring the log term, the above time complexity is equal to a single training and validation iteration for parametric approaches (i.e., Adaptors or PTFT), and has smaller constant factors since it does not perform any model forward passes.

The optimal $\gamma^{*}$ in Eq. 3 is calculated by solving linear inequalities resulting from the definition of $\mathcal{I}_{i}^{V}$. We provide an overview here and leave the details to Appx. B.2. First, note that $\texttt{MaxS-M}(\gamma)=\gamma\frac{{\bm{G}}}{\|{\bm{G}}\|}$, found using the KKT points of the optimization problem. Thus, BiMax-M reduces to finding a $\gamma$ that maximizes $\sum_{i\in[n_{V}]}\mathcal{I}_{i}^{V}(\gamma\frac{{\bm{G}}}{\|{\bm{G}}\|})$.
For each $i\in[n_{V}]$, substituting ${\bm{\Delta}}=\gamma\frac{{\bm{G}}}{\|{\bm{G}}\|}$ into the definition of $\mathcal{I}_{i}^{V}({\bm{\Delta}})$ in Eq. 1, we have $\mathcal{I}_{i}^{V}(\gamma\frac{{\bm{G}}}{\|{\bm{G}}\|})=1$ if the following holds, and zero otherwise:

$$ $\displaystyle{\bm{Q}}_{i}^{V}\cdot({\bm{D}}_{Y_{i}}+\gamma\frac{{\bm{G}}_{Y_{i}^{V}}}{\|{\bm{G}}_{Y_{i}^{V}}\|})>{\bm{Q}}_{i}^{V}\cdot({\bm{D}}_{j}+\gamma\frac{{\bm{G}}_{j}}{\|{\bm{G}}_{j}\|}),\quad\forall j\in[n]\setminus Y_{i}^{V}.$ (4) $$

Eq. 4 is a set of inequalities in $\gamma$. Denote the solution to the inequalities by $I_{i}$, so that $\gamma\in I_{i}$ if and only if $\mathcal{I}_{i}^{V}(\gamma\frac{{\bm{G}}}{\|{\bm{G}}\|})=1$. Since the inequalities are linear in $\gamma$, $I_{i}$ is an interval in $\mathcal{R}$. Consequently,

$$ $\displaystyle\gamma^{*}=\operatorname*{arg\,max}_{\gamma}\sum_{i\in n_{V}}\mathds{I}[\gamma\in I_{i}],$ (5) $$

and the solution to Eq. 5 is a $\gamma$ that intersects the most number of intervals across all $I_{i}$, $i\in[n_{V}]$, which can be found by a single iteration over the intervals after sorting their start and end points.

###### Theorem 2 .

#### 3.2.2 NUDGE-N: NUDGE with Normalized Embeddings

NUDGE-N additionally constrains the norm of the fine-tuned embedding. This constraint serves as an additional regularization, helping with out-of-distribution generalization (see Sec.4.2).

Optimization Formulation. Analogous to $\texttt{MaxS-M}(\gamma)$ but with an added constraint, we define $\texttt{MaxS-N}(\gamma)$ as the optimal solution to the following optimization problem:

$$ $\displaystyle\texttt{MaxS-N}(\gamma)=\operatorname*{arg\,max}$ $\displaystyle\sum_{i\in[n_{T}]}{\bm{Q}}^{T}_{i}\cdot({\bm{D}}_{Y_{i}^{T}}+{\bm{\Delta}}_{Y_{i}^{T}})$ s.t. $\displaystyle\;\,{\bm{\Delta}}\in\mathcal{R}^{n\times d},\|{\bm{\Delta}}_{i}\|^{2}\leq\gamma,{\color[rgb]{0.0,0.42,0.24}\|{\bm{D}}_{i}+{\bm{\Delta}}_{i}\|=1}\quad\forall i\in[n].$ $$

To find a suitable $\gamma$, we solve the same optimization problem as BiMax-M, except that we replace $\texttt{MaxS-M}(\gamma)$ with $\texttt{MaxS-N}(\gamma)$. We call this problem Bi-level Maximization with Normalized embeddings, BiMax-N, and refer to its optimal solution as ${\bm{\Delta}}^{N}$.

NUDGE-N. NUDGE-N is an algorithm that optimally solves BiMax-N:

###### Theorem 3 .

There exists an algorithm, referred to as NUDGE-N, that optimally solves BiMax-N in $O(n_{V}(nd+\log n_{V})+n_{T}d)$. Specifically, NUDGE-N sets ${\bm{\Delta}}^{N}$ as

$$ ${\bm{\Delta}}_{i}^{N}=\begin{cases*}\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}-{\bm{D}}_{i},&$\textnormal{if}\;\frac{{\bm{G}}_{i}\cdot{\bm{D}}_{i}}{\|{\bm{G}}_{i}\|}\geq 1-\frac{\gamma^{*}}{2}$\\ \frac{\sqrt{\gamma^{*}(4-\gamma^{*})}}{2}{\bm{Z}}_{i}-\frac{\gamma^{*}}{2}{\bm{D}}_{i},&{otherwise,}\end{cases*}$ (6) $$

where

$$ ${\bm{Z}}_{i}=\frac{{\bm{G}}_{i}-({\bm{D}}_{i}\cdot{\bm{G}}_{i}){\bm{D}}_{i}}{\|{\bm{G}}_{i}-({\bm{D}}_{i}\cdot{\bm{G}}_{i}){\bm{D}}_{i}\|},$ $$

and ${\bm{G}}_{i}$ is as defined in Eq. 3, for an optimally chosen scalar $\gamma^{*}$.

Eq. 6 is the update rule used by NUDGE-N to fine-tune data embeddings, using which the fine-tuned embeddings are obtained as ${\bm{D}}^{*}={\bm{D}}+{\bm{\Delta}}^{N}$. This moves the data embedding on the unit ball (to satisfy $\|{\bm{D}}_{i}+{\bm{\Delta}}_{i}\|=1$) between ${\bm{D}}_{i}$ and $\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}$, where $\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}$ is the normalized sum of embeddings of queries whose ground-truth answer is ${\bm{D}}_{i}$. $\gamma^{*}$ determines how much to move the embedding, and ${\bm{Z}}_{i}$ determines the direction. ${\bm{Z}}_{i}$ is the normalized projection of ${\bm{G}}_{i}$ onto the tangent plane of the unit ball at ${\bm{D}}_{i}$, so that moving in the direction of ${\bm{Z}}_{i}$ maximally increases MaxS-N objective.

Finding the optimal $\gamma^{*}$ is similar to NUDGE-M, where we first use KKT to solve $\texttt{MaxS-N}(\gamma)$ and substitute the resulting ${\bm{\Delta}}$ into the definition of $\mathcal{I}^{V}_{i}$ in Eq. 1. The optimal $\gamma^{*}$ is then found as the value that satisfies the maximum number of the resulting inequalities. The resulting inequalities are, in this case, quadratic due to $\sqrt{\gamma(4-\gamma)}$ in the solution to $\texttt{MaxS-N}(\gamma)$, but can still be solved in closed-form. Nevertheless, from a practical perspective, solving the quadratic equations is tedious as it requires considering various special cases. We observed that performing a grid search to find $\gamma^{*}$ that maximizes validation accuracy finds good enough solutions and is almost as efficient. Thus, in our experiments, we use this practical implementation.

###### Theorem 3 .

## 4 Experiments

We present results on standard text and image retrieval benchmarks and multiple pre-trained models. We present our main experimental results here, but for the sake of space, defer more detailed results and ablation studies to Appx. E.

Datasets. For text retrieval datasets we use 7 standard datasets: SciFacts (Wadden et al., ), Fever (Fever, ), ArguAna (Arguana, ) (we use their BEIR (Thakur et al., ) versions), TriviaQA Joshi et al. (), HotpotQA (Yang et al., ), and Natural Questions(Kwiatkowski et al., ) (we use their KILT (Petroni et al., ) versions), and NF-Corpus (Boteva et al., ) (although all datasets have a BEIR version, we use non-BEIR versions whenever that is larger). We use the datasets as is, without any preprocessing step, except for datasets from KILT, where we only use Wikipedia pages that contain an answer to at least one query (i.e., pages where we expect fine-tuning to have an impact). For image retrieval, we use COCO (Lin et al., ) (we use the dataset from 2014) and Flickr (Young et al., ) datasets. We use image captions as queries to retrieve the corresponding image. For all text and image datasets, we use 0.7-0.1-0.2 train, validation and test split, but limit test and validation sizes to at most 10,000 queries if there is more. Statistics about data and query size are presented in Table 2.

Pre-Trained Models. We report results on fine-tuning embeddings for 5 different pre-trained models, 3 for text and 2 for image retrieval, where we consider models of different sizes and embedding dimensions. For text, we use BGE-small (Xiao et al., ) with 33M parameters and embedding dimension 384, GTE-large (Li et al., ) with 434M parameters and embedding dimension 1024 and OpenAI’s text-embedding-large-3 (OpenAI, ), a closed-source model with embedding dimensions 3072. The three models are respectively referred to as BGE-S, GTE-L and TE3-L. For image retrieval, we use two CLIP variants (Radford et al., ), ViT-B/32 and ViT-L/14, which have, respectively, 151M and 427M parameters and 512 and 768 embedding dimensions. We respectively call them CLIP-B and CLIP-L.

Baselines. We report results using the embeddings without fine-tuning, called No Fine-Tuning, in addition to training Adaptors and fine-tuning the pre-trained model, referred to as PTFT (see Appx. E.1 for implementation details). Due to computational constraints, we report results for the latter only for the small open-source model BGE-S in our main experiments. For both, we present two versions. By default, we use the Multiple Negative Ranking (MNR) loss (Henderson et al., ) for training, which is the standard contrastive fine-tuning loss when positive query/answer pairs are available, suggested by SentenceTransformers (SentenceTransformers, ) and used by LlamaIndex (LlamaIndex, ) for fine-tuning (although LlamaIndex only uses a single positive example per query (LlamaIndex, )). Despite our hyperparameter tuning effort, we observed no accuracy improvements on some datasets through fine-tuning with this loss (see Table 6). We then modified the loss, so that only negative samples whose cosine similarity is at least equal to a threshold are included in the loss (see E.1 for details), which improved accuracy on some datasets but worsened it on other. We use the suffix -L to denote the baselines using this modified loss. We report results using this loss to gain more insight into the baseline’s behavior. We use cosine similarity as the retrieval distance metric for No Fine-Tuning, Adaptor, and PTFT.

Metrics. We report typical metrics Recall@$k$ (R@$k$ for short) and NDCG@$k$ with $k=10$ by default, following MTEB benchmark (Muennighoff et al., ). We also report Recall@1, the validation metric, and the change in NDCG@$k$ compared with No Fine-Tuning in parenthesis (+/-).

**Table 2: Total number of queries and records in the datasets**
|  | NF-Corpus | SciFact | ArguAna | Fever | NQ | TriviaQA | HotpotQA | COCO | Flickr |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Query # | 2,429 | 1,109 | 1,401 | 123,142 | 79,782 | 58,245 | 74,259 | 414,113 | 155,070 |
| Data # | 3,633 | 5,183 | 8,674 | 5,416,568 | 7,631,395 | 7,631,395 | 7,631,395 | 82,783 | 31,014 |

**Table 3: Average results across text datasets grouped by the embedding model used**
| Emb. Model → | BGE-S | GTE-L | TE3-L |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| ↓  Method | R@1 | R@10 | NDCG@10 | R@1 | R@10 | NDCG@10 | R@1 | R@10 | NDCG@10 |
| NUDGE-M | 49.7 | 66.6 | 57.0 (+8.4) | 52.1 | 73.4 | 61.0 (+7.7) | 54.1 | 75.6 | 63.2 (+11.0) |
| NUDGE-N | 52.0 | 72.6 | 61.1 (+12.4) | 53.4 | 74.8 | 62.7 (+9.4) | 55.2 | 76.0 | 63.9 (+11.7) |
| Adapter | 39.5 | 65.5 | 51.6 (+2.9) | 45.1 | 68.4 | 55.7 (+2.4) | 46.9 | 66.2 | 54.4 (+2.2) |
| PTFT | 40.9 | 66.1 | 52.5 (+3.8) | N/A | N/A | N/A | N/A | N/A | N/A |
| No Fine-Tuning | 37.0 | 62.4 | 48.7 | 41.6 | 67.0 | 53.3 | 40.0 | 67.5 | 52.2 |

**Table 4: Average results across image datasets grouped by the embedding model used**
| Emb. Model → | CLIP-B | CLIP-L |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| ↓  Method | R@1 | R@10 | NDCG@10 | R@1 | R@10 | NDCG@10 |
| NUDGE-M | 28.6 | 55.1 | 40.9 (+14.1) | 30.1 | 58.1 | 43.2 (+10.7) |
| NUDGE-N | 28.8 | 55.3 | 41.1 (+14.3) | 30.1 | 58.2 | 43.3 (+10.8) |
| Adapter | 18.5 | 43.5 | 29.9 (+3.0) | 24.1 | 50.9 | 36.5 (+4.0) |
| No Fine-Tuning | 15.9 | 40.1 | 26.9 | 20.5 | 46.5 | 32.5 |

**Table 6: NDCG@10 results for using BGE-S on text datasets**
| Method | ArguAna | Fever | HotpotQA | NF-Corpus | NQ | SciFact | TriviaQA |
| --- | --- | --- | --- | --- | --- | --- | --- |
| NUDGE-M | 47.9 (+0) | 95.0 (+13.7) | 63.1 (+5.0) | 40.0 (+6.1) | 38.6 (+17.5) | 79.2 (+6.5) | 35.5 (+9.6) |
| NUDGE-N | 47.9 (+0) | 93.5 (+12.3) | 65.2 (+7.1) | 44.6 (+10.7) | 45.9 (+24.8) | 87.8 (+15.1) | 43.0 (+17.2) |
| Adapter | 47.9 (+0) | 81.2 (+0) | 58.1 (+0) | 37.4 (+3.5) | 27.4 (+6.2) | 83.5 (+10.9) | 25.9 (+0) |
| Adapter-L | 47.9 (+0) | 88.4 (+7.2) | 62.7 (+4.6) | 35.7 (+1.9) | 33.6 (+12.0) | 85.1 (+12.4) | 27.2 (+1.2) |
| PTFT | 47.9 (+0) | 81.2 (+0) | 58.1 (+0) | 46.1 (+12.2) | 28.1 (+7.0) | 80.4 (+7.7) | 25.9 (+0) |
| PTFT-L | 47.9 (+0) | 84.1 (+2.9) | 62.1 (+4.0) | 36.0 (+2.2) | 36.8 (+15.6) | 72.7 (+0) | 26.0 (+0.1) |
| No Fine-Tuning | 47.9 | 81.2 | 58.1 | 33.8 | 21.2 | 72.7 | 25.9 |

**Table 7: Distribution shift results using BGE-S, average over text datasets**
| Method | In-Distribution | Out-of-Distribution |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| R@1 | R@10 | NDCG@10 | R@1 | R@10 | NDCG@10 |  |
| NUDGE-M | 49.5 | 65.5 | 56.3 (+9.4) | 30.8 | 46.9 | 38.0 (-10.0) |
| NUDGE-N | 51.1 | 71.5 | 60.0 (+13.1) | 40.7 | 64.3 | 51.2 (+3.2) |
| Adaptor | 40.1 | 58.6 | 47.6 (+0.7) | 37.3 | 56.6 | 45.0 (-3.0) |
| No Fine-Tuning | 37.7 | 59.1 | 46.9 | 39.5 | 60.1 | 48.0 |

### 4.1 Baseline Results

Summary of results. Tables 3-5 present our accuracy results averaged across all text or image datasets for different models. Table 6 presents the per dataset results for BGE-S. The per dataset results for other models followed similar trends and are deferred to Appx. E.2.

As Tables 3-5 show, both NUDGE-M and NUDGE-N provide significant accuracy gains, providing up to 14.3% NDCG@10 boost over No Fine-Tuning while PTFT and Adaptor only improve NDCG@10 up to 4.0%, when averaged across datasets, for both text and image retrieval. Interestingly, the accuracy gains from NUDGE-M and NUDGE-N depends on the pre-trained model. GTE-L outperforms TE3-L without fine-tuning, but using NUDGE TE3-L outperforms GTE-L.

Moreover, Table 5 shows the total fine-tuning time to run BGE-S on our text datasets (i.e., time obtain the associated results in Table 3) using an Nvidia A100 GPU as well as using 32 core Intel Broadwell CPUs. The reported time excludes the time to embed the data records (which is the same across all methods). NUDGE variants run in 1-2 minutes with GPU and in up to 11 minutes using CPUs, which is, respectively, more than 3 and 11 times faster than Adaptor and more than 200 times faster than PTFT, which cannot be run on CPUs in a reasonable time-frame. For both Adaptor and PTFT, the reported run times are for optimized implementations that include early stopping and optimizations for efficient calculation of validation accuracy (see Appx. E.1).

Detailed Results. Table 6 shows the detailed retrieval accuracy on text datasets for BGE-S. NUDGE significantly outperforms parametric methods on almost all datasets. NUDGE-N outperforms NUDGE-M on most datasets, showing the benefit of constraining embeddings to be normalized.

The results show that parametric approaches are unreliable and fail to provide significant accuracy improvements despite requiring significantly more computational resources. The reported results are after hyperparameter tuning as well as tweaking the loss function (i.e., -L variants). We observed that the latter does help improve (and sometimes worsen) accuracy for parametric approaches on some datasets, with Adaptor-L and PTFT-L providing accuracy improvements on Fever and HotpotQA where Adaptor and PTFT provided none. Meanwhile, NUDGE consistently provides significant accuracy boosts without any hyperparameter tuning. We provide a detailed discussion of the failure modes of the parametric approaches in Appx. E.3.

To better understand the results, we remark on the performance on ArguAna and Fever datasets. Fever, where NUDGE-M performs better than NUDGE-N has a skewed label distribution, where the same paragraph is the correct answer for many queries. This allows for setting the magnitude of the embeddings based on label distribution, assigning embeddings with larger magnitudes to more frequently accessed passages. Such an assignment can improve the accuracy when the label distribution is fixed and skewed, but leads to worse generalization when there is no skew (as the results on other datasets in Table 6 show) or when there is a distribution shift (see Sec. 4.2). Finally, in ArguAna, each data record is a factual argument and each query provides an argument and asks for a counterargument to the given argument. In such a setting, to improve accuracy, we expect larger systematic changes to the embedding space to be required to be able to retrieve the semantically opposite (instead of similar). Learning such changes from a small training set is challenging and perhaps a more task-specific methodology is required for this dataset.

### 4.2 Out-of-distribution Generalization

Next, we study the impact of fine-tuning on out-of-distribution queries. In this experiment, separately for each dataset, we use K-means to cluster all the queries in two clusters, referred to as $C_{1}$ and $C_{2}$. We split $C_{1}$ into 3 sets, $C_{1}^{\text{train}}$, $C_{1}^{\text{val}}$ and $C_{1}^{\text{test}}$, where $C_{1}^{\text{train}}$ and $C_{1}^{\text{val}}$ are used for training and validation. We report test results on $C_{1}^{\text{test}}$ as in-distribution and on $C_{2}$ as out-of-distribution results.

Average results across text datasets and with BGE-S model are shown in Table 4. As the table shows, NUDGE-N performs the best on the out-of-distribution test set, even outperforming No Fine-Tuning, while providing a significant accuracy boost on the in-distribution samples. Although NUDGE-M performs well on in-distribution samples, its performance deteriorates on out-of-distribution queries. The main difference between NUDGE-M and NUDGE-N is that NUDGE-M’s embeddings are not normalized. Thus, when retrieving top-$k$ results using inner product as similarity metric, a fine-tuned embedding with large magnitude can adversely impact the query answers for out-of-distribution queries. However, by keeping embeddings normalized, NUDGE-N ensures fine-tuned embeddings do not change the answer to queries that are far from fine-tuned data records, thus avoiding performance degradation on out-of-distribution queries. Finally, Adaptor provides little gain on in-distribution queries, while worsening accuracy on out-of-distribution samples.

### 4.3 Ablation Study

We provide an ablation study to better understand the impact of various constraints in NUDGE. In addition to NUDGE-M and NUDGE-N, we present NUDGE-M+N, which performs normalization on the output of NUDGE-M. That is, instead of incorporating normalization as a constraint in the optimization problem, NUDGE-M+N simply normalizes the embeddings after performing NUDGE-M. We also present NUDGE-NU, which is a variation of NUDGE-N that only includes the normalization constraint, but not the constraint on the magnitude of the change in the embeddings (the solution is equivalent to the first branch of Eq. 6).

Table 8 shows the results of comparing the above variants across text datasets using the BGE-S model. The table shows normalizing the embeddings as part of the optimization (NUDGE-N) is better than simply normalizing the output after optimization (NUDGE-M+N), although both work better than using unnormalized embeddings (NUDGE-M). Moreover, allowing the magnitude of change to the embeddings to be unbounded (NUDGE-NU) performs worse than all other variants, showing the benefit of constraining how much embeddings can change during fine-tuning. Overall, comparing NUDGE-N, No Fine-Tuning, and all other variants, we see that the benefits of NUDGE-N come from a combination of all design choices made.

## 5 Related Work

Decades of research has explored various retrieval methods, including sparse
(Robertson et al., ), dense (Karpukhin et al., ), late interaction Khattab & Zaharia () and generative retrieval Tay et al. () to name a few. Compared with such retrieval paradigms, $k$-NN retrieval has recently gained increased popularity (see Zhao et al. () for a survey of recent studies) due to its simplicity and efficiency. $k$-NN retrieval uses embeddings from pre-trained models, thus avoiding the need for extensive training on the dataset in hand, and performs retrieval through a simple vector index look-up avoiding expensive model inference at query time.

This paper focuses on improving $k$-NN retrieval accuracy given access to a pre-trained embedding model. Related work can be divided into two categories. The first category, including this paper, aims to improve the embeddings through fine-tuning for the specific dataset and query workload. Fine-tuning the pre-trained model itself, through a similar training strategy used during pre-training is possible, Zhao et al. (); Tang et al. (); Tam et al. (); Liu et al. (); Pires et al. (); Yu et al. (); Ma et al. (), but requires access to the model parameters, is computationally expensive and incurs extra hosting and maintenance costs the fine-tuned models at deployment time. A common alternative in practice is to train adaptors (Suvansh Sanjeev, ; LlamaIndex, ) to transform the output of the models. As our experiments show, adaptors provide limited accuracy gains. On the other hand, our approach, NUDGE, is efficient, model agnostic, does not require hosting and maintaining any model at deployment time, and provides a significant accuracy boost. Work in the second category, orthogonal to this paper, modify the retrieval algorithm to improve accuracy, e.g., through query rewriting, reranking, etc. (see Zhao et al. (); Gao et al. () for a survey). Notable examples include Gao et al. (), which rewrites the queries as a hypothetical documents, Sarthi et al. (), which adds summary text chunks to the dataset to improve retrieval, Sachan et al. () which reranks passages based on probability of observing the query, and Lin et al. () which extracts document structure for query answering.

Beyond retrieval, our work is related to recent work on fine-tuning pre-trained models for various purposes (Ouyang et al., ; Rafailov et al., ; Ziegler et al., ; Zhang et al., ; Patil et al., ), but shows the novel insight that non-parametric fine-tuning of model output, instead of fine-tuning model parameters, can provide significant accuracy improvements. Similar to Ouyang et al. (); Rafailov et al. (); Ziegler et al. (), our optimization constrains how much model output can change during fine-tuning. In NUDGE, this constraint represents the intuition that among all fine-tuned embeddings that achieve a specific training loss, one with the least change from non-fine-tuned embedding should be preferred. Although this intuition can be broadly applicable to fine-tuning, the KL-divergence constraint in Ouyang et al. (); Ziegler et al. () has additional significance due to the use of a reward model.

## 6 Conclusion

We studied the problem of fine-tuning embeddings to improve $k$-NN retrieval accuracy. We presented NUDGE, a novel non-parametric approach to embedding fine-tuning that is efficient, provides significant accuracy boosts and does not require any model hosting or maintenance at deployment time. Our experimental results show NUDGE improves accuracy by up to 16.0% compared with existing methods and up to 24.4% compared with no fine-tuning. Future work includes incorporating NUDGE inside vector databases and generating and maintaining query sets for fine-tuning.

## Appendix A Appendix Overview

This appendix is organized as follows:

- •
Appx. B contains the proofs of the theoretical results in the paper.
- •
Appx. C contains other practical NUDGE variants.
- •
Appx. D discusses the extension of NUDGE to multi-label settings.
- •
Appx. E provides details about the experimental setting, and provides additional experiments.

## Appendix B Proofs

Appx. B.1-B.3, respectively, provide the proofs of Theorems. 1-3. The proofs of technical lemmas are presented in Appx. B.4

### B.1 Proof of Theorem 1

We show a reduction from homogeneous maximum feasible linear subsystem, Max-FLS, shown to be NP-Hard in Amaldi & Kann (). We first formally state the decision version of the problem.

###### Problem 2 (Homogeneous Max-FLS) .

Given a linear system ${\bm{A}}{\bm{x}}<\mathbf{0}$, where ${\bm{A}}$ is of size $s\times t$, and an integer $K$ with $1<K<s$, does there exist a solution ${\bm{x}}\in\mathcal{R}^{t}$ satisfying at least $K$ inequalities of the system?

We show a reduction from Homogeneous Max-FLS to the decision version of MaxA-EFT. The decision version of MaxA-EFT asks whether there exists ${\bm{\Delta}}$ such that the training accuracy is at least $K$, i.e., whether at least $K$ different $\mathcal{I}_{i}({\bm{\Delta}})$, $i\in[n_{T}]$ can be satisfied.

Given ${\bm{A}}$, the reduction defines an instance of MaxA-EFT by specifying ${\bm{D}}$, ${\bm{Q}}$, and $Y$. Specifically, we let ${\bm{Q}}={\bm{A}}$, ${\bm{D}}=\mathbf{0}\in\mathcal{R}^{2\times t}$ (i.e., a $2\times t$ matrix only consisting of zeros) and $Y=\{Y_{1},...,Y_{s}\}$, $Y_{i}=0\;\forall i\in[s]$ (i.e., this instance only has 2 data records, embedding dimension is $t$ and there are $s$ training queries).

We next show that there exists ${\bm{\Delta}}$ so that the training accuracy of MaxA-EFT is at least $K$ if and only if there exists a solution ${\bm{x}}$ to Homogeneous Max-FLS satisfying at least $K$ inequalities of the system.

Observe that, by the above construction, $\mathcal{I}_{i}({\bm{\Delta}})$ is satisfied if and only if

$$ ${\bm{Q}}_{i}\cdot({\bm{\Delta}}_{1}-{\bm{\Delta}}_{0})<0.$ $$

Suppose the training accuracy is at least $K$ for some ${\bm{\Delta}}$. Let ${\bm{x}}={\bm{\Delta}}_{1}-{\bm{\Delta}}_{0}$, and let $\{i_{1},...,i_{K}\}$ be the index of $K$ training samples answered correctly. Thus, we have ${\bm{A}}_{i}\cdot{\bm{x}}<0$ for all $i\in\{i_{1},...,i_{K}\}$, showing the existing $K$ inequalities in the subsystem that are satisfied.

Conversely, assume some ${\bm{x}}$ satisfies at least $K$ inequalities in the subsystem. Let ${\bm{\Delta}}_{0}=\mathbf{0}$ and ${\bm{\Delta}}_{1}={\bm{x}}$. We have that at least $K$ inequalities in

$$ ${\bm{Q}}{\bm{\Delta}}_{1}<\mathbf{0}$ $$

are satisfied, so that the training accuracy is at least $K$. The reduction is polynomial time, thus showing MaxA-EFT is NP-hard.∎

###### Problem 2 (Homogeneous Max-FLS) .

### B.2 Proof of Theorem 2

Figure: Algorithm 1 NUDGE-M algorithm

Setup. Recall that for any $i\in[n]$,

$$ ${\bm{G}}_{i}=\sum_{j\in[n_{T}]}\mathds{I}[i=Y_{j}^{T}]{\bm{Q}}^{T}_{j},$ $$

so that

$$ $\underset{{\bm{\Delta}}\in\mathcal{R}^{n\times d}}{\arg\max}\sum_{i\in[n_{T}]}{\bm{Q}}^{T}_{i}\cdot({\bm{D}}_{Y_{i}^{T}}+{\bm{\Delta}}_{Y_{i}^{T}})=\underset{{\bm{\Delta}}\in\mathcal{R}^{n\times d}}{\arg\max}\sum_{i\in[n]}{\bm{G}}_{i}\cdot{\bm{\Delta}}_{i}=\underset{{\bm{\Delta}}\in\mathcal{R}^{n\times d}}{\arg\max}\sum_{i\in[n],\|{\bm{G}}_{i}\|\neq 0}{\bm{G}}_{i}\cdot{\bm{\Delta}}_{i}.$ $$

The proofs here use the above formulation for MaxS-M. Moreover, we set ${\bm{\Delta}}_{i}^{\gamma}=\textbf{0}$ for any $i$ where $\|{\bm{G}}_{i}\|=0$, given that they do not appear in the above objective. Note that even when ${\bm{\Delta}}_{i}^{\gamma}=\textbf{0}$ for any $i\in[n]$, the $i$-th record still influences the BiMax-M objective and needs to be taken into account when solving the outer optimization in BiMax-M.

Finding MaxS-M. We first find $\texttt{MaxS-M}(\gamma)$ by solving the following optimization problem:

$$ $\begin{array}[]{ll@{}ll}\underset{{\bm{\Delta}}\in\mathcal{R}^{n\times d}}{\arg\max}&\sum_{i\in[n]}{\bm{G}}_{i}\cdot{\bm{\Delta}}_{i}\[10.0pt] \textnormal{s. t.}&\|{\bm{\Delta}}_{i}\|\leq\gamma,&\forall i\in[n].\end{array}$ $$

In this problem, the constraints are independent for each $i\in[n]$, $\|{\bm{G}}_{i}\|\neq 0$, and the objective is simply a summation across ${\bm{G}}_{i}\cdot({\bm{D}}_{i}+{\bm{\Delta}}_{i})$ values, so that a solution ${\bm{\Delta}}^{*}$ is optimal for this problem if and only if for each $i\in[n]$, ${\bm{\Delta}}_{i}^{*}$ is an optimal solution to

$$ $\begin{array}[]{ll@{}ll}\underset{{\bm{\Delta}}\in\mathcal{R}^{d}}{\arg\max}&{\bm{G}}_{i}\cdot{\bm{\Delta}}_{i}\[10.0pt] \textnormal{s. t.}&\|{\bm{\Delta}}_{i}\|\leq\gamma.\end{array}$ $$

Solving this problem, we have:

###### Lemma 1 .

For any $i\in[n]$, whenever $\|{\bm{G}}_{i}\|\neq 0$ and $\gamma\geq 0$, the optimal solution to

$$ $\begin{array}[]{ll@{}ll}\underset{{\bm{\Delta}}\in\mathcal{R}^{d}}{\arg\min}&-{\bm{G}}_{i}\cdot{\bm{\Delta}}_{i}\[10.0pt] \textnormal{s. t.}&\|{\bm{\Delta}}_{i}\|\leq\gamma,\end{array}$ $$

is

$$ ${\bm{\Delta}}_{i}^{\gamma}=\gamma\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}.$ $$

Solving BiMax-M. The goal is now to find a parameter $\gamma\geq 0$ such that the maximum number of validation queries are answered correctly. Observe that, by definition, the $i$-th validation query, $i\in[n_{V}]$ is correctly answered when $\forall j\in[n_{V}]\setminus Y_{i}^{V}$,

$$ $\displaystyle{\bm{Q}}_{i}^{V}\cdot{\bm{D}}_{Y_{i}}+\gamma\mathds{I}[\|{\bm{G}}_{Y_{i}^{V}}\|\neq 0]{\bm{Q}}_{i}^{V}\cdot\frac{{\bm{G}}_{Y_{i}^{V}}}{\|{\bm{G}}_{Y_{i}^{V}}\|}>{\bm{Q}}_{i}^{V}\cdot{\bm{D}}_{j}+\gamma\mathds{I}[\|{\bm{G}}_{j}\|\neq 0]{\bm{Q}}_{i}^{V}\cdot\frac{{\bm{G}}_{j}}{\|{\bm{G}}_{j}\|}.$ $$

where, we abuse notation and assume $\frac{\mathds{I}[\|{\bm{G}}_{j}\|\neq 0]}{\|{\bm{G}}_{j}\|}=0$ if $\|{\bm{G}}_{j}\|=0$ for any $j$. Define

$$ $\mathcal{G}_{i,j}=\mathds{I}[\|{\bm{G}}_{j}\|\neq 0]{\bm{Q}}_{i}^{V}\cdot\frac{{\bm{G}}_{j}}{\|{\bm{G}}_{j}\|},\quad\text{and}\quad\mathcal{S}_{i,j}={\bm{Q}}_{i}^{V}\cdot{\bm{D}}_{j}$ $$

for any $j\in[n]$. Thus, we have that the $i$-th validation query is answered correctly when $\forall j\in[n_{V}]\setminus Y_{i}^{V}$

$$ $\gamma\in I_{i,j}=\begin{cases}\Bigl(-\infty,\frac{\mathcal{S}_{i,j}-\mathcal{S}_{i,Y_{i}^{V}}}{{\mathcal{G}_{i,Y_{i}^{V}}-\mathcal{G}_{i,j}}{}}\Bigr),&\text{if }{\mathcal{G}_{i,Y_{i}^{V}}-\mathcal{G}_{i,j}}{}<0\[5.0pt] \Big(\frac{\mathcal{S}_{i,j}-\mathcal{S}_{i,Y_{i}^{V}}}{{\mathcal{G}_{i,Y_{i}^{V}}-\mathcal{G}_{i,j}}{}},\infty\Big),&\text{if }{\mathcal{G}_{i,Y_{i}^{V}}-\mathcal{G}_{i,j}}{}>0\[5.0pt] \mathcal{R},&\text{if }{\mathcal{G}_{i,Y_{i}^{V}}-\mathcal{G}_{i,j}}{}=0\text{ and }\mathcal{S}_{i,j}-\mathcal{S}_{i,Y_{i}^{V}}<0\\ \emptyset,&\text{otherwise.}\end{cases}$ $$

$I_{i,j}$ defines an interval in $\mathcal{R}$ so that $\gamma\in I_{i,j}$ means the correct answer to the $i$-th validation query has higher similarity to the query compared with the $j$-th data record, for $j\neq Y_{i}^{V}$. Thus, to answer the $i$-th query correctly, we must have $\gamma\in I_{i}=\cap_{j\neq Y_{i}^{V}}I_{i,j}$. To maximize the number of queries answered correctly, after finding $I_{i}$ for all $i$, we simply need to find a $\gamma$ value that intersects the most number of intervals among $I_{1},...,I_{n_{V}}$, i.e., $\arg\max_{\gamma}\sum_{I_{i}\in I}\mathds{I}[\gamma\in I_{i}]$, where $I=\{I_{1},...,I_{n_{V}}\}$. Finding a point where maximum intervals overlap is a basic algorithmic problem and can be done by a single iteration through the intervals after sorting their start and end points.

NUDGE-M. Alg. 1 presents NUDGE-M, which formalizes the above procedure, and also incorporates the constraint $\gamma\geq 0$. Lines 6-15 find the intervals $I_{i}$, $\forall i\in[n_{V}]$ and add it to a list $I$ (intersection of half intervals can be found by calculating the maximum of lower bounds and minimum of upper bounds of the intervals, done in lines 9- 11). The algorithm returns new data embeddings by simply performing a single addition.

Time complexity. Alg. 1 can be implemented so that lines 11-7 with a single pass over the dataset. Therefore, finding $I_{i}$ for all queries (lines 6-15) take $O(n_{V}\times n\times d)$. Calculating $G$ takes time $O(n_{T}\times d)$. Finding $\gamma^{*}$ in line 16 is the basic problem of finding the maximum number of overlapping ranges and can be done in $O(n_{V}\log(n_{V}))$, by first sorting the ranges in $I$ based on their lower bound and iteratively traversing the sorted list and keeping track of the number of overlapping ranges. Thus, Alg. 1 can be implemented in $O(n_{V}(n\times d+\log(n_{V})+n_{T}\times d)$.

###### Lemma 1 .

### B.3 Proof of Theorem 3

Setup. In the discussion below, for simplicity, we assume for any $i\in[n]$ ${\bm{G}}_{i}\cdot{\bm{D}}_{i}\geq 0$. Although the discussion below can be extended to consider ${\bm{G}}_{i}\cdot{\bm{D}}_{i}<0$, the results will be more tedious (see Lemma 2). Moreover, in practice we expect ${\bm{G}}_{i}\cdot{\bm{D}}_{i}\geq 0$ to hold, as otherwise queries and their correct answers will have negative similarity suggesting either a poor training dataset or pre-trained embedding model. We simply set ${\bm{G}}_{i}=\textbf{0}$ whenever ${\bm{G}}_{i}\cdot{\bm{D}}_{i}<0$.
Moreover, similar to Appx. B.2, we rewrite the MaxS-N objective as

$$ $\underset{{\bm{\Delta}}\in\mathcal{R}^{n\times d}}{\arg\max}\sum_{i\in[n_{T}]}{\bm{Q}}^{T}_{i}\cdot({\bm{D}}_{Y_{i}^{T}}+{\bm{\Delta}}_{Y_{i}^{T}})=\underset{{\bm{\Delta}}\in\mathcal{R}^{n\times d}}{\arg\max}\sum_{i\in[n]}{\bm{G}}_{i}\cdot{\bm{\Delta}}_{i}=\underset{{\bm{\Delta}}\in\mathcal{R}^{n\times d}}{\arg\max}\sum_{i\in[n],\|{\bm{G}}_{i}\|\neq 0}{\bm{G}}_{i}\cdot{\bm{\Delta}}_{i},$ $$

and set ${\bm{\Delta}}_{i}^{\gamma}=\textbf{0}$ for any $i$ where $\|{\bm{G}}_{i}\|=0.$ Furthermore, we assume the embeddings ${\bm{D}}_{i}$ are normalized, (i.e., $\|{\bm{D}}_{i}\|=1$, $\forall i\in[n]$), or we otherwise normalize them.

Finding MaxS-N. We first find $\texttt{MaxS-N}(\gamma)$ by solving the following optimization problem:

$$ $\begin{array}[]{ll@{}ll}\underset{{\bm{\Delta}}\in\mathcal{R}^{n\times d}}{\arg\max}&\sum_{i\in[n]}{\bm{G}}_{i}\cdot{\bm{D}}_{i}\[10.0pt] \textnormal{s. t.}&\|{\bm{\Delta}}_{i}\|^{2}\leq\gamma,&\forall i\in[n]\\ &\|{\bm{\Delta}}_{i}+{\bm{D}}_{i}\|=1,&\forall i\in[n].\end{array}$ $$

In this problem, the constraints are independent for each $i\in[n]$, and the objective is simply a summation across ${\bm{G}}_{i}\cdot({\bm{D}}_{i}+{\bm{\Delta}}_{i})$ values, so that a solution ${\bm{\Delta}}^{*}$ is optimal for this problem if and only if for each $i\in[n]$, ${\bm{\Delta}}_{i}^{*}$ is an optimal solution to

$$ $\begin{array}[]{ll@{}ll}\underset{{\bm{\Delta}}\in\mathcal{R}^{d}}{\arg\max}&{\bm{G}}_{i}\cdot{\bm{D}}_{i}\[10.0pt] \textnormal{s. t.}&\|{\bm{\Delta}}_{i}\|^{2}\leq\gamma,\\ &\|{\bm{\Delta}}_{i}+{\bm{D}}_{i}\|=1.\end{array}$ $$

Solving this problem, we have:

###### Lemma 2 .

For any $i\in[n]$, let $\theta_{i}$ be the angle between ${\bm{G}}_{i}$ and ${\bm{D}}_{i}$. Whenever $\theta_{i}\in[0,\frac{\pi}{2}]$, $\gamma\geq 0$, $\|{\bm{D}}_{i}\|=1$ and $\|{\bm{G}}_{i}\|\neq 0$ the optimal solution to the optimization problem

$$ $\begin{array}[]{ll@{}ll}\underset{{\bm{\Delta}}\in\mathcal{R}^{d}}{\arg\min}&-{\bm{G}}_{i}\cdot{\bm{\Delta}}_{i}\[10.0pt] \textnormal{s. t.}&\|{\bm{\Delta}}_{i}\|^{2}\leq\gamma,\\ &\|{\bm{\Delta}}_{i}+{\bm{D}}_{i}\|=1,\end{array}$ $$

is

$$ ${\bm{\Delta}}_{i}^{\gamma}=\begin{cases*}\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}-{\bm{D}}_{i},&$\textnormal{if}\;\cos\theta_{i}\geq 1-\frac{\gamma}{2}$\\ \frac{\sqrt{\gamma(4-\gamma)}({\bm{G}}_{i}-({\bm{D}}_{i}\cdot{\bm{G}}_{i}){\bm{D}}_{i})}{2\|{\bm{G}}_{i}-({\bm{D}}_{i}\cdot{\bm{G}}_{i}){\bm{D}}_{i}\|}-\frac{\gamma}{2}{\bm{D}}_{i},&{otherwise.}\end{cases*}$ $$

For simplicity of notation, we denote by ${\bm{Z}}_{i}\in\mathcal{R}^{d}$ the vector

$$ ${\bm{Z}}_{i}=\frac{{\bm{G}}_{i}-({\bm{D}}_{i}\cdot{\bm{G}}_{i}){\bm{D}}_{i}}{\|{\bm{G}}_{i}-({\bm{D}}_{i}\cdot{\bm{G}}_{i}){\bm{D}}_{i}\|}.$ $$

We also denote by $\mathcal{{\bm{Z}}}_{i,j}={\bm{Q}}_{i}^{V}\cdot{\bm{Z}}_{j}$, by $\mathcal{{\bm{D}}}_{i,j}={\bm{Q}}_{i}^{V}\cdot{\bm{D}}_{j}$ and by $\mathcal{{\bm{G}}}_{i,j}=\mathds{I}[\|{\bm{G}}_{j}\|\neq 0]{\bm{Q}}_{i}^{V}\cdot\frac{{\bm{G}}_{j}}{\|{\bm{G}}_{j}\|}$ for all $i\in[n_{V}],j\in[n]$.

Solving BiMax-N. Next, we consider solving BiMax-N, $\forall j\in[n]$. Substituting $\Delta^{\gamma}$ into the definition of $\mathcal{I}_{i}^{V}({\bm{\Delta}}^{\gamma})$ for each $i\in[n_{V}]$, $\mathcal{I}_{i}^{V}({\bm{\Delta}}^{\gamma})=1$ if and only if for all $j\in[n]\setminus Y_{i}^{V}$

$$ $\displaystyle{\bm{Q}}^{V}_{i}\cdot({\bm{D}}_{Y_{i}^{V}}+{\bm{\Delta}}_{Y_{i}^{V}}^{\gamma})>{\bm{Q}}^{V}_{i}\cdot({\bm{D}}_{j}+{\bm{\Delta}}_{j}^{\gamma}).$ (7) $$

First, consider the case simpler setting when $\|{\bm{G}}_{j}\|\neq 0$ for all $j\in[n]$. Let $\bar{\theta}_{i,j}=\max\{\theta_{i},\theta_{j}\}$ and $\underaccent{\bar}{\theta}_{i,j}=\min\{\theta_{i},\theta_{j}\}$. Substituting the values from Lemma 2, we have Eq. 7 is equivalent to

$$ $\begin{cases*}(1-\frac{\gamma}{2})\mathcal{{\bm{D}}}_{i,Y_{i}^{V}}+\frac{\sqrt{\gamma(4-\gamma)}}{2}\mathcal{{\bm{Z}}}_{i,Y_{i}^{V}}>(1-\frac{\gamma}{2})\mathcal{{\bm{D}}}_{i,j}+\frac{\sqrt{\gamma(4-\gamma)}}{2}\mathcal{{\bm{Z}}}_{i,j},&$\text{if}\;\gamma<2-2\cos\underaccent{\bar}{\theta}_{Y_{i}^{V},j}$\\ (1-\frac{\gamma}{2})\mathcal{{\bm{D}}}_{i,Y_{i}^{V}}+\frac{\sqrt{\gamma(4-\gamma)}}{2}\mathcal{{\bm{Z}}}_{i,Y_{i}^{V}}>\mathcal{{\bm{G}}}_{i,j},&\parbox[t]{122.34692pt}{if $\gamma\geq 2-2\cos\underaccent{\bar}{\theta}_{Y_{i}^{V},j}$, \hskip 56.9055pt$\gamma<2-2\cos\bar{\theta}_{Y_{i}^{V},j}$, $\theta_{Y_{i}^{V}}<\theta_{j}$}\\ \mathcal{{\bm{G}}}_{i,Y_{i}^{V}}>(1-\frac{\gamma}{2})\mathcal{{\bm{D}}}_{i,j}+\frac{\sqrt{\gamma(4-\gamma)}}{2}\mathcal{{\bm{Z}}}_{i,j},&\parbox[t]{122.34692pt}{if $\gamma\geq 2-2\cos\underaccent{\bar}{\theta}_{Y_{i}^{V},j}$, \hskip 56.9055pt$\gamma<2-2\cos\bar{\theta}_{Y_{i}^{V},j}$, $\theta_{Y_{i}^{V}}>\theta_{j}$}\\ \mathcal{{\bm{G}}}_{i,Y_{i}^{V}}>\mathcal{{\bm{G}}}_{i,j},&\text{otherwise.}\end{cases*}$ (8) $$

Observe that finding the values of $\gamma$ for which the inequalities in Eq. 8 hold requires solving inequalities of the form
$a\sqrt{\gamma(4-\gamma)}+b\gamma+c>0,$ for some $a,b,c\in\mathcal{R}$.

###### Lemma 3 .

Let $f(\gamma)=a\sqrt{\gamma(4-\gamma)}+b\gamma+c$ for $a,b,c\in\mathcal{R}$. We say there are $k$ roots, $\gamma_{0},...,\gamma_{k-1}$, if there exists $k$ distinct $\gamma_{i}\in(0,4)$ for which $f(\gamma_{i})=0$. We must have $k\in\{0,1,2\}$, if two roots exist, we have

$$ $\gamma_{0}=\frac{2a^{2}-bc-a\sqrt{\delta}}{a^{2}+b^{2}},\;\gamma_{1}=\frac{2a^{2}-bc+a\sqrt{\delta}}{a^{2}+b^{2}},\;\textnormal{for }\delta=4a^{2}-4bc-a^{2}c^{2},$ $$

and if only one root exists

$$ $\gamma_{0}\in\{\frac{2a^{2}-bc-a\sqrt{\delta}}{a^{2}+b^{2}},\frac{2a^{2}-bc+a\sqrt{\delta}}{a^{2}+b^{2}}\}.$ $$

Moreover, for any $\gamma\in(0,4)$, $f(\gamma)>0$ holds if and only if

$$ $\hskip-14.22636pt\gamma\in\begin{cases*}(0,4)&{if zero roots and } $(c>0$ {or} $(c=0,b>0)$ {or} $(c=b=0,a>0))$\\ \mathcal{\emptyset}&{if zero roots and } $(c<0$ {or} $(c=0,b<0)$ {or} $(c=b=0,a\leq 0))$\\ (\gamma_{0},\gamma_{1})&{if two roots and} $c<0$\\ (0,\gamma_{0})\cup(\gamma_{1},4)&{if two roots and} $c>0$\\ (0,\gamma_{0})&{if one root and} $(c>0$ {or} $c=0,a>0)$\\ (\gamma_{0},4)&{if one root and} $(c<0$ {or} $c=0,a<0).$\\ \end{cases*}$ (9) $$

Thus, for the $i$-th query and the $j$-th data record, $i\in[n_{V}]$, $j\in[n]\setminus Y_{i}^{V}$, we can use Eq. 9 together with Eq. 8 to obtain a set $I_{i,j}\subseteq{(0,4)}$ such that Eq. 7 holds if and only if $\gamma\in I_{i,j}$. Moreover, $I_{i,j}$ will consist of at most 3 intervals in $\subseteq{(0,4)}$. Let $I_{i}=\cap_{j\in[n]\neq Y_{i}^{V}}I_{i,j}$, and note that the $i$-th query will be answered accurately if and only if $\gamma\in I_{i}$. Finally, $\gamma^{*}=\arg\max_{\gamma}\sum_{i\in[n_{V}]}\mathds{I}[\gamma\in I_{i}]$ is an optimal solution to the MAxSS problem.

Now whenever $\|{\bm{G}}_{j}\|=0$ for any $j\in[n]$, Eq. 7 changes since we need to also consider ${\bm{\Delta}}_{Y_{i}^{V}}^{\gamma}=0$, ${\bm{\Delta}}_{j}^{\gamma}=0$ or both. Each case leads to a similar set of inequalities to Eq. 8, which are similarly solved using Lemm 3. Moreover, we calculate validation accuracy separately for when $\gamma=0$.

NUDGE-N. NUDGE-N follows the above procedure. It first calculates ${\bm{G}}$ and ${\bm{Z}}$, so that for the $i$-th query, and $j$-th data points, $j\neq Y_{i}^{V}$ applying Lemma 3 to Eq. 8 gives $I_{i,j}$. Then, it computes $I_{i}$ by a single pass over $I_{i,j}$ values, and finally finds a $\gamma$ value that intersects most $I_{i}$’s by sorting their beginning and end and iteration through the list.

Time Complexity. Calculating ${\bm{G}}$ takes time $O(dn_{T})$, and ${\bm{Z}}$ takes $O(dn)$. Then, for the $i$-th query, it finds $I_{i}$ which takes $O(nd)$, since each $I_{i,j}$ only contains a constant number of intervals and can be computed in $O(d)$. Finally, finding $\gamma^{*}$ that intersects the most intervals, can be done in $O(n_{V}\log n_{V})$. Thus, in total, NUDGE-N takes total of $O(n_{V}(nd+\log n_{V})+n_{T}d)$.

###### Lemma 2 .

###### Lemma 3 .

### B.4 Proof of Technical Lemmas

#### B.4.1 Proof of Lemma 1

If $\gamma=0$ the only feasible, and therefore optimal, solution is ${\bm{\Delta}}=\textbf{0}$. Next, consider $\gamma>0$. Observe that the optimization problem is convex, so we find ${\bm{\Delta}}_{i}$ values that satisfy the KKT conditions which, since the Slater’s condition holds whenever $\gamma>0$, provide necessary and sufficient conditions for optimality.

We have that the Lagrangian is

$$ $L({\bm{\Delta}}_{i},\mu,\lambda)=-{\bm{G}}_{i}\cdot{\bm{D}}_{i}+\frac{1}{2}\mu(\|{\bm{\Delta}}_{i}\|^{2}-\gamma^{2}),$ $$

so that the KKT conditions are

$$ $\displaystyle-{\bm{G}}_{i}+\mu{\bm{\Delta}}_{i}$ $\displaystyle=\textbf{0},$ (10) $\displaystyle\mu(\|{\bm{\Delta}}_{i}\|^{2}-\gamma^{2})$ $\displaystyle=0,$ (11) $\displaystyle\mu\geq 0.$ (12) $$

If $\mu=0$, we must have $\|{\bm{G}}_{i}\|=0$, which is a contradiction. Thus, $\mu>0$, and

$$ $\displaystyle\|{\bm{\Delta}}_{i}\|^{2}-\gamma^{2}=0.$ (13) $$

From Eq. 10,

$$ $\displaystyle{\bm{\Delta}}_{i}=\frac{{\bm{G}}_{i}}{\mu}$ (14) $$

Substituting this into Eq. 13, and since $\mu>0$, we have

$$ $\mu=\frac{\|{\bm{G}}_{i}\|}{\gamma},$ $$

and substituting back into Eq. 14, we have

$$ ${\bm{\Delta}}_{i}=\gamma\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}.$ $$

#### B.4.2 Proof of Lemma 2

We replace $\|{\bm{\Delta}}_{i}+{\bm{D}}_{i}\|=1$ with $\|{\bm{\Delta}}_{i}+{\bm{D}}_{i}\|\leq 1$ so that the optimization is over a convex set, and solve the problem with $\|{\bm{\Delta}}_{i}+{\bm{D}}_{i}\|\leq 1$ constraint. As we will see, the only solution to the problem will have $\|{\bm{\Delta}}_{i}+{\bm{D}}_{i}\|=1$, implying that it is the optimal solution to the original problem as well. Thus, consider the convex problem with $\|{\bm{\Delta}}_{i}+{\bm{D}}_{i}\|\leq 1$ constraint, or equivalantly $\|{\bm{\Delta}}_{i}+{\bm{D}}_{i}\|^{2}\leq 1$.

We find ${\bm{\Delta}}_{i}$ values that satisfy the KKT conditions, which, since the Slater’s condition holds whenever $\gamma>0$, provide necessary and sufficient conditions for optimality.

We have that the Lagrangian is

$$ $L({\bm{\Delta}}_{i},\mu,\lambda)=-{\bm{G}}_{i}\cdot{\bm{D}}_{i}+\frac{1}{2}\mu(\|{\bm{\Delta}}_{i}\|^{2}-\gamma)+\frac{1}{2}\lambda(\|{\bm{\Delta}}_{i}\|^{2}+2{\bm{\Delta}}_{i}\cdot{\bm{D}}_{i}),$ $$

so that the KKT conditions are

$$ $\displaystyle-{\bm{G}}_{i}+\mu{\bm{\Delta}}_{i}+\lambda{\bm{\Delta}}_{i}+\lambda{\bm{D}}_{i}$ $\displaystyle=\textbf{0},$ (15) $\displaystyle\lambda(\|{\bm{\Delta}}_{i}\|^{2}+2{\bm{\Delta}}_{i}\cdot{\bm{D}}_{i})$ $\displaystyle=0,$ (16) $\displaystyle\mu(\|{\bm{\Delta}}_{i}\|^{2}-\gamma)$ $\displaystyle=0,$ (17) $\displaystyle\|{\bm{\Delta}}_{i}\|^{2}$ $\displaystyle\leq\gamma,$ (18) $\displaystyle\|{\bm{\Delta}}_{i}\|^{2}+2{\bm{\Delta}}_{i}\cdot{\bm{D}}_{i}$ $\displaystyle\leq 0,$ (19) $\displaystyle\mu,\lambda$ $\displaystyle\geq 0,$ (20) $$

where Eq. 15 is obtained by setting the gradient of the Lagrangian to zero, and Eq. 19 and  16 are obtained by substituting

$$ $\|{\bm{D}}_{i}+{\bm{\Delta}}_{i}\|^{2}=\|{\bm{D}}_{i}\|^{2}+\|{\bm{\Delta}}_{i}\|^{2}+2{\bm{\Delta}}_{i}\cdot{\bm{D}}_{i}=1+\|{\bm{\Delta}}_{i}\|^{2}+2{\bm{\Delta}}_{i}\cdot{\bm{D}}_{i},$ $$

since $\|{\bm{\Delta}}_{i}\|=1$.

To find the points satisfying all Eq. 15-20, we consider 4 setting depending on whether $\lambda=0$ or $\mu=0$ or not.

Case 1, $\lambda=0,\mu=0$. Substituting $\lambda=0$ and $\mu=0$ in Eq. 15, we have ${\bm{G}}_{i}=\mathbf{0}$. Thus, no solution with $\lambda=0$ and $\mu=0$ exists since ${\bm{G}}_{i}\neq\mathbf{0}$.

Case 2, $\lambda=0,\mu>0$. Having $\lambda=0$ and $\mu>0$, we have from Eq. 15

$$ ${\bm{\Delta}}_{i}=\frac{1}{\mu}{\bm{G}}_{i},$ $$

substituting which into Eq. 17 with $\mu>0$ w have

$$ $\displaystyle\frac{1}{\mu^{2}}\|{\bm{G}}_{i}\|^{2}=\gamma,$ $\displaystyle\mu=\frac{\|{\bm{G}}_{i}\|}{\sqrt{\gamma}},$ $$

and therefore ${\bm{\Delta}}_{i}=\sqrt{\gamma}\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}$ (KKT conditions become similar to the ones in Theorem 2). Because $\mu>0$, we must have $\|{\bm{\Delta}}_{i}\|^{2}=\gamma$ due to Eq. 17, so that from Eq. 19 we have

$$ $\displaystyle\gamma+2\sqrt{\gamma}\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}\cdot{\bm{D}}_{i}\leq 0,$ $\displaystyle\gamma+2\sqrt{\gamma}\cos\theta_{i}\leq 0,$ $$

where $\theta_{i}$ is the angle between ${\bm{G}}_{i}$ and ${\bm{D}}_{i}$. Thus, we must have

$$ $\cos\theta_{i}\leq-\frac{\sqrt{\gamma}}{2}.$ $$

Since $\cos\theta_{i}\geq 0$ and $\gamma>0$ by assumption, there are no solutions with $\lambda=0$, $\mu>0$.

Case 3, $\lambda>0,\mu=0$. Substituting $\mu=0$ in Eq. 15 we have

$$ ${\bm{\Delta}}_{i}=\frac{{\bm{G}}_{i}-\lambda{\bm{D}}_{i}}{\lambda}.$ $$

Substituting this in Eq. 16, we have

$$ $\displaystyle\|\frac{{\bm{G}}_{i}-\lambda{\bm{D}}_{i}}{\lambda}\|^{2}+2\frac{{\bm{G}}_{i}-\lambda{\bm{D}}_{i}}{\lambda}\cdot{\bm{D}}_{i}=0,$ $\displaystyle\|{\bm{G}}_{i}\|^{2}+\lambda^{2}-2\lambda{\bm{G}}_{i}\cdot{\bm{D}}_{i}+2\lambda({\bm{G}}_{i}\cdot{\bm{D}}_{i}-\lambda)=0,$ $$

implying, since $\lambda>0$,

$$ $\lambda=\|{\bm{G}}_{i}\|,$ $$

and therefore

$$ ${\bm{\Delta}}_{i}=\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}-{\bm{D}}_{i}.$ $$

Note that to satisfy Eq. 18, we must have

$$ $\displaystyle(\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}-{\bm{D}}_{i})\cdot(\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}-{\bm{D}}_{i})\leq\gamma,$ $$

simplifying which we have

$$ $\cos\theta_{i}\geq 1-\frac{\gamma}{2}.$ $$

To summarize, we showed that setting

$$ ${\bm{\Delta}}_{i}=\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}-{\bm{D}}_{i},\;\mu=0,\;\text{and}\;\lambda=\|{\bm{G}}_{i}\|$ $$

satisfy all KKT conditions whenever $\cos\theta_{i}\geq 1-\frac{\gamma}{2}$.

Case 4, $\lambda>0,\mu>0$. From Eq. 15, we have

$$ $\displaystyle{\bm{\Delta}}_{i}=\frac{{\bm{G}}_{i}-\lambda{\bm{D}}_{i}}{\lambda+\mu}$ (21) $$

and since $\|{\bm{\Delta}}_{i}\|-\gamma=0$, Eq. 16 simplifies to $\gamma+2{\bm{\Delta}}_{i}\cdot{\bm{D}}_{i}=0$, so that

$$ $2\frac{{\bm{G}}_{i}\cdot{\bm{D}}_{i}-\lambda{\bm{D}}_{i}\cdot{\bm{D}}_{i}}{\lambda+\mu}=-\gamma.$ $$

Therefore,

$$ $\displaystyle\mu=2\frac{\lambda-{\bm{G}}_{i}\cdot{\bm{D}}_{i}}{\gamma}-\lambda.$ (22) $$

Substituting this in Eq.‘21, we have

$$ $\displaystyle{\bm{\Delta}}_{i}=\frac{\gamma}{2}\frac{{\bm{G}}_{i}-\lambda{\bm{D}}_{i}}{\lambda-{\bm{G}}_{i}\cdot{\bm{D}}_{i}}.$ (23) $$

Now, substituting Eq. 23 in Eq. 17, we get

$$ $\frac{\gamma^{2}}{4(\lambda-{\bm{G}}_{i}\cdot{\bm{D}}_{i})^{2}}({\bm{G}}_{i}-\lambda{\bm{D}}_{i})\cdot({\bm{G}}_{i}-\lambda{\bm{D}}_{i})=\gamma$ $$

So

$$ $\frac{\gamma}{4}(\|{\bm{G}}_{i}\|^{2}-\lambda^{2}-2\lambda{\bm{G}}_{i}\cdot{\bm{D}}_{i})=\lambda^{2}+({\bm{G}}_{i}\cdot{\bm{D}}_{i})^{2}-2\lambda{\bm{G}}_{i}\cdot{\bm{D}}_{i}.$ $$

Rearranging, we obtain a quadratic equation in $\lambda$,

$$ $\lambda^{2}-2{\bm{D}}_{i}\cdot{\bm{G}}_{i}\lambda+\frac{\|{\bm{G}}_{i}\|^{2}(\gamma-4\cos^{2}\theta_{i})}{\gamma-4}=0,$ $$

where we have used the fact that $({\bm{D}}_{i}\cdot{\bm{G}}_{i})^{2}=\|{\bm{G}}_{i}\|^{2}\cos^{2}\theta_{i}$. Solving the equation and simplifying we have

$$ $\displaystyle\lambda={\bm{D}}_{i}\cdot{\bm{G}}_{i}\pm\|{\bm{G}}_{i}\|\sin\theta_{i}\sqrt{\frac{\gamma}{4-\gamma}}.$ (24) $$

Note that we must also have $\mu>0$, so substituting Eq. 24 into Eq. 22 and rearranging we must have

$$ $\displaystyle\pm\|{\bm{G}}_{i}\|\sin\theta_{i}\sqrt{\frac{\gamma}{4-\gamma}}(\frac{2}{\gamma}-1)-{\bm{D}}_{i}\cdot{\bm{G}}_{i}>$ $\displaystyle\,0,$ $\displaystyle\pm\sin\theta_{i}\sqrt{\frac{\gamma}{4-\gamma}}(\frac{2}{\gamma}-1)>$ $\displaystyle\cos\theta_{i}.$ (25) $$

Observe that, for $\theta_{i}\in[0,\frac{\pi}{2}]$, both $\sin\theta_{i}$ and $\cos\theta_{i}$ are non-negative, so that when $\gamma<2$ only the positive branch is able to satisfy Eq. 25. In this case, we have

$$ $\displaystyle\lambda={\bm{D}}_{i}\cdot{\bm{G}}_{i}+\|{\bm{G}}_{i}\|\sin\theta_{i}\sqrt{\frac{\gamma}{4-\gamma}}.$ (26) $$

Note that

$$ $\displaystyle\|{\bm{G}}_{i}\|\cos\theta_{i}+\|{\bm{G}}_{i}\|\sin\theta_{i}\sqrt{\frac{\gamma}{4-\gamma}}>0,$ $$

for $\theta_{i}\in[0,\frac{\pi}{2}]$, and thus $\lambda>0$ is satisfied. Simplifying Eq. 25, observe that for $\theta_{i}\in[0,\frac{\pi}{2}]$ and $0<\gamma<2$,

$$ $\displaystyle\sin\theta_{i}\sqrt{\frac{(2-\gamma)^{2}}{\gamma(4-\gamma)}}>\cos\theta_{i}\iff\theta_{i}>\arctan(\sqrt{\frac{\gamma(4-\gamma)}{(2-\gamma)^{2}}})\iff\cos\theta_{i}<\frac{1}{\sqrt{1+\frac{\gamma(4-\gamma)}{(2-\gamma)^{2}}}}=1-\frac{\gamma}{2}.$ (27) $$

To summarize, taking the positive branch in Eq. 24, we showed that

$$ $\displaystyle{\bm{\Delta}}_{i}$ $\displaystyle=\frac{\sqrt{\gamma(4-\gamma)}({\bm{G}}_{i}-({\bm{D}}_{i}\cdot{\bm{G}}_{i}){\bm{D}}_{i})}{2\|{\bm{G}}_{i}\|\sin\theta_{i}}-\frac{\gamma}{2}{\bm{D}}_{i},$ $\displaystyle\lambda$ $\displaystyle={\bm{D}}_{i}\cdot{\bm{G}}_{i}+\|{\bm{G}}_{i}\|\sin\theta_{i}\sqrt{\frac{\gamma}{4-\gamma}},\text{and}$ $\displaystyle\mu$ $\displaystyle=\|{\bm{G}}_{i}\|\sin\theta_{i}\sqrt{\frac{(2-\gamma)^{2}}{\gamma(4-\gamma)}}-{\bm{D}}_{i}\cdot{\bm{G}}_{i}$ $$

satisfy the KKT conditions whenever

$$ $\cos\theta_{i}<1-\frac{\gamma}{2}.$ $$

Finally, consider the negative branch in Eq. 24 and $\gamma>2$. To have $\mu>0$, following an argument similar to Eq. 27, we must have

$$ $\displaystyle\cos\theta_{i}<|1-\frac{\gamma}{2}|,$ $$

and similarly for $\lambda>0$, we must have

$$ $\displaystyle\|{\bm{G}}_{i}\|\cos\theta_{i}-\|{\bm{G}}_{i}\|\sin\theta_{i}\sqrt{\frac{\gamma}{4-\gamma}}>0\iff\theta_{i}<\arctan(\sqrt{\frac{4-\gamma}{\gamma}})\iff\cos\theta_{i}>\frac{1}{2}\sqrt{\gamma}.$ $$

However, $\frac{\sqrt{\gamma}}{2}\geq|1-\frac{\gamma}{2}|$ for all $\gamma\in[2,4]$, which implies $\mu>0$ and $\lambda>0$ cannot hold at the same time in this case. Finally, observe that $\|{\bm{G}}_{i}-({\bm{D}}_{i}\cdot{\bm{G}}_{i}){\bm{D}}_{i}\|=\|{\bm{G}}_{i}\|\sin\theta_{i}$.
∎

#### B.4.3 Proof of Lemma 3

We first find $\gamma$ values where $f(\gamma)=0$. Observe that

$$ $a\sqrt{\gamma(4-\gamma)}+b\gamma+c=0\Rightarrow a^{2}\gamma(4-\gamma)-(b\gamma+c)^{2}=0,$ $$

so that $a^{2}\gamma(4-\gamma)-(b\gamma+c)^{2}=0$ is necessary for $f(\gamma)=0$. Moreover solving the quadratic inequality, $a^{2}\gamma(4-\gamma)-(b\gamma+c)^{2}=0$ iff $\gamma\in\{\gamma_{0},\gamma_{1}\}$ where

$$ $\gamma_{0}=\frac{2a^{2}-bc-a\sqrt{\delta}}{a^{2}+b^{2}},\;\gamma_{1}=\frac{2a^{2}-bc+a\sqrt{\delta}}{a^{2}+b^{2}},\;\textnormal{for }\delta=4a^{2}-4bc-a^{2}c^{2}.$ $$

Thus, $\gamma\in\{\gamma_{0},\gamma_{1}\}$ is necessary for $f(\gamma)=0$, which proves the first part of the lemma.

The proof of the rest of the lemma uses the above, the fact that $f$ is continuous, in addition to the following facts:

$$ $\displaystyle c>0\Rightarrow f(0)>0,\;c<0\Rightarrow f(0)<0$ (28) $\displaystyle c=0,b>0\Rightarrow f(4)>0,\;c=0,b<0\Rightarrow f(4)<0$ (29) $\displaystyle f\text{ has at most 1 local extrema, which is a maximum if }a>0\text{ and a minimum if }a<0$ (30) $$

If there are zero roots, $f(\gamma)>0$ either for all of $(0,4)$ or none of it, which can be determined by checking the function value at 0 or 4 using Eq. 28 and 29 if $c\neq 0$ or $b\neq 0$. If $c=b=0$, then we can solve $f(\gamma)>0$ based on whether the function has a minimum or maximum using Eq. 30, or is a constant when $a=0$.

If there is one root, $\gamma_{0}$, then $f(\gamma)$ is either positive after $\gamma_{0}$ or before it. If $c\neq 0$, we can find this by checking $f(0)$ using Eq. 28. If $c=0$, then $f(\gamma)$ has two roots, at 0 and $\gamma_{0}$, and $f(\gamma)>0$ can be determined based on whether the function has a minimum or maximum using Eq. 30. Both $c$ and $a$ cannot be zero, because the function $b\gamma$ cannot be zero both at $\gamma=0$ and $\gamma=\gamma_{0}$ for $\gamma_{0}\neq 0$.

If there are two roots, then $f(\gamma)>0$ either between the two roots, or outside the interval between the two roots, which can be checked based on $f(0)$ using Eq 28. $c$ cannot be zero because $f(\gamma)$ cannot be zero at $\gamma=0$, $\gamma=\gamma_{0}$ and $\gamma=\gamma_{1}$ for 3 distinct values fo $0,\gamma_{0},\gamma_{1}$. ∎

## Appendix C Iterative NUDGE Variants

In the main body of the paper, we presented two NUDGE variants, NUDGE-M and NUDGE-N. this section presents other practical extensions that are more flexible in their optimization approach but do not provide closed-form optimal solutions.

Specifically, the NUDGE variants discussed in the paper can be difficult to implement (especially NUDGE-N) and are not flexible, e.g., considering other accuracy metrics or constraints requires a new theoretical study. Here, we discuss simple NUDGE variants that use gradient descent to optimize MaxS-EFT (e.g., to solve the inner optimization in BiMax-M) and hyperparameter tuning to optimize MaxA-EFT (e.g., to solve the outer optimization in BiMax-M). This approaches can be less efficient and suboptimal, but can still provide accurate solutions, and are simple and flexible. In such NUDGE variants, the learning rate and number of iterations act as knobs constraining how much the embeddings change.

NUDGE-IM. First, note that MaxS-EFT is equivalent to minimizing the following loss

$$ $\displaystyle\mathcal{L}=-\sum_{i\in[n_{T}]}{\bm{Q}}_{i}\cdot({\bm{D}}_{Y_{i}}+{\bm{\Delta}}_{Y_{i}}).$ (31) $$

NUDGE-IM performs gradient descent on loss in Eq. 31 with learning rate $\alpha$ for $t$ iterations ($\alpha$ and $t$ determined through hyperparameter tuning to maximize validation accuracy) with normalized gradients:

$$ $\displaystyle{\bm{\Delta}}^{(0)}\leftarrow\mathbf{0},\;{\bm{\Delta}}^{(t)}\leftarrow{\bm{\Delta}}^{(t-1)}-\alpha\frac{\nabla_{{\bm{\Delta}}}\mathcal{L}}{\|\nabla_{{\bm{\Delta}}}\mathcal{L}\|}.$ $$

###### Lemma 4 .

NUDGE-IM finds a solution equal to NUDGE-IM, and thus optimally solves BiMax-M, whenever $\alpha t=\gamma^{*}$, where $\gamma^{*}$ is the optimal $\gamma$ value found by NUDGE-M.

Proof. Observe that ${\bm{G}}_{i}=-\nabla_{{\bm{\Delta}}_{i}}\mathcal{L}$, and therefore the gradient remains constant through optimization. Thus, after $t$ iterations, we have

$$ ${\bm{\Delta}}_{i}^{(t)}=\alpha t\mathds{I}[{\bm{G}}_{i}\neq 0]\frac{{\bm{G}}_{i}}{\|{\bm{G}}_{i}\|}.$ $$

Thus, setting $\gamma^{*}=\alpha t$, we obtain the same results as NUDGE-M.∎

The above lemma implies using gradient descent with suitable $\alpha$ and $t$ can also provide accurate solutions, but at the cost of efficiency due to iterative updates and hyperparameter tuning (instead of using the closed-form solutions), and the added challenge of finding suitable $\alpha$ and $t$. Appx. E.5 presents an experimental study of these trade-offs.

NUDGE-IN. Another alternative is NUDGE-IN, an iteratively normalized NUDGE variant. NUDGE-IN is similar to NUDGE-IM but normalizes the embeddings after every update:

$$ ${\bm{D}}^{(0)}_{i}\leftarrow{\bm{D}}_{i},\quad{\bm{D}}^{(t)}_{i}\leftarrow\frac{{\bm{D}}^{(t-1)}_{i}+\alpha\frac{\nabla_{{\bm{\Delta}}}\mathcal{L}}{\|\nabla_{{\bm{\Delta}}}\mathcal{L}\|}}{\|{\bm{D}}^{(t-1)}_{i}+\alpha\frac{\nabla_{{\bm{\Delta}}}\mathcal{L}}{\|\nabla_{{\bm{\Delta}}}\mathcal{L}\|}\|}\quad\forall i\in[n].$ $$

NUDGE-IN ensure the fine-tuned embeddings are normalized similar to NUDGE-N. Although, there is no theoretical equivalency between the solutions of NUDGE-IN and NUDGE-N, we observed similar accuracy in practice. Meanwhile, NUDGE-IN is less efficient but simpler to implement.

###### Lemma 4 .

## Appendix D Multi-Label Formulation

In the main body of the paper, we provided fine-tuning solutions assuming each query has a single ground-truth answer. Here, we discuss how our results can be extended to a multi-label setting. We first formalize the problem setting with multiple labels and then discuss how to extend our results.

Ground-Truth Answers. For a query, ${\bm{q}}$, its ground-truth answer is a ranking of the data records so that the highest-ranked records are the most related to the query. This ranking can be represented using relevance scores, which, for each data record, quantifies how related the record is to the query (relevance score zero means the record is unrelated). The ground-truth ranking can be obtained by sorting the data records based on their relevance scores. More formally, we represent the ground-truth ranking for a query with a ground-truth rank index set, $y=\{y_{1},...,y_{p}\}$ and corresponding ground-truth relevance score set $r=\{r_{1},...,r_{p}\}$ for some integer $p$ denoting the number of data records that are related to the query; the remaining records are not relate to the query. This means that record $\bar{D}_{y_{i}}$ has relevance $r_{i}$ to the query, and any record index not present in $y$ is assumed to have zero relevance score. Thus, sorting the dataset based on $r$ gives the ground-truth answer to the query. We drop the set $r$ if $|y|=1$, or if $r_{1}=...=r_{p}=1$.

Fine-Tuning Query Sets. For fine-tuning, a query set and corresponding ground-truth answers are available, consisting of queries $\bar{Q}$ and ground-truth answer sets $Y$, $R$, where for the $j$-th query $\bar{q}_{j}\in\bar{Q}$, $Y_{j}$ is the ground-truth index set and $R_{j}$ is the ground-truth relevance score set for $\bar{q}_{j}$. We assume this training set is split into two, a training set $\bar{Q}^{T},Y^{T}$, $R^{T}$ and a validation set $\bar{Q}^{V},Y^{V},R^{V}$, with $n_{T}$ and $n_{V}$ queries respectively. Similar to single label setting, let ${\bm{Q}}^{T}\in\mathcal{R}^{n_{T}\times d}$ and ${\bm{Q}}^{V}\in\mathcal{R}^{n_{V}\times d}$ be matrices containing embeddings for training and validation queries.

Problem Formulation. Both MaxS-EFT and MaxA-EFT can be modified to utilize multiple labels. For MaxS-EFT we can change the objective to $\sum_{i\in[n_{T}]}\sum_{j^{*}\in Y_{i}^{T}}{\bm{Q}}^{T}_{i}\cdot({\bm{D}}_{j^{*}}+{\bm{\Delta}}_{j^{*}})$, where summation over $Y_{i}^{T}$ can optionally be weighted by relevance scores. For MaxA-EFT, we can adjust the inequalities in the definition of the correct answer to a query (i.e., Eq. 1), so that for a query ${\bm{q}}$ with two relevance scores $r_{1}$ and $r_{2}$, $r_{1}>r_{2}$, and for $R_{1}$ and $R_{2}$ containing document indexes with $r_{1}$ and $r_{2}$ relevance scores, we say ${\bm{q}}$ is answered correctly when

$$ $\displaystyle{\bm{q}}\cdot({\bm{D}}_{i}+{\bm{\Delta}}_{i})>{\bm{q}}\cdot({\bm{D}}_{j}+{\bm{\Delta}}_{j}),\;i\in R_{1},j\in R_{2}.$ (32) $$

NUDGE. To solve BiMax-M and BiMax-N, observe that the above modifications cause marginal changes for MaxS-M and MaxS-N, and only require modifying the definition of ${\bm{G}}$ in the corresponding optimal solutions. However, the solutions to the outer optimization problem in BiMax-M and BiMax-N require further modifications since now a different set of inequalities needs to be solved to find the range of $\gamma$ for which a query is answered correctly. However, each inequality is still of the same form as before (compare Eq. 32 with Eq. 1), and thus, the same methodology applies.

**Table 9: NDCG@10 results for GTE-L on text datasets**
| Method | ArguAna | Fever | HotpotQA | NF-Corpus | NQ | SciFact | TriviaQA |
| --- | --- | --- | --- | --- | --- | --- | --- |
| NUDGE-M | 52.4 (+0) | 95.6 (+8.6) | 60.8 (+10.3) | 45.2 (+7.9) | 50.6 (+9.5) | 82.4 (+7.9) | 40.1 (+9.9) |
| NUDGE-N | 52.4 (+0) | 93.1 (+6.1) | 57.0 (+6.4) | 46.9 (+9.6) | 56.2 (+15.1) | 88.3 (+13.8) | 45.0 (+14.7) |
| Adapter | 52.4 (+0) | 87.0 (+0) | 53.0 (+2.5) | 38.5 (+1.1) | 41.1 (+0) | 87.8 (+13.4) | 30.2 (+0) |
| No Fine-Tuning | 52.4 | 87.0 | 50.5 | 37.4 | 41.1 | 74.5 | 30.2 |

**Table 10: NDCG@10 results for TE3-L on text datasets**
| Method | ArguAna | Fever | HotpotQA | NF-Corpus | NQ | SciFact | TriviaQA |
| --- | --- | --- | --- | --- | --- | --- | --- |
| NUDGE-M | 42.4 (+0.1) | 94.8 (+14.8) | 65.2 (+14.2) | 50.7 (+10.5) | 56.6 (+13.0) | 86.5 (+11.1) | 46.1 (+13.1) |
| NUDGE-N | 42.4 (+0.1) | 93.1 (+13.2) | 63.4 (+12.3) | 49.0 (+8.7) | 59.6 (+16.0) | 89.8 (+14.4) | 50.1 (+17.1) |
| Adapter | 41.7 (–0.6) | 88.7 (+8.8) | 54.5 (+3.4) | 42.1 (+1.8) | 42.4 (–1.2) | 90.9 (+15.5) | 32.7 (–0.3) |
| No Fine-Tuning | 42.3 | 79.9 | 51.0 | 40.2 | 43.6 | 75.4 | 33.0 |

## Appendix E Additional Experiments and Details

Here we present additional experimental details and results:

- •
Appx. E.1 discussed details on the implementation of Adaptor and PTFT, including hyper-parameter tuning, loss, and efficiency considerations.
- •
Appx. E.2 contains detailed per dataset results summarized in the paper’s main body.
- •
Appx. E.3 presents experiments on the training processes of Adaptors and PTFT to understand their failure modes.
- •
Appx. E.4 provides an ablation study of various normalization methods in NUDGE.
- •
Appx. E.5 provides an experimental comparison between NUDGE-M and its corresponding iterative variant NUDGE-IM.

### E.1 Adaptor and PTFT details and hyper-parameter tuning

-L loss. The results presented with -L suffix use a modified version of MNR loss. The MNR loss, for a batch of $b$ queries, ${\bm{Q}}^{B}$, and positive examples (i.e., data records that the correct answer to queries) ${\bm{D}}^{B}$, where ${\bm{D}}_{i}$ is a positive example for ${\bm{Q}}_{i}$ for any $i\in[b]$, treats every other example in the batch as negative examples for ${\bm{Q}}_{i}$. Let $\mathcal{S}_{i,j}=\frac{{\bm{Q}}_{i}\cdot{\bm{D}}_{j}}{\|{\bm{Q}}_{i}\|\|{\bm{D}}_{i}\|}$ for any $i,j\in[b]$. Then, MNR loss minimizes

$$ $\mathcal{L}_{MNR}=-\sum_{i\in[b]}\log\frac{e^{\tau\mathcal{S}_{i,i}}}{\sum_{j\in[b]}e^{\tau\mathcal{S}_{i,j}}},$ $$

for some temperature parameter $\tau$. Our modified loss, for the $i$-th query, ignores samples, $j$, for which $\mathcal{S}_{i,j}<\eta$ for some threshold $\eta$:

$$ $\mathcal{L^{\prime}}=-\sum_{i\in[b]}\log\frac{\mathds{I}[\mathcal{S}_{i,i}\geq\eta]e^{\tau\mathcal{S}_{i,i}}}{\sum_{j\in[b]}\mathds{I}[\mathcal{S}_{i,j}\geq\eta]e^{\tau\mathcal{S}_{i,j}}}.$ $$

This follows the intuition that, at the fine-tuning stage, the model only needs to get better at distinguishing between records that have high similarity and is already accurate enough to separate relevant from non-relevant items. $\tau$ and $\eta$ are related and are jointly set through hyperparameter tuning.

Modeling details and hyper-parameter Tuning. For both Adaptor and PTFT, we did hyperparameter tuning to determine the learning rate (and use of a scheduler), batch size (although for PTFT it is bottlenecked by GPU memory size), number of training steps, model architecture and initialization (for Adaptor, we tried linear up to 8 layer MLPs) and which layers to train (for PTFT, we tried training the full model or training the last layer), and the choice and parameters of the loss function. We only performed hyper-parameter tuning for BGE-S, and used the resulting hyper-parameters for other models. We note that the choice of initialization is particularly important for Adaptor, and we observed a significant advantage to ensuring that at initialization, Adaptor is an identity function. For a single-layer adaptor, this can be achieved by setting the weight matrix to the identity matrix (also done by Llama Index (LlamaIndex, )). For multi-layer adaptors, using ReLU activation, assuming queries are normalized (so that a query input ${\bm{q}}\geq-1$), we achieve this by setting the weights to identity, the bias of first layer to +1, the bias of last layer to -1 and other biases to 0. We are unaware of this initialization being used by existing work for multi-layer adaptors, and we observed benefits to using this initialization over initialization that modify the embeddings at initialization (e.g., setting all biases to 0).

Efficient Implementation. For Adaptor, our implementation is based on Llama Index LlamaIndex () and for PTFT based on Sentence Transformers Aarsen (), but with additional considerations for initialization (for Adaptor, see above), loss function (see above) and efficiency. We observed that validation passes (for model checkpointing) often take longer than training passes (because the number of data records is often more than the number of training queries in our datasets), we used hyperparameter tuning to set the validation frequency to as low as possible without affecting final accuracy. For Adptor, when applying Adaptor only to queries (so that data records don’t get embedded), we also used a vector index (Faiss library Douze et al. ()) but did not observe any speed-ups (perhaps due to the already parallelizable nature of answering batched queries, and that we only do top-1 lookup during validation). For PTFT, a single validation pass, which requires re-embedding the entire dataset, can take more than an hour on our large datasets (Fever, NQ, TriviaQA, HotpotQA). To reduce the computational cost, for each validation query, we selected its top-10 answers based on the pre-trained model and only included those (in addition to ground-truth training and validation answers) data records in the dataset for validation. This provided more than 10x speed-up for validation on large datasets, and we observed similar final accuracy (intuitively, this removes data records from validation that, unless the pre-trained model significantly changes, are unlikely to impact validation accuracy). Finally, we use early stopping if validation accuracy drops by more than 5% compared with the maximum it had achieved.

### E.2 Other Per Dataset Results

Tables 9-12 present the per dataset results for the embedding models GTE-L, TE3-L, CLIP-B and CLIP-L. The tables (in addition to Table 6) present the detailed results from which Tables 3-5 are generated.

**Table 11: NDCG@10 results for CLIP-B on image datasets**
| Method | COCO | Flickr |
| --- | --- | --- |
| NUDGE-M | 29.7 (+11.6) | 52.2 (+16.5) |
| NUDGE-N | 29.9 (+11.9) | 52.4 (+16.7) |
| Adapter | 20.0 (+2.0) | 39.8 (+4.1) |
| No Fine-Tuning | 18.0 | 35.7 |

Figure: Figure 2: Training and validation accuracy for BGE-S on three datasets
Refer to caption: x2.png

### E.3 Training and Validation Accuracy During Training

To better understand the differences and failure modes of the approaches, Fig. 2 shows the validation and training accuracy for Adaptor, PTFT and NUDGE-IM, where T and V respectively signify training and validation sets.

Fig. 2 (a) and (b) show two failure modes for Adaptor, overfitting, and underfitting. Specifically, Fig. 2 (a) shows NUDGE provides much better validation accuracy compared with Adaptors at the same training accuracy, suggesting that Adaptor simply overfits to the training set instead of learning generalizable patterns. Fig. 2 (b) shows the other end of the spectrum, where Adaptor fails to fit the training set at all (while NUDGE both fits the training set and improves validation accuracy). We observed this behavior on large data and query sets. We also observed (but not shown here) that increasing the number of parameters, e.g., by introducing additional layers, did not improve accuracy, suggesting that perhaps using adaptors is a wrong modeling choice. Fig. 2 (c) shows the only dataset where Adaptor performs well, where it both fits the training set and improves validation accuracy.

PTFT, on the other hand, has a much smaller generalization gap compared with Adaptor. However, both validation and training accuracy increase at a much slower pace, and eventually plateau. Especially for NQ, we observe that the model underfits the training set. We hypothesized that one reason could be due to the loss function used, where indeed Table. 6 shows our attempt at modifying the loss function does help improve accuracy on NQ, but not consistently across datasets (and worsens the accuracy on other datasets).

### E.4 Normalization Ablation Study

We compare NUDGE-N, with NUDGE-IN (as described in Sec. C) with two other potential variants to understand the impact of normalization. NUDGE-M+N is a variant that first performs NUDGE-M and then normalizes embeddings post-hoc. NUDGE-IM+R is a variation of NUDGE-IM with L2 regularization added to the loss to penalize embeddings with large norms. Table 13 shows the results for this experiment, showing that normalizing embeddings after optimization, i.e., NUDGE-M+N performs worse than when normalization is considered as part of optimization, which is the case for both NUDGE-IN and NUDGE-N. NUDGE-IM+R performs worse than all methods, showing an advantage for enforcing a normalization constraint over L2 regularization. Meanwhile, NUDGE-IN and NUDGE-N perform similarly (see Sec. C for a discussion between the two).

**Table 13: Normalization Study, avg. BGE-S accuracy**
| Method | NDCG@10 |
| --- | --- |
| NUDGE-N | 61.1 |
| NUDGE-IN | 61.8 |
| NUDGE-M+N | 58.8 |
| NUDGE-IM+R | 52.4 |

**Table 14: Accuracy/efficiency of iterative and non-iterative NUDGE variants (BGE-S on text datasets)**
| Method | R@1 | R@10 | NDCG@10 | Fine-Tuning Time (s) |
| --- | --- | --- | --- | --- |
| NUDGE-IM-$(10^{-4},10^{3})$ | 50.4 | 66.5 | 57.2 | 11.3 |
| NUDGE-IM-$(10^{-3},10^{2})$ | 50.4 | 66.5 | 57.1 | 4.16 |
| NUDGE-IM-$(10^{-2},10)$ | 48.0 | 59.2 | 51.1 | 3.46 |
| NUDGE-M | 50.5 | 66.6 | 57.3 | 3.49 |

### E.5 Iterative vs. Closed-Form NUDGE variants

We present results comparing NUDGE-M and NUDGE-IM. We use NUDGE-IM-($\alpha$, $t$) to refer to NUDGE-IM with learning rate $\alpha$ run for $t$ iteration (although we use model checkpointing based on validation accuracy, so the presented accuracy can be for a model trained with fewer iterations than $t$). Overall, the results show that NUDGE-M saves time while providing the best accuracy, while some NUDGE-IM variants are as accurate while being less efficient. Nonetheless, NUDGE-IM variants are simple to implement and more flexible (e.g., in terms of validation accuracy metric to use), and thus may be preferred in some applications.

## Peer Reviews

confidence: 3
contribution: 3
initial_rating: 5
presentation: 3
questions: 1. What is the sensitivity of NUDGE's performance to hyperparameter selection, particularly the choice of γ. If 'NUDGEM sets γ by solving MaxA-EFT on the validation set', how should γ be set on the training set?

2. In Eq.1, the range of j is confusing, what does '\Y_j' represent?

3. Why do NUDGE-M and NUDGE-N methods have similar average results on image retrieval pre-trained models. （CLIP-B and CLIP-L）

4. The criteria for selecting the constraint boundaries in NUDGE-M and the specific reasoning behind the grid search implementation for NUDGE-N's gamma optimization are not fully detailed.

5. How to mitigate the impact of unreliable training query embeddings when fine-tuning based on these embeddings?
soundness: 3
strengths: 1.The s NUDGE, a non-parametric embedding fine-tuning method, which innovatively addresses the limitations of parametric approaches in k-Nearest Neighbor (k-NN) retrieval. This originality stems from shifting focus to the embeddings themselves rather than model parameters, offering a novel optimization perspective for retrieval tasks. 

2.Comprehensive experimental and theoretical analyses validate NUDGE's efficacy across five pre-trained models and nine retrieval datasets.

3.The paper is well-organized and presents its methodology and experimental findings clearly.

4.By providing a lightweight, model-agnostic solution with strong generalization to out-of-distribution queries, NUDGE offers substantial improvements in both computational efficiency and accuracy.
summary: This work presented a family of novel non-parametric embedding fine-tuning approaches that are significantly more accurate and efficient than both sets of existing approaches.
weaknesses: 1. It does not extensively explore or compare alternative constraint types. For example, additional regularization techniques, such as sparsity constraints or adaptive thresholds.

2. Lack a detailed ablation study that examines how skewed distributions impact both in-distribution and out-of-distribution performance could reveal if other normalization techniques or dataset-specific adjustments would better manage this overfitting.

3. While the optimization and constraint methods are described, some of the choices behind the approach could use further explanation.

---

confidence: 3
contribution: 2
initial_rating: 5
presentation: 3
questions: As the modifications of the embeddings still require learning and would be sufficiently large given a large dataset, how much benefit does this method still have when the dataset is large?
soundness: 2
strengths: 1. **Intuition of the Proposed Method**: The paper clearly presents NUDGE's core idea of directly modifying embeddings as parameters, offering a simple, intuitive approach to fine-tuning that improves retrieval accuracy without altering the model.

2. **Extensive Experimental Evaluation**: Experiments are comprehensive, covering diverse retrieval tasks (text, cross-modal) and configurations, validating NUDGE's effectiveness, efficiency, and adaptability across different datasets and models.
summary: This paper introduces NUDGE, a non-parametric embedding fine-tuning approach designed to enhance k-nearest neighbor (k-NN) retrieval accuracy in text and image retrieval tasks. Two main variants, NUDGE-M and NUDGE-N, apply controlled modifications to embeddings, with NUDGE-M using bounded changes and NUDGE-N adding normalization to improve out-of-distribution generalization. Experimental results across multiple datasets show that NUDGE consistently outperforms traditional PTFT and Adapter methods.
weaknesses: 1. **Theoretical Issues**:
   - Equation (1), defining MaxA-EFT, is disconnected from the actual task as it primarily maximizes inner product similarity without a clear link to retrieval-specific objectives.
   - The NP-hard nature of MaxA-EFT, while noted, lacks clear relevance to the search task, and the authors fail to define an explicit optimization problem for solving it.
   - Equation (2) being unbounded is more of a general mathematical property and seems unrelated to the paper’s focus on non-parametric methods.
   - Line 212’s constraint on \(\Delta\) uses matrix norm notation, which doesn’t adequately capture the constraints on embedding norms, indicating a need for clearer notation.

2. **Experimental Issues**:
   - Table 3’s results are overly generalized under “across text datasets,” obscuring which datasets contributed to the reported metrics.
   - In BEIR benchmark results (Table 5 and Table 9), the first column shows identical performance across all methods, which is counterintuitive and suggests either data or methodology issues.
   - The GPU speedup in Table 6 is marginal compared to the CPU, which raises efficiency concerns, as an A100 GPU should provide significantly higher speedup for such operations relative to CPU processing.

---

confidence: 4
contribution: 3
initial_rating: 5
presentation: 2
questions: I would be willing to raise my rating if the "closed-word" setting of the paper was clearly discussed and mentioned as a limitation compared to the baselines it compares with. It is not even sure it's legitimate to call the method "fine-tuning". However, it *is* an interesting study of what can happen if embeddings are optimized directly (it's just not practical beyond a benchmark setting). 

For out-of-sample results, it would be interesting to see what would happen if an actual feature transformation model was trained on top of the embeddings found by this method.
soundness: 3
strengths: S1. The study is an interesting exploration of dataset side adaptation, in the case of a "closed world" dataset that is frozen. 

S2. The approach and baselines are relevant. The adaptation relies on simple linear algebra, so it is fast and much can be done in closed form.

S3. Convincing results: since the training acts directly on the embeddings (as opposed to network parameters) it has more degrees of freedom than when training on the model (indirect fine-tuning)
summary: The context is embedding-based retrieval, for Q&A on documents, RAG, text-to-image retrieval, etc. The authors propose to do domain adaptation by "fine-tuning" the document embeddings with a supervision. The results show that this is more accurate (and faster) than to fine-tune the feature extraction model or to train a transformation model on top of frozen features.
weaknesses: W1. The "elephant in the room" for this method is that it does not work on out-of-sample documents. Since the embeddings of the database are adjusted at fine-tuning time, new documents cannot benefit from it, unless new training data is added for them as well, which becomes a really narrow application setting. This is all the more apparent since out-of-distribution on the queries side is considered in this work.

W2. The method works only on densely annotated training data, since a document that is never returned to a query will not be adapted. This is apparent in the KILT dataset where documents that do not appear in any result are simply removed. 

W3. Because of this particular setting, the queries in experiments must be split in train+val+test, which is unusual. Therefore there are no comparisons with state-of-the-art methods.

---

confidence: 5
contribution: 3
initial_rating: 8
presentation: 3
questions: [Q1] It seems appropriate to position NUDGE as the third paradigm for retrieval task fine-tuning. The three paradigms can be summarized as follows: 1) Fine-tuning the foundation model; 2) Training a tiny model to refine the embedding; 3) directly fine-tuning the embedding. These approaches present interesting trade-offs. In terms of training cost, the order is 1 > 2 > 3, while for cost of adding more photos to the DB, the order is reversed: 3 > 2 > 1. Fine-tuning a foundation model is computationally intensive, but it easily accommodates new images added to the database. NUDGE, on the other hand, is less demanding to train, but requires additional computation to update embeddings for newly added DB images. In this context, the second paradigm appears to offer the best balance among the three. Do you have any insights on this?



[Q2] How is the generalizability of other NUDGE variants?

 

Justification of my score:

Although concerns about generalizability and practicality have been raised, the overall contributions of NUDGE—such as its efficient training, strong performance, and introduction of a new fine-tuning paradigm—significantly outweigh its weaknesses. Based on these considerations, this paper merits acceptance. However, given the identified limitations, I look forward to discussing with the authors and other reviewers to further evaluate its merits. At present, I believe NUDGE represents a valuable and striking contribution to the retrieval community. I hope the authors can address my concerns or, at the very least, discuss them as limitations of this work in future revisions.
soundness: 3
strengths: [S1] The proposed method is novel, simple, and easy to implement.

[S2] The experiments effectively demonstrate the efficacy of NUDGE for in-distribution data.

[S3] The theoretical analysis clearly delineates the characteristics of NUDGE-N and NUDGE-M.

[S4] The paper is well-structured and easy to follow.

[S5] NUDGE represents a potential new paradigm for fine-tuning.

[S6] The authors have provided the code with their submission.
summary: This paper introduces NUDGE, a novel method for retrieval that directly fine-tunes index embeddings by treating them as "model parameters". The theoretical analysis yields two variants, NUDGE-M and -N, and elucidates their time complexities. Experimental results demonstrate that NUDGE significantly outperforms existing methods for in-distribution data and achieves comparable performance for out-of-distribution scenarios.
weaknesses: [W1] Fine-tuning the embedding directly makes the database difficult to update. Specifically, if new photos are added to the database, their embeddings must also be trained. This requires relabeling (or pseudo labeling) at least a few queries whose GT answers include the new DB images, which incurs additional cost (or the new DB embedding will not be updated). This weakness, however, does not appear in previous two lines of works, ie. fine-tuning the foundation model, or training a new lightweight model to refine the embeddings. Consequently, this limitation somewhat impacts the practicality of NUDGE.



[W2] NUDGE is unable to refine query embeddings. It has been well established that query embedding refinement can significantly enhance retrieval performance (as evidenced by query expansion and its variants). Both fine-tuning the foundation model and training an embedding update model are capable of updating query embeddings. However, NUDGE cannot accomplish this because the GT label for the input query is unknown, making it impossible to train. This limitation leaves considerable room for improvement.



[W3] The generalizability of the proposed method is questionable. Intuitively, embedding update methods are likely to suffer from significant overfitting issues. The authors have invested considerable effort to address this, including constraining the $\Delta$ and normalizing the updated embeddings (either pre- or post-update). While NUDGE-N ultimately achieves acceptable results for OOD data, overall confidence in its generalizability remains limited. For OOD scenarios, NUDGE-N shows only minor improvements on the BGE-S benchmark, with many other benchmarks left untested. When the embedding is not normalized (i.e., NUDGE-M), the generalizability appears notably poor. While it's plausible that the transition from NUDGE-M to NUDGE-N could yield such significant improvements, additional experiments elaborating on generalizability would be beneficial, as this might constitute a major drawback of NUDGE. Nevertheless, if NUDGE can perform adequately across most OOD benchmarks, or even in its current form, it may still be considered acceptable given the other strengths of this work.



[W4] Nit: The authors should follow the ICLR 2025 template guidelines by placing table captions above the tables.

Meta-review: Thanks for your submission to ICLR.

This paper received borderline reviews, with two positive and two negative reviews.  Some of the issues raised in the original reviews included i) missing experimental results (e.g., ablation studies), ii) missing details throughout the paper, iii) questions about the theoretical results, iv) inability to apply out-of-sample data, v) generalizability.  

The authors provided an extensive rebuttal to all of the points raised by the reviewers, including adding several new results.  I read through these carefully, along with the paper.  One of the negative reviewers never responded to the author rebuttal, though in my opinion the rebuttal clarified most of the issues raised by this reviewer.  The other negative reviewer seemed largely concerned that the paper was unnecessarily complicated (e.g., they felt the NP-hardness results were not necessary).  I disagree with the reviewer on this point, and in general agree with the authors that the weaknesses raised by this reviewer were adequately addressed by the rebuttal.  Further, the other reviewers maintained their positive score, and furthermore, the authors adequately addressed the issues in those reviews as well.

So, overall, I am willing to advocate for accepting this paper, as I think the authors have done a good job in rebutting the reviews and responding to the various concerns raised.

Decision: Accept (Poster)