macadeliccc
commited on
Commit
β’
10953f7
1
Parent(s):
ef27742
Update README.md
Browse files
README.md
CHANGED
@@ -9,14 +9,31 @@ library_name: transformers
|
|
9 |
|
10 |
Merge of two SOLAR models. This is an experiment to improve models ability to learn math and retain other skills.
|
11 |
|
12 |
-
![solar](solar.png)
|
13 |
-
|
14 |
-
## π Usage
|
15 |
|
16 |
|
17 |
## π
Code Example
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
## Evaluations
|
22 |
|
|
|
9 |
|
10 |
Merge of two SOLAR models. This is an experiment to improve models ability to learn math and retain other skills.
|
11 |
|
12 |
+
![solar](solar-math.png)
|
|
|
|
|
13 |
|
14 |
|
15 |
## π
Code Example
|
16 |
|
17 |
+
```python
|
18 |
+
import torch
|
19 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
20 |
+
|
21 |
+
tokenizer = AutoTokenizer.from_pretrained("macadeliccc/SOLAR-math-2x10.7b",load_in_4bit=True)
|
22 |
+
model = AutoModelForCausalLM.from_pretrained(
|
23 |
+
"macadeliccc/SOLAR-math-2x10.7b",
|
24 |
+
device_map="auto",
|
25 |
+
torch_dtype=torch.float16,
|
26 |
+
)
|
27 |
+
|
28 |
+
conversation = [ {'role': 'user', 'content': 'A rectangle has a length that is twice its width and its area is 50 square meters. Find the dimensions of the rectangle.'} ]
|
29 |
+
|
30 |
+
prompt = tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
|
31 |
+
|
32 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
33 |
+
outputs = model.generate(**inputs, use_cache=True, max_length=4096)
|
34 |
+
output_text = tokenizer.decode(outputs[0])
|
35 |
+
print(output_text)
|
36 |
+
```
|
37 |
|
38 |
## Evaluations
|
39 |
|