Spaces:
Sleeping
Sleeping
Commit ·
c90a1ed
1
Parent(s): b91ab33
Fix BM25: lecture paginee de la collection (evite 'too many SQL variables' sur 84k chunks -> BM25 enfin actif)
Browse files
app.py
CHANGED
|
@@ -163,10 +163,17 @@ def build_bm25_index() -> None:
|
|
| 163 |
if not _BM25_AVAILABLE:
|
| 164 |
return
|
| 165 |
try:
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
_bm25_metas =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
if not _bm25_docs:
|
| 171 |
_bm25_index = None
|
| 172 |
logger.info("BM25 index empty (no documents in store yet).")
|
|
|
|
| 163 |
if not _BM25_AVAILABLE:
|
| 164 |
return
|
| 165 |
try:
|
| 166 |
+
# Lecture PAGINEE : un collection.get() global depasse la limite SQLite
|
| 167 |
+
# "too many SQL variables" sur un gros corpus (84k chunks) -> BM25 jamais construit.
|
| 168 |
+
total = collection.count()
|
| 169 |
+
_bm25_ids, _bm25_docs, _bm25_metas = [], [], []
|
| 170 |
+
_off, _step = 0, 2000
|
| 171 |
+
while _off < total:
|
| 172 |
+
_batch = collection.get(include=["documents", "metadatas"], limit=_step, offset=_off)
|
| 173 |
+
_bm25_ids.extend(_batch.get("ids", []) or [])
|
| 174 |
+
_bm25_docs.extend(_batch.get("documents", []) or [])
|
| 175 |
+
_bm25_metas.extend(_batch.get("metadatas", []) or [])
|
| 176 |
+
_off += _step
|
| 177 |
if not _bm25_docs:
|
| 178 |
_bm25_index = None
|
| 179 |
logger.info("BM25 index empty (no documents in store yet).")
|