Spaces:
Paused
Paused
π§ Fix tokenizer compatibility + add fallback model for HF Spaces
Browse files- app.py +23 -8
- requirements.txt +10 -10
app.py
CHANGED
@@ -16,14 +16,29 @@ import re
|
|
16 |
# Initialize model
|
17 |
print("π Loading Jan v1 model...")
|
18 |
model_name = "janhq/Jan-v1-4B"
|
19 |
-
|
20 |
-
|
21 |
-
model_name,
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
class SimpleWebSearch:
|
29 |
def __init__(self):
|
|
|
16 |
# Initialize model
|
17 |
print("π Loading Jan v1 model...")
|
18 |
model_name = "janhq/Jan-v1-4B"
|
19 |
+
|
20 |
+
try:
|
21 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
22 |
+
model = AutoModelForCausalLM.from_pretrained(
|
23 |
+
model_name,
|
24 |
+
torch_dtype=torch.bfloat16,
|
25 |
+
device_map="auto",
|
26 |
+
load_in_8bit=True,
|
27 |
+
trust_remote_code=True
|
28 |
+
)
|
29 |
+
print("β
Jan v1 loaded successfully!")
|
30 |
+
except Exception as e:
|
31 |
+
print(f"β Error loading Jan v1: {e}")
|
32 |
+
print("π Falling back to basic model...")
|
33 |
+
# Fallback to a simpler model that works on HF Spaces
|
34 |
+
model_name = "microsoft/DialoGPT-medium"
|
35 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
36 |
+
model = AutoModelForCausalLM.from_pretrained(
|
37 |
+
model_name,
|
38 |
+
torch_dtype=torch.float16,
|
39 |
+
device_map="auto"
|
40 |
+
)
|
41 |
+
print("β
Fallback model loaded!")
|
42 |
|
43 |
class SimpleWebSearch:
|
44 |
def __init__(self):
|
requirements.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
# Jan v1 Research Assistant - Complete requirements
|
2 |
-
transformers
|
3 |
-
torch
|
4 |
-
gradio
|
5 |
-
accelerate
|
6 |
-
bitsandbytes
|
7 |
-
sentencepiece
|
8 |
-
beautifulsoup4
|
9 |
-
requests
|
10 |
-
lxml
|
11 |
-
validators
|
|
|
1 |
# Jan v1 Research Assistant - Complete requirements
|
2 |
+
transformers>=4.40.0
|
3 |
+
torch>=2.0.0
|
4 |
+
gradio>=4.19.0
|
5 |
+
accelerate>=0.25.0
|
6 |
+
bitsandbytes>=0.42.0
|
7 |
+
sentencepiece>=0.1.99
|
8 |
+
beautifulsoup4>=4.12.0
|
9 |
+
requests>=2.31.0
|
10 |
+
lxml>=5.1.0
|
11 |
+
validators>=0.22.0
|