Model Card for Mistral-7B-v0.1-Math-Shepherd-PRM-0.2

This model is a fine-tuned version of mistralai/Mistral-7B-v0.1 on the trl-lib/math_shepherd dataset. It has been trained using TRL.

Quick start

Example 1)

from datasets import load_dataset
from transformers import pipeline
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"

model_name = "plaguss/Mistral-7B-v0.1-Math-Shepherd-PRM-0.2"

pipe = pipeline("token-classification", model=model_name, device="cuda")
dataset = load_dataset("trl-lib/math_shepherd")
example = dataset["test"][10]

sep = "\n"

print(sep.join((example["prompt"], *example["completions"])))
for idx in range(1, len(example["completions"])+1):
    text = sep.join((example["prompt"], *example["completions"][0:idx])) + sep
    output = pipe(text)
    score = float(output[-1]["score"])
    pred = True if output[-1]["entity"] == "LABEL_1" else False
    print(f"Step {idx}\tPredicted (score): {pred} ({score:.2f})\tLabel: {example['labels'][idx-1]}")

# 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?
# Step 1: Let $b$ be the number of raisins Bryce received and $c$ be the number of raisins Carter received.
# Step 2: We are given that $b = c + 6$ and $c = \frac{1}{2}b$.
# Step 3: Substituting the second equation into the first equation, we get $b = c + 6 = \frac{1}{2}b + 6$.
# Step 4: Simplifying, we have $b = \frac{1}{2}b + 6$.
# Step 5: Subtracting $\frac{1}{2}b$ from both sides, we get $\frac{1}{2}b - b = 6$.
# Step 6: Simplifying further, we have $\frac{1}{2}b - 2b = 6$.
# Step 7: Combining like terms, we have $-\frac{1}{2}b = 6$.
# Step 8: Multiplying both sides by $-2$, we get $b = -12$.
# Step 9: Therefore, Bryce received $\boxed{-12}$ raisins.The answer is: -12
# Step 1  Predicted (score): True (0.99)  Label: True
# Step 2  Predicted (score): True (0.94)  Label: True
# Step 3  Predicted (score): True (0.94)  Label: True
# Step 4  Predicted (score): True (0.82)  Label: True
# Step 5  Predicted (score): True (0.50)  Label: True
# Step 6  Predicted (score): False (0.71) Label: False
# Step 7  Predicted (score): False (0.73) Label: False
# Step 8  Predicted (score): False (0.77) Label: False
# Step 9  Predicted (score): False (0.97) Label: False

Example 2)

from datasets import load_dataset
from transformers import pipeline
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"

model_name = "plaguss/Mistral-7B-v0.1-Math-Shepherd-PRM-0.2"

pipe = pipeline("token-classification", model=model_name, device="cuda")
dataset = load_dataset("trl-lib/math_shepherd")
i = 32 # 10, 32
example = dataset["test"][i]

sep = "\n"

print(sep.join((example["prompt"], *example["completions"])))
for idx in range(1, len(example["completions"])+1):
    text = sep.join((example["prompt"], *example["completions"][0:idx])) + sep
    output = pipe(text)
    score = float(output[-1]["score"])
    pred = True if output[-1]["entity"] == "LABEL_1" else False
    print(f"Step {idx}\tPredicted (score): {pred} ({score:.2f})\tLabel: {example['labels'][idx-1]}")


# 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?
# Step 1: Draymond earned 12 points, Curry earned twice the points as Draymond, which is 2*12 = 24 points.
# Step 2: Kelly earned 9 points, Durant earned twice the points as Kelly, which is 2*9 = 18 points.
# Step 3: Klay earned half the points as Draymond, which is 12/2 = <<12/2=6>>6 points.
# Step 4: The Golden State Team had 12+24+9+18+6 = <<12+24+9+18+6=51>>51 points. The answer is: 51
# Step 1  Predicted (score): True (1.00)  Label: True
# Step 2  Predicted (score): True (1.00)  Label: True
# Step 3  Predicted (score): True (1.00)  Label: True
# Step 4  Predicted (score): False (0.99) Label: False

Example 3)

This example corresponds to the one shown in the peiyi9979/math-shepherd-mistral-7b-prm:

from datasets import load_dataset
from transformers import pipeline
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"

model_name = "plaguss/Mistral-7B-v0.1-Math-Shepherd-PRM-0.2"

pipe = pipeline("token-classification", model=model_name, device="cuda")

examples = [
    {
        "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?",
        "completions": [
            "Step 1: Janet's ducks lay 16 eggs per day.",
            'Step 2: She eats three for breakfast every morning, so she has 16 - 3 = 13 eggs left.',
            'Step 3: She bakes muffins for her friends every day with four eggs, so she has 13 - 4 = 9 eggs left.',
            "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"
        ],
        "labels": [True, True, True, True]
    },
    {
        "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?",
        "completions": [
            "Step 1: Janet's ducks lay 16 eggs per day.",
            'Step 2: She eats three for breakfast every morning, so she has 16 - 3 = 13 eggs left.',
            'Step 3: She bakes muffins for her friends every day with four eggs, so she has 13 - 4 = 9 eggs left.',
            "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"
        ],
        "labels": [True, True, True, False]
    },
    
]


sep = "\n"

for i, example in enumerate(examples):
    print(f"- Example {i}:")
    for idx in range(1, len(example["completions"])+1):
        text = "\n".join((example["prompt"], *example["completions"][0:idx])) + "\n"
        output = pipe(text)
        score = float(output[-1]["score"])
        pred = True if output[-1]["entity"] == "LABEL_1" else False
        print(f"Step {idx}\tPredicted (score): {pred} ({score:.2f})\tLabel: {example['labels'][idx-1]}")

# - Example 0:
# Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.
# Step 1  Predicted (score): True (0.98)  Label: True
# Step 2  Predicted (score): True (0.87)  Label: True
# Step 3  Predicted (score): True (0.93)  Label: True
# Step 4  Predicted (score): True (0.98)  Label: True
# - Example 1:
# Step 1  Predicted (score): True (0.98)  Label: True
# Step 2  Predicted (score): True (0.87)  Label: True
# Step 3  Predicted (score): True (0.93)  Label: True
# Step 4  Predicted (score): False (0.99) Label: False

Training procedure

Visualize in Weights & Biases

This model was trained with Stepwise Reward.

Framework versions

  • TRL: 0.13.0.dev0
  • Transformers: 4.47.0
  • Pytorch: 2.4.1
  • Datasets: 3.0.1
  • Tokenizers: 0.21.0

Citations

Cite Stepwise Reward as:

@article{uesato2022solving,
    title        = {Solving Math Word Problems With Process- and Outcome-Based Feedback},
    author       = {Uesato, Jonathan and Kushman, Nate and Kumar, Ramana and Song, Francis and Siegel, Noah and Wang, Lisa and Creswell, Antonia and Irving, Geoffrey and Higgins, Irina},
    year         = 2022,
    journal      = {arXiv preprint arXiv:2211.14275}
}

Cite TRL as:

@misc{vonwerra2022trl,
    title        = {{TRL: Transformer Reinforcement Learning}},
    author       = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallouédec},
    year         = 2020,
    journal      = {GitHub repository},
    publisher    = {GitHub},
    howpublished = {\url{https://github.com/huggingface/trl}}
}
Downloads last month
24
Safetensors
Model size
7.11B params
Tensor type
BF16
·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Model tree for plaguss/Mistral-7B-v0.1-Math-Shepherd-PRM-0.2

Finetuned
(802)
this model

Dataset used to train plaguss/Mistral-7B-v0.1-Math-Shepherd-PRM-0.2