Update inference.py

This commit is contained in:
p83651209 2024-11-03 20:04:38 +08:00
parent cd1bdcf117
commit 58a7967a98
1 changed files with 278 additions and 270 deletions

View File

@ -211,10 +211,11 @@ def get_result_1(model, tokenizer):
answers = {}
for model_path in [
"/mnt/disk2/home/wujianfeng/LLaMA-Factory/all_new_1/checkpoint-600",
"/mnt/disk2/home/wujianfeng/LLaMA-Factory/all_new/checkpoint-600/",
for model_path in [
"/mnt/disk2/home/wujianfeng/LLaMA-Factory/all/TACO/",
"/mnt/disk2/home/wujianfeng/LLaMA-Factory/all_new_2/CodeNet4Repair/",
"/mnt/disk2/home/wujianfeng/LLaMA-Factory/all_new_1/CodeExercise-Python-27k/",
]:
print("model_path: ", model_path)
model = AutoModelForCausalLM.from_pretrained(
@ -234,14 +235,21 @@ for model_path in [
test, score = exec_code(test)
answers[score] = test
'''
import os
for path in os.listdir("./"):
if "home-wujianfeng" in path:
with open(path, "r") as f:
test = json.load(f)
answers[float(path.split(".")[-2].split("-")[-1])] = test
'''
answers = list(dict(sorted(answers.items())).values())
print("answers: ", answers)
right = 0
jiuge_right = 0
merge = []
for i in range(len(answers)):
for i in range(len(answers[0])):
#for i in range(2):
flag = 0
for answer in answers:
@ -257,7 +265,7 @@ for i in range(len(answers)):
print(right / len(answers), jiuge_right / len(answers))
print(right / len(answers[0]), jiuge_right / len(answers[0]))
with open("wjf_jiuge.jsonl", "w") as f:
for item in merge:
item.pop("result")