Improve model card with full details and usage for LoRI-D_nlu_llama3_rank_64 (#1)
Browse files- Improve model card with full details and usage for LoRI-D_nlu_llama3_rank_64 (663383aac9e7478eceaed5f8c05b67cc0ec1c955)
Co-authored-by: Niels Rogge <[email protected]>
README.md
CHANGED
@@ -2,192 +2,174 @@
|
|
2 |
base_model: meta-llama/Meta-Llama-3-8B
|
3 |
library_name: peft
|
4 |
pipeline_tag: text-generation
|
|
|
5 |
---
|
6 |
|
7 |
# Model Card for LoRI-D_nlu_llama3_rank_64
|
8 |
|
9 |
This model is part of [LoRI: Reducing Cross-Task Interference in Multi-Task Low-Rank Adaptation](https://arxiv.org/abs/2504.07448).
|
10 |
|
11 |
-
|
12 |
|
|
|
|
|
|
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
## Model Details
|
16 |
|
17 |
### Model Description
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
-
-
|
24 |
-
-
|
25 |
-
-
|
26 |
-
-
|
27 |
-
-
|
28 |
-
- **License:** [More Information Needed]
|
29 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
30 |
|
31 |
-
### Model Sources
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
-
|
36 |
-
- **Paper [optional]:** [More Information Needed]
|
37 |
-
- **Demo [optional]:** [More Information Needed]
|
38 |
|
39 |
## Uses
|
40 |
|
41 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
42 |
-
|
43 |
### Direct Use
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
[More Information Needed]
|
48 |
|
49 |
-
### Downstream Use
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
[More Information Needed]
|
54 |
|
55 |
### Out-of-Scope Use
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
[More Information Needed]
|
60 |
|
61 |
## Bias, Risks, and Limitations
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
[More Information Needed]
|
66 |
|
67 |
### Recommendations
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
72 |
|
73 |
## How to Get Started with the Model
|
74 |
|
75 |
Use the code below to get started with the model.
|
76 |
|
77 |
-
|
|
|
|
|
|
|
78 |
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
-
|
|
|
82 |
|
83 |
-
|
|
|
84 |
|
85 |
-
|
|
|
|
|
86 |
|
87 |
-
|
|
|
|
|
|
|
88 |
|
89 |
-
|
|
|
|
|
90 |
|
91 |
-
|
92 |
|
93 |
-
|
94 |
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
-
|
97 |
|
98 |
-
|
99 |
|
100 |
-
|
|
|
|
|
101 |
|
102 |
-
|
103 |
|
104 |
-
|
|
|
|
|
|
|
|
|
105 |
|
106 |
## Evaluation
|
107 |
|
108 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
109 |
-
|
110 |
### Testing Data, Factors & Metrics
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
<!-- This should link to a Dataset Card if possible. -->
|
115 |
-
|
116 |
-
[More Information Needed]
|
117 |
-
|
118 |
-
#### Factors
|
119 |
-
|
120 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
121 |
-
|
122 |
-
[More Information Needed]
|
123 |
|
124 |
#### Metrics
|
125 |
|
126 |
-
|
127 |
-
|
128 |
-
[More Information Needed]
|
129 |
-
|
130 |
-
### Results
|
131 |
-
|
132 |
-
[More Information Needed]
|
133 |
-
|
134 |
-
#### Summary
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
## Model Examination [optional]
|
139 |
-
|
140 |
-
<!-- Relevant interpretability work for the model goes here -->
|
141 |
-
|
142 |
-
[More Information Needed]
|
143 |
|
144 |
-
## Technical Specifications
|
145 |
|
146 |
### Model Architecture and Objective
|
147 |
|
148 |
-
|
149 |
|
150 |
### Compute Infrastructure
|
151 |
|
152 |
-
[More Information Needed]
|
153 |
-
|
154 |
#### Hardware
|
155 |
|
156 |
-
|
157 |
|
158 |
#### Software
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
## Citation [optional]
|
163 |
-
|
164 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
165 |
-
|
166 |
-
**BibTeX:**
|
167 |
-
|
168 |
-
[More Information Needed]
|
169 |
|
170 |
-
|
171 |
|
172 |
-
[
|
173 |
|
174 |
-
##
|
175 |
|
176 |
-
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
[More Information Needed]
|
187 |
|
188 |
## Model Card Contact
|
189 |
|
190 |
-
|
|
|
191 |
### Framework versions
|
192 |
|
193 |
- PEFT 0.12.0
|
|
|
2 |
base_model: meta-llama/Meta-Llama-3-8B
|
3 |
library_name: peft
|
4 |
pipeline_tag: text-generation
|
5 |
+
license: apache-2.0
|
6 |
---
|
7 |
|
8 |
# Model Card for LoRI-D_nlu_llama3_rank_64
|
9 |
|
10 |
This model is part of [LoRI: Reducing Cross-Task Interference in Multi-Task Low-Rank Adaptation](https://arxiv.org/abs/2504.07448).
|
11 |
|
12 |
+
This is an adapter model based on the paper **LoRI: Reducing Cross-Task Interference in Multi-Task Low-Rank Adaptation**, which introduces a simple yet effective approach to Low-Rank Adaptation (LoRA) for Large Language Models (LLMs). LoRI freezes the projection matrices A as random projections and sparsifies the matrices B using task-specific masks. This design substantially reduces the number of trainable parameters while maintaining strong task performance, minimizes cross-task interference in adapter merging, and supports continual learning by using sparsity to mitigate catastrophic forgetting.
|
13 |
|
14 |
+
<div align="center">
|
15 |
+
<img src="https://github.com/juzhengz/LoRI/raw/main/LoRI.png" alt="LoRI Framework" width="80%">
|
16 |
+
</div>
|
17 |
|
18 |
+
### ✨ Key Highlights
|
19 |
+
|
20 |
+
* **Scalable & Efficient**: Uses up to 95% fewer trainable parameters than traditional LoRA while maintaining performance.
|
21 |
+
* **Reduced Interference**: Minimizes cross-task interference in multi-task scenarios by leveraging orthogonality between adapter subspaces.
|
22 |
+
* **Continual Learning**: Supports continual learning by using sparsity to mitigate catastrophic forgetting.
|
23 |
+
* **Universal Applicability**: Evaluated across natural language understanding, mathematical reasoning, code generation, and safety alignment tasks.
|
24 |
|
25 |
## Model Details
|
26 |
|
27 |
### Model Description
|
28 |
|
29 |
+
The `LoRI-D_nlu_llama3_rank_64` model is a LoRA adapter specifically designed for Natural Language Understanding (NLU) tasks, fine-tuned on the `meta-llama/Meta-Llama-3-8B` base model with a rank of 64. It is part of the LoRI family of models, which aims to provide parameter-efficient fine-tuning with reduced cross-task interference.
|
|
|
|
|
30 |
|
31 |
+
- **Developed by:** Juzheng Zhang, Jiacheng You, Ashwinee Panda, Tom Goldstein
|
32 |
+
- **Model type:** Low-Rank Adaptation (LoRI) adapter (PEFT method for LLMs)
|
33 |
+
- **Language(s) (NLP):** English
|
34 |
+
- **License:** Apache 2.0
|
35 |
+
- **Finetuned from model:** `meta-llama/Meta-Llama-3-8B`
|
|
|
|
|
36 |
|
37 |
+
### Model Sources
|
38 |
|
39 |
+
- **Repository:** [https://github.com/juzhengz/LoRI/](https://github.com/juzhengz/LoRI/)
|
40 |
+
- **Paper:** [https://arxiv.org/abs/2504.07448](https://arxiv.org/abs/2504.07448)
|
41 |
+
- **HuggingFace Collection:** [https://huggingface.co/collections/tomg-group-umd/lori-adapters-67f795549d792613e1290011](https://huggingface.co/collections/tomg-group-umd/lori-adapters-67f795549d792613e1290011)
|
|
|
|
|
42 |
|
43 |
## Uses
|
44 |
|
|
|
|
|
45 |
### Direct Use
|
46 |
|
47 |
+
This model is intended to be used as a PEFT adapter on top of the `meta-llama/Meta-Llama-3-8B` base model for natural language understanding tasks, leveraging its efficient design for reduced parameter overhead and improved multi-task performance.
|
|
|
|
|
48 |
|
49 |
+
### Downstream Use
|
50 |
|
51 |
+
LoRI adapters can be merged for multi-task applications or sequentially applied for continual learning without significant performance degradation. This makes LoRI suitable for building generalist agents or systems that need to learn new skills over time.
|
|
|
|
|
52 |
|
53 |
### Out-of-Scope Use
|
54 |
|
55 |
+
This model is not intended for use in high-stakes or safety-critical applications without further rigorous testing and validation. Given its focus on NLU tasks, its performance on other domains or tasks without specific fine-tuning is not guaranteed.
|
|
|
|
|
56 |
|
57 |
## Bias, Risks, and Limitations
|
58 |
|
59 |
+
As with any language model, this model may inherit biases present in its training data, including the base model (`Llama-3-8B`) and the datasets used for LoRI fine-tuning. Potential risks include generating biased, inaccurate, or harmful content.
|
|
|
|
|
60 |
|
61 |
### Recommendations
|
62 |
|
63 |
+
Users should carefully evaluate the model's output for their specific application and consider fine-tuning on domain-specific, curated data to mitigate potential biases or limitations.
|
|
|
|
|
64 |
|
65 |
## How to Get Started with the Model
|
66 |
|
67 |
Use the code below to get started with the model.
|
68 |
|
69 |
+
```python
|
70 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
71 |
+
from peft import PeftModel
|
72 |
+
import torch
|
73 |
|
74 |
+
# Load the base model
|
75 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
76 |
+
"meta-llama/Meta-Llama-3-8B",
|
77 |
+
torch_dtype=torch.bfloat16, # or torch.float16 depending on your hardware
|
78 |
+
device_map="auto"
|
79 |
+
)
|
80 |
|
81 |
+
# Load the LoRI adapter
|
82 |
+
adapter = PeftModel.from_pretrained(base_model, "tomg-group-umd/LoRI-D_nlu_llama3_rank_64")
|
83 |
|
84 |
+
# Load the tokenizer
|
85 |
+
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B")
|
86 |
|
87 |
+
# Example usage for a general text generation task (adjust for specific NLU use-cases)
|
88 |
+
prompt = "The quick brown fox jumps over the lazy dog."
|
89 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(adapter.device)
|
90 |
|
91 |
+
# Generate text
|
92 |
+
outputs = adapter.generate(**inputs, max_new_tokens=50, do_sample=True, temperature=0.7)
|
93 |
+
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
94 |
+
print(generated_text)
|
95 |
|
96 |
+
# For specific NLU tasks, the prompt and expected output format would vary.
|
97 |
+
# You would then apply relevant NLU processing to the generated text or use the adapter's output directly.
|
98 |
+
```
|
99 |
|
100 |
+
## Training Details
|
101 |
|
102 |
+
### Training Data
|
103 |
|
104 |
+
The LoRI models are trained on various datasets depending on the task:
|
105 |
+
- **Natural Language Understanding (NLU):** Specific NLU datasets, as indicated by this model.
|
106 |
+
- **Code generation:** CodeAlpaca dataset.
|
107 |
+
- **Mathematical reasoning:** GSM8K dataset.
|
108 |
+
- **Safety alignment:** Saferpaca dataset.
|
109 |
|
110 |
+
More details on specific datasets can be found in the [GitHub repository](https://github.com/juzhengz/LoRI/).
|
111 |
|
112 |
+
### Training Procedure
|
113 |
|
114 |
+
LoRI is implemented using Fully Sharded Data Parallel (FSDP) for multi-GPU training. The training involves two main stages:
|
115 |
+
1. **LoRI-D (Dense) training**: Adapters are trained with random projection matrices `A` frozen and `B` matrices dense. Sparse masks are then extracted.
|
116 |
+
2. **LoRI-S (Sparse) training**: Training continues with the extracted sparse masks applied to matrices `B`, typically at 90% sparsity.
|
117 |
|
118 |
+
#### Training Hyperparameters
|
119 |
|
120 |
+
- **Training regime:** Mixed precision (e.g., `bfloat16` for Llama-3) is typically used for training large models.
|
121 |
+
- **Adapter Rank (`r`):** 64 (for this `LoRI-D_nlu_llama3_rank_64` model).
|
122 |
+
- **LoRA Alpha (`lora_alpha`):** 128 (from `adapter_config.json`).
|
123 |
+
- **LoRA Dropout (`lora_dropout`):** 0.05 (from `adapter_config.json`).
|
124 |
+
- **Target Modules (`target_modules`):** `o_proj`, `k_proj`, `up_proj`, `q_proj`, `v_proj`, `down_proj`, `gate_proj` (from `adapter_config.json`).
|
125 |
|
126 |
## Evaluation
|
127 |
|
|
|
|
|
128 |
### Testing Data, Factors & Metrics
|
129 |
|
130 |
+
LoRI's performance has been extensively evaluated across natural language understanding, mathematical reasoning, code generation (e.g., HumanEval), and safety alignment tasks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
#### Metrics
|
133 |
|
134 |
+
Performance is measured using relevant metrics for each task. The paper demonstrates that LoRI consistently outperforms full fine-tuning and existing PEFT methods across various tasks, while using up to 95% fewer trainable parameters than traditional LoRA. In multi-task experiments, LoRI enables effective adapter merging and continual learning with reduced cross-task interference. For detailed quantitative results, please refer to the [paper](https://arxiv.org/abs/2504.07448).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
+
## Technical Specifications
|
137 |
|
138 |
### Model Architecture and Objective
|
139 |
|
140 |
+
LoRI introduces a novel architecture where projection matrices `A` in LoRA are frozen as random projections, and matrices `B` are sparsified using task-specific masks. This design is intended to achieve monosemantic experts, reduce trainable parameters, and minimize cross-task interference. The objective remains focused on improving performance on downstream tasks while promoting parameter efficiency and modularity.
|
141 |
|
142 |
### Compute Infrastructure
|
143 |
|
|
|
|
|
144 |
#### Hardware
|
145 |
|
146 |
+
Training was performed in a multi-GPU environment using technologies like Fully Sharded Data Parallel (FSDP).
|
147 |
|
148 |
#### Software
|
149 |
|
150 |
+
The implementation uses Python, PyTorch, and the Hugging Face `transformers` and `peft` libraries.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
+
## Acknowledgements
|
153 |
|
154 |
+
This project builds on the codebase of [dpo-rlaif](https://github.com/architsharma97/dpo-rlaif) and incorporates code from [lottery-ticket-adaptation](https://github.com/kiddyboots216/lottery-ticket-adaptation). Code generation performance on HumanEval is evaluated using the [bigcode-evaluation-harness](https://github.com/bigcode-project/bigcode-evaluation-harness).
|
155 |
|
156 |
+
## Citation
|
157 |
|
158 |
+
If you use LoRI in your work, please cite:
|
159 |
|
160 |
+
```bibtex
|
161 |
+
@article{zhang2025lori,
|
162 |
+
title={LoRI: Reducing Cross-Task Interference in Multi-Task Low-Rank Adaptation},
|
163 |
+
author={Zhang, Juzheng and You, Jiacheng and Panda, Ashwinee and Goldstein, Tom},
|
164 |
+
journal={arXiv preprint arXiv:2504.07448},
|
165 |
+
year={2025}
|
166 |
+
}
|
167 |
+
```
|
|
|
168 |
|
169 |
## Model Card Contact
|
170 |
|
171 |
+
For questions or inquiries, please refer to the contact information provided in the original [repository](https://github.com/juzhengz/LoRI/).
|
172 |
+
|
173 |
### Framework versions
|
174 |
|
175 |
- PEFT 0.12.0
|