awacke1 commited on
Commit
a63d286
1 Parent(s): bf7d87d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ st.title("Question Answering with Hugging Face")
5
+
6
+ model_name = "distilbert-base-cased-distilled-squad"
7
+ nlp = pipeline("question-answering", model=model_name)
8
+
9
+ context = st.text_area("Enter the context here:")
10
+
11
+ if not context:
12
+ st.warning("Please enter a context.")
13
+ else:
14
+ question = st.text_input("Enter your question here:")
15
+ if not question:
16
+ st.warning("Please enter a question.")
17
+ else:
18
+ answer = nlp({"question": question, "context": context})
19
+ st.write(f"Answer: {answer['answer']}")