Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,27 +3,21 @@ from inductor import BartInductor
|
|
3 |
|
4 |
inductor = BartInductor()
|
5 |
|
6 |
-
def bart(
|
7 |
-
results = inductor.generate(
|
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 |
-
|
13 |
-
inputs=gr.inputs.Textbox(default='<mask> is the capital of <mask>.'),
|
14 |
outputs=gr.Label(),
|
15 |
-
title="
|
16 |
-
examples=[['<mask> is the capital 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()
|