Commit 18772e5
committed
fix(rerank): unswallow exception, shim Qwen2 prepare_for_model, cache reranker on backend
Three independent retrieval-path bugs surfaced by Phase 10 --full LongMemEval_S:
1. tuned_hybrid.py was swallowing every reranker exception with bare
`except Exception`, hiding the actual failure cause and violating the
project hard constraint (CLAUDE.md: "NEVER suppress errors in
indexing/retrieval paths"). Replaced with type+message logging plus
full traceback.
2. mxbai-rerank 0.1.6 calls `tokenizer.prepare_for_model(...)`
unconditionally, but transformers >=4.50 no longer exposes this
method on the slow Qwen2Tokenizer (and PreTrainedTokenizerBase no
longer provides a fallback impl). mxbai-rerank upstream is
effectively unmaintained (only 1 PR ever merged, no fix released).
Bound a minimal hand-written prepare_for_model on the tokenizer
instance covering the exact call signature mxbai uses
(add_special_tokens=False, padding=False, truncation="only_second").
3. tuned_hybrid.query() called load_reranker() on every retrieval call,
constructing a fresh wrapper with `_model=None` each time, which
then triggered a fresh model weight load. Cache the reranker on the
backend instance keyed by name so a long-lived process loads weights
exactly once.
Verified via uv run pytest (620 passed, 4 skipped, 1 upstream warning)
and end-to-end via supamem eval --suite longmemeval_s --full
(470 questions; rerank now actually runs, weights load once per process).1 parent 7b3541c commit 18772e5
2 files changed
Lines changed: 93 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
38 | 98 | | |
39 | 99 | | |
40 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
174 | 180 | | |
175 | 181 | | |
176 | 182 | | |
| |||
213 | 219 | | |
214 | 220 | | |
215 | 221 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
222 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
223 | 241 | | |
224 | 242 | | |
225 | 243 | | |
| |||
299 | 317 | | |
300 | 318 | | |
301 | 319 | | |
302 | | - | |
| 320 | + | |
303 | 321 | | |
304 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
305 | 327 | | |
306 | 328 | | |
307 | 329 | | |
308 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
309 | 333 | | |
| 334 | + | |
310 | 335 | | |
311 | 336 | | |
312 | 337 | | |
| |||
0 commit comments