Update README.md
Browse files
README.md
CHANGED
@@ -34,22 +34,50 @@ Below is a simple example demonstrating how to use the model for solving a mathe
|
|
34 |
|
35 |
```python
|
36 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
37 |
|
38 |
# Load the tokenizer and model
|
39 |
tokenizer = AutoTokenizer.from_pretrained("haijian06/Yi-1.5-6B-Chat-Math")
|
40 |
-
model = AutoModelForCausalLM.from_pretrained("haijian06/Yi-1.5-6B-Chat-Math")
|
41 |
|
42 |
-
|
43 |
-
input_text = "Solve the equation x^2 - 5x + 6 = 0"
|
44 |
-
inputs = tokenizer(input_text, return_tensors="pt")
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
|
|
50 |
print(answer)
|
51 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
## Contributing
|
54 |
|
55 |
Contributions are welcome! Whether you have suggestions for improvements, bug reports, or want to contribute code, feel free to open an issue or submit a pull request on GitHub.
|
|
|
34 |
|
35 |
```python
|
36 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
37 |
+
import torch
|
38 |
|
39 |
# Load the tokenizer and model
|
40 |
tokenizer = AutoTokenizer.from_pretrained("haijian06/Yi-1.5-6B-Chat-Math")
|
41 |
+
model = AutoModelForCausalLM.from_pretrained("haijian06/Yi-1.5-6B-Chat-Math", torch_dtype=torch.float16, device_map="auto")
|
42 |
|
43 |
+
input_text = "Solve the equation x^2 - 5x + 6 = 0 Let's solve this step-by-step:"
|
|
|
|
|
44 |
|
45 |
+
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
|
46 |
+
|
47 |
+
with torch.no_grad():
|
48 |
+
outputs = model.generate(
|
49 |
+
**inputs,
|
50 |
+
max_new_tokens=200,
|
51 |
+
do_sample=True,
|
52 |
+
temperature=0.7,
|
53 |
+
top_p=0.95,
|
54 |
+
)
|
55 |
|
56 |
+
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
57 |
print(answer)
|
58 |
```
|
59 |
+
```
|
60 |
+
Solve the equation x^2 - 5 x + 6 = 0 Let's solve this step-by-step:
|
61 |
+
|
62 |
+
Step 1: Factor the equation
|
63 |
+
The equation can be factored as follows:
|
64 |
+
|
65 |
+
x^2 - 5x + 6 = 0
|
66 |
+
(x - 2)(x - 3) = 0
|
67 |
|
68 |
+
Step 2: Apply the zero product property
|
69 |
+
If the product of two numbers is zero, then at least one of the numbers must be zero.
|
70 |
+
|
71 |
+
So, either (x - 2) = 0 or (x - 3) = 0
|
72 |
+
|
73 |
+
Step 3: Solve for x
|
74 |
+
If (x - 2) = 0, then x = 2
|
75 |
+
If (x - 3) = 0, then x = 3
|
76 |
+
|
77 |
+
So, the solutions are x = 2 and x = 3.
|
78 |
+
|
79 |
+
Answer: 2, 3
|
80 |
+
```
|
81 |
## Contributing
|
82 |
|
83 |
Contributions are welcome! Whether you have suggestions for improvements, bug reports, or want to contribute code, feel free to open an issue or submit a pull request on GitHub.
|