Reproduction help: Discrepancy in GSM8K reproduction – 40.63 % vs. 73.4 %
Following the evaluation protocol and hyper-parameters described in #36, I obtain 40.63 % accuracy (536 / 1319) on the GSM8K test set with Gen-Verse/MMaDA-8B-MixCoT, which is significantly lower than the score reported in Table 4(73.4 %).
Here is my evaluation code.
device = 'cuda'
model = MMadaModelLM.from_pretrained("Gen-Verse/MMaDA-8B-MixCoT", trust_remote_code=True, torch_dtype=torch.bfloat16).to(device).eval()
tokenizer = AutoTokenizer.from_pretrained("Gen-Verse/MMaDA-8B-MixCoT", trust_remote_code=True)
tokenizer.chat_template = "{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n'+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{{ '<|start_header_id|>assistant<|end_header_id|>\n' }}"
ds = load_dataset("openai/gsm8k", "main")['test']
ds = list(ds)
random.shuffle(ds)
for i in tqdm(range(len(ds))):
question = ds[i]['question']
answer = ds[i]['answer']
think_prompt = "You should first think about the reasoning process in the mind and then provide the user with the answer. The reasoning process is enclosed within <think> </think> tags, i.e. <think> reasoning process here </think> answer here\n"
prompt = think_prompt + question
m = [{"role": "user", "content": prompt}, ]
prompt = tokenizer.apply_chat_template(m, add_generation_prompt=True, tokenize=False)
input_ids = tokenizer(text=prompt, return_tensors="pt", padding=True, padding_side="left")['input_ids']
input_ids = torch.tensor(input_ids).to(device)
out = generate(model, input_ids, steps=512, gen_length=512, block_length=64, temperature=1, cfg_scale=0., remasking='low_confidence')
output_text = tokenizer.batch_decode(out[:, input_ids.shape[1]:], skip_special_tokens=True)
output_dict = {
"question": question,
"answer": answer,
"output": output_text,
}
with open(f"gsm8k-output.jsonl", "a") as f:
f.write(json.dumps(output_dict) + "\n")
Follow the instruction in #36, I use math_verify package to verify the results.
def gsm8k_verify(question, answer, output):
parsed_answer = parse(answer.split("####")[-1])
parsed_output = parse(output.split("</think>")[-1])
return verify(parsed_answer, parsed_output)
with open(test_file, 'r') as f:
for line in f:
data = json.loads(line)
question = data['question']
answer = data['answer']
output = data['output']
is_correct = gsm8k_verify(question, answer, output[0])
if is_correct:
correct += 1
all_count += 1
Could you please confirm whether there are any additional settings (e.g., prompt variants, generation length, random seed) that might explain the gap? Any pointers would be greatly appreciated. Thanks in advance!
Hi, thanks for your attention. Please note that the released model corresponds to our stage-2 checkpoint, rather than the final version reported in the paper.
While we use similar evaluation scripts, our results are based on manual parsing instead of the math_verify tool. The 0-shot accuracy (comparable to what you reported) is around 49%, and the 5-shot accuracy (commonly used by LLaDA and other language models) reaches approximately 63%. Hope that helps!
Oh I see. Thanks!
Hi, Following up on this, should we expect the released MMaDA-8B-MixCoT model to achieve performance close to the multimodal benchmark scores reported in Table 2 (like POPE and MME), or are those results also based on the final model? I was able to reproduce MMMU with the checkpoint but have some difficulty with POPE and MME.
Thanks!
Sorry for interrupting again, I'd like to know more about the 5-shot setting. I modeled the 5-shot prompt as llada's code, but the experiment results still doesn't work well(Around 35%). Here is my prompt. Can you help me find out what's wrong?
messages = [
{"role": "user", "content": "Here are some examples of mathematical reasoning problems and their solutions. Please learn from them to solve the following problem."},
]
for j in in_context_sample_idx:
question = ds[j]['question']
answer = ds[j]['answer']
# import ipdb; ipdb.set_trace()
thinking_process, result = answer.split("####")[0].strip(), answer.split("####")[1]
messages.append({"role": "user", "content": question})
messages.append({"role": "assistant", "content": f"<think> {thinking_process}</think>\n####{result}"})
question = ds[i]['question']
answer = ds[i]['answer']
messages.append({"role": "user", "content": question})
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
Hi, thanks for your attention. Please note that the released model corresponds to our stage-2 checkpoint, rather than the final version reported in the paper.
While we use similar evaluation scripts, our results are based on manual parsing instead of the
math_verifytool. The 0-shot accuracy (comparable to what you reported) is around 49%, and the 5-shot accuracy (commonly used by LLaDA and other language models) reaches approximately 63%. Hope that helps!
Thank you for your reply. I would like to ask two follow-up questions:
-
In the 5-shot setting, are the questions and answers in the provided examples also augmented with the thinking mode, or is the thinking mode added only to the final question to be predicted?
-
I am using evaluation code similar to lm-eval in LLaDA for testing. I noticed that LLaDA sets num_shot to 4 for the GSM8K task. Did you adopt the same setting in your experiments?
@yzchen02 1. Correct 2. We adopt a 5-shot setting, though 4-shot should yield comparable results. @zrporz @siyan-zhao Regarding the evaluation, since our model handles a wide range of tasks with varying configurations, and considering the current intense workload, I plan to release a unified reproducible evaluation code after this busy period. It will include the full benchmark processing logic and is scheduled to be released before August 15.
@yzchen02 1. Correct 2. We adopt a 5-shot setting, though 4-shot should yield comparable results. @zrporz @siyan-zhao Regarding the evaluation, since our model handles a wide range of tasks with varying configurations, and considering the current intense workload, I plan to release a unified reproducible evaluation code after this busy period. It will include the full benchmark processing logic and is scheduled to be released before August 15.
Hi @tyfeld, I followed this code to run evaluation on GSM8k(using Gen-Verse/MMaDA-8B-MixCoT), and the result was like
"results": {
"gsm8k": {
"alias": "gsm8k",
"exact_match,strict-match": 0.5094768764215315,
"exact_match_stderr,strict-match": 0.01377001065116882,
"exact_match,flexible-extract": 0.5451099317664898,
"exact_match_stderr,flexible-extract": 0.013716318771794602
}
the config I used was:
"configs": {
"gsm8k": {
"task": "gsm8k",
"tag": [
"math_word_problems"
],
"dataset_path": "gsm8k",
"dataset_name": "main",
"training_split": "train",
"test_split": "test",
"fewshot_split": "train",
"doc_to_text": "Question: {{question}}\nAnswer:",
"doc_to_target": "{{answer}}",
"unsafe_code": false,
"description": "",
"target_delimiter": " ",
"fewshot_delimiter": "\n\n",
"num_fewshot": 5,
"metric_list": [
{
"metric": "exact_match",
"aggregation": "mean",
"higher_is_better": true,
"ignore_case": true,
"ignore_punctuation": false,
"regexes_to_ignore": [
",",
"\\$",
"(?s).*#### ",
"\\.$"
]
}
],
"output_type": "generate_until",
"generation_kwargs": {
"until": [
"Question:",
"</s>",
"<|im_end|>"
],
"do_sample": false,
"temperature": 0.0
},
"repeats": 1,
"filter_list": [
{
"name": "strict-match",
"filter": [
{
"function": "regex",
"regex_pattern": "#### (\\-?[0-9\\.\\,]+)"
},
{
"function": "take_first"
}
]
},
{
"name": "flexible-extract",
"filter": [
{
"function": "regex",
"group_select": -1,
"regex_pattern": "(-?[$0-9.,]{2,})|(-?[0-9]+)"
},
{
"function": "take_first"
}
]
}
],
"should_decontaminate": false,
"metadata": {
"version": 3.0,
"model_path": "MMaDA/MMaDA-8B-MixCoT",
"gen_length": 256,
"steps": 256,
"block_length": 64,
"show_speed": true
}
}
},
"versions": {
"gsm8k": 3.0
},
"n-shot": {
"gsm8k": 5
},
"higher_is_better": {
"gsm8k": {
"exact_match": true
}
},
"n-samples": {
"gsm8k": {
"original": 1319,
"effective": 1319
}
},
Did I do something wrong here? Because I saw in your previous comment that the 5-shot accuracy of "2nd stage model(if I understood correctly, it corresponds to MMaDA-8B-MixCoT)" reaches approximately 63%...?
Thank you in advance for your help!