File size: 1,255 Bytes
6d92158
59c5207
3060053
59c5207
4e58ddc
fbed307
 
 
 
 
62cbf4f
6732406
 
3060053
7110a4a
fbed307
 
 
6732406
7270722
fbed307
 
 
7270722
6d92158
59c5207
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
from inductor import BartInductor

inductor = BartInductor()

def bart(prompt, num, return_score):
    results = inductor.generate(prompt, k=num, topk=num, return_scores=return_score)
    if return_score:
        results = [(result[0], float(result[1]) * 100) for result in results]
    else:
        results = [(result, 0) for result in results]
    results_dict = {result[0]: float(result[1]) for result in results}
    return results_dict

demo = gr.Interface(fn=bart, 
                     inputs=[gr.inputs.Textbox(default='<mask> is the capital of <mask>.'),
                             gr.Slider(0, 10, value=5, step=1),
                             gr.Checkbox(label="Hell Yes", info="Return Scores?")],
                     outputs=gr.Label(),
                     title="ORION: Open Rule InductiON",
                     examples=[['<mask> is the capital of <mask>.', 5, True],
                               ['<mask> is founder and CEO of <mask>.', 5, False],
                              ["<mask>'s mother was a <mask>-based actress, <mask>.", 5, False]],
                     description="Enter a text prompt to generate text. Make sure using <mask> to replace entities.")


if __name__ == "__main__":
    demo.launch()