Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
from constants import *
|
4 |
+
|
5 |
+
# ... 其他导入 ...
|
6 |
+
|
7 |
+
# 定义自定义 CSS
|
8 |
+
custom_css = """
|
9 |
+
h1 { /* 根据需要选择正确的标题标签 */
|
10 |
+
background-color: blue; /* 蓝色背景 */
|
11 |
+
color: white; /* 白色文字 */
|
12 |
+
padding: 10px; /* 内边距 */
|
13 |
+
text-align: center; /* 文本居中 */
|
14 |
+
}
|
15 |
+
h2 { /* 根据需要选择正确的标题标签 */
|
16 |
+
color: white; /* 白色文字 */
|
17 |
+
padding: 10px; /* 内边距 */
|
18 |
+
text-align: center; /* 文本居中 */
|
19 |
+
}
|
20 |
+
|
21 |
+
"""
|
22 |
+
|
23 |
+
def get_preview_data():
|
24 |
+
df = pd.read_json(DATA_DIR)
|
25 |
+
df=df.head(4)
|
26 |
+
return df
|
27 |
+
def get_result_data():
|
28 |
+
df={
|
29 |
+
"DataSet": ["WikiData_recent", "WikiData_recent", "WikiData_recent", "WikiData_recent",
|
30 |
+
"ZsRE", "ZsRE", "ZsRE", "ZsRE",
|
31 |
+
"WikiBio", "WikiBio", "WikiBio",
|
32 |
+
"WikiData_counterfact", "WikiData_counterfact", "WikiData_counterfact", "WikiData_counterfact",
|
33 |
+
"ConvSent", "ConvSent", "ConvSent",
|
34 |
+
"Sanitation", "Sanitation", "Sanitation"],
|
35 |
+
"Metric": ["Edit Succ. ↑", "Portability ↑", "Locality ↑", "Fluency ↑",
|
36 |
+
"Edit Succ. ↑", "Portability ↑", "Locality ↑", "Fluency ↑",
|
37 |
+
"Edit Succ. ↑", "Locality ↑", "Fluency ↑",
|
38 |
+
"Edit Succ. ↑", "Portability ↑", "Locality ↑", "Fluency ↑",
|
39 |
+
"Edit Succ. ↑", "Locality ↓", "Fluency ↑",
|
40 |
+
"Edit Succ. ↑", "Locality ↑", "Fluency ↑"],
|
41 |
+
"SERAC": [98.68, 63.52, 100.00, 553.19,
|
42 |
+
99.67, 56.48, 30.23, 410.89,
|
43 |
+
99.69, 69.79, 606.95,
|
44 |
+
99.99, 76.07, 98.96, 549.91,
|
45 |
+
62.75, 0.26, 458.21,
|
46 |
+
0.00, 100.00, 416.29],
|
47 |
+
"ICE": [60.74, 36.93, 33.34, 531.01,
|
48 |
+
66.01, 63.94, 23.14, 541.14,
|
49 |
+
95.53, 47.90, 632.92,
|
50 |
+
69.83, 45.32, 32.38, 547.22,
|
51 |
+
52.78, 49.73, 621.45,
|
52 |
+
72.50, 56.58, 794.15],
|
53 |
+
"AdaLoRA": [65.61, 47.22, 55.78, 537.51,
|
54 |
+
69.86, 52.95, 72.21, 532.82,
|
55 |
+
97.02, 57.87, 615.86,
|
56 |
+
72.14, 55.17, 66.78, 553.85,
|
57 |
+
44.89, 0.18, 606.42,
|
58 |
+
2.50, 65.50, 330.44],
|
59 |
+
"MEND": [76.88, 50.11, 92.87, 586.34,
|
60 |
+
96.74, 60.41, 92.79, 524.33,
|
61 |
+
93.66, 69.51, 609.39,
|
62 |
+
78.82, 57.53, 94.16, 588.94,
|
63 |
+
50.76, 3.42, 379.43,
|
64 |
+
0.00, 5.29, 407.18],
|
65 |
+
"ROME": [85.08, 37.45, 66.2, 574.28,
|
66 |
+
96.57, 52.20, 27.14, 570.47,
|
67 |
+
95.05, 46.96, 617.25,
|
68 |
+
83.21, 38.69, 65.4, 578.84,
|
69 |
+
45.79, 0.00, 606.32,
|
70 |
+
85.00, 50.31, 465.12],
|
71 |
+
"MEMIT": [85.32, 37.94, 64.78, 566.66,
|
72 |
+
83.07, 51.43, 25.46, 559.72,
|
73 |
+
94.29, 51.56, 616.65,
|
74 |
+
83.41, 40.09, 63.68, 568.58,
|
75 |
+
44.75, 0.00, 602.62,
|
76 |
+
48.75, 67.47, 466.10],
|
77 |
+
"FT-L": [71.18, 48.71, 63.7, 549.35,
|
78 |
+
54.65, 45.02, 71.12, 474.18,
|
79 |
+
83.41, 40.09, 63.68, 568.58,
|
80 |
+
66.27, 60.14, 604.00,
|
81 |
+
51.12, 39.07, 62.51,
|
82 |
+
48.75, 67.47, 466.10]
|
83 |
+
}
|
84 |
+
df=pd.DataFrame(df)
|
85 |
+
return df
|
86 |
+
|
87 |
+
block = gr.Blocks(css=custom_css) # 应用自定义 CSS
|
88 |
+
|
89 |
+
with block:
|
90 |
+
gr.Markdown(TITLE)
|
91 |
+
|
92 |
+
gr.Markdown("## BACKGROUND")
|
93 |
+
gr.Markdown(
|
94 |
+
BACKGROUND
|
95 |
+
)
|
96 |
+
gr.Image('./img/demo.gif')
|
97 |
+
|
98 |
+
gr.Markdown("## DATA PREVIEW")
|
99 |
+
gr.Markdown(LEADERBORAD_INTRODUCTION)
|
100 |
+
|
101 |
+
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
102 |
+
with gr.TabItem("🏅 Data preview ", elem_id="ke-benchmark-tab-table", id=0):
|
103 |
+
# 创建数据帧组件
|
104 |
+
ke_data_component = gr.components.Dataframe(
|
105 |
+
value=get_preview_data(),
|
106 |
+
headers=DATA_COLUMN_NAMES,
|
107 |
+
type="pandas",
|
108 |
+
)
|
109 |
+
with gr.TabItem("data Structure", elem_id="about-struct-tab-table", id=3):
|
110 |
+
gr.Markdown(DATA_STRUCT, elem_classes="markdown-text")
|
111 |
+
|
112 |
+
with gr.TabItem("📝 data schema", elem_id="about-benchmark-tab-table", id=4):
|
113 |
+
gr.Markdown(DATA_SCHEMA, elem_classes="markdown-text")
|
114 |
+
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
gr.Markdown("## EXPERIMENT RESULTS")
|
119 |
+
gr.Markdown("We list the results of current knowledge editing methods on Llama2-7b-chat in Table")
|
120 |
+
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
121 |
+
with gr.TabItem("🏅 result", elem_id="ke-benchmark-tab-table", id=0):
|
122 |
+
# 创建数据帧组件
|
123 |
+
ke_data_component = gr.components.Dataframe(
|
124 |
+
value=get_result_data(),
|
125 |
+
headers=RESULT_COLUMN_NAMES,
|
126 |
+
type="pandas",
|
127 |
+
)
|
128 |
+
# About tab
|
129 |
+
with gr.TabItem("📝 About", elem_id="about-benchmark-tab-table", id=4):
|
130 |
+
gr.Markdown("Results of existing knowledge edit methods on the constructed benchmark. The symbol indicates that higher numbers correspond to better performance, while ��� denotes the opposite, with lower numbers indicating better performance. For WikiBio and Convsent, we do not test the portability as they are about specific topics. ", elem_classes="markdown-text")
|
131 |
+
|
132 |
+
with gr.Row():
|
133 |
+
with gr.Accordion("Citation", open=False):
|
134 |
+
citation_button = gr.Textbox(
|
135 |
+
value=CITATION_BUTTON_TEXT,
|
136 |
+
label=CITATION_BUTTON_LABEL,
|
137 |
+
elem_id="citation-button",
|
138 |
+
).style(show_copy_button=True)
|
139 |
+
|
140 |
+
block.launch(share=True)
|