Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-metamath-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 $(r,\\theta),$ where $r > 0$ and $0 \\le \\theta < 2 \\pi.$"
|
15 |
+
question = question_template.format(question=question)
|
16 |
+
|
17 |
+
input_tensor = torch.tensor([tokenizer.encode(question)])
|
18 |
+
outputs = model.generate(input_tensor.to(model.device), max_new_tokens=500)
|
19 |
+
|
20 |
+
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
21 |
+
print(result)
|
22 |
+
```
|
23 |
+
|
24 |
+
Example result:
|
25 |
+
|
26 |
+
```
|
27 |
+
# Question
|
28 |
+
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.$
|
29 |
+
|
30 |
+
# Solution
|
31 |
+
To convert from rectangular coordinates to polar coordinates, we use the formulas $r = \sqrt{x^2 + y^2}$ and $\theta = \arctan\left(\frac{y}{x}\right)$.
|
32 |
+
|
33 |
+
In this case, $x = 0$ and $y = 3$, so $r = \sqrt{0^2 + 3^2} = 3$ and $\theta = \arctan\left(\frac{3}{0}\right)$.
|
34 |
+
|
35 |
+
Since $\frac{3}{0}$ is undefined, we can say that $\theta$ is undefined.
|
36 |
+
However, we know that $\theta$ is an angle, and since $r > 0$, we can say that $\theta$ is any angle that satisfies $0 \le \theta < 2 \pi$.
|
37 |
+
|
38 |
+
Therefore, the polar coordinates of the point $(0,3)$ are $\boxed{(3,\theta)}$, where $0 \le \theta < 2 \pi$.
|
39 |
+
|
40 |
+
# Answer
|
41 |
+
|
42 |
+
(3,\theta)
|
43 |
+
```
|