Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -26,17 +26,22 @@ config['device'] = 'cpu' # mps
|
|
26 |
recognitor = Predictor(config)
|
27 |
model_name = "microsoft/xdoc-base-squad2.0"
|
28 |
nlp = pipeline('question-answering', model=model_name)
|
29 |
-
|
30 |
-
|
|
|
31 |
result={}
|
32 |
for question in questions:
|
33 |
QA_input = {
|
34 |
'question': question,
|
35 |
'context': doc
|
36 |
}
|
37 |
-
|
38 |
res= nlp(QA_input)
|
39 |
-
|
|
|
|
|
|
|
|
|
40 |
result[question]=value
|
41 |
return result
|
42 |
|
|
|
26 |
recognitor = Predictor(config)
|
27 |
model_name = "microsoft/xdoc-base-squad2.0"
|
28 |
nlp = pipeline('question-answering', model=model_name)
|
29 |
+
|
30 |
+
def query(doc, labels):
|
31 |
+
questions = labels.split(", ")
|
32 |
result={}
|
33 |
for question in questions:
|
34 |
QA_input = {
|
35 |
'question': question,
|
36 |
'context': doc
|
37 |
}
|
38 |
+
print(QA_input)
|
39 |
res= nlp(QA_input)
|
40 |
+
print(res)
|
41 |
+
if res['score']>0.5:
|
42 |
+
value = res['answer']
|
43 |
+
else:
|
44 |
+
value=''
|
45 |
result[question]=value
|
46 |
return result
|
47 |
|