Text Generation
PEFT
Safetensors
nielsr HF Staff commited on
Commit
8413d71
·
verified ·
1 Parent(s): 335eb85

Improve model card for LoRI-S_safety_llama3_rank_64

Browse files

This PR significantly enhances the model card for `LoRI-S_safety_llama3_rank_64`.

Key improvements include:
- Adding the `license` to the metadata.
- Providing a detailed model description from the paper abstract and GitHub README.
- Including direct links to the GitHub repository and Hugging Face collection.
- Adding a runnable Python code snippet for quick inference.
- Populating sections such as "Model Details", "Uses", "Bias, Risks, and Limitations", "Training Details", "Evaluation", and "Citation" with information extracted from the paper and repository.

Files changed (1) hide show
  1. README.md +102 -119
README.md CHANGED
@@ -2,192 +2,175 @@
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-S_safety_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
- <!-- Provide a quick summary of what the model is/does. -->
12
-
13
 
 
 
 
14
 
15
  ## Model Details
16
 
17
  ### Model Description
18
 
19
- <!-- Provide a longer summary of what this model is. -->
20
-
21
-
22
 
23
- - **Developed by:** [More Information Needed]
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
- ### Model Sources [optional]
32
 
33
- <!-- Provide the basic links for the model. -->
34
-
35
- - **Repository:** [More Information Needed]
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
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
46
-
47
- [More Information Needed]
48
 
49
- ### Downstream Use [optional]
50
 
51
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
52
-
53
- [More Information Needed]
54
 
55
  ### Out-of-Scope Use
56
 
57
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
58
-
59
- [More Information Needed]
60
 
61
  ## Bias, Risks, and Limitations
62
 
63
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
64
-
65
- [More Information Needed]
 
66
 
67
  ### Recommendations
68
 
69
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
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
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
  ## Training Details
80
 
81
- ### Training Data
82
 
83
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
84
 
85
- [More Information Needed]
86
 
87
  ### Training Procedure
88
 
89
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
90
-
91
- #### Preprocessing [optional]
92
-
93
- [More Information Needed]
94
-
95
 
96
  #### Training Hyperparameters
97
 
