1import json
2import datasets
3import torch
4import random
5import numpy as np
6from transformers import AutoTokenizer, AutoModelForCausalLM
78910tokenizer = AutoTokenizer.from_pretrained("SimpleBerry/LLaMA-O1-Supervised-1129")
11model = AutoModelForCausalLM.from_pretrained("SimpleBerry/LLaMA-O1-Supervised-1129",device_map='auto')
12131415template = "<start_of_father_id>-1<end_of_father_id><start_of_local_id>0<end_of_local_id><start_of_thought><problem>{content}<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>0<end_of_father_id><start_of_local_id>1<end_of_local_id><start_of_thought><expansion>"
1617def llama_o1_template(query):
18 text = template.format(content=query)
19 return text
202122def batch_predict(input_texts):
23 input_texts = [input_text.replace('<|end_of_text|>','') for input_text in input_texts]
24 inputs = tokenizer(input_texts, return_tensors="pt").to(model.device)
25 responses = model.generate(**inputs, max_new_tokens=1024)
26 response_texts = tokenizer.batch_decode(responses, skip_special_tokens=False)
27 # assitant_responses = [item[len(input_texts[i]):] for i,item in enumerate(response_texts)]
28 assitant_responses = [item for i,item in enumerate(response_texts)]
29 return assitant_responses
3031def format_response(response):
32 response = response.replace('<start_of_father_id>','')
33 response = response.replace('<end_of_father_id><start_of_local_id>','👉')
34 response = response.replace('<end_of_local_id><start_of_thought>',', ')
35 response = response.replace('<end_of_thought><start_of_rating>','')
36 response = response.replace('<end_of_rating>','')
37 response = response.replace('<positive_rating>','👍')
38 response = response.replace('<negative_rating>','👎')
39 return response
4041i = 'If Diana needs to bike 10 miles to reach home and she can bike at a speed of 3 mph for two hours before getting tired, and then at a speed of 1 mph until she reaches home, how long will it take her to get home?'
42input_texts = [llama_o1_template(i)]
43assitant_responses = batch_predict(input_texts)
44# assitant_responses = [format_response(response) for response in assitant_responses]
45print(assitant_responses)
46
If Diana needs to bike 10 miles to reach home and she can bike at a speed of 3 mph for two hours before getting tired, and then at a speed of 1 mph until she reaches home, how long will it take her to get home?
Output
python
1<|begin_of_text|><start_of_father_id>-1<end_of_father_id><start_of_local_id>0<end_of_local_id><start_of_thought><problem>If Diana needs to bike 10 miles to reach home and she can bike at a speed of 3 mph for two hours before getting tired,and then at a speed of 1 mph until she reaches home, how long will it take her to get home?<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>0<end_of_father_id><start_of_local_id>1<end_of_local_id><start_of_thought><expansion>Let's start by understanding the problem. Diana needs to bike a total of 10 miles, and we know her biking speeds at different stages. We will break down the problem into smaller parts: first, calculate the distance she can cover at her initial speed, then calculate the time taken at her slower speed to reach home.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>1<end_of_father_id><start_of_local_id>2<end_of_local_id><start_of_thought><sub_problem>First, we need to determine how far Diana can bike at her initial speed of 3 mph for 2 hours. This will help us understand how much distance she has covered before getting tired.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>2<end_of_father_id><start_of_local_id>3<end_of_local_id><start_of_thought><expansion>To find the distance covered at 3 mph for 2 hours, we use the formula: Distance = Speed × Time. Therefore, Distance = 3 mph × 2 hours = 6 miles.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>2<end_of_father_id><start_of_local_id>4<end_of_local_id><start_of_thought><sub_conclusion>Diana can cover 6 miles in the first 2 hours.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>1<end_of_father_id><start_of_local_id>5<end_of_local_id><start_of_thought><sub_problem>Now we need to determine how far Diana has left to bike after the first 2 hours. This will help us calculate the remaining time she needs to cover the remaining distance.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>5<end_of_father_id><start_of_local_id>6<end_of_local_id><start_of_thought><expansion>Diana has 10 miles total and has already biked 6 miles. Thus, the remaining distance is: 10 miles - 6 miles = 4 miles.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>5<end_of_father_id><start_of_local_id>7<end_of_local_id><start_of_thought><sub_conclusion>Diana has 4 miles left to bike.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>1<end_of_father_id><start_of_local_id>8<end_of_local_id><start_of_thought><sub_problem>Next, we need to calculate how long it will take Diana to bike the remaining 4 miles at her slower speed of 1 mph.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>8<end_of_father_id><start_of_local_id>9<end_of_local_id><start_of_thought><expansion>To find the time taken to cover the remaining distance at 1 mph, we use the formula: Time = Distance / Speed. Therefore, Time = 4 miles / 1 mph = 4 hours.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>8<end_of_father_id><start_of_local_id>10<end_of_local_id><start_of_thought><sub_conclusion>Diana will take 4 hours to bike the remaining 4 miles at her slower speed.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>1<end_of_father_id><start_of_local_id>11<end_of_local_id><start_of_thought><expansion>Now, we combine the time taken in both stages: 2 hours (initial speed) + 4 hours (slower speed) = 6 hours.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>1<end_of_father_id><start_of_local_id>12<end_of_local_id><start_of_thought><conclusion>The total time it will take Diana to reach home is 6 hours.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>12<end_of_father_id><start_of_local_id>13<end_of_local_id><start_of_thought><critic>Let's review the calculations to ensure accuracy. The distance covered at the initial speed and the time taken at the slower speed seem correct. The final addition of the times also checks out.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>12<end_of_father_id><start_of_local_id>14<end_of_local_id><start_of_thought><refine>To enhance clarity, we can rephrase the conclusion to explicitly state the total biking time and the distance covered at each speed.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>14<end_of_father_id><start_of_local_id>15<end_of_local_id><start_of_thought><conclusion>In conclusion, Diana will take a total of 6 hours to bike 10 miles, covering 6 miles in the first 2 hours at a speed of 3 mph and the remaining 4 miles at a speed of 1 mph, which takes an additional 4 hours.<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>15<end_of_father_id><start_of_local_id>16<end_of_local_id><start_of_thought><conclusion>\\boxed{6}<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<|eot_id|>2
Golden Chain of Thought
Problem:
If Diana needs to bike 10 miles to reach home and she can bike at a speed of 3 mph for two hours before getting tired, and then at a speed of 1 mph until she reaches home, how long will it take her to get home?
Step 1: Calculate the distance covered at her initial speed.
Diana bikes at 3 mph for 2 hours.
Using the formula:
$$
\text{Distance} = \text{Speed} \times \text{Time} = 3 , \text{mph} \times 2 , \text{hours} = 6 , \text{miles}
$$
Conclusion: Diana covers 6 miles in the first 2 hours.
Step 2: Determine the remaining distance to bike.
Diana has 10 miles to cover in total.
After biking 6 miles, the remaining distance is:
$$
\text{Remaining distance} = 10 , \text{miles} - 6 , \text{miles} = 4 , \text{miles}
$$
Conclusion: Diana has 4 miles left to bike.
Step 3: Calculate the time to bike the remaining 4 miles.
Diana bikes at 1 mph for the remaining distance.
Using the formula:
$$
\text{Time} = \frac{\text{Distance}}{\text{Speed}} = \frac{4 , \text{miles}}{1 , \text{mph}} = 4 , \text{hours}
$$
Conclusion: It will take Diana 4 hours to bike the remaining 4 miles.
Step 4: Calculate the total time to bike home.
The total time is the sum of the time spent biking at both speeds:
$$
\text{Total time} = 2 , \text{hours} + 4 , \text{hours} = 6 , \text{hours}
$$
Conclusion: The total time for Diana to reach home is 6 hours.
Final Conclusion:
Diana will take 6 hours to bike 10 miles, covering 6 miles in the first 2 hours at a speed of 3 mph, and the remaining 4 miles at a speed of 1 mph, which takes an additional 4 hours.
$$
\boxed{6}
$$
Marked Language of Long Chain of Thought
xml
1<|begin_of_text|>2<start_of_father_id>-1</start_of_father_id>3<start_of_local_id>0</start_of_local_id>4<start_of_thought>5<problem>If Diana needs to bike 10 miles to reach home and she can bike at a speed of 3 mph for two hours before getting tired, and then at a speed of 1 mph until she reaches home, how long will it take her to get home?</problem>6</start_of_thought>7<start_of_rating><positive_rating></start_of_rating>89<start_of_father_id>0</start_of_father_id>10<start_of_local_id>1</start_of_local_id>11<start_of_thought>12<expansion>Let's start by understanding the problem. Diana needs to bike a total of 10 miles, and we know her biking speeds at different stages. We will break down the problem into smaller parts: first, calculate the distance she can cover at her initial speed, then calculate the time taken at her slower speed to reach home.</expansion>13</start_of_thought>14<start_of_rating><positive_rating></start_of_rating>1516<start_of_father_id>1</start_of_father_id>17<start_of_local_id>2</start_of_local_id>18<start_of_thought>19<sub_problem>First, we need to determine how far Diana can bike at her initial speed of 3 mph for 2 hours. This will help us understand how much distance she has covered before getting tired.</sub_problem>20</start_of_thought>21<start_of_rating><positive_rating></start_of_rating>2223<start_of_father_id>2</start_of_father_id>24<start_of_local_id>3</start_of_local_id>25<start_of_thought>26<expansion>To find the distance covered at 3 mph for 2 hours, we use the formula: Distance = Speed × Time. Therefore, Distance = 3 mph × 2 hours = 6 miles.</expansion>27</start_of_thought>28<start_of_rating><positive_rating></start_of_rating>2930<start_of_father_id>2</start_of_father_id>31<start_of_local_id>4</start_of_local_id>32<start_of_thought>33<sub_conclusion>Diana can cover 6 miles in the first 2 hours.</sub_conclusion>34</start_of_thought>35<start_of_rating><positive_rating></start_of_rating>3637<start_of_father_id>1</start_of_father_id>38<start_of_local_id>5</start_of_local_id>39<start_of_thought>40<sub_problem>Now we need to determine how far Diana has left to bike after the first 2 hours. This will help us calculate the remaining time she needs to cover the remaining distance.</sub_problem>41</start_of_thought>42<start_of_rating><positive_rating></start_of_rating>4344<start_of_father_id>5</start_of_father_id>45<start_of_local_id>6</start_of_local_id>46<start_of_thought>47<expansion>Diana has 10 miles total and has already biked 6 miles. Thus, the remaining distance is: 10 miles - 6 miles = 4 miles.</expansion>48</start_of_thought>49<start_of_rating><positive_rating></start_of_rating>5051<start_of_father_id>5</start_of_father_id>52<start_of_local_id>7</start_of_local_id>53<start_of_thought>54<sub_conclusion>Diana has 4 miles left to bike.</sub_conclusion>55</start_of_thought>56<start_of_rating><positive_rating></start_of_rating>5758<start_of_father_id>1</start_of_father_id>59<start_of_local_id>8</start_of_local_id>60<start_of_thought>61<sub_problem>Next, we need to calculate how long it will take Diana to bike the remaining 4 miles at her slower speed of 1 mph.</sub_problem>62</start_of_thought>63<start_of_rating><positive_rating></start_of_rating>6465<start_of_father_id>8</start_of_father_id>66<start_of_local_id>9</start_of_local_id>67<start_of_thought>68<expansion>To find the time taken to cover the remaining distance at 1 mph, we use the formula: Time = Distance / Speed. Therefore, Time = 4 miles / 1 mph = 4 hours.</expansion>69</start_of_thought>70<start_of_rating><positive_rating></start_of_rating>7172<start_of_father_id>8</start_of_father_id>73<start_of_local_id>10</start_of_local_id>74<start_of_thought>75<sub_conclusion>Diana will take 4 hours to bike the remaining 4 miles at her slower speed.</sub_conclusion>76</start_of_thought>77<start_of_rating><positive_rating></start_of_rating>7879<start_of_father_id>1</start_of_father_id>80<start_of_local_id>11</start_of_local_id>81<start_of_thought>82<expansion>Now, we combine the time taken in both stages: 2 hours (initial speed) + 4 hours (slower speed) = 6 hours.</expansion>83</start_of_thought>84<start_of_rating><positive_rating></start_of_rating>8586<start_of_father_id>1</start_of_father_id>87<start_of_local_id>12</start_of_local_id>88<start_of_thought>89<conclusion>The total time it will take Diana to reach home is 6 hours.</conclusion>90</start_of_thought>91<start_of_rating><positive_rating></start_of_rating>9293<start_of_father_id>12</start_of_father_id>94<start_of_local_id>13</start_of_local_id>95<start_of_thought>96<critic>Let's review the calculations to ensure accuracy. The distance covered at the initial speed and the time taken at the slower speed seem correct. The final addition of the times also checks out.</critic>97</start_of_thought>98<start_of_rating><positive_rating></start_of_rating>99100<start_of_father_id>12</start_of_father_id>101<start_of_local_id>14</start_of_local_id>102<start_of_thought>103<refine>To enhance clarity, we can rephrase the conclusion to explicitly state the total biking time and the distance covered at each speed.</refine>104</start_of_thought>105<start_of_rating><positive_rating></start_of_rating>106107<start_of_father_id>14</start_of_father_id>108<start_of_local_id>15</start_of_local_id>109<start_of_thought>110<conclusion>In conclusion, Diana will take a total of 6 hours to bike 10 miles, covering 6 miles in the first 2 hours at a speed of 3 mph and the remaining 4 miles at a speed of 1 mph, which takes an additional 4 hours.</conclusion>111</start_of_thought>112<start_of_rating><positive_rating></start_of_rating>113114<start_of_father_id>15</start_of_father_id>115<start_of_local_id>16</start_of_local_id>116<start_of_thought>117<conclusion>\boxed{6}</conclusion>118</start_of_thought>119<start_of_rating><positive_rating></start_of_rating>120<|end_of_text|>
Tree View
bash
1.2├── problem
3│ └── If Diana needs to bike 10 miles to reach home and she can bike at a speed of 3 mph for two hours before getting tired, and then at a speed of 1 mph until she reaches home, how long will it take her to get home?
4├── expansion
5│ └── Let's start by understanding the problem. Diana needs to bike a total of 10 miles, and we know her biking speeds at different stages. We will break down the problem into smaller parts: first, calculate the distance she can cover at her initial speed, then calculate the time taken at her slower speed to reach home.
6├── sub_problem
7│ └── First, we need to determine how far Diana can bike at her initial speed of 3 mph for 2 hours. This will help us understand how much distance she has covered before getting tired.
8│ └── expansion
9│ └── To find the distance covered at 3 mph for 2 hours, we use the formula: Distance = Speed × Time. Therefore, Distance = 3 mph × 2 hours = 6 miles.
10│ └── sub_conclusion
11│ └── Diana can cover 6 miles in the first 2 hours.
12├── sub_problem
13│ └── Now we need to determine how far Diana has left to bike after the first 2 hours. This will help us calculate the remaining time she needs to cover the remaining distance.
14│ └── expansion
15│ └── Diana has 10 miles total and has already biked 6 miles. Thus, the remaining distance is: 10 miles - 6 miles = 4 miles.
16│ └── sub_conclusion
17│ └── Diana has 4 miles left to bike.
18├── sub_problem
19│ └── Next, we need to calculate how long it will take Diana to bike the remaining 4 miles at her slower speed of 1 mph.
20│ └── expansion
21│ └── To find the time taken to cover the remaining distance at 1 mph, we use the formula: Time = Distance / Speed. Therefore, Time = 4 miles / 1 mph = 4 hours.
22│ └── sub_conclusion
23│ └── Diana will take 4 hours to bike the remaining 4 miles at her slower speed.
24├── expansion
25│ └── Now, we combine the time taken in both stages: 2 hours (initial speed) + 4 hours (slower speed) = 6 hours.
26├── conclusion
27│ └── The total time it will take Diana to reach home is 6 hours.
28├── critic
29│ └── Let's review the calculations to ensure accuracy. The distance covered at the initial speed and the time taken at the slower speed seem correct. The final addition of the times also checks out.
30├── refine
31│ └── To enhance clarity, we can rephrase the conclusion to explicitly state the total biking time and the distance covered at each speed.
32├── conclusion
33│ └── In conclusion, Diana will take a total of 6 hours to bike 10 miles, covering 6 miles in the first 2 hours at a speed of 3 mph and the remaining 4 miles at a speed of 1 mph, which takes an additional 4 hours.
34└── conclusion
35 └── \boxed{6}