Update README.md
Browse files
README.md
CHANGED
@@ -35,7 +35,28 @@ This is the model card of a 🤗 transformers model that has been pushed on the
|
|
35 |
|
36 |
## Uses
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
### Direct Use
|
41 |
|
|
|
35 |
|
36 |
## Uses
|
37 |
|
38 |
+
Example from: [peiyi9979/math-shepherd-mistral-7b-prm](https://huggingface.co/peiyi9979/math-shepherd-mistral-7b-prm):
|
39 |
+
|
40 |
+
```python
|
41 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
42 |
+
import torch
|
43 |
+
|
44 |
+
model_name = "plaguss/mistal-7b-prm-openrlhf"
|
45 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
46 |
+
model = AutoTokenizer.from_pretrained(model_name)
|
47 |
+
|
48 |
+
for output in [output1, output2]:
|
49 |
+
input_for_prm = f"{question} {output}"
|
50 |
+
input_id = torch.tensor([tokenizer.encode(input_for_prm)])
|
51 |
+
with torch.no_grad():
|
52 |
+
logits = model(input_id).logits[:,:,candidate_tokens]
|
53 |
+
scores = logits.softmax(dim=-1)[:,:,0]
|
54 |
+
step_scores = scores[input_id == step_tag_id]
|
55 |
+
print(step_scores)
|
56 |
+
|
57 |
+
# tensor([0.9982, 0.9780, 0.9969, 0.9983])
|
58 |
+
# tensor([0.9982, 0.9780, 0.9969, 0.0441])
|
59 |
+
```
|
60 |
|
61 |
### Direct Use
|
62 |
|