YanshekWoo commited on
Commit
e44ee1e
·
1 Parent(s): 5ff4622

Initial requirements.txt

Browse files
Files changed (1) hide show
  1. app.py +8 -25
app.py CHANGED
@@ -1,31 +1,14 @@
1
- # import gradio as gr
2
- # from transformers import BertTokenizer, BartForConditionalGeneration
3
- #
4
- #
5
- # tokenizer = BertTokenizer.from_pretrained("HIT-TMG/dialogue-bart-large-chinese")
6
- # model = BartForConditionalGeneration.from_pretrained("HIT-TMG/dialogue-bart-large-chinese")
7
- #
8
- #
9
- # def generate_reponse(history):
10
- # history_prefix = "对话历史:"
11
- # history = history_prefix + history
12
- #
13
- # input_ids = tokenizer(history, return_tensors='pt').input_ids
14
- # output_ids = model.generate(input_ids)[0]
15
- #
16
- # return tokenizer.decode(output_ids, skip_special_tokens=True)
17
- #
18
- #
19
- # iface = gr.Interface(fn=generate_reponse, inputs="text", outputs="text")
20
- # iface.launch()
21
-
22
-
23
  import gradio as gr
24
  from transformers import BertTokenizer, BartForConditionalGeneration
25
 
26
 
27
- title = "标题"
28
- description = "描述"
 
 
 
 
 
29
 
30
 
31
  tokenizer = BertTokenizer.from_pretrained("HIT-TMG/dialogue-bart-large-chinese")
@@ -45,7 +28,7 @@ def chat(history):
45
  chatbot = gr.Chatbot().style(color_map=("green", "pink"))
46
  demo = gr.Interface(
47
  chat,
48
- inputs=gr.Textbox(lines=2, placeholder="输入你的对话历史"),
49
  title=title,
50
  description=description,
51
  outputs =["text"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from transformers import BertTokenizer, BartForConditionalGeneration
3
 
4
 
5
+ title = "HIT-TMG/dialogue-bart-large-chinese"
6
+ description = """
7
+ This is a seq2seq model fine-tuned on several Chinese dialogue datasets, from bart-large-chinese.
8
+ See some details of model card at https://huggingface.co/HIT-TMG/dialogue-bart-large-chinese .
9
+
10
+ Input example: 可以 认识 一下 吗 ?[SEP]当然 可以 啦 , 你好 。[SEP]嘿嘿 你好 , 请问 你 最近 在 忙 什么 呢 ?[SEP]我 最近 养 了 一只 狗狗 , 我 在 训练 它 呢 。
11
+ """
12
 
13
 
14
  tokenizer = BertTokenizer.from_pretrained("HIT-TMG/dialogue-bart-large-chinese")
 
28
  chatbot = gr.Chatbot().style(color_map=("green", "pink"))
29
  demo = gr.Interface(
30
  chat,
31
+ inputs=gr.Textbox(lines=2, placeholder="输入你的对话历史(请以'[SEP]'作为每段对话的间隔)\nInput the dialogue history (Please split utterances by '[SEP]')"),
32
  title=title,
33
  description=description,
34
  outputs =["text"]