File size: 682 Bytes
88472e6
53d4151
ca0b264
88472e6
6197243
88472e6
f54a6f9
 
ca0b264
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from transformers import pipeline
import streamlit as st

st.title("Question Answering with XLM-RoBERTa")

# Load the question-answering pipeline with the new model
with st.spinner('Loading model...'):
    qa_pipeline = pipeline("question-answering", model="IProject-10/xlm-roberta-base-finetuned-squad2")

context = st.text_area("Context", "Provide the context here...")
question = st.text_input("Question", "Ask your question here...")

if st.button("Get Answer"):
    if context and question:
        result = qa_pipeline(question=question, context=context)
        st.write(f"Answer: {result['answer']}")
    else:
        st.write("Please provide both context and a question.")