Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Usage:
|
2 |
+
|
3 |
+
```python
|
4 |
+
import torch
|
5 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
6 |
+
|
7 |
+
question_template = "# Question\n\n{question}\n\n# Solution\n\n"
|
8 |
+
|
9 |
+
model_name = "ScalableMath/llemma-7b-sft-prm800k-level-1to3-hf"
|
10 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
|
11 |
+
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/llemma_7b")
|
13 |
+
|
14 |
+
question = "Convert the point $(0,3)$ in rectangular coordinates to polar coordinates. Enter your answer in the form $
|
15 |
+
(r,\\theta),$ where $r > 0$ and $0 \\le \\theta < 2 \\pi.$"
|
16 |
+
question = question_template.format(question=question)
|
17 |
+
|
18 |
+
input_tensor = torch.tensor([tokenizer.encode(question)])
|
19 |
+
outputs = model.generate(input_tensor.to(model.device), max_new_tokens=500)
|
20 |
+
|
21 |
+
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
22 |
+
print(result)
|
23 |
+
```
|
24 |
+
|
25 |
+
Example Results:
|
26 |
+
```
|
27 |
+
# Question
|
28 |
+
|
29 |
+
Convert the point $(0,3)$ in rectangular coordinates to polar coordinates. Enter your answer in the form $(r,\theta),$ where $r > 0$ and $0 \le \theta < 2 \pi.$
|
30 |
+
|
31 |
+
# Solution
|
32 |
+
|
33 |
+
To convert from rectangular to polar coordinates, I need to use the formulas $r = \sqrt{x^2 + y^2}$ and $\theta = \tan^{-1}(y/x).$
|
34 |
+
|
35 |
+
In this case, $x = 0$ and $y = 3,$ so I can plug them into the formulas.
|
36 |
+
|
37 |
+
For $r,$ I get $r = \sqrt{0^2 + 3^2} = \sqrt{9} = 3.$
|
38 |
+
|
39 |
+
For $\theta,$ I get $\theta = \tan^{-1}(3/0).$
|
40 |
+
|
41 |
+
This is undefined, since the tangent function is not defined at $0.$
|
42 |
+
|
43 |
+
However, I can use the fact that the point $(0,3)$ lies on the positive $y$-axis, which has an angle of $\pi/2$ radians or $90^\circ.$
|
44 |
+
|
45 |
+
Therefore, I can choose any angle in the range $(0,\pi/2)$ as the value of $\theta.$
|
46 |
+
|
47 |
+
I will choose $\theta = \pi/2,$ since it is the simplest and most natural choice.
|
48 |
+
|
49 |
+
Therefore, the polar coordinates of the point $(0,3)$ are $(3,\pi/2).$
|
50 |
+
|
51 |
+
# Answer
|
52 |
+
|
53 |
+
(3,\pi/2)
|
54 |
+
```
|