Spaces:
Build error
Build error
Renegadesoffun
commited on
Commit
·
703ea1c
1
Parent(s):
8f0d2e8
Updated for CPU evalgguf2
Browse files
app.py
CHANGED
|
@@ -1,35 +1,27 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from
|
| 3 |
-
import torch
|
| 4 |
|
| 5 |
-
model_name = "TheBloke/TinyLlama-1.1B-Chat-v0.3-GGUF"
|
| 6 |
|
| 7 |
# Load model and tokenizer
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
-
# Set model to
|
| 12 |
-
model.eval()
|
| 13 |
|
| 14 |
st.title("Buddy Christ Chatbot")
|
| 15 |
|
| 16 |
user_input = st.text_input("You:", "")
|
| 17 |
-
|
| 18 |
if user_input:
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
# Print and display full response
|
| 32 |
-
print(response_text)
|
| 33 |
-
response_text = tokenizer.decode(response[0])
|
| 34 |
-
|
| 35 |
-
st.write("Buddy Christ:", response_text)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 3 |
|
| 4 |
+
model_name = "TheBloke/TinyLlama-1.1B-Chat-v0.3-GGUF"
|
| 5 |
|
| 6 |
# Load model and tokenizer
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 8 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 9 |
|
| 10 |
+
# Set model to evaluation mode
|
| 11 |
+
model.eval()
|
| 12 |
|
| 13 |
st.title("Buddy Christ Chatbot")
|
| 14 |
|
| 15 |
user_input = st.text_input("You:", "")
|
|
|
|
| 16 |
if user_input:
|
| 17 |
+
# Encode the user input
|
| 18 |
+
inputs = tokenizer.encode(user_input, return_tensors="pt", truncation=True, max_length=1000)
|
| 19 |
+
|
| 20 |
+
# Generate a response using the model
|
| 21 |
+
response = model.generate(inputs, max_length=1000, temperature=1.0, top_k=10, pad_token_id=tokenizer.eos_token_id, gguf_mode=True)
|
| 22 |
+
|
| 23 |
+
# Decode the response
|
| 24 |
+
response_text = tokenizer.decode(response[0], skip_special_tokens=True)
|
| 25 |
+
|
| 26 |
+
# Display the response in Streamlit
|
| 27 |
+
st.write("Buddy Christ:", response_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|