Spaces:
Runtime error
Runtime error
Commit
·
84cf206
1
Parent(s):
4b8d940
deploy
Browse files- models/model_loader.py +13 -2
models/model_loader.py
CHANGED
|
@@ -1,4 +1,15 @@
|
|
| 1 |
from sentence_transformers import SentenceTransformer
|
|
|
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from sentence_transformers import SentenceTransformer
|
| 2 |
+
import os
|
| 3 |
|
| 4 |
+
# Model path and Hugging Face model ID
|
| 5 |
+
model_dir = 'models/sentence_transformer'
|
| 6 |
+
hf_model_id = 'Alibaba-NLP/gte-base-en-v1.5'
|
| 7 |
+
|
| 8 |
+
# Check if model directory exists
|
| 9 |
+
if not os.path.exists(model_dir):
|
| 10 |
+
print(f"Downloading model '{hf_model_id}' from Hugging Face...")
|
| 11 |
+
model = SentenceTransformer(hf_model_id, trust_remote_code=True)
|
| 12 |
+
model.save(model_dir)
|
| 13 |
+
else:
|
| 14 |
+
print(f"Loading model from local directory: {model_dir}")
|
| 15 |
+
model = SentenceTransformer(model_dir)
|