Update README.md
Browse files
README.md
CHANGED
@@ -6,6 +6,45 @@ datasets:
|
|
6 |
tags:
|
7 |
- math
|
8 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
## Training procedure
|
10 |
|
11 |
|
|
|
6 |
tags:
|
7 |
- math
|
8 |
---
|
9 |
+
|
10 |
+
### WIP
|
11 |
+
|
12 |
+
## Usage:
|
13 |
+
|
14 |
+
```
|
15 |
+
import torch
|
16 |
+
from peft import PeftModel
|
17 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
18 |
+
|
19 |
+
model_name = "microsoft/phi-1_5"
|
20 |
+
adapters_name = 'aloobun/phi_mini_math23k_v1'
|
21 |
+
|
22 |
+
model = AutoModelForCausalLM.from_pretrained(
|
23 |
+
model_name,
|
24 |
+
load_in_4bit=True,
|
25 |
+
torch_dtype=torch.bfloat16,
|
26 |
+
device_map="auto",
|
27 |
+
quantization_config=BitsAndBytesConfig(
|
28 |
+
load_in_4bit=True,
|
29 |
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
30 |
+
bnb_4bit_use_double_quant=True,
|
31 |
+
bnb_4bit_quant_type='nf4'
|
32 |
+
),
|
33 |
+
)
|
34 |
+
model = PeftModel.from_pretrained(model, adapters_name)
|
35 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
36 |
+
```
|
37 |
+
|
38 |
+
```
|
39 |
+
prompt = "What is the largest two-digit integer whose digits are distinct and form a geometric sequence?"
|
40 |
+
formatted_prompt = (
|
41 |
+
f"### Instruction: {prompt} ### Response:"
|
42 |
+
)
|
43 |
+
inputs = tokenizer(formatted_prompt, return_tensors="pt").to("cuda:0")
|
44 |
+
outputs = model.generate(inputs=inputs.input_ids, max_new_tokens=1048)
|
45 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
46 |
+
```
|
47 |
+
|
48 |
## Training procedure
|
49 |
|
50 |
|