这里就写一下自己理解代码中不会的地方吧!
1.自评函数的实现
这里着重讲讲下面这个自评函数,因为困惑我了一阵子,好好解析一下。
为了自评训练效果,并且每天只能去官网提交三次结果,故可以选择自行评测。这里主要来理解怎么得出结果分数。测评分时,是用训练集去评测,因为训练集中有正确答案(即answer字段),而测试集中没有(见下图)
def evaluate(ofn):
data = []
with open(ofn) as reader:
for line in reader:
sample = json.loads(line)
data.append(sample)
pse = 0
cnt = 0
tot = 0
for task in data:
for question in task['questions']:
if MODEL_NAME in question:
tot += 1
cnt += question[MODEL_NAME] == question['answer']
else:
pse += 1
print(cnt, tot, cnt/tot, pse)
故此处在process_data函数下图红框处需要改一下字段名,改为MODEL_NAME(原来为"answer"字段),这样方便自评。
2.Prompt中运用的思想——CoT(思维链)
思维链就是一系列中间的推理步骤(a series of intermediate reasoning steps)
一文读懂「Chain of Thought,CoT」思维链-CSDN博客
就是在Prompt中加入细节,比如给出示例,该示例中带有推理过程。或者直接说think step by step