Upload run_program.py with huggingface_hub
Browse files- run_program.py +4 -4
run_program.py
CHANGED
@@ -330,17 +330,17 @@ def call_answer_question(question, model_name='gpt', cot=False):
|
|
330 |
return outputs[0]["generated_text"][-1]['content']
|
331 |
|
332 |
|
333 |
-
def answer_question(model_name='gpt'):
|
334 |
infile = open('data/math/test_dump_gsm8k_train_perturbed_with_new_questions.json', 'r')
|
335 |
program_data = json.load(infile)
|
336 |
print(len(program_data))
|
337 |
for case in tqdm(program_data):
|
338 |
-
response = call_answer_question(case['question'], model_name=model_name, cot=
|
339 |
case['prediction'] = response
|
340 |
# print(case['prediction'])
|
341 |
case['new_prediction'] = []
|
342 |
for question in case['new_questions']:
|
343 |
-
response = call_answer_question(question, model_name=model_name, cot=
|
344 |
case['new_prediction'].append(response)
|
345 |
# print(case)
|
346 |
# break
|
@@ -439,7 +439,7 @@ def evaluator(infile_path):
|
|
439 |
def main():
|
440 |
# generate_new_parameter_value()
|
441 |
# update_question_with_new_parameters()
|
442 |
-
answer_question(model_name='llama')
|
443 |
# collect_self_consistency_result('data/math/gsm8k_cot_sc')
|
444 |
# evaluator('data/math/gsm8k_cot_sc_merged_result.json')
|
445 |
# evaluator('data/math/test_dump_gsm8k_train_perturbed_with_new_questions_answer_few_shot_cot_qwen.json')
|
|
|
330 |
return outputs[0]["generated_text"][-1]['content']
|
331 |
|
332 |
|
333 |
+
def answer_question(model_name='gpt', cot=False):
|
334 |
infile = open('data/math/test_dump_gsm8k_train_perturbed_with_new_questions.json', 'r')
|
335 |
program_data = json.load(infile)
|
336 |
print(len(program_data))
|
337 |
for case in tqdm(program_data):
|
338 |
+
response = call_answer_question(case['question'], model_name=model_name, cot=cot)
|
339 |
case['prediction'] = response
|
340 |
# print(case['prediction'])
|
341 |
case['new_prediction'] = []
|
342 |
for question in case['new_questions']:
|
343 |
+
response = call_answer_question(question, model_name=model_name, cot=cot)
|
344 |
case['new_prediction'].append(response)
|
345 |
# print(case)
|
346 |
# break
|
|
|
439 |
def main():
|
440 |
# generate_new_parameter_value()
|
441 |
# update_question_with_new_parameters()
|
442 |
+
answer_question(model_name='llama', cot=True)
|
443 |
# collect_self_consistency_result('data/math/gsm8k_cot_sc')
|
444 |
# evaluator('data/math/gsm8k_cot_sc_merged_result.json')
|
445 |
# evaluator('data/math/test_dump_gsm8k_train_perturbed_with_new_questions_answer_few_shot_cot_qwen.json')
|