-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.py
42 lines (31 loc) · 1.34 KB
/
temp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# @Time : 2024/3/27 20:21
# @Author : Li Jiaqi
# @Description :
import matplotlib.pyplot as plt
import numpy as np
from peft import load_peft_weights
file_path="calibration-tuning/Llama-2-7b-chat-hf-ct-oe"
model = load_peft_weights(file_path, device='cuda')
model['base_model.model.lm_head.weight']=model['base_model.model.lm_head.weight'][:32000,:]
model['base_model.model.model.embed_tokens.weight']=model['base_model.model.model.embed_tokens.weight'][:32000]
plt.rcParams['font.sans-serif'] = ['SimHei']
labels = ['GPT-4', 'LLaMA2', 'UT', 'HotpotQA', 'ST',"UT \n& HotpotQA","US-Tuning"]
f1s=[81.6,67.2,64.6,66.5,69.6,32.8,85.8]
pos_accs=[79.6,79.3,52.4,77.5,84.8,77.0,79.7]
neg_accs=[83.6,58.3,84.4,58.3,59.0,20.9,93.0]
x = np.arange(len(labels)) # the label locations
width = 0.18 # the width of the bars
fig, ax = plt.subplots(figsize=(6, 4))
rects1 = ax.bar(x - 1.3* width, f1s, width, label='F1 Score',color='salmon')
rects2 = ax.bar(x , pos_accs, width, label='Accuracy of Known Questions',color='deepskyblue')
rects3 = ax.bar(x + 1.3* width , neg_accs, width, label='Accuracy of Unknown Questions',color='lightslategray')
# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('score')
ax.set_xticks(x)
ax.set_xticklabels(labels)
ax.legend()
fig.tight_layout()
plt.ylim(50,100)
# save
plt.savefig("result.png")
plt.show()