Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import pipeline
|
3 |
-
|
|
|
4 |
|
5 |
def main():
|
6 |
st.title("Chatbot with Hugging Face Model")
|
7 |
|
8 |
# Check if the model is already saved locally
|
9 |
-
model_path = "./zephyr-7b-beta"
|
10 |
try:
|
11 |
-
pipe = pipeline("text-generation", model=
|
12 |
except:
|
13 |
# If not saved, load the model and save it
|
14 |
st.warning("Model not found locally. Downloading and saving the model. Please wait...")
|
15 |
pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", torch_dtype=torch.bfloat16, device_map="auto")
|
16 |
-
pipe.save_pretrained(
|
17 |
|
18 |
# Define chat messages
|
19 |
messages = [
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
MODEL_PATH = "zephyr_7b_beta_model"
|
5 |
|
6 |
def main():
|
7 |
st.title("Chatbot with Hugging Face Model")
|
8 |
|
9 |
# Check if the model is already saved locally
|
|
|
10 |
try:
|
11 |
+
pipe = pipeline("text-generation", model=MODEL_PATH, torch_dtype=torch.bfloat16, device_map="auto")
|
12 |
except:
|
13 |
# If not saved, load the model and save it
|
14 |
st.warning("Model not found locally. Downloading and saving the model. Please wait...")
|
15 |
pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", torch_dtype=torch.bfloat16, device_map="auto")
|
16 |
+
pipe.save_pretrained(MODEL_PATH)
|
17 |
|
18 |
# Define chat messages
|
19 |
messages = [
|