Spaces:
Running
Running
eureka commited on
Commit ·
226a425
1
Parent(s): 68a5d48
Fix tokenizer compatibility issue with fallback to slow tokenizer
Browse files
app.py
CHANGED
|
@@ -50,7 +50,12 @@ class DesklibAIDetectionModel(PreTrainedModel):
|
|
| 50 |
|
| 51 |
|
| 52 |
def load_model():
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
model = DesklibAIDetectionModel.from_pretrained(MODEL_ID, cache_dir=HF_CACHE_DIR)
|
| 55 |
model.to(DEVICE)
|
| 56 |
model.eval()
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
def load_model():
|
| 53 |
+
# Try fast tokenizer first, fall back to slow tokenizer if there's a compatibility issue
|
| 54 |
+
try:
|
| 55 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, cache_dir=HF_CACHE_DIR, use_fast=True)
|
| 56 |
+
except Exception as e:
|
| 57 |
+
print(f"Warning: Fast tokenizer failed ({e}), falling back to slow tokenizer")
|
| 58 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, cache_dir=HF_CACHE_DIR, use_fast=False)
|
| 59 |
model = DesklibAIDetectionModel.from_pretrained(MODEL_ID, cache_dir=HF_CACHE_DIR)
|
| 60 |
model.to(DEVICE)
|
| 61 |
model.eval()
|