Improve model card for LoRI-D_safety_llama3_rank_32
#1
by
nielsr
HF Staff
- opened
README.md
CHANGED
@@ -2,192 +2,165 @@
|
|
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_safety_llama3_rank_32
|
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 |
-
- **Funded by [optional]:** [More Information Needed]
|
25 |
-
- **Shared by [optional]:** [More Information Needed]
|
26 |
-
- **Model type:** [More Information Needed]
|
27 |
-
- **Language(s) (NLP):** [More Information Needed]
|
28 |
-
- **License:** [More Information Needed]
|
29 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
30 |
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
|
34 |
|
35 |
-
-
|
36 |
-
-
|
37 |
-
-
|
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 [optional]
|
50 |
|
51 |
-
|
52 |
|
53 |
-
|
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 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
## Training Details
|
80 |
|
81 |
### Training Data
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
[More Information Needed]
|
86 |
|
87 |
### Training Procedure
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
[More Information Needed]
|
94 |
|
|
|
95 |
|
96 |
#### Training Hyperparameters
|
97 |
|
98 |
-
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
103 |
-
|
104 |
-
[More Information Needed]
|
105 |
|
106 |
## Evaluation
|
107 |
|
108 |
-
|
109 |
-
|
110 |
-
### Testing Data, Factors & Metrics
|
111 |
-
|
112 |
-
#### Testing Data
|
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 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
127 |
-
|
128 |
-
[More Information Needed]
|
129 |
|
130 |
### Results
|
131 |
|
132 |
-
[
|
133 |
-
|
134 |
-
#### Summary
|
135 |
-
|
136 |
-
|
137 |
|
138 |
-
##
|
139 |
-
|
140 |
-
<!-- Relevant interpretability work for the model goes here -->
|
141 |
-
|
142 |
-
[More Information Needed]
|
143 |
-
|
144 |
-
## Technical Specifications [optional]
|
145 |
|
146 |
### Model Architecture and Objective
|
147 |
|
148 |
-
|
149 |
|
150 |
### Compute Infrastructure
|
151 |
|
152 |
-
|
153 |
|
154 |
#### Hardware
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
#### Software
|
159 |
-
|
160 |
-
[More Information Needed]
|
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 |
-
**APA:**
|
171 |
-
|
172 |
-
[More Information Needed]
|
173 |
-
|
174 |
-
## Glossary [optional]
|
175 |
-
|
176 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
177 |
-
|
178 |
-
[More Information Needed]
|
179 |
-
|
180 |
-
## More Information [optional]
|
181 |
-
|
182 |
-
[More Information Needed]
|
183 |
|
184 |
-
##
|
185 |
|
186 |
-
|
187 |
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
|
190 |
-
[More Information Needed]
|
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 |
+
language: en
|
7 |
+
tags:
|
8 |
+
- peft
|
9 |
+
- lora
|
10 |
+
- safety-llm
|
11 |
+
- llm
|
12 |
---
|
13 |
|
14 |
# Model Card for LoRI-D_safety_llama3_rank_32
|
15 |
|
16 |
This model is part of [LoRI: Reducing Cross-Task Interference in Multi-Task Low-Rank Adaptation](https://arxiv.org/abs/2504.07448).
|
17 |
|
18 |
+
**LoRI (LoRA with Reduced Interference)** is a simple yet effective variant of LoRA for fine-tuning Large Language Models (LLMs). It addresses the challenges of parameter overhead and cross-task interference in multi-task scenarios by freezing the projection matrices `A` as random projections and sparsifying the matrices `B` using task-specific masks. This design substantially reduces the number of trainable parameters while maintaining strong task performance. Moreover, LoRI minimizes cross-task interference in adapter merging by leveraging the orthogonality between adapter subspaces, and supports continual learning by using sparsity to mitigate catastrophic forgetting. Extensive experiments across natural language understanding, mathematical reasoning, code generation, and safety alignment tasks demonstrate that LoRI outperforms full fine-tuning and existing PEFT methods, while using up to 95% fewer trainable parameters than LoRA.
|
|
|
19 |
|
20 |
+
<div align="center">
|
21 |
+
<img src="https://github.com/juzhengz/LoRI/raw/main/LoRI.png" alt="LoRI" width="80%">
|
22 |
+
</div>
|
23 |
|
24 |
## Model Details
|
25 |
|
26 |
### Model Description
|
27 |
|
28 |
+
LoRI (LoRA with Reduced Interference) is a parameter-efficient fine-tuning (PEFT) method designed to reduce cross-task interference in multi-task low-rank adaptation for LLMs. It achieves this by freezing projection matrices `A` as random projections and sparsifying matrices `B` with task-specific masks, significantly reducing trainable parameters (up to 95% fewer than LoRA). LoRI maintains strong task performance, minimizes interference in adapter merging through orthogonal adapter subspaces, and supports continual learning by mitigating catastrophic forgetting via sparsity.
|
|
|
|
|
29 |
|
30 |
+
This specific model, `LoRI-D_safety_llama3_rank_32`, is a `LoRI-D` adapter for the `meta-llama/Meta-Llama-3-8B` base model, specifically fine-tuned for safety alignment tasks.
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
+
- **Developed by:** Juzheng Zhang, Jiacheng You, Ashwinee Panda, Tom Goldstein
|
33 |
+
- **Model type:** PEFT LoRA adapter for causal language models (LLMs)
|
34 |
+
- **Language(s) (NLP):** English (primary for safety alignment task, built on a multilingual base model)
|
35 |
+
- **License:** Apache 2.0
|
36 |
+
- **Finetuned from model:** `meta-llama/Meta-Llama-3-8B`
|
37 |
|
38 |
+
### Model Sources
|
39 |
|
40 |
+
- **Repository:** [https://github.com/juzhengz/LoRI/](https://github.com/juzhengz/LoRI/)
|
41 |
+
- **Paper:** [https://arxiv.org/abs/2504.07448](https://arxiv.org/abs/2504.07448)
|
42 |
+
- **Hugging Face Collection:** [https://huggingface.co/collections/tomg-group-umd/lori-adapters-67f795549d792613e1290011](https://huggingface.co/collections/tomg-group-umd/lori-adapters-67f795549d792613e1290011)
|
43 |
|
44 |
## Uses
|
45 |
|
|
|
|
|
46 |
### Direct Use
|
47 |
|
48 |
+
This adapter can be loaded with a compatible base model (`meta-llama/Meta-Llama-3-8B`) using the `peft` library to enable specialized performance on safety alignment tasks. It is intended for use in scenarios where efficient fine-tuning and reduced cross-task interference are critical.
|
|
|
|
|
|
|
|
|
49 |
|
50 |
+
### Downstream Use
|
51 |
|
52 |
+
LoRI enables effective adapter merging, allowing multiple task-specific adapters to be combined with minimal interference. It also supports continual learning, where new tasks can be learned without catastrophically forgetting previously acquired knowledge.
|
53 |
|
54 |
### Out-of-Scope Use
|
55 |
|
56 |
+
This model is not intended for generating harmful, biased, or unethical content. Users should exercise caution and implement appropriate safeguards when deploying the model in sensitive applications.
|
|
|
|
|
57 |
|
58 |
## Bias, Risks, and Limitations
|
59 |
|
60 |
+
While LoRI aims to reduce cross-task interference, like all language models, it may still exhibit biases present in its base model and training data. Since this model is based on Llama 3, it inherits any biases or limitations present in the original Llama 3 base model. As a parameter-efficient fine-tuning method, while it aims to reduce interference, complex multi-task interactions might still present unforeseen challenges. Performance might vary on highly out-of-distribution data or tasks not well-represented in the training process.
|
|
|
|
|
61 |
|
62 |
### Recommendations
|
63 |
|
64 |
+
Users (both direct and downstream) should be made aware of the risks, biases, and limitations of the model. It is recommended to perform thorough testing and validation on specific use cases, especially for safety-critical applications. Further research and fine-tuning may be necessary to mitigate any identified biases or risks.
|
|
|
|
|
65 |
|
66 |
## How to Get Started with the Model
|
67 |
|
68 |
+
To load and use this LoRI adapter with the `Meta-Llama-3-8B` base model:
|
69 |
+
|
70 |
+
```python
|
71 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
72 |
+
from peft import PeftModel
|
73 |
+
import torch
|
74 |
+
|
75 |
+
# Load the base model
|
76 |
+
base_model_name = "meta-llama/Meta-Llama-3-8B"
|
77 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
78 |
+
base_model_name,
|
79 |
+
torch_dtype=torch.bfloat16, # or torch.float16, depending on your hardware
|
80 |
+
low_cpu_mem_usage=True,
|
81 |
+
device_map="auto"
|
82 |
+
)
|
83 |
+
|
84 |
+
# Load the LoRI adapter on top of the base model
|
85 |
+
# This model is tomg-group-umd/LoRI-D_safety_llama3_rank_32
|
86 |
+
lori_adapter_name = "tomg-group-umd/LoRI-D_safety_llama3_rank_32"
|
87 |
+
model = PeftModel.from_pretrained(base_model, lori_adapter_name)
|
88 |
+
|
89 |
+
# Load the tokenizer
|
90 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
|
91 |
+
|
92 |
+
# Example usage (chat completion)
|
93 |
+
messages = [
|
94 |
+
{"role": "system", "content": "You are a helpful AI assistant."},
|
95 |
+
{"role": "user", "content": "Explain the concept of quantum entanglement."},
|
96 |
+
]
|
97 |
+
|
98 |
+
input_ids = tokenizer.apply_chat_template(
|
99 |
+
messages,
|
100 |
+
add_generation_prompt=True,
|
101 |
+
return_tensors="pt"
|
102 |
+
).to(model.device)
|
103 |
+
|
104 |
+
outputs = model.generate(input_ids, max_new_tokens=256, temperature=0.7)
|
105 |
+
response = tokenizer.decode(outputs[0][input_ids.shape[1]:], skip_special_tokens=True)
|
106 |
+
print(response)
|
107 |
+
```
|
108 |
|
109 |
## Training Details
|
110 |
|
111 |
### Training Data
|
112 |
|
113 |
+
LoRI models are trained on various datasets corresponding to specific tasks. For safety alignment (which this adapter is fine-tuned for), the `saferpaca` dataset is used, as indicated by the `saferpaca_*.sh` scripts in the GitHub repository. The paper further mentions extensive experiments across Natural Language Understanding, Mathematical Reasoning, Code Generation, and Safety Alignment tasks. More details about the datasets can be found in the [LoRI GitHub repository](https://github.com/juzhengz/LoRI/).
|
|
|
|
|
114 |
|
115 |
### Training Procedure
|
116 |
|
117 |
+
LoRI is implemented using Fully Sharded Data Parallel (FSDP) and can be executed in a multi-GPU environment. The training process involves two stages:
|
118 |
+
1. **LoRI-D (Dynamic):** Initial training where projection matrices `A` are frozen as random projections, and matrices `B` are learned. This stage also extracts sparse masks.
|
119 |
+
2. **LoRI-S (Sparse):** Continues training with the sparse masks applied to matrices `B` (e.g., 90% sparsity).
|
|
|
|
|
120 |
|
121 |
+
Training scripts for specific tasks (e.g., `scripts/saferpaca_llama3_r_32.sh`) are available in the [GitHub repository](https://github.com/juzhengz/LoRI/tree/main/scripts).
|
122 |
|
123 |
#### Training Hyperparameters
|
124 |
|
125 |
+
- **Training regime:** Mixed precision (specifics depend on environment/GPU, typically `bf16` or `fp16`).
|
126 |
+
- **Adapter Ranks:** 32 (for this specific model) or 64.
|
127 |
+
- **Sparsity:** Up to 90% for `LoRI-S` models.
|
|
|
|
|
|
|
|
|
128 |
|
129 |
## Evaluation
|
130 |
|
131 |
+
The paper presents extensive evaluations across multiple benchmarks for natural language understanding, mathematical reasoning, code generation, and safety alignment tasks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
### Results
|
134 |
|
135 |
+
The paper demonstrates that LoRI outperforms full fine-tuning and existing PEFT methods, while using up to 95% fewer trainable parameters than standard LoRA. In multi-task experiments, LoRI enables effective adapter merging and continual learning with reduced cross-task interference. For detailed performance metrics on safety alignment, please refer to the [official paper](https://arxiv.org/abs/2504.07448).
|
|
|
|
|
|
|
|
|
136 |
|
137 |
+
## Technical Specifications
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
### Model Architecture and Objective
|
140 |
|
141 |
+
LoRI introduces a novel approach to low-rank adaptation. It freezes the projection matrices `A` as random projections and sparsifies the matrices `B` using task-specific masks. This design allows for a significant reduction in the number of trainable parameters while maintaining strong task performance and minimizing cross-task interference.
|
142 |
|
143 |
### Compute Infrastructure
|
144 |
|
145 |
+
The training process leverages FSDP for multi-GPU environments.
|
146 |
|
147 |
#### Hardware
|
148 |
|
149 |
+
Training has been demonstrated on multi-GPU setups. Specific hardware configurations used for original training are detailed in the paper or supplementary materials.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
+
## Citation
|
152 |
|
153 |
+
If you use LoRI in your work, please cite:
|
154 |
|
155 |
+
```bibtex
|
156 |
+
@article{zhang2025lori,
|
157 |
+
title={LoRI: Reducing Cross-Task Interference in Multi-Task Low-Rank Adaptation},
|
158 |
+
author={Zhang, Juzheng and You, Jiacheng and Panda, Ashwinee and Goldstein, Tom},
|
159 |
+
journal={arXiv preprint arXiv:2504.07448},
|
160 |
+
year={2025}
|
161 |
+
}
|
162 |
+
```
|
163 |
|
|
|
164 |
### Framework versions
|
165 |
|
166 |
- PEFT 0.12.0
|