Spaces:
Build error
Build error
File size: 1,049 Bytes
3ff518e b78672c 08f4c14 c9bbb12 3ff518e b78672c 08f4c14 c9bbb12 3ff518e de9b0be 3ff518e 08f4c14 c9bbb12 3ff518e 08f4c14 3ff518e 08f4c14 c9bbb12 3ff518e c9bbb12 08f4c14 |
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 32 |
import streamlit as st
from huggingface_hub import hf_hub_download
from llama_cpp import Llama
# Set up model from public Hugging Face repo
REPO_ID = "MaziyarPanahi/BioMistral-7B-GGUF"
FILENAME = "BioMistral-7B.Q4_K_M.gguf"
st.set_page_config(page_title="🩺 Medical Chatbot")
st.title("🧠 Medical Chatbot using BioMistral")
# Download from HF Hub (automatically caches)
with st.spinner("📥 Downloading BioMistral model from Hugging Face..."):
model_path = hf_hub_download(repo_id=REPO_ID, filename=FILENAME)
# Load the GGUF model with llama-cpp-python
with st.spinner("⚙️ Loading the model into memory..."):
llm = Llama(
model_path=model_path,
n_ctx=4096,
n_threads=8,
n_gpu_layers=35 # Use 0 for CPU-only
)
# UI to get user input
query = st.text_input("💬 Ask a medical question:")
if query:
with st.spinner("🧠 Thinking..."):
response = llm(query, max_tokens=512, stop=["</s>"])
st.markdown("**Answer:**")
st.write(response["choices"][0]["text"].strip())
|