Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,27 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
| 4 |
qa_pipeline = pipeline("text-generation", model="EleutherAI/gpt-neo-125m")
|
| 5 |
|
|
|
|
| 6 |
st.title("GPT-Neo 125M Q&A App")
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Generate answer
|
| 12 |
if user_question:
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load the model
|
| 5 |
qa_pipeline = pipeline("text-generation", model="EleutherAI/gpt-neo-125m")
|
| 6 |
|
| 7 |
+
# Streamlit interface
|
| 8 |
st.title("GPT-Neo 125M Q&A App")
|
| 9 |
|
| 10 |
+
# Example questions
|
| 11 |
+
example_questions = [
|
| 12 |
+
"Who is Spider-Man?",
|
| 13 |
+
"Who is Venom?",
|
| 14 |
+
"Who is OpenAI?",
|
| 15 |
+
"Who is Rocket Raccoon?"
|
| 16 |
+
]
|
| 17 |
+
|
| 18 |
+
st.subheader("Select an example question or type your own:")
|
| 19 |
+
selected_question = st.selectbox("Choose an example question", example_questions)
|
| 20 |
+
user_question = st.text_input("Or ask your own question:", value=selected_question)
|
| 21 |
|
| 22 |
# Generate answer
|
| 23 |
if user_question:
|
| 24 |
+
with st.spinner('Generating answer...'):
|
| 25 |
+
response = qa_pipeline(user_question, max_length=50)
|
| 26 |
+
answer = response[0]['generated_text']
|
| 27 |
+
st.write(answer)
|