Easy-to-Hard Generalization Models
Collection
6 items
•
Updated
•
1
Usage:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
question_template = "# Question\n\n{question}\n\n# Solution\n\n"
model_name = "ScalableMath/llemma-7b-sft-metamath-level-1to3-hf"
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/llemma_7b")
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.$"
question = question_template.format(question=question)
input_tensor = torch.tensor([tokenizer.encode(question)])
outputs = model.generate(input_tensor.to(model.device), max_new_tokens=500)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(result)
Example result:
# 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.$
# Solution
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)$.
In this case, $x = 0$ and $y = 3$, so $r = \sqrt{0^2 + 3^2} = 3$ and $\theta = \arctan\left(\frac{3}{0}\right)$.
Since $\frac{3}{0}$ is undefined, we can say that $\theta$ is undefined.
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$.
Therefore, the polar coordinates of the point $(0,3)$ are $\boxed{(3,\theta)}$, where $0 \le \theta < 2 \pi$.
# Answer
(3,\theta)