Spaces:
Sleeping
Sleeping
Update model/model_utils.py
Browse files- model/model_utils.py +5 -2
model/model_utils.py
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 2 |
import torch
|
|
|
|
| 3 |
|
| 4 |
def load_model():
|
| 5 |
model_name = "bigcode/starcoder"
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
model.eval()
|
| 9 |
|
| 10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 1 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 2 |
import torch
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
def load_model():
|
| 6 |
model_name = "bigcode/starcoder"
|
| 7 |
+
hf_token = os.getenv("HF_TOKEN") # ✅ Securely pulled from Space Secrets
|
| 8 |
+
|
| 9 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=hf_token)
|
| 10 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, use_auth_token=hf_token, trust_remote_code=True)
|
| 11 |
model.eval()
|
| 12 |
|
| 13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|