Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -124,8 +124,16 @@ class PersistentSearchEngine:
|
|
| 124 |
self.collection = self.client.get_or_create_collection(name=collection_name)
|
| 125 |
|
| 126 |
# 2. Load Models
|
| 127 |
-
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
# 3. Initialize/Load BM25 (Sparse)
|
| 131 |
self.bm25 = None
|
|
|
|
| 124 |
self.collection = self.client.get_or_create_collection(name=collection_name)
|
| 125 |
|
| 126 |
# 2. Load Models
|
| 127 |
+
# We force the device to CPU to avoid "meta tensor" errors in Docker
|
| 128 |
+
device = "cpu"
|
| 129 |
+
self.bi_encoder = SentenceTransformer('all-MiniLM-L6-v2', device=device)
|
| 130 |
+
|
| 131 |
+
# We disable "low_cpu_mem_usage" to prevent the model from loading as a ghost (meta device)
|
| 132 |
+
self.cross_encoder = CrossEncoder(
|
| 133 |
+
'cross-encoder/ms-marco-MiniLM-L-6-v2',
|
| 134 |
+
device=device,
|
| 135 |
+
automodel_args={"low_cpu_mem_usage": False}
|
| 136 |
+
)
|
| 137 |
|
| 138 |
# 3. Initialize/Load BM25 (Sparse)
|
| 139 |
self.bm25 = None
|