Update app.py
Browse files
app.py
CHANGED
@@ -3,42 +3,51 @@ from utils import *
|
|
3 |
from transformers import pipeline
|
4 |
|
5 |
css = """
|
6 |
-
|
7 |
-
background-color: #673AB7; /* 设置按钮背景为紫色 */
|
8 |
-
color: white; /* 设置按钮文字颜色为白色 */
|
9 |
-
border-radius: 8px; /* 设置按钮边角为圆角 */
|
10 |
-
padding: 10px 20px; /* 设置按钮内边距 */
|
11 |
-
border: none; /* 移除按钮边框 */
|
12 |
-
}
|
13 |
"""
|
14 |
|
15 |
ori_model = None
|
16 |
edit_model = None
|
17 |
|
18 |
-
with gr.Blocks(css=css) as demo:
|
19 |
-
gr.
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
with gr.Row():
|
22 |
with gr.Column():
|
23 |
-
|
24 |
-
prompt = gr.Textbox(label="Input Prompt",lines=4)
|
25 |
-
with gr.Row():
|
26 |
-
target_new = gr.Textbox(label="Input Target New")
|
27 |
-
with gr.Row():
|
28 |
-
button4clear = gr.Button("Clear")
|
29 |
-
button4edit = gr.Button("Edit")
|
30 |
-
with gr.Row():
|
31 |
-
input_text = gr.Label(label="Status Information",value="The editing process may take up to 30 seconds. Please be patient.")
|
32 |
with gr.Column():
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
with gr.Row():
|
38 |
-
button4gen_ori=gr.Label(label="origin output")
|
39 |
-
with gr.Row():
|
40 |
-
button4gen_edit=gr.Label(label="edited output")
|
41 |
-
|
42 |
button4clear.click(lambda: ("", ""), outputs=[prompt,target_new])
|
43 |
button4edit.click(fn=edit, inputs=[prompt,target_new], outputs=input_text)
|
44 |
button4gen.click(fn=generate, inputs=input, outputs=[button4gen_ori,button4gen_edit])
|
|
|
3 |
from transformers import pipeline
|
4 |
|
5 |
css = """
|
6 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
"""
|
8 |
|
9 |
ori_model = None
|
10 |
edit_model = None
|
11 |
|
12 |
+
with gr.Blocks(css=css,theme=gr.themes.Soft(text_size="sm")) as demo:
|
13 |
+
gr.HTML("""<div style="text-align: center; margin: 0 auto;"><p><h1> Knowledge Editing</h1></div>""")
|
14 |
+
|
15 |
+
with gr.Row():
|
16 |
+
gr.Markdown("<p align='center'><a href='https://github.com/zjunlp/EasyEdit'>🔧https://github.com/zjunlp/EasyEdit</a></p>")
|
17 |
+
|
18 |
+
with gr.Row():
|
19 |
+
gr.Markdown("### Large Language Models (LLMs) often suffer from knowledge cutoff or fallacy issues, meaning they are unable to recognize unseen events or generate text with incorrect facts due to outdated/noisy data. To address this, many knowledge editing methods for LLMs aim to subtly inject/edit updated knowledge or adjust undesirable behaviors, while minimizing the impact on unrelated inputs.")
|
20 |
+
|
21 |
+
|
22 |
+
with gr.Row():
|
23 |
+
prompt = gr.Textbox(label="Edit Prompt")
|
24 |
+
target_new = gr.Textbox(label="Edit Target New")
|
25 |
+
with gr.Row():
|
26 |
+
button4clear = gr.Button("Clear")
|
27 |
+
button4edit = gr.Button("Edit",variant="primary")
|
28 |
+
with gr.Row():
|
29 |
+
examples = gr.Examples(
|
30 |
+
examples=[
|
31 |
+
["Who is the architect for Toodyay Fire Station?","Wong Tung & Sons"],
|
32 |
+
["Who is Claire Clairmont\'s sister?","Clairmont-Mayer"],
|
33 |
+
["Which fictional universe is Chlorophyll Kid part of?","Image Universe"]
|
34 |
+
],
|
35 |
+
examples_per_page=3,
|
36 |
+
inputs=[prompt,target_new],
|
37 |
+
)
|
38 |
+
with gr.Row():
|
39 |
+
input_text = gr.Textbox(label="Status Information",value="Model editing may take about a minute, please be patient.")
|
40 |
+
|
41 |
+
with gr.Row():
|
42 |
+
input = gr.Textbox(label="Input Text",lines=3)
|
43 |
with gr.Row():
|
44 |
with gr.Column():
|
45 |
+
button4gen_ori=gr.Textbox(label="origin output")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
with gr.Column():
|
47 |
+
button4gen_edit=gr.Textbox(label="edited output")
|
48 |
+
with gr.Row():
|
49 |
+
button4gen = gr.Button("Generate",variant="primary")
|
50 |
+
|
|
|
|
|
|
|
|
|
|
|
51 |
button4clear.click(lambda: ("", ""), outputs=[prompt,target_new])
|
52 |
button4edit.click(fn=edit, inputs=[prompt,target_new], outputs=input_text)
|
53 |
button4gen.click(fn=generate, inputs=input, outputs=[button4gen_ori,button4gen_edit])
|