anamikac2708
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,101 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
#
|
7 |
|
8 |
-
|
|
|
|
|
9 |
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
### Model Description
|
15 |
-
|
16 |
-
<!-- Provide a longer summary of what this model is. -->
|
17 |
-
|
18 |
-
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
19 |
-
|
20 |
-
- **Developed by:** [More Information Needed]
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
-
|
28 |
-
### Model Sources [optional]
|
29 |
-
|
30 |
-
<!-- Provide the basic links for the model. -->
|
31 |
-
|
32 |
-
- **Repository:** [More Information Needed]
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
-
|
36 |
-
## Uses
|
37 |
-
|
38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
-
|
40 |
-
### Direct Use
|
41 |
-
|
42 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
-
|
44 |
-
[More Information Needed]
|
45 |
-
|
46 |
-
### Downstream Use [optional]
|
47 |
-
|
48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
-
|
50 |
-
[More Information Needed]
|
51 |
-
|
52 |
-
### Out-of-Scope Use
|
53 |
-
|
54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
-
|
56 |
-
[More Information Needed]
|
57 |
-
|
58 |
-
## Bias, Risks, and Limitations
|
59 |
-
|
60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
-
|
62 |
-
[More Information Needed]
|
63 |
-
|
64 |
-
### Recommendations
|
65 |
-
|
66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
-
|
68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
|
70 |
## How to Get Started with the Model
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
## Training Details
|
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 |
## Evaluation
|
104 |
|
105 |
<!-- This section describes the evaluation protocols and provides the results. -->
|
|
|
|
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
|
193 |
-
|
|
|
194 |
|
195 |
-
|
196 |
|
197 |
-
|
198 |
|
199 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
license: cc-by-nc-4.0
|
5 |
+
tags:
|
6 |
+
- text-generation-inference
|
7 |
+
- transformers
|
8 |
+
- unsloth
|
9 |
+
- gemma
|
10 |
+
- trl
|
11 |
+
- finlang
|
12 |
+
- dora
|
13 |
+
base_model: mistralai/Mistral-7B-v0.1
|
14 |
---
|
15 |
|
16 |
+
# Uploaded model
|
17 |
|
18 |
+
- **Developed by:** anamikac2708
|
19 |
+
- **License:** cc-by-nc-4.0
|
20 |
+
- **Finetuned from model :** mistralai/Mistral-7B-v0.1
|
21 |
|
22 |
+
This Mistral model was trained Huggingface's TRL library and DoRA (https://arxiv.org/abs/2402.09353) using open-sourced finance dataset https://huggingface.co/datasets/FinLang/investopedia-instruction-tuning-dataset developed for finance application by FinLang Team
|
23 |
|
24 |
+
This paper proposes Weight-Decomposed LowRank Adaptation which decomposes the pre-trained weight into two components, magnitude and direction, for fine-tuning, specifically
|
25 |
+
employing LoRA for directional updates to efficiently minimize the number of trainable parameters. Therefore can enhance both the learning capacity and training stability of LoRA while avoiding any additional inference overhead.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
## How to Get Started with the Model
|
28 |
|
29 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
30 |
+
```python
|
31 |
+
import torch
|
32 |
+
from unsloth import FastLanguageModel
|
33 |
+
from transformers import AutoTokenizer, pipeline
|
34 |
+
peft_model_id = "anamikac2708/Mistral-7B-DORA-finetuned-investopedia-Lora-Adapters"
|
35 |
+
# Load Model with PEFT adapter
|
36 |
+
model = AutoPeftModelForCausalLM.from_pretrained(
|
37 |
+
peft_model_id,
|
38 |
+
device_map="auto",
|
39 |
+
torch_dtype=torch.float16,
|
40 |
+
#load_in_4bit = True
|
41 |
+
)
|
42 |
+
tokenizer = AutoTokenizer.from_pretrained(peft_model_id)
|
43 |
+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
44 |
+
example = [{'content': 'You are a financial expert and you can answer any questions related to finance. You will be given a context and a question. Understand the given context and\n try to answer. Users will ask you questions in English and you will generate answer based on the provided CONTEXT.\n CONTEXT:\n D. in Forced Migration from the University of the Witwatersrand (Wits) in Johannesburg, South Africa; A postgraduate diploma in Folklore & Cultural Studies at Indira Gandhi National Open University (IGNOU) in New Delhi, India; A Masters of International Affairs at Columbia University; A BA from Barnard College at Columbia University\n', 'role': 'system'}, {'content': ' In which universities did the individual obtain their academic qualifications?\n', 'role': 'user'}, {'content': ' University of the Witwatersrand (Wits) in Johannesburg, South Africa; Indira Gandhi National Open University (IGNOU) in New Delhi, India; Columbia University; Barnard College at Columbia University.', 'role': 'assistant'}]
|
45 |
+
prompt = pipe.tokenizer.apply_chat_template(example[:2], tokenize=False, add_generation_prompt=True)
|
46 |
+
outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.1, top_k=50, top_p=0.1, eos_token_id=pipe.tokenizer.eos_token_id, pad_token_id=pipe.tokenizer.pad_token_id)
|
47 |
+
print(f"Query:\n{example[1]['content']}")
|
48 |
+
print(f"Context:\n{example[0]['content']}")
|
49 |
+
print(f"Original Answer:\n{example[2]['content']}")
|
50 |
+
print(f"Generated Answer:\n{outputs[0]['generated_text'][len(prompt):].strip()}")
|
51 |
+
```
|
52 |
|
53 |
## Training Details
|
54 |
+
```
|
55 |
+
Peft Config :
|
56 |
+
|
57 |
+
{
|
58 |
+
'Technqiue' : 'QLORA',
|
59 |
+
'rank': 256,
|
60 |
+
'target_modules' : ["q_proj", "k_proj", "v_proj", "o_proj","gate_proj", "up_proj", "down_proj",],
|
61 |
+
'lora_alpha' : 128,
|
62 |
+
'lora_dropout' : 0,
|
63 |
+
'bias': "none",
|
64 |
+
}
|
65 |
+
|
66 |
+
Hyperparameters:
|
67 |
+
|
68 |
+
{
|
69 |
+
"epochs": 3,
|
70 |
+
"evaluation_strategy": "epoch",
|
71 |
+
"gradient_checkpointing": True,
|
72 |
+
"max_grad_norm" : 0.3,
|
73 |
+
"optimizer" : "adamw_torch_fused",
|
74 |
+
"learning_rate" : 2e-5,
|
75 |
+
"lr_scheduler_type": "constant",
|
76 |
+
"warmup_ratio" : 0.03,
|
77 |
+
"per_device_train_batch_size" : 4,
|
78 |
+
"per_device_eval_batch_size" : 4,
|
79 |
+
"gradient_accumulation_steps" : 4
|
80 |
+
}
|
81 |
+
```
|
82 |
+
|
83 |
+
## Model was trained on 1xA100 80GB, below loss and memory consmuption details:
|
84 |
+
{'eval_loss': 0.946821391582489, 'eval_runtime': 840.1526, 'eval_samples_per_second': 0.801, 'eval_steps_per_second': 0.401, 'epoch': 3.0}
|
85 |
+
{'train_runtime': 64796.4597, 'train_samples_per_second': 0.246, 'train_steps_per_second': 0.031, 'train_loss': 0.709615581515563, 'epoch': 3.0}
|
86 |
|
87 |
## Evaluation
|
88 |
|
89 |
<!-- This section describes the evaluation protocols and provides the results. -->
|
90 |
+
We evaluated the model on test set (sample 1k) https://huggingface.co/datasets/FinLang/investopedia-instruction-tuning-dataset. Evaluation was done using Proprietary LLMs as jury on four criteria Correctness, Faithfullness, Clarity, Completeness on scale of 1-5 (1 being worst & 5 being best) inspired by the paper Replacing Judges with Juries https://arxiv.org/abs/2404.18796. Model got an average score of 4.48.
|
91 |
+
Average inference speed of the model is 37 secs. Human Evaluation is in progress to see the percentage of alignment between human and LLM.
|
92 |
|
93 |
+
## Bias, Risks, and Limitations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
96 |
+
This model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance. It does not have any moderation mechanisms. We're looking into ways to make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
|
97 |
|
98 |
+
## License
|
99 |
|
100 |
+
Since non-commercial datasets are used for fine-tuning, we release this model as cc-by-nc-4.0.
|
101 |
|
|