Adder: Adapted Dense Retrieval

Anirudh Khatry, Yasharth Bajpai, Priyanshu Gupta, Sumit Gulwani, Ashish Tiwari · Submission to ICLR 2024 · Rejected

TL;DR

ADDER (Adapted Dense Retrieval) introduces a lightweight, parameter-efficient way to adapt frozen, black-box embeddings (such as OpenAI's text embeddings) to domain-specific retrieval tasks. By learning a low-rank residual transformation via a softmax key-value lookup and global hard-negative mining, ADDER significantly improves strict top-$k$ retrieval performance (e.g., $k=1, 3, 5$) without modifying underlying model weights.

What Problem Does This Paper Address?

Traditional Information Retrieval (IR) usually assumes homogeneous and relaxed conditions: queries and corpus elements are both natural language text, and retrieving relevant items anywhere in the top-20 to top-100 is acceptable.

However, modern applications—such as Retrieval-Augmented Generation (RAG) and few-shot prompt selection for large language models (LLMs)—require heterogeneous and strict retrieval:

  1. Heterogeneity: Queries and target documents often span different formats or modalities (e.g., a natural language query retrieving code snippets, structured records, or domain-specific language statements).
  2. Strictness: Because LLM context windows are limited and costly, only the top-1, top-3, or top-5 items matter.
  3. Semantic Mismatch: Off-the-shelf embedding models (e.g., OpenAI text-embedding-ada-002) are trained for general semantic text similarity, which frequently diverges from task-specific definitions of relevance (e.g., whether a claim supports or refutes an evidence snippet).

Full model fine-tuning is often impossible because production embeddings are accessed via black-box APIs, or training data is too limited to train large models without overfitting.

Methods

ADDER applies parameter-efficient fine-tuning (PEFT) directly in the latent embedding space rather than updating model weights.

Query (q) ---> [Frozen Embedding E] ---> e_q ---> [Adapter Tr] ---> e'_q
                                                                        \  Cosine
                                                                         > Similarity
Corpus (c) ---> [Frozen Embedding E] ---> e_c ---> [Adapter Tr'] -> e'_c /
  • Residual Adapter Formulation: Embeddings are adapted additively:
    $$\text{Tr}(e) = e + f(e, \theta)$$ The paper explores two variants: ADDER (which only transforms query embeddings) and ADDER2 (which transforms both query and corpus embeddings with separate parameters $\theta$ and $\theta'$).

  • Key-Value Dictionary Lookup: The residual function $f$ is parameterized as an attention-style memory lookup: $$f(e, K, V) = \text{softmax}(e K^T) V$$ where $K$ (keys) and $V$ (values) are matrices of dimension $h \times d$. Here, $d$ is the embedding dimension (e.g., 1536 for OpenAI ADA), and $h \ll d$ (typically 16 to 128). This restricts the residual correction to a low-rank $h$-dimensional subspace using only $2dh$ learnable parameters.

  • Global Negative Contrastive Loss: Standard in-batch negative sampling often yields poor representations. ADDER dynamically computes global hard negatives across the entire corpus for each batch under the model's current state.

Datasets

The authors evaluated ADDER on two sets of tasks:

  1. BEIR Benchmark Subsets: Four of the smallest datasets from the BEIR benchmark representing limited-data settings: SciFact (scientific claim verification), ArguAna (counter-argument retrieval), FiQA (financial QA), and NFCorpus (medical information retrieval).
  2. Repurposed NL-to-Code (NL2X) Benchmarks: Repurposed for retrieving code given natural language instructions:
  3. NL2SMCALFLOW: Natural language mapped to Lisp-like dataflow programs (low-resource, domain-specific).
  4. NL2BASH: Natural language mapped to Bash scripts (moderate popularity).
  5. NL2PYTHON (CoNaLa): Natural language mapped to Python snippets from StackOverflow (high-resource, widely used).

Key Insights and Ideas

  • Target unfamiliarity dictates adaptation value: Pretrained embeddings perform reasonably well on widespread languages like Python. But on specialized or low-resource targets like SMCALFLOW, off-the-shelf embeddings struggle. Adapting the embedding space yields the largest gains precisely where base embeddings have the least pretraining coverage.
  • Task semantics vs. semantic similarity: On SciFact, where relevance implies an asymmetric "supports/refutes" relationship rather than topical similarity, the adapter successfully redirects general-purpose representations toward task-specific logic.
  • Safeguard against collapse: When tasks already align well with general language semantics (e.g., NFCorpus), ADDER’s residual formulation preserves baseline performance without degrading into poor local minima.

Key Results

Evaluated using Normalized Discounted Cumulative Gain (nDCG@$k$):

  • Specialized Code Retrieval (NL2SMCALFLOW):
  • OAI Baseline: nDCG@1 = 0.64, nDCG@10 = 0.75
  • ADDER: nDCG@1 = 0.96, nDCG@10 = 0.98 (a 50% relative gain at top-1)
  • Command Retrieval (NL2BASH):
  • OAI Baseline: nDCG@1 = 0.75
  • ADDER2: nDCG@1 = 0.79
  • Claim Verification (SciFact):
  • OAI Baseline: nDCG@1 = 0.62, nDCG@10 = 0.73
  • ADDER2: nDCG@1 = 0.74, nDCG@10 = 0.83
  • CoNaLa (Python): ADDER slightly trailed the baseline (nDCG@1 of 0.75 vs. 0.77), primarily because ADA is already strong on Python and the dataset features unhandled one-to-many query-code mappings.

Limitations and Future Work

  • One-to-Many Mappings: Ungrouped duplicate positive matches degrade the contrastive ranking objective, as seen on the CoNaLa dataset.
  • Simple Adapter Architecture: The authors only explored single-layer softmax key-value lookups; deeper non-linear adapters remain unstudied.
  • Scalability of Global Negatives: Computing dynamic global negatives against the full corpus during training works well for small-to-moderate corpora (a few thousand items), but would require approximate indexing strategies on web-scale collections.

Summary updated

BibTeX
@misc{khatry2023adder,
  author = {Anirudh Khatry and Yasharth Bajpai and Priyanshu Gupta and Sumit Gulwani and Ashish Tiwari},
  title = {{Adder: Adapted Dense Retrieval}},
  year = {2023},
  eprint = {2310.05380},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.05380},
}
Figure