muqeet1234 commited on
Commit
b66a1b6
·
verified ·
1 Parent(s): 5284951

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py CHANGED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load the question-answering pipeline
5
+ qa_model = pipeline("question-answering", model="distilbert-base-cased-distilled-squad")
6
+
7
+ # Pre-defined FAQ context
8
+ FAQ_CONTEXT = """
9
+ Streamlit is an open-source app framework for Machine Learning and Data Science projects.
10
+ It helps developers create interactive and user-friendly applications quickly.
11
+ Hugging Face Spaces is a platform for hosting ML models and applications, including Streamlit apps.
12
+ To deploy a Streamlit app on Hugging Face Spaces, you need to upload your app code and requirements file.
13
+ DistilBERT is a smaller, faster, and cheaper version of BERT, designed for NLP tasks.
14
+ """
15
+
16
+ # Streamlit app
17
+ st.title("FAQ Chatbot")
18
+ st.write("Ask a question about Streamlit, Hugging Face, or DistilBERT, and I’ll provide an answer!")
19
+
20
+ # User input
21
+ question = st.text_input("Enter your question:")
22
+
23
+ if question:
24
+ # Perform question answering
25
+ result = qa_model(question=question, context=FAQ_CONTEXT)
26
+ answer = result["answer"]
27
+
28
+ # Display the answer
29
+ st.write("### Answer:")
30
+ st.write(answer)