Spaces:
Build error
Build error
noelstan99 commited on
Commit ·
d7a1db1
1
Parent(s): 67e7cfb
Add EdStem Chatbot Demo with Streamlit and LLaMA model integration
Browse filesFiles changed (4)
- README.md+19-9
- app.pyAdded+55
- packages.txtAdded+4
- requirments.txtAdded+3
12345678910111213---title: EdstemBot Demoemoji: 📉colorFrom: pinkcolorTo: graysdk: streamlitsdk_version: 1.41.1app_file: app.pypinned: falseshort_description: Demo Space for CS4641/CS7641 Edstem chat bot---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference1234567891011121314151617181920212223---title: "EdStem Chatbot Demo"emoji: "🤖"colorFrom: "blue"colorTo: "purple"sdk: "streamlit"sdk_version: "1.23.0"app_file: "app.py"pinned: false---# EdStem Chatbot DemoA Streamlit app showcasing a fine-tuned LLaMA 3.1 model for course-related Q&A. Try asking your questions and see how the chatbot performs!**Features:**- Interactive chat interface- Pretrained on course-related data- Built with 🤗 Transformers and Streamlit### Instructions1. Type your question in the input box.2. View the bot's response in the chat history.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import streamlit as stfrom transformers import AutoModelForCausalLM, AutoTokenizerimport torch
# Load model and tokenizer@st.cache_resourcedef load_model(): model_name = "meta-llama/Llama-3.1-8B" # Replace with the model path or identifier tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float32) return tokenizer, model
tokenizer, model = load_model()
# App UIst.set_page_config( page_title="EdStem Chatbot Demo", page_icon="🤖", layout="wide",)
st.title("🤖 EdStem Chatbot Demo")st.markdown( """ This is a demo of a fine-tuned LLaMA 3.1 model for EdStem course-related Q&A. Enter your questions below and see how the chatbot responds! """)
# Initialize session stateif "messages" not in st.session_state: st.session_state.messages = []
# Chat Interfacedef add_message(user_message, bot_message): st.session_state.messages.append({"user": user_message, "bot": bot_message})
# Input boxuser_input = st.text_input("Type your message:", placeholder="Ask a course-related question here...")
if user_input: # Generate response inputs = tokenizer(user_input, return_tensors="pt") outputs = model.generate(inputs["input_ids"], max_length=200, num_return_sequences=1) response = tokenizer.decode(outputs[0], skip_special_tokens=True) # Add to conversation add_message(user_input, response)
# Display chat historyst.write("---")for chat in st.session_state.messages: st.markdown(f"**You:** {chat['user']}") st.markdown(f"**Bot:** {chat['bot']}") st.write("---")1234libglib2.0-0libsm6libxrender1libxext6123transformers>=4.46.1torch>=1.13.0safetensorsREADME.md+19-9
app.pyAdded+55
packages.txtAdded+4
requirments.txtAdded+3