macadeliccc commited on
Commit
10953f7
β€’
1 Parent(s): ef27742

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -4
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
- TODO
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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