Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the QA pipeline with the specified model
|
5 |
+
qa_pipeline = pipeline("question-answering", model="Suhaib-27/my_awesome_qa_model")
|
6 |
+
|
7 |
+
# Streamlit app
|
8 |
+
st.title("Question Answering with Transformers")
|
9 |
+
st.write("Enter the context and the question, and the model will provide the answer.")
|
10 |
+
|
11 |
+
# Input fields for context and question
|
12 |
+
context = st.text_area("Context", height=200)
|
13 |
+
question = st.text_input("Question")
|
14 |
+
|
15 |
+
# If context and question are provided, perform the inference
|
16 |
+
if context and question:
|
17 |
+
# Get the answer from the pipeline
|
18 |
+
result = qa_pipeline(question=question, context=context)
|
19 |
+
answer = result['answer']
|
20 |
+
|
21 |
+
st.write("### Answer")
|
22 |
+
st.write(answer)
|