匹配字符
import re
from tqdm import tqdm
Evaluate the model on the MATH dataset
correct = 0
total = 0
for example in tqdm(dataset):
prompt = example['problem']
ans = re.findall(r'\boxed{([+-]?\d+)}', example['solution'])
generated_ans = generate_answer(prompt)
parsed_ans = re.findall(r'\\boxed\{([+-]?\d+)\}', generated_ans)
if parsed_ans == ans:
    correct += 1
total += 1
accuracy = correct / total
print(f"Accuracy: {accuracy * 100:.2f}%")
从dataset数据集中选取一部分样本
A = dataset.select(range(20))

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号