Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,12 +8,13 @@ MODEL_ID = "Cydercoder/qwen2.5-coder-3b"
|
|
| 8 |
|
| 9 |
print("Loading tokenizer...")
|
| 10 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
model = AutoModelForCausalLM.from_pretrained(
|
| 14 |
MODEL_ID,
|
| 15 |
torch_dtype=torch.float32,
|
| 16 |
-
|
| 17 |
)
|
| 18 |
|
| 19 |
def chat_function(message, history):
|
|
@@ -51,7 +52,7 @@ def chat_function(message, history):
|
|
| 51 |
partial_text += new_text
|
| 52 |
yield partial_text
|
| 53 |
|
| 54 |
-
# 4. Initialize the
|
| 55 |
demo = gr.ChatInterface(
|
| 56 |
fn=chat_function,
|
| 57 |
title="🤖 Cydercoder Qwen 3B AI Chatbot",
|
|
|
|
| 8 |
|
| 9 |
print("Loading tokenizer...")
|
| 10 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
| 11 |
+
|
| 12 |
+
print("Loading model on CPU via standard clean mapping...")
|
| 13 |
+
# Forcing float32 without low_cpu_mem_usage prevents the Transformers v5 thread crash
|
| 14 |
model = AutoModelForCausalLM.from_pretrained(
|
| 15 |
MODEL_ID,
|
| 16 |
torch_dtype=torch.float32,
|
| 17 |
+
device_map="cpu"
|
| 18 |
)
|
| 19 |
|
| 20 |
def chat_function(message, history):
|
|
|
|
| 52 |
partial_text += new_text
|
| 53 |
yield partial_text
|
| 54 |
|
| 55 |
+
# 4. Initialize the native Gradio browser interface
|
| 56 |
demo = gr.ChatInterface(
|
| 57 |
fn=chat_function,
|
| 58 |
title="🤖 Cydercoder Qwen 3B AI Chatbot",
|