Spaces:
Runtime error
Runtime error
Commit
•
be6a27c
1
Parent(s):
5c29784
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,25 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
if text:
|
8 |
-
out = pipe(text)
|
9 |
-
st.json(out)
|
10 |
-
|
11 |
#from transformers import pipeline
|
12 |
|
13 |
#model_name = "deepset/xlm-roberta-large-squad2"
|
|
|
1 |
import streamlit as st
|
2 |
+
import transformers
|
3 |
from transformers import pipeline
|
4 |
+
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
|
5 |
|
6 |
+
model_name = 'deepset/xlm-roberta-large-squad2'
|
7 |
+
|
8 |
+
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
|
9 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
10 |
+
|
11 |
+
# a) Get predictions
|
12 |
+
ctx = st.text_area('Gib context')
|
13 |
+
q = st.text_area('Gib question')
|
14 |
+
|
15 |
+
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
|
16 |
+
#QA_input = {
|
17 |
+
# 'question': 'Why is model conversion important?',
|
18 |
+
# 'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.'
|
19 |
+
#}
|
20 |
+
res = nlp(context=ctx, question=q)
|
21 |
+
st.json(res["answer"])
|
22 |
|
|
|
|
|
|
|
|
|
23 |
#from transformers import pipeline
|
24 |
|
25 |
#model_name = "deepset/xlm-roberta-large-squad2"
|