Instructions to use jnanliu/LiveMath-Judge with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jnanliu/LiveMath-Judge with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jnanliu/LiveMath-Judge") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("jnanliu/LiveMath-Judge") model = AutoModel.from_pretrained("jnanliu/LiveMath-Judge", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jnanliu/LiveMath-Judge with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jnanliu/LiveMath-Judge" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jnanliu/LiveMath-Judge", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/jnanliu/LiveMath-Judge
- SGLang
How to use jnanliu/LiveMath-Judge with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "jnanliu/LiveMath-Judge" \ --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": "jnanliu/LiveMath-Judge", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "jnanliu/LiveMath-Judge" \ --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": "jnanliu/LiveMath-Judge", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use jnanliu/LiveMath-Judge with Docker Model Runner:
docker model run hf.co/jnanliu/LiveMath-Judge
LiveMath-Judge
Introduction
LiveMath-Judge is a mathematical judge model for evaluating the consistency of the model-generated answer and the golden answer.
Given the question, golden answer, and model-generated answer as input, LiveMath-Judge will output yes for the equivalent answer, and no for the inequal answer.
To train LiveMath-Judge, we collect about 2.8 million data in LiveMathBench judged by Qwen2.5-72B-Instruct, and finetune Qwen2.5-3B-Instruct for one epoch with learning-rate of 5e-6.
Use
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
# load the model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
'jnanliu/LiveMath-Judge',
device_map='auto',
torch_dtype=torch.bfloat16,
)
tokenizer = AutoTokenizer.from_pretrained(
'jnanliu/LiveMath-Judge',
trust_remote_code=True
)
question = 'In $\\triangle ABC$, given $\\cos C = \\frac{\\sin A + \\cos A}{2} = \\frac{\\sin B + \\cos B}{2}$, find the value of $\\sin C$.'
golden_answer = '$\\frac{3}{4}$'
generated_answer = '\\frac{3}{4}'
prompt = '''Please act as an expert in grading mathematics exam papers, and judge whether the following answers match the standard answers, i.e., whether the examinee answered correctly. Here are some evaluation criteria:
1. Some answers may contain multiple parts, such as single-choice questions, multiple-choice questions, fill-in-the-blank questions, and problem-solving questions. As long as the answer matches the standard answer, it is considered correct. For multiple-choice questions and fill-in-the-blank questions with multiple blanks, the examinee must answer all corresponding options or blanks correctly to be considered correct.
2. Some answers may be expressed in different ways; for example, some answers may be mathematical expressions, while others may be textual descriptions. As long as the meaning conveyed is consistent, it is considered correct. Additionally, some formulas may be expressed differently but are equivalent, which is also considered correct.
3. You do not need to recalculate the problem answers, as the standard answers are already provided. You only need to judge whether the examinee's answer matches the standard answer based on the form of the question and whether it is correct.
Please judge whether the following answer matches the standard answer according to the above criteria. If they match, output \\boxed{{yes}}, otherwise output \\boxed{{no}}. If it is difficult to judge, also output \\boxed{{no}}.
Original Question: {question}
Standard Answer: {gold_answer}
Examinee's Answer: {answer}
Analysis:
'''
# prompt for chinese questions
# prompt = '''่ฏทไฝ ไฝไธบไธไธชๆฐๅญฆ้
ๅทไธๅฎถ๏ผๅคๆญไธ้ข็็ญๆกๆฏๅฆไธๆ ๅ็ญๆกไธ่ด๏ผๅณ่็ๆฏๅฆๅ็ญๆญฃ็กฎใไธ้ขๆฏไธไบ่ฏๅคๆ ๅ๏ผ
# 1. ๆไบ็ญๆกๅฏ่ฝๅ
ๅซๅค้กนๅ
ๅฎน๏ผๅฏ่ฝๆๅ้้ข๏ผๅค้้ข๏ผๅกซ็ฉบ้ขๅ้ฎ็ญ้ข๏ผๅช่ฆ็ญๆกไธๆ ๅ็ญๆกไธ่ดๅณๅฏ, ๅฏนไบๅค้้ขๅๅคไธช็ฉบ็ๅกซ็ฉบ้ข๏ผ้่ฆ่็ๅฏนๅบ็้้กนๆ็ฉบ้ฝๅ็ญๆญฃ็กฎๆ็ฎๆญฃ็กฎใ
# 2. ๆไบ็ญๆกๅฏ่ฝ้่ฟไธๅ็ๆนๅผ่กจ่พพ๏ผๆฏๅฆๆไบ็ญๆกๅฏ่ฝๆฏไธไธชๆฐๅญฆ่กจ่พพๅผ๏ผๆไบ็ญๆกๅฏ่ฝๆฏไธไธชๆๅญๆ่ฟฐ๏ผๅช่ฆ่กจ่พพ็ๆๆไธ่ดๅณๅฏใไธๆไบๅ
ฌๅผ้่ฟไธๅ็ๆนๅผ่กจ่พพ๏ผไฝ็ญไปท๏ผไนๆฏๆญฃ็กฎ็ใ
# 3. ไฝ ไธ้่ฆ้ๆฐ่ฎก็ฎ้ฎ้ข็ญๆก๏ผๅ ไธบๆ ๅ็ญๆกๅทฒ็ป็ปๅบ๏ผๅช้่ฆๆ นๆฎ้ฎ้ขๅฝขๅผๆฅๅคๆญ่็็็ญๆกๆฏๅฆไธๆ ๅ็ญๆกไธ่ด๏ผๆฏๅฆๆญฃ็กฎๅณๅฏใ
# ่ฏทไฝ ๆ นๆฎไธ่ฟฐๆ ๅ๏ผๅคๆญไธ้ข็็ญๆกๆฏๅฆไธๆ ๅ็ญๆกไธ่ด๏ผๅฆๆไธ่ด๏ผ่ฏทๅจๆๅ่พๅบ\\boxed{{yes}}, ๅฆๅ่พๅบ\\boxed{{no}}, ๅฆๆ้พไปฅๅคๆญ๏ผ่ฏท่พๅบ\\boxed{{no}}.
# ๅ้ฎ้ข๏ผ{question}
# ๆ ๅ็ญๆก๏ผ{gold_answer}
# ่็็ญๆก๏ผ{answer}
# ๅๆ๏ผ
# '''
conversations = [
{'role': 'user', 'content': prompt.format(question=question, gold_answer=golden_answer, answer=generated_answer)}
]
inputs = tokenizer.apply_chat_template(conversations, return_tensors='pt')
# do inference
pred = model.generate(
input_ids=inputs['input_ids'].to(model.device),
attention_mask=inputs['attention_mask'].to(model.device),
num_return_sequences=1,
)[0].cpu().tolist()
response = tokenizer.decode(pred, skip_special_tokens=True)
# \\boxed{yes}
Performance
Following is the mG-Pass@16 results of Qwen2.5-72B-Instruct-as-Judge and LiveMath-Judge-as-Judge of 10 models.
| model | Qwen2.5-72B-Instruct | LiveMath-Judge |
|---|---|---|
| Qwen2.5-7B-Instruct | 26.45 | 28.17 |
| Qwen2.5-Math-7B-Instruct | 37.91 | 39.54 |
| Llama-3.1-8B-Instruct | 10.43 | 9.29 |
| Llama-3.1-70B-Instruct | 21.37 | 22.12 |
| Llama-3.3-70B-Instruct | 27.36 | 30.47 |
| Mistral-Large-Instruct-2411 | 36.66 | 36.67 |
| Qwen2.5-32B-Instruct | 39.09 | 37.84 |
| Qwen2.5-72B-Instruct | 38.52 | 37.57 |
| deepseek-math-7b-rl | 14.01 | 14.13 |
| Qwen2.5-Math-72B-Instruct | 43.80 | 42.10 |
Related Citation
@article{liu2024your,
title={Are Your LLMs Capable of Stable Reasoning?},
author={Liu, Junnan and Liu, Hongwei and Xiao, Linchen and Wang, Ziyi and Liu, Kuikun and Gao, Songyang and Zhang, Wenwei and Zhang, Songyang and Chen, Kai},
journal={arXiv preprint arXiv:2412.13147},
year={2024}
}
- Downloads last month
- 621