savan360 commited on
Commit
d44146d
·
verified ·
1 Parent(s): fe708c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -1,18 +1,21 @@
1
- from transformers import AutoTokenizer, AutoModelForCausalLM
2
- import torch
3
 
4
  MODEL_ID = "savan360/Qwen_prompt_creator"
5
- SUBFOLDER = "merged" # or "adapter" if you’re using the LoRA route
6
 
7
- tokenizer = AutoTokenizer.from_pretrained(
8
- MODEL_ID, subfolder=SUBFOLDER, trust_remote_code=True
9
- )
 
 
 
 
 
10
 
 
11
  model = AutoModelForCausalLM.from_pretrained(
12
  MODEL_ID,
13
- subfolder=SUBFOLDER,
14
- dtype=torch.float16, # <- replaces deprecated torch_dtype
15
- device_map="auto",
16
  trust_remote_code=True,
17
- quantization_config=None # <- THIS LINE disables auto 4-bit path
 
18
  )
 
1
+ from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
 
2
 
3
  MODEL_ID = "savan360/Qwen_prompt_creator"
 
4
 
5
+ cfg = AutoConfig.from_pretrained(MODEL_ID, trust_remote_code=True)
6
+
7
+ # ---- PATCH: remove/normalize bad quantization_config ----
8
+ if hasattr(cfg, "quantization_config"):
9
+ qc = getattr(cfg, "quantization_config")
10
+ if qc is None:
11
+ # remove the attribute entirely; from_pretrained doesn't need it if you're not quantizing via HF APIs
12
+ delattr(cfg, "quantization_config")
13
 
14
+ tok = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
15
  model = AutoModelForCausalLM.from_pretrained(
16
  MODEL_ID,
17
+ config=cfg,
 
 
18
  trust_remote_code=True,
19
+ torch_dtype="auto",
20
+ device_map="auto",
21
  )