plaguss HF staff commited on
Commit
0994eb4
1 Parent(s): 892c05d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +141 -4
README.md CHANGED
@@ -15,15 +15,152 @@ licence: license
15
  This model is a fine-tuned version of [meta-llama/Llama-3.1-8B](https://huggingface.co/meta-llama/Llama-3.1-8B) on the [trl-lib/math_shepherd](https://huggingface.co/datasets/trl-lib/math_shepherd) dataset.
16
  It has been trained using [TRL](https://github.com/huggingface/trl).
17
 
 
18
  ## Quick start
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  ```python
 
21
  from transformers import pipeline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
24
- generator = pipeline("text-generation", model="plaguss/Llama-3.1-8B-Math-Shepherd-PRM-0.2", device="cuda")
25
- output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
26
- print(output["generated_text"])
 
 
 
 
 
 
27
  ```
28
 
29
  ## Training procedure
 
15
  This model is a fine-tuned version of [meta-llama/Llama-3.1-8B](https://huggingface.co/meta-llama/Llama-3.1-8B) on the [trl-lib/math_shepherd](https://huggingface.co/datasets/trl-lib/math_shepherd) dataset.
16
  It has been trained using [TRL](https://github.com/huggingface/trl).
17
 
18
+
19
  ## Quick start
20
 
21
+ Example 1)
22
+
23
+ ```python
24
+ from datasets import load_dataset
25
+ from transformers import pipeline
26
+ import os
27
+ os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
28
+
29
+ model_name = "plaguss/Llama-3.1-8B-Math-Shepherd-PRM-0.2"
30
+
31
+ pipe = pipeline("token-classification", model=model_name, device="cuda")
32
+ dataset = load_dataset("trl-lib/math_shepherd")
33
+ example = dataset["test"][10]
34
+
35
+ sep = "\n"
36
+
37
+ print(sep.join((example["prompt"], *example["completions"])))
38
+ for idx in range(1, len(example["completions"])+1):
39
+ text = sep.join((example["prompt"], *example["completions"][0:idx])) + sep
40
+ output = pipe(text)
41
+ score = float(output[-1]["score"])
42
+ pred = True if output[-1]["entity"] == "LABEL_1" else False
43
+ print(f"Step {idx}\tPredicted (score): {pred} ({score:.2f})\tLabel: {example['labels'][idx-1]}")
44
+
45
+ # Grandma gave Bryce and Carter some raisins. Bryce received 6 more raisins than Carter, and Carter received half the number of raisins Bryce received. How many raisins did Bryce receive?
46
+ # Step 1: Let $b$ be the number of raisins Bryce received and $c$ be the number of raisins Carter received.
47
+ # Step 2: We are given that $b = c + 6$ and $c = \frac{1}{2}b$.
48
+ # Step 3: Substituting the second equation into the first equation, we get $b = c + 6 = \frac{1}{2}b + 6$.
49
+ # Step 4: Simplifying, we have $b = \frac{1}{2}b + 6$.
50
+ # Step 5: Subtracting $\frac{1}{2}b$ from both sides, we get $\frac{1}{2}b - b = 6$.
51
+ # Step 6: Simplifying further, we have $\frac{1}{2}b - 2b = 6$.
52
+ # Step 7: Combining like terms, we have $-\frac{1}{2}b = 6$.
53
+ # Step 8: Multiplying both sides by $-2$, we get $b = -12$.
54
+ # Step 9: Therefore, Bryce received $\boxed{-12}$ raisins.The answer is: -12
55
+ # Step 1 Predicted (score): True (0.99) Label: True
56
+ # Step 2 Predicted (score): True (1.00) Label: True
57
+ # Step 3 Predicted (score): True (0.97) Label: True
58
+ # Step 4 Predicted (score): True (0.77) Label: True
59
+ # Step 5 Predicted (score): True (0.68) Label: True
60
+ # Step 6 Predicted (score): False (0.70) Label: False
61
+ # Step 7 Predicted (score): False (0.82) Label: False
62
+ # Step 8 Predicted (score): False (0.97) Label: False
63
+ # Step 9 Predicted (score): False (0.99) Label: False
64
+ ```
65
+
66
+
67
+ Example 2)
68
+
69
+ ```python
70
+ from datasets import load_dataset
71
+ from transformers import pipeline
72
+ import os
73
+ os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
74
+
75
+ model_name = "plaguss/Llama-3.1-8B-Math-Shepherd-PRM-0.2"
76
+
77
+ pipe = pipeline("token-classification", model=model_name, device="cuda")
78
+ dataset = load_dataset("trl-lib/math_shepherd")
79
+ i = 32 # 10, 32
80
+ example = dataset["test"][i]
81
+
82
+ sep = "\n"
83
+
84
+ print(sep.join((example["prompt"], *example["completions"])))
85
+ for idx in range(1, len(example["completions"])+1):
86
+ text = sep.join((example["prompt"], *example["completions"][0:idx])) + sep
87
+ output = pipe(text)
88
+ score = float(output[-1]["score"])
89
+ pred = True if output[-1]["entity"] == "LABEL_1" else False
90
+ print(f"Step {idx}\tPredicted (score): {pred} ({score:.2f})\tLabel: {example['labels'][idx-1]}")
91
+
92
+
93
+ # In the Golden State Team, each player earned points. Draymond earned 12 points, Curry earned twice the points as Draymond, Kelly earned 9, Durant earned twice the points as Kelly, Klay earned half the points as Draymond. How many points did the Golden States have in total?
94
+ # Step 1: Draymond earned 12 points, Curry earned twice the points as Draymond, which is 2*12 = 24 points.
95
+ # Step 2: Kelly earned 9 points, Durant earned twice the points as Kelly, which is 2*9 = 18 points.
96
+ # Step 3: Klay earned half the points as Draymond, which is 12/2 = <<12/2=6>>6 points.
97
+ # Step 4: The Golden State Team had 12+24+9+18+6 = <<12+24+9+18+6=51>>51 points. The answer is: 51
98
+ # Step 1 Predicted (score): True (0.99) Label: True
99
+ # Step 2 Predicted (score): True (1.00) Label: True
100
+ # Step 3 Predicted (score): True (1.00) Label: True
101
+ # Step 4 Predicted (score): False (0.99) Label: False
102
+ ```
103
+
104
+ Example 3)
105
+
106
+ This example corresponds to the one shown in the [peiyi9979/math-shepherd-mistral-7b-prm](https://huggingface.co/peiyi9979/math-shepherd-mistral-7b-prm):
107
+
108
  ```python
109
+ from datasets import load_dataset
110
  from transformers import pipeline
111
+ import os
112
+ os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
113
+
114
+ model_name = "plaguss/Llama-3.1-8B-Math-Shepherd-PRM-0.2"
115
+
116
+ pipe = pipeline("token-classification", model=model_name, device="cuda")
117
+
118
+ examples = [
119
+ {
120
+ "prompt": "Janet\u2019s ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?",
121
+ "completions": [
122
+ "Step 1: Janet's ducks lay 16 eggs per day.",
123
+ 'Step 2: She eats three for breakfast every morning, so she has 16 - 3 = 13 eggs left.',
124
+ 'Step 3: She bakes muffins for her friends every day with four eggs, so she has 13 - 4 = 9 eggs left.',
125
+ "Step 4: She sells the remainder at the farmers' market daily for $2 per fresh duck egg, so she makes 9 * $2 = $18 every day at the farmers' market. The answer is: 18"
126
+ ],
127
+ "labels": [True, True, True, True]
128
+ },
129
+ {
130
+ "prompt": "Janet\u2019s ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?",
131
+ "completions": [
132
+ "Step 1: Janet's ducks lay 16 eggs per day.",
133
+ 'Step 2: She eats three for breakfast every morning, so she has 16 - 3 = 13 eggs left.',
134
+ 'Step 3: She bakes muffins for her friends every day with four eggs, so she has 13 - 4 = 9 eggs left.',
135
+ "Step 4: She sells the remainder at the farmers' market daily for $2 per fresh duck egg, so she makes 9 * $2 = $18 every day at the farmers' market. The answer is: 17"
136
+ ],
137
+ "labels": [True, True, True, False]
138
+ },
139
+
140
+ ]
141
+
142
+
143
+ sep = "\n"
144
+
145
+ for i, example in enumerate(examples):
146
+ print(f"- Example {i}:")
147
+ for idx in range(1, len(example["completions"])+1):
148
+ text = "\n".join((example["prompt"], *example["completions"][0:idx])) + "\n"
149
+ output = pipe(text)
150
+ score = float(output[-1]["score"])
151
+ pred = True if output[-1]["entity"] == "LABEL_1" else False
152
+ print(f"Step {idx}\tPredicted (score): {pred} ({score:.2f})\tLabel: {example['labels'][idx-1]}")
153
 
154
+ # - Example 0:
155
+ # Step 1 Predicted (score): True (0.98) Label: True
156
+ # Step 2 Predicted (score): True (0.86) Label: True
157
+ # Step 3 Predicted (score): True (0.91) Label: True
158
+ # Step 4 Predicted (score): True (0.84) Label: True
159
+ # - Example 1:
160
+ # Step 1 Predicted (score): True (0.98) Label: True
161
+ # Step 2 Predicted (score): True (0.86) Label: True
162
+ # Step 3 Predicted (score): True (0.91) Label: True
163
+ # Step 4 Predicted (score): False (0.99) Label: False
164
  ```
165
 
166
  ## Training procedure