| 88 | return None |
| 89 | |
| 90 | def extract_ans(completion, answer): |
| 91 | |
| 92 | split_ans = re.split("Problem:", completion, flags=re.IGNORECASE)[0] |
| 93 | split_ans = re.split("answer is ", split_ans, flags=re.IGNORECASE) |
| 94 | if len(split_ans) > 1: |
| 95 | ans = split_ans[-1] |
| 96 | extract_ans_temp = ans.split('.\n')[0] |
| 97 | extract_ans_temp = extract_ans_temp.strip() |
| 98 | if len(extract_ans_temp)>0 and extract_ans_temp[-1] == '.': |
| 99 | extract_ans = extract_ans_temp[0:-1] |
| 100 | else: |
| 101 | extract_ans = extract_ans_temp |
| 102 | extract_ans = extract_ans.strip() |
| 103 | return extract_ans |
| 104 | else: |
| 105 | return None |
| 106 | |
| 107 | def batch_data(prompts, batch_size=1): |
| 108 | batch_data = [] |