samidh commited on
Commit
cad7e4e
·
verified ·
1 Parent(s): e771d98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -22,14 +22,19 @@ bnb_config = BitsAndBytesConfig(
22
  #bnb_4bit_use_double_quant=True
23
  )
24
 
25
- model = AutoModelForCausalLM.from_pretrained(base_model_name,
26
- token=os.environ['HF_TOKEN'],
27
- quantization_config=bnb_config,
28
- device_map="auto")
29
- model = PeftModel.from_pretrained(model, adapter_model_name, token=os.environ['HF_TOKEN'])
30
- model.merge_and_unload()
31
-
32
- model = model.to(device)
 
 
 
 
 
33
 
34
  tokenizer = AutoTokenizer.from_pretrained(base_model_name)
35
 
 
22
  #bnb_4bit_use_double_quant=True
23
  )
24
 
25
+ @spaces.GPU
26
+ def load_model():
27
+ model = AutoModelForCausalLM.from_pretrained(base_model_name,
28
+ token=os.environ['HF_TOKEN'],
29
+ quantization_config=bnb_config,
30
+ device_map="auto")
31
+ model = PeftModel.from_pretrained(model, adapter_model_name, token=os.environ['HF_TOKEN'])
32
+ model.merge_and_unload()
33
+
34
+ model = model.to(device)
35
+ return model
36
+
37
+ model = load_model()
38
 
39
  tokenizer = AutoTokenizer.from_pretrained(base_model_name)
40