Saanvi12011 commited on
Commit
5a64aa9
·
verified ·
1 Parent(s): 138ba06

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Initialize question-answering pipeline
5
+ qa_model = pipeline("question-answering", model="distilbert-base-cased-distilled-squad")
6
+
7
+ st.title("Question-Answering System")
8
+ st.write("Provide a paragraph and ask a question to get an answer.")
9
+
10
+ context = st.text_area("Enter the context paragraph:", placeholder="Paste your context here...")
11
+ question = st.text_input("Enter your question:", placeholder="Ask something about the context...")
12
+
13
+ if st.button("Get Answer"):
14
+ if not context.strip() or not question.strip():
15
+ st.error("Please provide both a context and a question.")
16
+ else:
17
+ with st.spinner("Finding the answer..."):
18
+ answer = qa_model(question=question, context=context)
19
+ st.subheader("Answer:")
20
+ st.write(answer["answer"])