HyperLoRA: Efficient Cross-task Generalization via Constrained Low-Rank Adapters Generation

Chuancheng Lv, Lei Li, Shitou Zhang, Gang Chen, Fanchao Qi, Ningyu Zhang, Hai-Tao ZhengEMNLP 2024

Introduction

Adapting Large Language Models (LLMs) to new, unseen tasks typically involves either fine-tuning or In-Context Learning (ICL). Fine-tuning is computationally intensive and risks "catastrophic forgetting," while ICL requires long, token-heavy prompts that increase inference latency and cost. Hypernetworks—models that predict weights for another model—offer a middle ground but often suffer from training instability and poor few-shot adaptation.

HyperLoRA addresses these challenges by generating task-specific Low-Rank Adaptation (LoRA) parameters directly from instructions and demonstrations. It introduces a "truth-guided" constrained loss and an automated demonstration selection strategy to achieve stable training and superior cross-task generalization.

Methods

HyperLoRA consists of two primary components: a Text Encoder and a P-generator (Parameter generator). The encoder maps task instructions and demonstrations into a latent space. The P-generator, implemented as a Transformer decoder, then transforms these latent representations into LoRA weights ($A$ and $B$ matrices) for the target LLM.

Overview of the HyperLoRA architecture, including the P-generator and the pre-training/fine-tuning workflows.

The framework incorporates three major innovations:

  1. Instruction-Based Pre-training: HyperLoRA is pre-trained on multi-task instruction data (FLAN) rather than general text, teaching the model to map specific task descriptions to weight configurations.
  2. Truth-Guided Training Objective: To mitigate training instability caused by backpropagating through a frozen LLM, the authors introduce a weight-space loss. By pre-calculating "gold" LoRA weights for training tasks, the hypernetwork is encouraged to generate weights close to these targets, providing a stable optimization signal.
  3. Gradient-based Demonstration Selection: Instead of random sampling, HyperLoRA uses gradient-based influence estimation to select the most representative demonstrations for a given task, enhancing the quality of the generated weights.

Datasets and Evaluation

The model was trained and evaluated using several benchmark suites:

  • Pre-training: A subset of 83 tasks from the FLAN collection.
  • Cross-task Generalization: Evaluated on P3 (Public Pool of Prompts) and Super-Natural Instructions (S-NI).
  • Few-shot Performance: Tested on BIG-Bench Hard (BBH) and select SuperGLUE tasks (BoolQ, CB, SciTail).

Key Insights

  • Stability via Constraints: The weight-space loss is critical. Without it, the hypernetwork struggles to converge due to the noisy gradient signal from the frozen LLM.
  • Inference Efficiency: Unlike ICL, which processes demonstrations for every query, HyperLoRA generates weights once per task. This significantly reduces the token count during inference (e.g., 111 tokens vs. 597 tokens on BBH).
  • Task Representation: Analysis reveals that HyperLoRA clusters similar tasks together in the weight space, indicating it learns a meaningful semantic mapping of task requirements.

Results

HyperLoRA achieves state-of-the-art results across multiple benchmarks. On the P3 suite, it reached a 57.3% average accuracy, surpassing previous hypernetwork methods like HyperTuning+. In few-shot scenarios on BBH, HyperLoRA reached 43.0 Exact Match (EM), outperforming both FLAN-T5 and Llama2-7B using standard ICL.

Performance comparison of HyperLoRA against baselines on SuperGLUE tasks, highlighting the benefit of automated demonstration selection.

Limitations

Despite its efficiency at inference time, HyperLoRA requires significant upfront computation for pre-training and generating "gold" weights. Current experiments are limited to models up to 3B parameters and English-language tasks; future work will explore scaling to larger models and multi-lingual settings.

Summary updated

BibTeX
@inproceedings{lv2024hyperlora,
  author = {Chuancheng Lv and Lei Li and Shitou Zhang and Gang Chen and Fanchao Qi and Ningyu Zhang and Hai-Tao Zheng},
  title = {{HyperLoRA: Efficient Cross-task Generalization via Constrained Low-Rank Adapters Generation}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.findings-emnlp.956},
}
Figure