VersaPRM
Collection
Collection of VersaPRMs using various training configurations • 8 items • Updated • 1
How to use UW-Madison-Lee-Lab/Qwen-PRM800K with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="UW-Madison-Lee-Lab/Qwen-PRM800K")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("UW-Madison-Lee-Lab/Qwen-PRM800K")
model = AutoModelForCausalLM.from_pretrained("UW-Madison-Lee-Lab/Qwen-PRM800K")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use UW-Madison-Lee-Lab/Qwen-PRM800K with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "UW-Madison-Lee-Lab/Qwen-PRM800K"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "UW-Madison-Lee-Lab/Qwen-PRM800K",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/UW-Madison-Lee-Lab/Qwen-PRM800K
How to use UW-Madison-Lee-Lab/Qwen-PRM800K with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "UW-Madison-Lee-Lab/Qwen-PRM800K" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "UW-Madison-Lee-Lab/Qwen-PRM800K",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "UW-Madison-Lee-Lab/Qwen-PRM800K" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "UW-Madison-Lee-Lab/Qwen-PRM800K",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use UW-Madison-Lee-Lab/Qwen-PRM800K with Docker Model Runner:
docker model run hf.co/UW-Madison-Lee-Lab/Qwen-PRM800K
This model is a fine-tuned version of Qwen/Qwen2.5-Math-7B-Instruct on on PRM800K.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
def get_tokenizer(model_id):
tokenizer = AutoTokenizer.from_pretrained(model_id)
tokenizer.pad_token = tokenizer.eos_token
tokenizer.padding_side = 'left'
tokenizer.truncation_side = 'left'
return tokenizer
device = 'cuda' if torch.cuda.is_available() else 'cpu'
tokenizer = get_tokenizer('UW-Madison-Lee-Lab/Qwen-PRM800K')
model = AutoModelForCausalLM.from_pretrained('UW-Madison-Lee-Lab/Qwen-PRM800K')
candidate_tokens = [12, 10]
model.to(device)
question = 'Question: In Python 3, which of the following function convert a string to an int in python?\nA. short(x)\nB. float(x)\nC. integer(x [,base])\nD. double(x)\nE. int(x [,base])\nF. long(x [,base] )\nG. num(x)\nH. str(x)\nI. char(x)\nJ. digit(x [,base])'
solution = ["To convert a string to an integer in Python 3, we use the built-in function int().",
"The int() function takes two arguments: the string to be converted and an optional base (default is 10, which is for decimal).",
"For example: int(\"123\", 10) converts the string \"123\" to the integer 123.",
"Looking at the options, we can see that the correct function is option E: int(x [,base]).",
"The answer is (E)."]
input_text = question + ' \n\n' + ' \n\n\n\n'.join(solution) + ' \n\n\n\n' # solution steps are separated by ' \n\n\n\n'
input_id = torch.tensor([tokenizer.encode(input_text)]).to(device)
with torch.no_grad():
logits = model(input_id).logits[:,:,candidate_tokens]
scores = logits.softmax(dim=-1)[:,:,1]
step_scores = scores[input_id == 23535]
step_probs = step_scores.tolist()