File size: 1,123 Bytes
b66a1b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import streamlit as st
from transformers import pipeline

# Load the question-answering pipeline
qa_model = pipeline("question-answering", model="distilbert-base-cased-distilled-squad")

# Pre-defined FAQ context
FAQ_CONTEXT = """
Streamlit is an open-source app framework for Machine Learning and Data Science projects. 
It helps developers create interactive and user-friendly applications quickly. 
Hugging Face Spaces is a platform for hosting ML models and applications, including Streamlit apps.
To deploy a Streamlit app on Hugging Face Spaces, you need to upload your app code and requirements file.
DistilBERT is a smaller, faster, and cheaper version of BERT, designed for NLP tasks.
"""

# Streamlit app
st.title("FAQ Chatbot")
st.write("Ask a question about Streamlit, Hugging Face, or DistilBERT, and I’ll provide an answer!")

# User input
question = st.text_input("Enter your question:")

if question:
    # Perform question answering
    result = qa_model(question=question, context=FAQ_CONTEXT)
    answer = result["answer"]
    
    # Display the answer
    st.write("### Answer:")
    st.write(answer)