dfurman commited on
Commit
ac01a3e
1 Parent(s): 63cf39f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +72 -141
README.md CHANGED
@@ -12,11 +12,27 @@ base_model: mistralai/Mistral-7B-v0.1
12
  ---
13
 
14
 
15
- # mistral-7b-instruct-peft
16
 
17
- This instruction model was built via parameter-efficient QLoRA finetuning of [Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) on the first 5k rows of [ehartford/dolphin](https://huggingface.co/datasets/ehartford/dolphin) and the first 5k rows of [garage-bAInd/Open-Platypus](https://huggingface.co/datasets/garage-bAInd/Open-Platypus). Finetuning was executed on 1x A100 (40 GB SXM) for roughly 2 hours on the [Lambda Labs](https://cloud.lambdalabs.com/instances) platform.
18
 
19
- ## Benchmark metrics
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  | Metric | Value |
22
  |-----------------------|-------|
@@ -28,178 +44,81 @@ This instruction model was built via parameter-efficient QLoRA finetuning of [Mi
28
 
29
  We use Eleuther.AI's [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) to run the benchmark tests above, the same version as Hugging Face's [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard).
30
 
31
- ## Helpful links
32
-
33
- * Model license: Apache 2.0
34
- * Basic usage: [here](https://github.com/daniel-furman/sft-demos/blob/main/src/sft/one_gpu/mistral/sft-mistral-7b-instruct-basic-usage.ipynb)
35
- * Finetuning code: [here](https://github.com/daniel-furman/sft-demos/blob/main/src/sft/one_gpu/mistral/sft-mistral-7b-instruct-peft.ipynb)
36
- * Runtime stats: [here](https://huggingface.co/dfurman/mistral-7b-instruct-peft#runtime-tests)
37
-
38
- ## Loss curve
39
-
40
- ![loss curve](https://raw.githubusercontent.com/daniel-furman/sft-demos/main/assets/sep_27_23_mistral-7b-instruct.png)
41
-
42
- The above loss curve was generated from the run's private wandb.ai log.
43
-
44
- ## Example prompts and responses
45
-
46
- Example 1:
47
-
48
- **User**:
49
- > Write me a numbered list of things to do in New York City.
50
-
51
- **mistral-7b-instruct-peft**:
52
-
53
-
54
- > 1. Visit the Statue of Liberty - This iconic symbol of freedom stands tall on Liberty Island in New York Harbor. Visitors can take a ferry ride over to see it up close and learn about its history.
55
- >
56
- > 2. Take a Walk Through Central Park - One of the most beautiful parks in the world, Central Park offers plenty of activities for visitors, including boating, ice skating, and picnicking.
57
- >
58
- > 3. Catch a Broadway Show - The Great White Way is home to some of the best theater productions in the world. From musicals to plays, there's something for everyone.
59
- >
60
- > 4. Explore Chinatown - A vibrant neighborhood filled with authentic Chinese restaurants, shops, and cultural landmarks, Chinatown is a must-visit destination for anyone interested in experiencing another culture within the city.
61
- >
62
- > 5. Shop at Popular Stores and Markets - New York City has countless shopping opportunities, ranging from high-end designer boutiques to bustling street vendors selling everything imaginable. Some notable places to check out include Macy's Herald Square, Fifth Avenue, and Chelsea Market.
63
- >
64
- > 6. Try Delicious Local Food Options - No visit to NYC is complete without sampling some of their signature dishes. Pizza from Lombardi's (the oldest pizzeria in America), bagels from Ess-a-Bagel, and cheesecake from Junior's are just a few examples of what you should try while in the Big Apple!
65
- >
66
- > In conclusion, these six items make up an excellent starting point for your adventure in New York City.
67
-
68
- <br>
69
 
70
- Example 2:
71
 
72
- **User**:
73
 
74
- > Write a short email inviting my friends to a dinner party on Friday. Respond succinctly.
75
 
76
- **mistral-7b-instruct-peft**:
77
 
78
- > Dear Friends,
79
- >
80
- > Please join me for an evening of delicious food and great company at my home this Friday night! Bring your favorite dish or beverage to share with everyone else. I can't wait to see you all there!
81
- >
82
- > Best regards,
83
- > Your Name
84
- >
85
- > P.S.: Don't forget to RSVP by Wednesday so we know how much food to prepare! 😋
86
 
87
- <br>
88
 
89
- Example 3:
90
 
91
- **User**:
92
 
93
- > What is a good recipe for vegan banana bread?
94
 
95
- **mistral-7b-instruct-peft**:
96
 
97
- > Let's start by gathering all of our ingredients: 2 cups flour, 1 teaspoon baking soda, 1/4 teaspoon salt, and 3 very ripe bananas (the more brown spots they have, the better). Then we need some wet ingredients to mix with the dry ones: 1 cup sugar, 1/2 cup vegetable oil or applesauce, and 1 tablespoon vanilla extract. Now let's make sure everything is ready before we begin mixing it together. Preheat your oven to 350 degrees Fahrenheit and grease an 8x4 inch loaf pan with cooking spray or butter. Next, in a large bowl, whisk together the flour, baking soda, and salt until well combined. In another smaller bowl, mash up those bananas really well using a fork or potato masher - you want them to be almost liquid-y. Add the sugar, oil or applesauce, and vanilla extract to the bananas and stir until smooth. Pour this mixture into the larger bowl with the dry ingredients and use a wooden spoon or spatula to gently fold everything together until just combined - don't overmix! The batter will still look slightly lumpy but that's okay. Finally, pour the batter into your prepared loaf pan and bake for about one hour or until a toothpick inserted into the center comes out clean. Allow the bread to cool completely before slicing and serving. Enjoy your delicious vegan banana bread! 🍌😋
98
- >
99
- > Note: If you prefer a sweeter taste, feel free to add chocolate chips or nuts like walnuts or pecans to the batter before baking. Just remember not to overdo it as too many additions can affect how the bread rises during baking. Happy baking! 😊
100
 
101
- <br>
102
 
103
- ## Limitations and biases
104
 
105
- _The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
106
 
107
- This model can produce factually incorrect output, and should not be relied on to produce factually accurate information.
108
- This model was trained on various public datasets.
109
- While great efforts have been taken to clean the pretraining data, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
110
 
111
- ## Basic usage
112
 
113
- ```python
114
- !pip install -q -U huggingface_hub peft transformers torch accelerate
115
- ```
116
 
117
- ```python
118
- from huggingface_hub import notebook_login
119
- import torch
120
- from peft import PeftModel, PeftConfig
121
- from transformers import (
122
- AutoModelForCausalLM,
123
- AutoTokenizer,
124
- BitsAndBytesConfig,
125
- pipeline,
126
- )
127
 
128
- notebook_login()
129
- ```
130
 
131
- ```python
132
- peft_model_id = "dfurman/mistral-7b-instruct-peft"
133
- config = PeftConfig.from_pretrained(peft_model_id)
134
 
135
- bnb_config = BitsAndBytesConfig(
136
- load_in_4bit=True,
137
- bnb_4bit_quant_type="nf4",
138
- bnb_4bit_compute_dtype=torch.bfloat16,
139
- )
140
 
141
- model = AutoModelForCausalLM.from_pretrained(
142
- config.base_model_name_or_path,
143
- quantization_config=bnb_config,
144
- use_auth_token=True,
145
- device_map="auto",
146
- )
147
 
148
- tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path, use_fast=True)
149
- tokenizer.pad_token = tokenizer.eos_token
150
 
151
- model = PeftModel.from_pretrained(model, peft_model_id)
152
 
153
- format_template = "You are a helpful assistant. Write a response that appropriately completes the request. {query}\n"
154
- ```
155
 
156
- ```python
157
- # First, format the prompt
158
- query = "Tell me a recipe for vegan banana bread."
159
- prompt = format_template.format(query=query)
160
 
161
- # Inference can be done using model.generate
162
- print("\n\n*** Generate:")
163
 
164
- input_ids = tokenizer(prompt, return_tensors="pt").input_ids.cuda()
165
- with torch.autocast("cuda", dtype=torch.bfloat16):
166
- output = model.generate(
167
- input_ids=input_ids,
168
- max_new_tokens=512,
169
- do_sample=True,
170
- temperature=0.7,
171
- return_dict_in_generate=True,
172
- eos_token_id=tokenizer.eos_token_id,
173
- pad_token_id=tokenizer.pad_token_id,
174
- repetition_penalty=1.2,
175
- )
176
 
177
- print(tokenizer.decode(output["sequences"][0], skip_special_tokens=True))
178
- ```
179
 
180
- ## Runtime tests
181
 
182
- | runtime / 50 tokens (sec) | GPU | attn | torch dtype | VRAM (GB) |
183
- |:-----------------------------:|:----------------------:|:---------------------:|:-------------:|:-----------------------:|
184
- | 3.1 | 1x A100 (40 GB SXM) | torch | fp16 | 13 |
185
-
186
- ## Acknowledgements
187
-
188
- This model was finetuned by Daniel Furman on Sep 27, 2023 and is for research applications only.
189
 
190
- ## Disclaimer
 
 
 
 
 
 
 
 
 
 
191
 
192
- The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please cosult an attorney before using this model for commercial purposes.
193
 
194
- ## mistralai/Mistral-7B-v0.1 citation
195
-
196
- ```
197
- coming
198
- ```
199
-
200
- ## Training procedure
201
-
202
- The following `bitsandbytes` quantization config was used during training:
203
  - quant_method: bitsandbytes
204
  - load_in_8bit: False
205
  - load_in_4bit: True
@@ -211,6 +130,18 @@ The following `bitsandbytes` quantization config was used during training:
211
  - bnb_4bit_use_double_quant: False
212
  - bnb_4bit_compute_dtype: bfloat16
213
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  ## Framework versions
215
 
216
  - PEFT 0.6.0.dev0
 
12
  ---
13
 
14
 
15
+ # mistral-7b-instruct-v0.1
16
 
17
+ General instruction-following llm finetuned from [mistralai/Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1).
18
 
19
+ ## Model Details
20
+
21
+ ### Model Description
22
+
23
+ This instruction-following llm was built via parameter-efficient QLoRA finetuning of [mistralai/Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) on the first 200k rows of [ehartford/dolphin](https://huggingface.co/datasets/ehartford/dolphin). Finetuning was executed on 1x A100 (40 GB SXM) for roughly 20 hours on Google Colab. **Only** the `peft` adapter weights are included in this model repo, alonside the tokenizer.
24
+
25
+ - **Developed by:** Daniel Furman
26
+ - **Model type:** Decoder-only
27
+ - **Language(s) (NLP):** English
28
+ - **License:** Yi model license
29
+ - **Finetuned from model:** [mistralai/Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1)
30
+
31
+ ### Model Sources
32
+
33
+ - **Repository:** [github.com/daniel-furman/sft-demos](https://github.com/daniel-furman/sft-demos/blob/main/src/sft/one_gpu/mistral/sft-mistral-7b-instruct-peft.ipynb)
34
+
35
+ ### Evaluation Results
36
 
37
  | Metric | Value |
38
  |-----------------------|-------|
 
44
 
45
  We use Eleuther.AI's [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) to run the benchmark tests above, the same version as Hugging Face's [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard).
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
+ ## Uses
49
 
50
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
51
 
52
+ ### Direct Use
53
 
54
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
55
 
56
+ [More Information Needed]
 
 
 
 
 
 
 
57
 
58
+ ### Downstream Use
59
 
60
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
61
 
62
+ [More Information Needed]
63
 
64
+ ### Out-of-Scope Use
65
 
66
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
67
 
68
+ [More Information Needed]
 
 
69
 
70
+ ## Bias, Risks, and Limitations
71
 
72
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
73
 
74
+ [More Information Needed]
75
 
76
+ ### Recommendations
 
 
77
 
78
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
79
 
80
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
 
 
81
 
82
+ ## How to Get Started with the Model
 
 
 
 
 
 
 
 
 
83
 
84
+ Use the code below to get started with the model.
 
85
 
86
+ [More Information Needed]
 
 
87
 
88
+ ## Training Details
 
 
 
 
89
 
90
+ ### Training Data
 
 
 
 
 
91
 
92
+ <!-- This should link to a Data 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. -->
 
93
 
94
+ [More Information Needed]
95
 
 
 
96
 
97
+ ### Preprocessing
 
 
 
98
 
99
+ [More Information Needed]
 
100
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
+ ### Training Hyperparameters
 
103
 
104
+ We used the [`SFTTrainer` from TRL library](https://huggingface.co/docs/trl/main/en/sft_trainer) that gives a wrapper around transformers `Trainer` to easily fine-tune models on instruction based datasets.
105
 
106
+ The following `TrainingArguments` config was used:
 
 
 
 
 
 
107
 
108
+ - num_train_epochs = 1
109
+ - auto_find_batch_size = True
110
+ - gradient_accumulation_steps = 1
111
+ - optim = "paged_adamw_32bit"
112
+ - save_strategy = "epoch"
113
+ - learning_rate = 3e-4
114
+ - lr_scheduler_type = "cosine"
115
+ - warmup_ratio = 0.03
116
+ - logging_strategy = "steps"
117
+ - logging_steps = 25
118
+ - bf16 = True
119
 
120
+ The following `bitsandbytes` quantization config was used:
121
 
 
 
 
 
 
 
 
 
 
122
  - quant_method: bitsandbytes
123
  - load_in_8bit: False
124
  - load_in_4bit: True
 
130
  - bnb_4bit_use_double_quant: False
131
  - bnb_4bit_compute_dtype: bfloat16
132
 
133
+ ### Speeds, Sizes, Times
134
+
135
+ | runtime / 50 tokens (sec) | GPU | attn | torch dtype | VRAM (GB) |
136
+ |:-----------------------------:|:----------------------:|:---------------------:|:-------------:|:-----------------------:|
137
+ | 3.1 | 1x A100 (40 GB SXM) | torch | fp16 | 13 |
138
+
139
+
140
+ ## Model Card Contact
141
+
142
+ dryanfurman at gmail
143
+
144
+
145
  ## Framework versions
146
 
147
  - PEFT 0.6.0.dev0