xusong28
commited on
Commit
•
7faefc8
1
Parent(s):
62edb7a
update
Browse files- demo_chatbot_jddc.py +8 -4
- demo_corrector.py +4 -4
- demo_mlm.py +3 -3
- demo_sum.py +4 -5
- demo_sum_diverse.py +2 -2
demo_chatbot_jddc.py
CHANGED
@@ -14,7 +14,6 @@ tokenizer = BertTokenizer.from_pretrained(model_dir)
|
|
14 |
|
15 |
|
16 |
def predict(input, history=[]):
|
17 |
-
|
18 |
# append the new user input tokens to the chat history
|
19 |
history = history + [input] # history如果包含错误的response,可能会造成误差传递
|
20 |
|
@@ -47,13 +46,18 @@ jddc_examples = [
|
|
47 |
|
48 |
jddc_iface = gr.Interface(
|
49 |
fn=predict,
|
50 |
-
inputs=["text", "state"],
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
outputs=["chatbot", "state"],
|
|
|
52 |
examples=jddc_examples,
|
53 |
title="电商客服--生成式对话(Response Generation)",
|
54 |
-
description=''
|
55 |
)
|
56 |
|
57 |
if __name__ == "__main__":
|
58 |
jddc_iface.launch()
|
59 |
-
|
|
|
14 |
|
15 |
|
16 |
def predict(input, history=[]):
|
|
|
17 |
# append the new user input tokens to the chat history
|
18 |
history = history + [input] # history如果包含错误的response,可能会造成误差传递
|
19 |
|
|
|
46 |
|
47 |
jddc_iface = gr.Interface(
|
48 |
fn=predict,
|
49 |
+
# inputs=["text", "state"],
|
50 |
+
inputs=[
|
51 |
+
gr.Textbox(
|
52 |
+
label="输入文本",
|
53 |
+
value="发什么快递"), # gr.State() 报错
|
54 |
+
"state"
|
55 |
+
],
|
56 |
outputs=["chatbot", "state"],
|
57 |
+
|
58 |
examples=jddc_examples,
|
59 |
title="电商客服--生成式对话(Response Generation)",
|
|
|
60 |
)
|
61 |
|
62 |
if __name__ == "__main__":
|
63 |
jddc_iface.launch()
|
|
demo_corrector.py
CHANGED
@@ -65,15 +65,15 @@ def test():
|
|
65 |
|
66 |
corr_iface = gr.Interface(
|
67 |
fn=correct,
|
68 |
-
inputs=gr.
|
69 |
label="输入文本",
|
70 |
-
|
71 |
outputs=[
|
72 |
-
gr.
|
73 |
label="Output",
|
74 |
show_legend=True,
|
75 |
),
|
76 |
-
gr.
|
77 |
label="JSON Output"
|
78 |
)
|
79 |
],
|
|
|
65 |
|
66 |
corr_iface = gr.Interface(
|
67 |
fn=correct,
|
68 |
+
inputs=gr.Textbox(
|
69 |
label="输入文本",
|
70 |
+
value="少先队员因该为老人让坐"),
|
71 |
outputs=[
|
72 |
+
gr.HighlightedText(
|
73 |
label="Output",
|
74 |
show_legend=True,
|
75 |
),
|
76 |
+
gr.JSON(
|
77 |
label="JSON Output"
|
78 |
)
|
79 |
],
|
demo_mlm.py
CHANGED
@@ -41,11 +41,11 @@ mlm_examples = [
|
|
41 |
|
42 |
mlm_iface = gr.Interface(
|
43 |
fn=fill_mask,
|
44 |
-
inputs=gr.
|
45 |
label="输入文本",
|
46 |
-
|
47 |
# outputs=gr.Label(
|
48 |
-
outputs=gr.
|
49 |
label="填词",
|
50 |
),
|
51 |
examples=mlm_examples,
|
|
|
41 |
|
42 |
mlm_iface = gr.Interface(
|
43 |
fn=fill_mask,
|
44 |
+
inputs=gr.Textbox(
|
45 |
label="输入文本",
|
46 |
+
value="这款连[MASK]裙真漂亮"),
|
47 |
# outputs=gr.Label(
|
48 |
+
outputs=gr.Label(
|
49 |
label="填词",
|
50 |
),
|
51 |
examples=mlm_examples,
|
demo_sum.py
CHANGED
@@ -34,9 +34,9 @@ sum_examples = [
|
|
34 |
|
35 |
sum_iface = gr.Interface(
|
36 |
fn=summarize,
|
37 |
-
inputs=gr.
|
38 |
label="商品信息(Product Info)",
|
39 |
-
|
40 |
"M以上的距离尤其是左右两侧距离必须保证。关于尺寸的更多问题可,LED冷光源,纤薄机身,风冷"
|
41 |
"无霜,智能操控,远程调温,节能静音,照亮你的视野,535L大容量,系统散热和使用的便利性,"
|
42 |
"建议左右两侧、顶部和背部需要预留10C,电源线和调平脚等。冰箱放置时为保证,菜谱推荐,半开"
|
@@ -49,9 +49,8 @@ sum_iface = gr.Interface(
|
|
49 |
title="生成式摘要(Abstractive Summarization)",
|
50 |
description='<div>这是一个生成式摘要的demo,用于电商领域的商品营销文案写作。'
|
51 |
'该demo基于KPLUG预训练语言模型,输入商品信息,输出商品的营销文案。</div>'
|
52 |
-
'<div
|
53 |
-
'
|
54 |
-
'<div>Github: <a href="https://github.com/xu-song/k-plug">https://github.com/xu-song/k-plug </a> </div>'
|
55 |
)
|
56 |
|
57 |
if __name__ == "__main__":
|
|
|
34 |
|
35 |
sum_iface = gr.Interface(
|
36 |
fn=summarize,
|
37 |
+
inputs=gr.Textbox(
|
38 |
label="商品信息(Product Info)",
|
39 |
+
value="美的对开门风冷无霜家用智能电冰箱波光金纤薄机身高颜值助力保鲜,美的家居风,尺寸说明:"
|
40 |
"M以上的距离尤其是左右两侧距离必须保证。关于尺寸的更多问题可,LED冷光源,纤薄机身,风冷"
|
41 |
"无霜,智能操控,远程调温,节能静音,照亮你的视野,535L大容量,系统散热和使用的便利性,"
|
42 |
"建议左右两侧、顶部和背部需要预留10C,电源线和调平脚等。冰箱放置时为保证,菜谱推荐,半开"
|
|
|
49 |
title="生成式摘要(Abstractive Summarization)",
|
50 |
description='<div>这是一个生成式摘要的demo,用于电商领域的商品营销文案写作。'
|
51 |
'该demo基于KPLUG预训练语言模型,输入商品信息,输出商品的营销文案。</div>'
|
52 |
+
'<div><a href="https://aclanthology.org/2021.findings-emnlp.1/">pdf</a> </div>'
|
53 |
+
'<div><a href="https://github.com/xu-song/k-plug">code </a> </div>'
|
|
|
54 |
)
|
55 |
|
56 |
if __name__ == "__main__":
|
demo_sum_diverse.py
CHANGED
@@ -40,14 +40,14 @@ sum_examples = [
|
|
40 |
|
41 |
sum_iface = gr.Interface(
|
42 |
fn=summarize,
|
43 |
-
inputs=gr.
|
44 |
label="商品信息(Product Info)",
|
45 |
default="美的对开门风冷无霜家用智能电冰箱波光金纤薄机身高颜值助力保鲜,美的家居风,尺寸说明:"
|
46 |
"M以上的距离尤其是左右两侧距离必须保证。关于尺寸的更多问题可,LED冷光源,纤薄机身,风冷"
|
47 |
"无霜,智能操控,远程调温,节能静音,照亮你的视野,535L大容量,系统散热和使用的便利性,"
|
48 |
"建议左右两侧、顶部和背部需要预留10C,电源线和调平脚等。冰箱放置时为保证,菜谱推荐,半开"
|
49 |
"门俯视图,全开门俯视图,预留参考图"),
|
50 |
-
outputs=gr.
|
51 |
label="文本摘要(Summarization)- diverse beam search"
|
52 |
),
|
53 |
# gr.Textbox(
|
|
|
40 |
|
41 |
sum_iface = gr.Interface(
|
42 |
fn=summarize,
|
43 |
+
inputs=gr.Textbox(
|
44 |
label="商品信息(Product Info)",
|
45 |
default="美的对开门风冷无霜家用智能电冰箱波光金纤薄机身高颜值助力保鲜,美的家居风,尺寸说明:"
|
46 |
"M以上的距离尤其是左右两侧距离必须保证。关于尺寸的更多问题可,LED冷光源,纤薄机身,风冷"
|
47 |
"无霜,智能操控,远程调温,节能静音,照亮你的视野,535L大容量,系统散热和使用的便利性,"
|
48 |
"建议左右两侧、顶部和背部需要预留10C,电源线和调平脚等。冰箱放置时为保证,菜谱推荐,半开"
|
49 |
"门俯视图,全开门俯视图,预留参考图"),
|
50 |
+
outputs=gr.JSON(
|
51 |
label="文本摘要(Summarization)- diverse beam search"
|
52 |
),
|
53 |
# gr.Textbox(
|