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
Safetensors
Model size
3B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for jnanliu/LiveMath-Judge

Base model

Qwen/Qwen2.5-3B
Finetuned
(1,666)
this model

Paper for jnanliu/LiveMath-Judge