Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# model = AutoModelForCausalLM.from_pretrained("Karzan/ckb-gpt2-medium-base-test-1024")
|
5 |
+
model_id = "Karzan/bart-qa-ckb"
|
6 |
+
pipe = pipeline("text2text-generation", model=model_id,max_answer_len=300,handle_impossible_answer=True,top_k=1)
|
7 |
+
|
8 |
+
|
9 |
+
def func(context, question):
|
10 |
+
result = pipe(question = question, context=context)
|
11 |
+
return result['answer']
|
12 |
+
|
13 |
+
|
14 |
+
text_input = gr.Textbox(lines=10, placeholder="Enter your text here", label="Your Text")
|
15 |
+
text_outputs = gr.Textbox(lines=10)
|
16 |
+
# submit_btn = gr.Button(value="Generate",variant="secondary")
|
17 |
+
|
18 |
+
interface = gr.Interface(
|
19 |
+
fn=func,
|
20 |
+
inputs=text_input,
|
21 |
+
inputs=[gr.Textbox(lines=7, label="Context paragraph"), gr.Textbox(lines=2, label="Question")],
|
22 |
+
outputs=[gr.Textbox(label="Answer"), gr.Textbox(label="Score")],
|
23 |
+
# submit_btn=submit_btn,
|
24 |
+
)
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
interface.launch()
|