|
import streamlit as st |
|
from transformers.pipelines import pipeline |
|
from transformers.modeling_auto import AutoModelForQuestionAnswering |
|
from transformers.tokenization_auto import AutoTokenizer |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model_name = "deepset/xlm-roberta-base-squad2" |
|
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name) |
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(): |
|
st.title("Question & Answering") |
|
|
|
with st.form("text_field"): |
|
sentence_1= st.text_area('Enter Q1:') |
|
sentence_2= st.text_area('Enter Q2:') |
|
QA_input = {'question':sentence_1, 'context':sentence_2} |
|
|
|
clicked = st.form_submit_button("Submit") |
|
if clicked: |
|
results = nlp(QA_input) |
|
st.json(results) |
|
|
|
if __name__ == "__main__": |
|
main() |