Text Generation
PEFT
Safetensors
juzhengz nielsr HF Staff commited on
Commit
8470f0f
·
verified ·
1 Parent(s): fadcd3d

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]>

Files changed (1) hide show
  1. README.md +89 -107
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
- <!-- 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-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