Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,15 +6,19 @@ import os
|
|
6 |
# Cargar el token de Hugging Face desde los secretos
|
7 |
token = os.environ.get("HF_TOKEN")
|
8 |
|
9 |
-
|
10 |
-
model_id = "PrunaAI/google-shieldgemma-2b-bnb-4bit-smashed"
|
11 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id, token=token)
|
12 |
|
13 |
-
#
|
|
|
|
|
|
|
|
|
|
|
14 |
model = AutoModelForCausalLM.from_pretrained(
|
15 |
model_id,
|
16 |
-
|
17 |
-
|
|
|
18 |
token=token
|
19 |
)
|
20 |
|
|
|
6 |
# Cargar el token de Hugging Face desde los secretos
|
7 |
token = os.environ.get("HF_TOKEN")
|
8 |
|
9 |
+
model_id = "google/shieldgemma-2b"
|
|
|
|
|
10 |
|
11 |
+
# use quantization to lower GPU usage
|
12 |
+
bnb_config = BitsAndBytesConfig(
|
13 |
+
load_in_4bit=True, bnb_4bit_use_double_quant=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.bfloat16
|
14 |
+
)
|
15 |
+
|
16 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id,token=token)
|
17 |
model = AutoModelForCausalLM.from_pretrained(
|
18 |
model_id,
|
19 |
+
torch_dtype=torch.bfloat16,
|
20 |
+
device_map="auto",
|
21 |
+
quantization_config=bnb_config,
|
22 |
token=token
|
23 |
)
|
24 |
|