98
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
99
-
100
- #### Speeds, Sizes, Times [optional]
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
- <!-- This section describes the evaluation protocols and provides the results. -->
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
- [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 [optional]
145
 
146
  ### Model Architecture and Objective
147
 
148
- [More Information Needed]
149
 
150
  ### Compute Infrastructure
151
 
152
- [More Information Needed]
153
-
154
  #### Hardware
155
 
156
- [More Information Needed]
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
- ## Model Card Authors [optional]
185
-
186
- [More Information Needed]
187
 
188
  ## Model Card Contact
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
  ---
7
 
8
  # Model Card for LoRI-S_safety_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
+ **LoRI** (LoRA with Reduced Interference) is a simple yet effective variant of Low-Rank Adaptation (LoRA) for fine-tuning Large Language Models (LLMs). It addresses the challenges of overhead and parameter 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 (up to 95% fewer than LoRA) while maintaining strong task performance and minimizing cross-task interference. LoRI also 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" width="80%">
16
+ </div>
17
 
18
  ## Model Details
19
 
20
  ### Model Description
21
 
22
+ LoRI-S_safety_llama3_rank_64 is a LoRI-S (Sparse) adapter specifically fine-tuned for safety alignment tasks. It is built upon the `meta-llama/Meta-Llama-3-8B` base model and utilizes a low-rank adapter with `r=64`. This model is part of the LoRI family of models presented in the paper cited above, demonstrating improved efficiency and reduced cross-task interference in multi-task and continual learning settings.
 
 
23
 
24
+ - **Developed by:** Juzheng Zhang, Jiacheng You, Ashwinee Panda, Tom Goldstein
25
+ - **Model type:** Low-Rank Adaptation (LoRA) adapter for Causal Language Models, specifically LoRI-S (Sparse)
26
+ - **Language(s) (NLP):** English
27
+ - **License:** Apache 2.0
28
+ - **Finetuned from model:** `meta-llama/Meta-Llama-3-8B`
 
 
29
 
30
+ ### Model Sources
31
 
32
+ - **Repository:** [https://github.com/juzhengz/LoRI/](https://github.com/juzhengz/LoRI/)
33
+ - **Paper:** [https://arxiv.org/abs/2504.07448](https://arxiv.org/abs/2504.07448)
34
+ - **Hugging Face Collection:** [https://huggingface.co/collections/tomg-group-umd/lori-adapters-67f795549d792613e1290011](https://huggingface.co/collections/tomg-group-umd/lori-adapters-67f795549d792613e1290011)
 
 
35
 
36
  ## Uses
37
 
 
 
38
  ### Direct Use
39
 
40
+ This model is intended to be used as a PEFT adapter with the `meta-llama/Meta-Llama-3-8B` base model for text generation tasks, particularly for improving safety alignment capabilities. It can be loaded with the `peft` library and combined with the base LLM for efficient inference.
 
 
41
 
42
+ ### Downstream Use
43
 
44
+ LoRI enables effective adapter merging, allowing multiple task-specific adapters to be combined into a single model while minimizing performance degradation due to cross-task interference. It also supports continual learning scenarios, where the model needs to adapt to new tasks sequentially without suffering from catastrophic forgetting of previously learned tasks.
 
 
45
 
46
  ### Out-of-Scope Use
47
 
48
+ This model is not intended for use as a standalone LLM; it requires the `meta-llama/Meta-Llama-3-8B` base model to function. As a fine-tuned model, it may exhibit biases present in its training data or the base model. Users should exercise caution and perform additional evaluations for critical or sensitive applications, and not rely on it for factually accurate or harmless outputs without further safeguards.
 
 
49
 
50
  ## Bias, Risks, and Limitations
51
 
52
+ While fine-tuned for safety alignment, this LoRI adapter, like all large language models, may still generate harmful, biased, or nonsensical content. Its performance and robustness are highly dependent on the quality and diversity of the safety alignment data it was trained on. Potential risks include:
53
+ - Generation of unintended or inappropriate responses despite safety training.
54
+ - Reinforcement of societal biases present in the base model or the training data.
55
+ - Limitations in generalizing to novel or highly out-of-distribution safety scenarios.
56
 
57
  ### Recommendations
58
 
59
+ Users should always:
60
+ - Carefully evaluate the model's outputs in their specific use cases.
61
+ - Implement additional safety filters and human oversight for sensitive applications.
62
+ - Be aware that the model's behavior is influenced by both the base model and the LoRI adapter's training.
63
 
64
  ## How to Get Started with the Model
65
 
66
+ Install the necessary libraries:
67
+ ```bash
68
+ pip install transformers peft
69
+ ```
70
+
71
+ Use the code below to load and use the LoRI adapter:
72
+
73
+ ```python
74
+ from transformers import AutoModelForCausalLM, AutoTokenizer
75
+ from peft import PeftModel
76
+ import torch
77
+
78
+ # Load the base model (Meta-Llama-3-8B)
79
+ # Ensure you have access to Llama-3 models on Hugging Face
80
+ base_model_name = "meta-llama/Meta-Llama-3-8B"
81
+ base_model = AutoModelForCausalLM.from_pretrained(
82
+ base_model_name,
83
+ torch_dtype=torch.bfloat16, # Use bfloat16 for better performance if supported
84
+ low_cpu_mem_usage=True,
85
+ device_map="auto"
86
+ )
87
+
88
+ # Load the LoRI adapter
89
+ adapter_name = "tomg-group-umd/LoRI-S_safety_llama3_rank_64"
90
+ model = PeftModel.from_pretrained(base_model, adapter_name)
91
+
92
+ # Load the tokenizer
93
+ tokenizer = AutoTokenizer.from_pretrained(base_model_name)
94
+
95
+ # Example usage for text generation
96
+ prompt = "Explain why it is important for AI models to prioritize user safety."
97
+ messages = [
98
+ {"role": "user", "content": prompt},
99
+ ]
100
+
101
+ input_ids = tokenizer.apply_chat_template(
102
+ messages,
103
+ tokenize=True,
104
+ add_generation_prompt=True,
105
+ return_tensors="pt"
106
+ ).to(model.device)
107
+
108
+ outputs = model.generate(input_ids, max_new_tokens=256, temperature=0.7, do_sample=True)
109
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
110
+ print(response)
111
+ ```
112
 
113
  ## Training Details
114
 
115
+ LoRI models are trained using a two-stage process: `LoRI-D` (Dense) and `LoRI-S` (Sparse). The training is implemented using Fully Sharded Data Parallel (FSDP) and can be executed in a multi-GPU environment.
116
 
117
+ ### Training Data
118
 
119
+ LoRI models are trained on various datasets depending on the task. For safety alignment, this model was trained using the `saferpaca` script, which implies a safety-related dataset. More details on the specific datasets used for different tasks (Natural Language Understanding, Code Generation, Mathematical Reasoning, and Safety Alignment) can be found in the [LoRI GitHub repository](https://github.com/juzhengz/LoRI/).
120
 
121
  ### Training Procedure
122
 
123
+ 1. **LoRI-D (Dense) Training:** Initial training where projection matrices `A` are frozen as random projections and `B` matrices are dense.
124
+ 2. **Sparse Mask Extraction:** After `LoRI-D` training, sparse masks are extracted from the learned `B` matrices.
125
+ 3. **LoRI-S (Sparse) Training:** Continual training is performed with the extracted sparse masks applied to `B` matrices to achieve a desired sparsity (e.g., 90% sparsity), while keeping `A` frozen. This model, `LoRI-S_safety_llama3_rank_64`, is the result of the `LoRI-S` training stage.
 
 
 
126
 
127
  #### Training Hyperparameters
128
 
129
+ - **Adapter Rank (r):** 64
130
+ - **LoRA Alpha:** 128
131
+ - **LoRA Dropout:** 0.05
132
+ - **Sparsity:** 90% (for LoRI-S stage)
133
+ - **Training regime:** Mixed precision (using FSDP for multi-GPU setups).
 
 
134
 
135
  ## Evaluation
136
 
137
+ LoRI has been extensively evaluated across various tasks, including natural language understanding, mathematical reasoning, code generation, and safety alignment.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
  ### Results
140
 
141
+ Extensive experiments demonstrate that LoRI outperforms full fine-tuning and existing PEFT methods, while using up to 95% fewer trainable parameters than LoRA. In multi-task experiments, LoRI enables effective adapter merging and continual learning with reduced cross-task interference.
 
 
 
 
 
 
 
 
 
 
142
 
143
+ ## Technical Specifications
144
 
145
  ### Model Architecture and Objective
146
 
147
+ LoRI introduces a novel architecture within the PEFT paradigm. It leverages random projections for matrix `A` and task-specific sparse masks for matrix `B`, integrated directly into the training process. The objective is to achieve monosemantic adaptations that reduce cross-task interference and enable efficient multi-task and continual learning.
148
 
149
  ### Compute Infrastructure
150
 
 
 
151
  #### Hardware
152
 
153
+ LoRI can be trained and inferred efficiently in multi-GPU environments, leveraging technologies like Fully Sharded Data Parallel (FSDP).
154
 
155
  #### Software
156
 
157
+ The implementation builds on PyTorch, Hugging Face Transformers, and PEFT libraries.
 
 
 
 
 
 
 
 
 
 
158
 
159
+ - **Framework versions:** PEFT 0.12.0
160
 
161
+ ## Citation
162
 
163
+ If you use LoRI in your work, please cite:
164
 
165
+ ```bibtex
166
+ @article{zhang2025lori,
167
+ title={LoRI: Reducing Cross-Task Interference in Multi-Task Low-Rank Adaptation},
168
+ author={Zhang, Juzheng and You, Jiacheng and Panda, Ashwinee and Goldstein, Tom},
169
+ journal={arXiv preprint arXiv:2504.07448},
170
+ year={2025}
171
+ }
172
+ ```
 
173
 
174
  ## Model Card Contact
175
 
176
+ For questions or inquiries, please refer to the contact information on the [official LoRI GitHub repository](https://github.com/juzhengz/LoRI/). You may also contact the authors listed in the paper.