Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -204,18 +204,12 @@ def load_model():
|
|
204 |
print("Adding special tokens...")
|
205 |
tokenizer.add_special_tokens(special_tokens)
|
206 |
|
207 |
-
print("Loading model
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
print("Loading model weights...")
|
214 |
-
state_dict = torch.load(
|
215 |
-
os.path.join(model_id, "pytorch_model.bin"),
|
216 |
-
map_location="cpu"
|
217 |
)
|
218 |
-
model.load_state_dict(state_dict)
|
219 |
|
220 |
# Move model to device manually
|
221 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
204 |
print("Adding special tokens...")
|
205 |
tokenizer.add_special_tokens(special_tokens)
|
206 |
|
207 |
+
print("Loading model from Hugging Face Hub...")
|
208 |
+
model = AutoModelForCausalLM.from_pretrained(
|
209 |
+
model_id,
|
210 |
+
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
211 |
+
trust_remote_code=True
|
|
|
|
|
|
|
|
|
|
|
212 |
)
|
|
|
213 |
|
214 |
# Move model to device manually
|
215 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|