Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
810bbae
1
Parent(s):
26dc4f5
Fix tokenizer loading issue with use_fast parameter
Browse files
app.py
CHANGED
@@ -8,11 +8,17 @@ DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
|
8 |
|
9 |
# Initialize model and tokenizer
|
10 |
print(f"Loading model {MODEL_ID}...")
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
12 |
model = AutoModelForCausalLM.from_pretrained(
|
13 |
MODEL_ID,
|
14 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
15 |
-
device_map="auto" if torch.cuda.is_available() else None
|
|
|
16 |
)
|
17 |
|
18 |
if not torch.cuda.is_available():
|
|
|
8 |
|
9 |
# Initialize model and tokenizer
|
10 |
print(f"Loading model {MODEL_ID}...")
|
11 |
+
try:
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, use_fast=False)
|
13 |
+
except Exception as e:
|
14 |
+
print(f"Failed to load tokenizer with use_fast=False, trying with use_fast=True: {e}")
|
15 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, use_fast=True, trust_remote_code=True)
|
16 |
+
|
17 |
model = AutoModelForCausalLM.from_pretrained(
|
18 |
MODEL_ID,
|
19 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
20 |
+
device_map="auto" if torch.cuda.is_available() else None,
|
21 |
+
trust_remote_code=True
|
22 |
)
|
23 |
|
24 |
if not torch.cuda.is_available():
|