Spaces:
Sleeping
Sleeping
ravi.naik
commited on
Commit
·
341d7fc
1
Parent(s):
472a7ec
updated bnb configs
Browse files
app.py
CHANGED
@@ -9,20 +9,14 @@ from transformers import (
|
|
9 |
|
10 |
model_name = "RaviNaik/Phi2-Osst"
|
11 |
|
12 |
-
|
13 |
-
load_in_4bit=True,
|
14 |
-
bnb_4bit_quant_type="nf4",
|
15 |
-
bnb_4bit_compute_dtype=torch.float16,
|
16 |
-
)
|
17 |
-
|
18 |
model = AutoModelForCausalLM.from_pretrained(
|
19 |
model_name,
|
20 |
-
quantization_config=bnb_config,
|
21 |
trust_remote_code=True,
|
22 |
-
device_map=
|
23 |
)
|
24 |
model.config.use_cache = False
|
25 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True, device_map=
|
26 |
tokenizer.pad_token = tokenizer.eos_token
|
27 |
chat_template = """<|im_start|>system
|
28 |
You are a helpful assistant who always respond to user queries<|im_end|>
|
|
|
9 |
|
10 |
model_name = "RaviNaik/Phi2-Osst"
|
11 |
|
12 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
|
|
|
|
|
|
|
13 |
model = AutoModelForCausalLM.from_pretrained(
|
14 |
model_name,
|
|
|
15 |
trust_remote_code=True,
|
16 |
+
device_map=device
|
17 |
)
|
18 |
model.config.use_cache = False
|
19 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True, device_map=device)
|
20 |
tokenizer.pad_token = tokenizer.eos_token
|
21 |
chat_template = """<|im_start|>system
|
22 |
You are a helpful assistant who always respond to user queries<|im_end|>
|