newtechdevng commited on
Commit
01f27e4
·
verified ·
1 Parent(s): f796207

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -1,16 +1,22 @@
1
  import gradio as gr
2
- from transformers import AutoTokenizer, AutoModelForCausalLM
3
  import torch
4
 
5
  print("Loading model...")
6
  MODEL_ID = "newtechdevng/qwen-math-tutor"
 
7
  tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
 
 
 
 
 
8
  model = AutoModelForCausalLM.from_pretrained(
9
  MODEL_ID,
10
- torch_dtype = torch.float32,
11
- device_map = "cpu",
12
- quantization_config = None,
13
  )
 
14
  print("Model loaded!")
15
 
16
  def solve(question, history):
@@ -40,7 +46,7 @@ def solve(question, history):
40
  skip_special_tokens=True
41
  )
42
 
43
- with gr.Blocks(title="Math Tutor AI") as demo: # ← theme removed from here
44
  gr.Markdown("""
45
  # 🧮 Math Tutor AI
46
  ### Powered by Qwen2.5-Math — Fine-tuned for NCERT & competitive math
@@ -74,4 +80,4 @@ with gr.Blocks(title="Math Tutor AI") as demo: # ← theme removed from here
74
  submit.click(respond, [question, chatbot], [question, chatbot])
75
  question.submit(respond, [question, chatbot], [question, chatbot])
76
 
77
- demo.launch(theme=gr.themes.Soft()) # ← theme moved to launch()
 
1
  import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM, AutoConfig
3
  import torch
4
 
5
  print("Loading model...")
6
  MODEL_ID = "newtechdevng/qwen-math-tutor"
7
+
8
  tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
9
+
10
+ # Load config and strip quantization settings
11
+ config = AutoConfig.from_pretrained(MODEL_ID)
12
+ config.quantization_config = {} # ← remove baked-in quantization
13
+
14
  model = AutoModelForCausalLM.from_pretrained(
15
  MODEL_ID,
16
+ config = config,
17
+ dtype = torch.float32, # ← fixed from torch_dtype
 
18
  )
19
+ model = model.to("cpu")
20
  print("Model loaded!")
21
 
22
  def solve(question, history):
 
46
  skip_special_tokens=True
47
  )
48
 
49
+ with gr.Blocks(title="Math Tutor AI") as demo:
50
  gr.Markdown("""
51
  # 🧮 Math Tutor AI
52
  ### Powered by Qwen2.5-Math — Fine-tuned for NCERT & competitive math
 
80
  submit.click(respond, [question, chatbot], [question, chatbot])
81
  question.submit(respond, [question, chatbot], [question, chatbot])
82
 
83
+ demo.launch(theme=gr.themes.Soft())