Spaces:
Runtime error
Runtime error
Create app.py
Browse files
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']}")
|