Update README.md
Browse files
README.md
CHANGED
@@ -50,6 +50,7 @@ It took ~1 hour to train 1 epoch on 1x A100.
|
|
50 |
|
51 |
Prompt format:
|
52 |
This model (and all my future releases) use [ChatML](https://huggingface.co/docs/transformers/chat_templating#what-template-should-i-use) prompt format.
|
|
|
53 |
```
|
54 |
<|im_start|>system
|
55 |
You are a helpful assistant.<|im_end|>
|
@@ -57,6 +58,7 @@ You are a helpful assistant.<|im_end|>
|
|
57 |
{prompt}<|im_end|>
|
58 |
<|im_start|>assistant
|
59 |
### Training Hyperparameters
|
|
|
60 |
|
61 |
We use the [`SFTTrainer`] (https://huggingface.co/docs/trl/main/en/sft_trainer) from 🤗's TRL package to easily fine-tune llms on instruction-following datasets.
|
62 |
|
@@ -91,7 +93,84 @@ The following `bitsandbytes` quantization config was used:
|
|
91 |
|
92 |
Use the code below to get started with the model.
|
93 |
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
### Speeds, Sizes, Times
|
97 |
|
|
|
50 |
|
51 |
Prompt format:
|
52 |
This model (and all my future releases) use [ChatML](https://huggingface.co/docs/transformers/chat_templating#what-template-should-i-use) prompt format.
|
53 |
+
|
54 |
```
|
55 |
<|im_start|>system
|
56 |
You are a helpful assistant.<|im_end|>
|
|
|
58 |
{prompt}<|im_end|>
|
59 |
<|im_start|>assistant
|
60 |
### Training Hyperparameters
|
61 |
+
```
|
62 |
|
63 |
We use the [`SFTTrainer`] (https://huggingface.co/docs/trl/main/en/sft_trainer) from 🤗's TRL package to easily fine-tune llms on instruction-following datasets.
|
64 |
|
|
|
93 |
|
94 |
Use the code below to get started with the model.
|
95 |
|
96 |
+
```python
|
97 |
+
!pip install -q -U transformers peft torch accelerate bitsandbytes einops sentencepiece
|
98 |
+
|
99 |
+
import torch
|
100 |
+
from peft import PeftModel, PeftConfig
|
101 |
+
from transformers import (
|
102 |
+
AutoModelForCausalLM,
|
103 |
+
AutoTokenizer,
|
104 |
+
BitsAndBytesConfig,
|
105 |
+
)
|
106 |
+
```
|
107 |
+
|
108 |
+
```python
|
109 |
+
peft_model_id = "dfurman/mistral-7b-instruct-v0.1"
|
110 |
+
config = PeftConfig.from_pretrained(peft_model_id)
|
111 |
+
|
112 |
+
model = AutoModelForCausalLM.from_pretrained(
|
113 |
+
config.base_model_name_or_path,
|
114 |
+
torch_dtype=torch.bfloat16,
|
115 |
+
device_map="auto",
|
116 |
+
trust_remote_code=True,
|
117 |
+
)
|
118 |
+
|
119 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
120 |
+
config.base_model_name_or_path,
|
121 |
+
use_fast=True,
|
122 |
+
trust_remote_code=True,
|
123 |
+
)
|
124 |
+
|
125 |
+
model = PeftModel.from_pretrained(model, peft_model_id)
|
126 |
+
|
127 |
+
format_template = "You are a helpful assistant. Write a response that appropriately completes the request. {query}\n"
|
128 |
+
```
|
129 |
+
|
130 |
+
```python
|
131 |
+
query = "Write a short email inviting my friends to a dinner party on Friday. Respond succinctly."
|
132 |
+
prompt = format_template.format(query=query)
|
133 |
+
|
134 |
+
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.cuda()
|
135 |
+
with torch.autocast("cuda", dtype=torch.bfloat16):
|
136 |
+
output = model.generate(
|
137 |
+
input_ids=input_ids,
|
138 |
+
max_new_tokens=512,
|
139 |
+
do_sample=True,
|
140 |
+
temperature=0.1,
|
141 |
+
return_dict_in_generate=True,
|
142 |
+
eos_token_id=tokenizer.eos_token_id,
|
143 |
+
pad_token_id=tokenizer.pad_token_id,
|
144 |
+
repetition_penalty=1.2,
|
145 |
+
no_repeat_ngram_size=5,
|
146 |
+
)
|
147 |
+
|
148 |
+
print("\n\n*** Generate:")
|
149 |
+
print(tokenizer.decode(output["sequences"][0][len(input_ids[0]):], skip_special_tokens=True))
|
150 |
+
```
|
151 |
+
|
152 |
+
<details>
|
153 |
+
|
154 |
+
<summary>Output</summary>
|
155 |
+
|
156 |
+
**Prompt**: Write a short email inviting my friends to a dinner party on Friday. Respond succinctly.
|
157 |
+
|
158 |
+
**Generation**: The invitation should be brief and to-the-point, so it's best to use simple language and avoid unnecessary details or long explanations. Here is an example of a concise invitation:
|
159 |
+
|
160 |
+
Dear Friends,
|
161 |
+
|
162 |
+
I hope you can join me for a fun evening at my place this Friday! We'll have delicious food, great conversation, and maybe even some games if we feel like it. Please RSVP by Wednesday night so I know who will be there.
|
163 |
+
|
164 |
+
Looking forward to seeing you all soon!
|
165 |
+
|
166 |
+
Best regards,
|
167 |
+
Your Name
|
168 |
+
|
169 |
+
This message clearly communicates the essential information about the event while maintaining a friendly tone. It also includes a specific date (Friday) and timeframe (evening), as well as a clear call to action (RSVP). The closing line adds a personal touch and expresses excitement for the gathering. Overall, this invitation strikes a good balance between being informative and engaging without overwhelming the reader with too much text.
|
170 |
+
|
171 |
+
Remember, when writing emails, always keep in mind your audience and their preferences. If they prefer more detailed information or additional context, adjust accordingly. However, try not to make the invitation overly complicated or lengthy – simplicity often makes for a better experience. Happy emailing!
|
172 |
+
|
173 |
+
</details>
|
174 |
|
175 |
### Speeds, Sizes, Times
|
176 |
|