Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,17 +3,38 @@ 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(
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
|
9 |
def func(context, question):
|
10 |
-
result = pipe(question
|
11 |
-
return result[
|
|
|
12 |
|
13 |
interface = gr.Interface(
|
14 |
fn=func,
|
15 |
-
inputs=[
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
# submit_btn=submit_btn,
|
18 |
)
|
19 |
|
|
|
3 |
|
4 |
# model = AutoModelForCausalLM.from_pretrained("Karzan/ckb-gpt2-medium-base-test-1024")
|
5 |
model_id = "Karzan/bart-qa-ckb"
|
6 |
+
pipe = pipeline(
|
7 |
+
"question-answering",
|
8 |
+
model=model_id,
|
9 |
+
max_answer_len=300,
|
10 |
+
handle_impossible_answer=True,
|
11 |
+
top_k=1,
|
12 |
+
)
|
13 |
|
14 |
|
15 |
def func(context, question):
|
16 |
+
result = pipe(question=question, context=context)
|
17 |
+
return result[0]["answer"], result[0]["score"], result[1]["answer"], result[1]["score"], result[2]["answer"], result[2]["score"], result[3]["answer"], result[3]["score"], result[4]["answer"], result[4]["score"]
|
18 |
+
|
19 |
|
20 |
interface = gr.Interface(
|
21 |
fn=func,
|
22 |
+
inputs=[
|
23 |
+
gr.Textbox(lines=7, label="Context paragraph"),
|
24 |
+
gr.Textbox(lines=2, label="Question"),
|
25 |
+
],
|
26 |
+
outputs=[
|
27 |
+
gr.Textbox(label="Answer 1"),
|
28 |
+
gr.Textbox(label="Score 1"),
|
29 |
+
gr.Textbox(label="Answer 2"),
|
30 |
+
gr.Textbox(label="Score 2"),
|
31 |
+
gr.Textbox(label="Answer 3"),
|
32 |
+
gr.Textbox(label="Score 3"),
|
33 |
+
gr.Textbox(label="Answer 4"),
|
34 |
+
gr.Textbox(label="Score 4"),
|
35 |
+
gr.Textbox(label="Answer 5"),
|
36 |
+
gr.Textbox(label="Score 5"),
|
37 |
+
],
|
38 |
# submit_btn=submit_btn,
|
39 |
)
|
40 |
|