Cydercoder commited on
Commit
d247b31
·
verified ·
1 Parent(s): dfffdfa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
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
- print("Loading model on CPU (Free Tier)...")
12
- # We load in 8-bit or float32 to fit inside the free 16GB CPU RAM limit safely
 
13
  model = AutoModelForCausalLM.from_pretrained(
14
  MODEL_ID,
15
  torch_dtype=torch.float32,
16
- low_cpu_mem_usage=True
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 gorgeous, interactive native Gradio browser interface
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",