Spaces:
Running
on
L4
Running
on
L4
Update app.py
Browse files
app.py
CHANGED
@@ -22,14 +22,19 @@ bnb_config = BitsAndBytesConfig(
|
|
22 |
#bnb_4bit_use_double_quant=True
|
23 |
)
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
model
|
|
|
|
|
|
|
|
|
|
|
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 |
|