MCPcopy Create free account
hub / github.com/SmartFlowAI/TheGodOfCookery / evaluate_model

Function evaluate_model

eval/evaluate.py:56–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54
55
56def evaluate_model():
57 # 正式评估请手动替换下一行的路径
58 with open('./eval_dataset_test.json', 'r', encoding='utf-8') as f:
59 # 评测模型耗时较长,可以只评测部分数据
60 data = json.load(f)[:10]
61 f1_sum = 0
62 model, tokenizer, llm = load_model()
63 qa_chain = load_chain(llm)
64 for d in tqdm(data):
65 query = d["conversation"][0]['input']
66 output = qa_chain({"query": query})['result']
67 gt = d["conversation"][0]['input'] + '\n' + d["conversation"][0]['output']
68 print("--------------------输入:", query)
69 print("--------------------输出:", output)
70 print("--------------------答案:", gt)
71 f1_sum += f1_score(output, gt)
72 print(f'F1 score sum: {f1_sum}')
73 print(f'The number of data: {len(data)}')
74 print(f'F1 average: {f1_sum / len(data)}')
75
76
77if __name__ == '__main__':

Callers

nothing calls this directly

Calls 3

load_modelFunction · 0.90
load_chainFunction · 0.90
f1_scoreFunction · 0.85

Tested by

no test coverage detected