← Open Source
sail-sg

lorahub

[COLM 2024] LoraHub: Efficient Cross-Task Generalization via Dynamic LoRA Composition.

Model DevelopmentFine-tuningPython
Open on GitHub
Momentum
+0stars in 24 hours0.0%
669
Stars
44
Forks
+1
This week
4
Contributors
Created 2023-07-20 · Updated 2026-10-13 · #15242 today
Top developers
SivilTaramChengsong-Huangmiboyu24

sail-sg/lorahub is ranked 15,242 with 669 stars.

Same-category comparison

sail-sg/lorahub is ranked 15,242 among these 8 peers; mks0601/ExAvatar_RELEASE is ranked 15,240.

Same-category comparison
NameRankMetrics
Waikato/moa15,233
Language:
Java
Stars:
669
Forks:
369
Description:
MOA is an open source framework for Big Data stream mining. It includes a collection of machine learning algorithms (classification, regression, clustering, outlier detection, concept drift detection and recommender systems) and tools for evaluation.
arunponnusamy/cvlib15,236
Language:
Python
Stars:
669
Forks:
126
Description:
A simple, high level, easy to use, open source Computer Vision library for Python.
google-deepmind/hanabi-learning-environment15,238
Language:
Python
Stars:
669
Forks:
164
Description:
hanabi_learning_environment is a research platform for Hanabi experiments.
mks0601/ExAvatar_RELEASE15,240
Language:
Python
Stars:
669
Forks:
72
Description:
Official PyTorch implementation of "Expressive Whole-Body 3D Gaussian Avatar", ECCV 2024.
PetarV-/DGI15,246
Language:
Python
Stars:
668
Forks:
135
Description:
Deep Graph Infomax (https://arxiv.org/abs/1809.10341).
cnkuangshi/LightCTR15,248
Language:
C++
Stars:
668
Forks:
138
Description:
Lightweight and Scalable framework that combines mainstream algorithms of Click-Through-Rate prediction based computational DAG, philosophy of Parameter Server and Ring-AllReduce collective communication.
zhangxiaosong18/FreeAnchor15,253
Language:
Python
Stars:
668
Forks:
108
Description:
FreeAnchor: Learning to Match Anchors for Visual Object Detection (NeurIPS 2019).
PaddlePaddle/PaddleYOLO15,254
Language:
Python
Stars:
667
Forks:
156
Description:
🚀🚀🚀 YOLO series of PaddlePaddle implementation, PP-YOLOE+, RT-DETR, YOLOv5, YOLOv6, YOLOv7, YOLOv8, YOLOv10, YOLO11, YOLOX, YOLOv5u, YOLOv7u, YOLOv6Lite, RTMDet and so on.
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguagePython
CategoryModel Development
SubcategoryFine-tuning
KeywordsBenchmarks, LoRA, PEFT
Stars669
Forks44
Contributors4
Created date2023-07-20
Updated date2026-10-13
Stars in 1 day0
Stars in 7 days1
Rank15,242
Previous rank15,065
Rank change-177
7-day stars rank10,987
Previous 7-day stars rank14,901
7-day stars rank change3,914
Total stars rank15,415
Previous total stars rank15,393
Total stars rank change-22
CountrySingapore
README summary

LoraHub: Efficient Cross-Task Generalization via Dynamic LoRA Composition The official repository which contains the code and pre-trained models for our paper LoraHub: Efficient Cross-Task Generalization via Dynamic LoRA Composition. 🔥 Updates [**2024-7-18**]: Our paper is accpeted by COLM 2024! [**2023-9-13**]: Now Available for Easy Installation via . For usage instructions regarding the interface, please refer to the file [**2023-8-29**]: We released the full produce code at reproduce_bbh. Please checkout the script to

reproduce our results! [**2023-8-03**]: Integrated into Replicate, check out the demo! [**2023-7-27**]: We released our code and demo. 🏴󠁶󠁵󠁭󠁡󠁰󠁿 Overview Low-rank adaptations (LoRA) are techniques for fine-tuning large language models on new tasks. We propose **LoraHub**, a framework that allows **composing multiple LoRA modules** trained on different tasks. The goal is to achieve good performance on **unseen tasks** using just a few examples, **without needing extra parameters or training**. And we want to build a

marketplace where users can share their trained LoRA modules, thereby facilitating the application of these modules to new tasks. The figure demostrates the zero-shot learning, few-shot in-context learning and few-shot lorahub learning (ours). Note that the Compose procedure is conducted per task rather than per example. Our method achieves similar inference throughput as zero-shot learning, yet approaches the performance of in-context learning on the BIG-Bench Hard (BBH) benchmark. The experimental results show the

superior efficacy of our method in comparison to zero-shot learning while closely resembling the performance of in-context learning (ICL) in few-shot scenarios. The figure shows the pipeline of LoraHub Learning. Our method encompasses two stages: the Compose stage and the Adapt stage. During the Compose stage, existing LoRA modules are integrated into one unified module, employing a set of weights, denoted as w , as coefficients. In the Adapt stage, the amalgamated LoRA module is evaluated on a

few examples from the unseen task. Subsequently, a gradient-free algorithm is applied to refine w . After executing K iterations, a highly adapted LoRA module is produced, which can be incorporated with the LLM to perform the intended task. ⚡️ Quickstart You can install lorahub using And then you can use lorahub learning by simply calling the function : The function has the following interface design: A full example can be found in example. 🌲 Project Structure The lorahub source code is organized

as below: 🏰 Resource LoRA Candidates Our methodology requires a compendium of LoRA modules trained on preceding tasks. For parity with Flan, we adopt the tasks utilized to instruct Flan-T5, thereby incorporating nearly 196 distinct tasks and their corresponding instructions via the following command Following this, we created several LoRA modules as possible candidates. These LoRA modules can be accessed at 💬 Citation If our work is useful for you, please consider citing our paper:

Frequently asked questions

How many stars and forks are recorded?

sail-sg/lorahub has 669 stars and 44 forks.

What is the repository rank?

sail-sg/lorahub is ranked 15,242.

What language and category are recorded?

sail-sg/lorahub has 669 stars, uses Python and belongs to Model Development.

Which repository is closest in rank?

sail-sg/lorahub is compared with mks0601/ExAvatar_RELEASE, ranked 15,240 with 669 stars.

README

LoraHub: Efficient Cross-Task Generalization via Dynamic LoRA Composition

The official repository which contains the code and pre-trained models for our paper LoraHub: Efficient Cross-Task Generalization via Dynamic LoRA Composition.

🔥 Updates

  • [2024-7-18]: Our paper is accpeted by COLM 2024!
  • [2023-9-13]: Now Available for Easy Installation via pip install lorahub. For usage instructions regarding the interface, please refer to the example.py file
  • [2023-8-29]: We released the full produce code at reproduce_bbh.py. Please checkout the script to reproduce our results!
  • [2023-8-03]: Integrated into Replicate, check out the demo!
  • [2023-7-27]: We released our code and demo. Check it out!
  • [2023-7-26]: We released our paper.

🏴󠁶󠁵󠁭󠁡󠁰󠁿 Overview

Low-rank adaptations (LoRA) are techniques for fine-tuning large language models on new tasks. We propose LoraHub, a framework that allows composing multiple LoRA modules trained on different tasks. The goal is to achieve good performance on unseen tasks using just a few examples, without needing extra parameters or training. And we want to build a marketplace where users can share their trained LoRA modules, thereby facilitating the application of these modules to new tasks.

The figure demostrates the zero-shot learning, few-shot in-context learning and few-shot lorahub learning (ours). Note that the Compose procedure is conducted per task rather than per example. Our method achieves similar inference throughput as zero-shot learning, yet approaches the performance of in-context learning on the BIG-Bench Hard (BBH) benchmark. The experimental results show the superior efficacy of our method in comparison to zero-shot learning while closely resembling the performance of in-context learning (ICL) in few-shot scenarios.

The figure shows the pipeline of LoraHub Learning. Our method encompasses two stages: the Compose stage and the Adapt stage. During the Compose stage, existing LoRA modules are integrated into one unified module, employing a set of weights, denoted as w, as coefficients. In the Adapt stage, the amalgamated LoRA module is evaluated on a few examples from the unseen task. Subsequently, a gradient-free algorithm is applied to refine w. After executing K iterations, a highly adapted LoRA module is produced, which can be incorporated with the LLM to perform the intended task.

⚡️ Quickstart

You can install lorahub using

pip install lorahub

And then you can use lorahub learning by simply calling the function lorahub_learning:

from lorahub.algorithm import lorahub_learning, lorahub_inference
from lorahub.constant import LORA_MODULE_NAMES
import random


def get_examples_for_learning():
    """
    Get a few examples to learn to compose given LoRA modules
    """
    return [
        {"input":
            "Infer the date from context.\n\nQ: Jane is celebrating the last day of Jan 2012. What is the date tomorrow in MM/DD/YYYY?\nOptions:\n(A) 02/02/2012\n(B) 02/15/2012\n(C) 01/25/2012\n(D) 04/22/2012\n(E) 02/01/2012\n(F) 02/11/2012\nA:", "output": "(E)"}
    ]

def get_lora_module_list():
    """
    You can have a custom filtering strategy to select the modules to be used in the composition. Here we randomly select 20 modules.
    """
    random.seed(42)
    return random.sample(LORA_MODULE_NAMES, 20)


# get a list of modules to be used in the composition
modules = get_lora_module_list()
print("modules:", modules)

# construct input list and output list
example_inputs, examples_outputs = [], []
for example in get_examples_for_learning():
    example_inputs.append(example["input"])
    examples_outputs.append(example["output"])

# perform LoRAHub learning
module_weights, model, tokenizer = lorahub_learning(lora_module_list=modules,
                                                    example_inputs=example_inputs,
                                                    example_outputs=examples_outputs,
                                                    max_inference_step=40,
                                                    batch_size=1)

print("module_weights:", module_weights)

The lorahub_learning function lorahub_learning has the following interface design:

lorahub_learning(lora_module_list: List[str], # list of lora candidates
                 example_inputs: List[str],
                 example_outputs: List[str],
                 max_inference_step: int, 
                 model_name_or_path=None, # if not given, we will use the model_name_or_path in lora config
                 batch_size=None, 
                 get_loss=default_get_loss, # The function to get the objective for optimiztion, use loss as default (can be changed to something like acc. or similarity)
                 get_regular=default_l1_regularization,  # The function to get regularization term for the weight, use 0.05*|w_i| as default
                 seed=42)

A full example can be found in example.py.

🌲 Project Structure

The lorahub source code is organized as below:

|-- lorahub
    -- algorithm.py # main code for lorahub learning and inference
    -- constant.py # lora candidate module names
|-- example.py # usage code for demonstration purpose

🏰 Resource

LoRA Candidates

Our methodology requires a compendium of LoRA modules trained on preceding tasks. For parity with Flan, we adopt the tasks utilized to instruct Flan-T5, thereby incorporating nearly 196 distinct tasks and their corresponding instructions via the following command

git clone https://huggingface.co/datasets/lorahub/flanv2

Following this, we created several LoRA modules as possible candidates. These LoRA modules can be accessed at https://huggingface.co/models?search=lorahub.

💬 Citation

If our work is useful for you, please consider citing our paper:

@misc{huang2023lorahub,
    title={LoraHub: Efficient Cross-Task Generalization via Dynamic LoRA Composition}, 
    author={Chengsong Huang and Qian Liu and Bill Yuchen Lin and Tianyu Pang and Chao Du and Min Lin},
    year={2023},
    eprint={2307.13269},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}
Nearby in the ranking
Similar items