Retrieval Instead of Fine-tuning: A Retrieval-based Parameter Ensemble for Zero-shot Learning

Pengfei Jin, Peng Shu, Sekeun Kim, Qing Xiao, Sifan Song, Cheng Chen, Tianming Liu, Xiang Li, Quanzheng Li · Submission to ICLR 2025 · Rejected

TL;DR

Rather than fine-tuning a model on new tasks or retrieving private raw text/images via standard RAG, Retrieval-based Parameter Ensemble (RPE) retrieves and blends pre-trained parameter adapters (LoRAs) directly from a shared vector database. By computing ensemble weights based on the distance between task representations in feature space, RPE enables zero-shot task adaptation in minutes while matching or outperforming supervised fine-tuning and preserving data privacy.

What Problem Does This Paper Address?

Adapting foundation models (like LLaMA or SAM) typically requires supervised fine-tuning (SFT)—a process that is computationally expensive and demands labeled task-specific data. While parameter-efficient fine-tuning (PEFT) methods like LoRA reduce overhead, they still need target labels and compute.

Conversely, Retrieval-Augmented Generation (RAG) supports zero-shot performance without parameter updates, but retrieving raw data or data-level feature embeddings introduces major data privacy risks—especially in sensitive domains like healthcare. Furthermore, existing parameter ensemble methods (e.g., Model Soups, Mixture of Experts) either rely on simple uniform averaging across runs or require labeled validation data and expensive neural network evaluations to optimize routing weights.

RPE bridges this gap: it adapts models to unseen tasks with zero fine-tuning, zero labeled data, and no access to external raw training samples.

Methods

RPE formalizes adaptation as retrieving modular weights rather than retrieving raw documents:

  1. LoRA Vector Database (LoRA-VecDB): The authors store pre-trained LoRA weights $\{\delta\theta_i\}$ alongside a task representation vector $z_i$. The task vector is simply the mean feature map extracted from the foundation model's frozen encoder across the dataset: $$z_i = \frac{1}{|D_i|} \sum_{x_j \in D_i} E^F(x_j, \theta_0)$$
  2. Retrieval via $k$-NN: Given an unlabeled target dataset $D^{\text{trg}}$, its query representation $z^{\text{trg}}$ is extracted. The closest reference LoRAs are retrieved using squared Euclidean distance $\|z_i - z^{\text{trg}}\|_2^2$.
  3. Weight Computation: RPE calculates combination weights $w_i$ using three strategies:
  4. Similarity-based Softmax: Normalizes inverted distances via temperature-scaled softmax.
  5. Linear Combination: Solves a constrained optimization problem ($\sum w_i = 1$) to find the linear combination of reference representations that best reconstructs $z^{\text{trg}}$.
  6. Regularized Linear Combination: Adds an $\ell_1$ penalty ($\lambda_2 \|w\|_1$) to encourage sparse, robust weight allocations when facing significant distribution shifts.
  7. Parameter Merging: The adapted model parameters are assembled directly: $$\theta^{\text{trg}} = \theta_0 + \sum w_i \delta\theta_i^{\text{ref}}$$

Datasets

The authors evaluated RPE across two distinct modalities and foundation models:

  • Medical Report Impression Generation (Llama 3.1 8B): Four distinct radiology report datasets collected from Massachusetts General Hospital (MGH), including 24,801 CT abdomen, 63,745 CT head, 18,157 MRI, and 60,000 X-ray reports.
  • Medical Image Segmentation (SAM / MA-SAM): Six multi-site prostate MRI segmentation datasets (Sites A–F: RUNMC, BMC, HCRUDB, UCL, BIDMC, HK), exhibiting significant domain shifts due to differences in scanner manufacturers (Siemens, Philips, GE), magnetic field strengths (1.5T vs. 3T), and coil types.

Key Insights and Ideas

  • Parameter Space Mirrors Representation Space: The performance of a transferred LoRA strongly correlates with the distance between the target and reference dataset embeddings. The closer two datasets are in the foundation model's representation space, the higher the accuracy of the transferred LoRA.
  • Ensembles Beat the Single Nearest Neighbor: Selecting only the single closest LoRA ($k=1$) leads to severe dataset-specific overfitting and volatile results. Blending multiple LoRAs provides stability across unseen distributions.
  • Negative and Sparse Weights Matter: Unlike simple softmax similarity, linear reconstruction can assign negative weights (e.g., penalizing features from orthogonal domains) and regularized weights (shrinking noisy LoRAs to zero), which proved vital under extreme domain shift.

Key Results

  • Medical Text Generation: On the CT abdomen impression task, RPE’s linear combination achieved a 0.1393 ROUGE-L and 0.8076 BertScore F1, outperforming supervised LoRA fine-tuning (0.1387 ROUGE-L, 0.8060 F1) entirely zero-shot.
  • Medical Segmentation: Off-the-shelf SAM without LoRA completely fails on organ segmentation (random segmentations). RPE with regularized linear combination (lin+R) achieved high DICE scores across all six sites (e.g., Site A: 90.5%, Site B: 86.0%, Site D: 90.3%, Site F: 90.3%), closely approaching supervised LoRA bounds (91.2%–95.4%).
  • Speed & Efficiency: While fine-tuning a single LoRA model took 30 minutes to multiple hours, RPE assembled adapted models in a few minutes on an 8×H100 GPU cluster.

Limitations and Future Work

  • Database Scale: Experiments were performed on relatively small pools of LoRAs (4 text datasets, 6 image datasets); scaling to large community repositories requires scalable indexing and LoRA compression techniques.
  • Naive Feature Pooling: Dataset representations currently rely on a simple unweighted average of encoder feature maps. The authors note that trained meta-encoders or more expressive pooling could further improve weight determination.

Summary updated

Abstract

Foundation models have become a cornerstone in deep learning, with techniques like Low-Rank Adaptation (LoRA) offering efficient fine-tuning of large models. Similarly, methods such as Retrieval-Augmented Generation (RAG), which leverage vectorized databases, have further improved model performance by grounding outputs in external information. While these approaches have demonstrated notable success, they often require extensive training or labeled data, which can limit their adaptability in resource-constrained environments. To address these challenges, we introduce Retrieval-based Parameter Ensemble (RPE), a new method that creates a vectorized database of LoRAs, enabling efficient retrieval and application of model adaptations to new tasks. RPE minimizes the need for extensive training and eliminates the requirement for labeled data, making it particularly effective for zero-shot learning. Additionally, RPE is well-suited for privacy-sensitive domains like healthcare, as it modifies model parameters without accessing raw data. When applied to tasks such as medical report generation and image segmentation, RPE not only proved effective but also surpassed supervised fine-tuning methods in certain cases, highlighting its potential to enhance both computational efficiency and privacy in deep learning applications.
BibTeX
@misc{jin2024retrieval,
  author = {Pengfei Jin and Peng Shu and Sekeun Kim and Qing Xiao and Sifan Song and Cheng Chen and Tianming Liu and Xiang Li and Quanzheng Li},
  title = {{Retrieval Instead of Fine-tuning: A Retrieval-based Parameter Ensemble for Zero-shot Learning}},
  year = {2024},
  eprint = {2410.09908},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.09908},
}

Loading related content...

Figure