Spaces:
Sleeping
Sleeping
| 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) | |