Spaces:
Runtime error
Runtime error
Pavankalyan
commited on
Commit
•
4e12acb
1
Parent(s):
ddb6e98
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
-
from
|
4 |
import os
|
5 |
-
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
|
6 |
|
7 |
-
model_name = "deepset/deberta-v3-large-squad2"
|
8 |
|
9 |
-
# a) Get predictions
|
10 |
-
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
|
11 |
|
12 |
|
13 |
|
14 |
hf_writer = gr.HuggingFaceDatasetSaver('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', "Pavankalyan/chitti_data")
|
15 |
|
16 |
-
df = pd.read_csv("Responses.csv")
|
17 |
-
text = list(df["text"].values)
|
18 |
-
|
19 |
|
20 |
def chitti(query):
|
21 |
-
re_table = search(query
|
22 |
answers_re_table = [re_table[i][0] for i in range(0,5)]
|
|
|
23 |
sorted_indices = sorted(range(len(answers_re_table)), key=lambda k: len(answers_re_table[k]))
|
24 |
repeated_answers_indices =list()
|
25 |
for i in range(4):
|
@@ -27,19 +21,15 @@ def chitti(query):
|
|
27 |
repeated_answers_indices.append(sorted_indices[i])
|
28 |
for idx in repeated_answers_indices:
|
29 |
answers_re_table.pop(idx)
|
|
|
30 |
|
31 |
-
QA_input = {'question': query,'context': answers_re_table[0]}
|
32 |
-
res1 = nlp(QA_input)['answer']
|
33 |
-
QA_input = {'question': query,'context': answers_re_table[1]}
|
34 |
-
res2 = nlp(QA_input)['answer']
|
35 |
#return [res1,answers_re_table[0],res2,answers_re_table[1]]
|
36 |
-
return [answers_re_table[0],answers_re_table[1]]
|
37 |
|
38 |
demo = gr.Interface(
|
39 |
fn=chitti,
|
40 |
inputs=["text"],
|
41 |
-
|
42 |
-
outputs=["text","text"],
|
43 |
allow_flagging = "manual",
|
44 |
flagging_options = ["0","1","None"],
|
45 |
flagging_callback=hf_writer
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
+
from load_data import *
|
4 |
import os
|
|
|
5 |
|
|
|
6 |
|
|
|
|
|
7 |
|
8 |
|
9 |
|
10 |
hf_writer = gr.HuggingFaceDatasetSaver('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', "Pavankalyan/chitti_data")
|
11 |
|
|
|
|
|
|
|
12 |
|
13 |
def chitti(query):
|
14 |
+
re_table = search(query)
|
15 |
answers_re_table = [re_table[i][0] for i in range(0,5)]
|
16 |
+
answer_links = [re_table[i][3] for i in range(0,5)]
|
17 |
sorted_indices = sorted(range(len(answers_re_table)), key=lambda k: len(answers_re_table[k]))
|
18 |
repeated_answers_indices =list()
|
19 |
for i in range(4):
|
|
|
21 |
repeated_answers_indices.append(sorted_indices[i])
|
22 |
for idx in repeated_answers_indices:
|
23 |
answers_re_table.pop(idx)
|
24 |
+
answer_links.pop(idx)
|
25 |
|
|
|
|
|
|
|
|
|
26 |
#return [res1,answers_re_table[0],res2,answers_re_table[1]]
|
27 |
+
return [answers_re_table[0],answers_links[0],answers_re_table[1],answer_links[1]]
|
28 |
|
29 |
demo = gr.Interface(
|
30 |
fn=chitti,
|
31 |
inputs=["text"],
|
32 |
+
outputs=["text","text","text","text"],
|
|
|
33 |
allow_flagging = "manual",
|
34 |
flagging_options = ["0","1","None"],
|
35 |
flagging_callback=hf_writer
|