Spaces:
Running
Running
Added HF key to visualize_pca.py
Browse files- utils/visualize_pca.py +11 -2
utils/visualize_pca.py
CHANGED
|
@@ -22,6 +22,9 @@ def load_model_tokenizer(model_name: str):
|
|
| 22 |
"""
|
| 23 |
logger.info(f"Loading model and tokenizer for '{model_name}'")
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
# Device selection: MPS (Apple Silicon) > CUDA > CPU
|
| 26 |
if torch.cuda.is_available():
|
| 27 |
device = torch.device("cuda")
|
|
@@ -31,8 +34,14 @@ def load_model_tokenizer(model_name: str):
|
|
| 31 |
device = torch.device("cpu")
|
| 32 |
logger.info(f"Using device: {device}")
|
| 33 |
|
| 34 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
model = model.to(device)
|
| 38 |
|
|
|
|
| 22 |
"""
|
| 23 |
logger.info(f"Loading model and tokenizer for '{model_name}'")
|
| 24 |
|
| 25 |
+
# Get HF token from environment for gated models
|
| 26 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 27 |
+
|
| 28 |
# Device selection: MPS (Apple Silicon) > CUDA > CPU
|
| 29 |
if torch.cuda.is_available():
|
| 30 |
device = torch.device("cuda")
|
|
|
|
| 34 |
device = torch.device("cpu")
|
| 35 |
logger.info(f"Using device: {device}")
|
| 36 |
|
| 37 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 38 |
+
model_name,
|
| 39 |
+
token=hf_token # ← AÑADIR ESTA LÍNEA
|
| 40 |
+
)
|
| 41 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 42 |
+
model_name,
|
| 43 |
+
token=hf_token # ← AÑADIR ESTA LÍNEA
|
| 44 |
+
)
|
| 45 |
|
| 46 |
model = model.to(device)
|
| 47 |
|