andreslu commited on
Commit
fbed307
1 Parent(s): 7110a4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -3,19 +3,24 @@ from inductor import BartInductor
3
 
4
  inductor = BartInductor()
5
 
6
- def bart(prompt, num):
7
- results = inductor.generate(prompt, k=num, topk=num, return_scores=True)
8
- results = [(result[0], float(result[1]) * 100) for result in results]
 
 
 
9
  results_dict = {result[0]: float(result[1]) for result in results}
10
  return results_dict
11
 
12
  demo = gr.Interface(fn=bart,
13
- inputs=[gr.inputs.Textbox(default='<mask> is the capital of <mask>.'),gr.Slider(0, 10)],
 
 
14
  outputs=gr.Label(),
15
  title="Orion",
16
- examples=[['<mask> is the capital of <mask>.',5],
17
- ['<mask> is founder and CEO of <mask>.',5],
18
- ["<mask>'s mother was a <mask>-based actress, <mask>.",5]],
19
  description="Enter a text prompt to generate text using BART.")
20
 
21
 
 
3
 
4
  inductor = BartInductor()
5
 
6
+ def bart(prompt, num, return_score):
7
+ results = inductor.generate(prompt, k=num, topk=num, return_scores=return_score)
8
+ if return_score:
9
+ results = [(result[0], float(result[1]) * 100) for result in results]
10
+ else:
11
+ results = [(result[0], 0) for result in results]
12
  results_dict = {result[0]: float(result[1]) for result in results}
13
  return results_dict
14
 
15
  demo = gr.Interface(fn=bart,
16
+ inputs=[gr.inputs.Textbox(default='<mask> is the capital of <mask>.'),
17
+ gr.Slider(0, 10, value=5, step=1),
18
+ gr.Checkbox(label="Hell Yes", info="Return Scores?")],
19
  outputs=gr.Label(),
20
  title="Orion",
21
+ examples=[['<mask> is the capital of <mask>.', 5, True],
22
+ ['<mask> is founder and CEO of <mask>.', 5, False],
23
+ ["<mask>'s mother was a <mask>-based actress, <mask>.", 5, False]],
24
  description="Enter a text prompt to generate text using BART.")
25
 
26