Views
No views yet
{question} + "\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."{question} + "\n\nPresent the answer in LaTex format: \\boxed{Your answer}"1import os
2from tqdm import tqdm
3import torch
4from transformers import AutoTokenizer
5from vllm import LLM, SamplingParams
6os.environ["NCCL_IGNORE_DISABLED_P2P"] = "1"
7os.environ["TOKENIZERS_PARALLELISM"] = "true"
8def generate(question_list,model_path):
9 llm = LLM(
10 model=model_path,
11 trust_remote_code=True,
12 tensor_parallel_size=torch.cuda.device_count(),
13 gpu_memory_utilization=0.90,
14 )
15 sampling_params = SamplingParams(max_tokens=8192,
16 temperature=0.0,
17 n=1)
18 outputs = llm.generate(question_list, sampling_params, use_tqdm=True)
19 completions = [[output.text for output in output_item.outputs] for output_item in outputs]
20 return completions
21def make_conv_hf(question, tokenizer):
22 # for math problem
23 content = question + "\n\nPresent the answer in LaTex format: \\boxed{Your answer}"
24 # for code problem
25 # content = question + "\n\nWrite Python code to solve the problem. Present the code in \n```python\nYour code\n```\nat the end."
26 msg = [
27 {"role": "user", "content": content}
28 ]
29 chat = tokenizer.apply_chat_template(msg, tokenize=False, add_generation_prompt=True)
30 return chat
31
32def run():
33 model_path = "PRIME-RL/Eurus-2-7B-SFT"
34 all_problems = [
35 "which number is larger? 9.11 or 9.9?"
36 ]
37 tokenizer = AutoTokenizer.from_pretrained(model_path)
38 completions = generate([make_conv_hf(problem_data, tokenizer) for problem_data in all_problems],model_path)
39 print(completions)
40 # [['[ASSESS]\n\n# The task is to compare two decimal numbers, 9.11 and 9.9, to determine which one is larger.\n# The numbers are in a standard decimal format, making direct comparison possible.\n# No additional information or context is provided that could affect the comparison.\n\nNext action: [ADVANCE]\n\n[ADVANCE]\n\n# To compare the two numbers, I will examine their whole and decimal parts separately.\n# The whole part of both numbers is 9, so I will focus on the decimal parts.\n# The decimal part of 9.11 is 0.11, and the decimal part of 9.9 is 0.9.\n# Since 0.9 is greater than 0.11, I can conclude that 9.9 is larger than 9.11.\n\nNext action: [VERIFY]\n\n[VERIFY]\n\n# I will review my comparison of the decimal parts to ensure accuracy.\n# Upon re-examination, I confirm that 0.9 is indeed greater than 0.11.\n# I also consider the possibility of a mistake in my initial assessment, but the comparison seems straightforward.\n# I evaluate my process and conclude that it is sound, as I correctly identified the whole and decimal parts of the numbers and compared them accurately.\n# No potential errors or inconsistencies are found in my reasoning.\n\nNext action: [OUTPUT]\n\n[OUTPUT]\n\nTo determine which number is larger, 9.11 or 9.9, I compared their whole and decimal parts. Since the whole parts are equal, I focused on the decimal parts, finding that 0.9 is greater than 0.11. After verifying my comparison, I concluded that 9.9 is indeed larger than 9.11.\n\n\\boxed{9.9}\n\n']]
41if __name__ == "__main__":
42 run()
1@article{cui2025process,
2 title={Process reinforcement through implicit rewards},
3 author={Cui, Ganqu and Yuan, Lifan and Wang, Zefan and Wang, Hanbin and Li, Wendi and He, Bingxiang and Fan, Yuchen and Yu, Tianyu and Xu, Qixin and Chen, Weize and others},
4 journal={arXiv preprint arXiv:2502.01456},
5 year={2025}
6}1@article{yuan2024implicitprm,
2 title={Free Process Rewards without Process Labels},
3 author={Lifan Yuan and Wendi Li and Huayu Chen and Ganqu Cui and Ning Ding and Kaiyan Zhang and Bowen Zhou and Zhiyuan Liu and Hao Peng},
4 journal={arXiv preprint arXiv:2412.01981},
5 year={2024}
6}