andreslu commited on
Commit
7110a4a
Β·
1 Parent(s): 8baa350

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -3,27 +3,21 @@ from inductor import BartInductor
3
 
4
  inductor = BartInductor()
5
 
6
- def bart(text):
7
- results = inductor.generate(text, 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
- bivar = gr.Interface(fn=bart,
13
- inputs=gr.inputs.Textbox(default='<mask> is the capital of <mask>.'),
14
  outputs=gr.Label(),
15
- title="BART Inductor εŒε˜ι‡",
16
- examples=[['<mask> is the capital of <mask>.'],['<mask> is founder and CEO of <mask>.']],
 
 
17
  description="Enter a text prompt to generate text using BART.")
18
 
19
- trivar = gr.Interface(fn=bart,
20
- inputs=gr.inputs.Textbox(default='<mask> is the parent of <mask>, who is the sibling of <mask>.'),
21
- outputs=gr.Label(),
22
- title="BART Inductor δΈ‰ε˜ι‡",
23
- examples=[['<mask> is the parent of <mask>, who is the sibling of <mask>.']],
24
- description="this might not work so well")
25
-
26
- demo = gr.TabbedInterface([bivar, trivar], ["εŒε˜ι‡", "δΈ‰ε˜ι‡"])
27
 
28
  if __name__ == "__main__":
29
  demo.launch()
 
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
 
22
  if __name__ == "__main__":
23
  demo.launch()