from transformers import AutoModelForCausalLM, AutoTokenizerfrom vllm import LLM, SamplingParams model_id = "launch/ThinkPRM-14B" # Replace with actual model ID on Hubtokenizer = AutoTokenizer.from_pretrained(model_id)llm = LLM(model=model_id, max_model_len=16384) # Example problem and solutionproblem = "Solve for x: 2x + 3 = 7"prefix = "Step 1: Subtract 3 from both sides: 2x = 4Step 2: Divide by 2: x = 1" # Format the promptprompt = f"""You are given a math problem and a proposed step-by-step solution: [Math Problem] {problem} [Solution] {prefix} Review and critique each step in the proposed solution to determine whether each step is correct. If the solution is incomplete, only verify the provided steps""" prompt = tokenizer.apply_chat_template([ {'role': "user", "content": prompt}], tokenize=False, add_generation_prompt=True) + "Let's verify step by step:" # Set sampling parameterssampling_params = SamplingParams( temperature=0.0, max_tokens=4096, stop=None) # Generate the verificationoutputs = llm.generate(prompt, sampling_params)verification_cot = outputs[0].outputs[0].text print(verification_cot)"""Step 1: Subtract 3 from both sides: 2x = 4 Critique: Starting with the equation 2x + 3 = 7, subtracting 3 from both sides is a correct operation to isolate the term with the variable. So, 2x + 3 - 3 = 7 - 3, which simplifies to 2x = 4. This step seems correct. Step 2: Divide by 2: x = 1 Critique: Now, to solve for x, we need to divide both sides of the equation by 2. So, 2x / 2 = 4 / 2, which simplifies to x = 2. Wait a minute, the solution says x = 1, but according to this calculation, it should be x = 2. This seems incorrect. Therefore, the first step is correct, but the second step has an error. **Final Output:** Let's verify step by step: Step 1: Subtract 3 from both sides: 2x = 4 Critique: This step is correct. Subtracting 3 from both sides of the equation 2x + 3 = 7 properly isolates the term with the variable, resulting in 2x = 4. Step 1 is \boxed{correct} Step 2: Divide by 2: x = 1 Critique: This step is incorrect. Dividing both sides of the equation 2x = 4 by 2 should yield x = 2, not x = 1. Step 2 is \boxed{incorrect}</think>Is the solution correct? No"""