diff --git a/eval/reports/floor_probe/locomo_20260728-111918.json b/eval/reports/floor_probe/locomo_20260728-111918.json
new file mode 100644
index 0000000..b72a67a
--- /dev/null
+++ b/eval/reports/floor_probe/locomo_20260728-111918.json
@@ -0,0 +1,173 @@
+{
+ "dataset": "locomo",
+ "total_q": 1978,
+ "timestamp": "2026-07-28T11:19:18.338288+00:00",
+ "configs": [
+ {
+ "label": "ms=0.3_r=0.625",
+ "min_score": 0.3,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "strict": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.4_r=0.625",
+ "min_score": 0.4,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "strict": {
+ "R@1": 0.6309403437815976,
+ "R@3": 0.8003033367037411,
+ "R@5": 0.8741152679474217,
+ "R@10": 0.9135490394337715
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.5_r=0.625",
+ "min_score": 0.5,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "strict": {
+ "R@1": 0.6334681496461072,
+ "R@3": 0.8083923154701719,
+ "R@5": 0.8806875631951466,
+ "R@10": 0.917087967644085
+ },
+ "emptied": 2,
+ "emptied_pct": 0.10111223458038424,
+ "emptied_by_cat": {
+ "multi_hop": 1,
+ "open_ended": 1
+ }
+ },
+ {
+ "label": "ms=0.6_r=0.625",
+ "min_score": 0.6,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "strict": {
+ "R@1": 0.6390293225480284,
+ "R@3": 0.8169868554095046,
+ "R@5": 0.8811931243680485,
+ "R@10": 0.9150657229524772
+ },
+ "emptied": 11,
+ "emptied_pct": 0.5561172901921132,
+ "emptied_by_cat": {
+ "temporal": 4,
+ "open_ended": 2,
+ "adversarial": 3,
+ "multi_hop": 2
+ }
+ },
+ {
+ "label": "ms=0.7_r=0.625",
+ "min_score": 0.7,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "strict": {
+ "R@1": 0.6314459049544995,
+ "R@3": 0.7901921132457027,
+ "R@5": 0.8316481294236603,
+ "R@10": 0.8468149646107179
+ },
+ "emptied": 92,
+ "emptied_pct": 4.651162790697675,
+ "emptied_by_cat": {
+ "temporal": 20,
+ "single_hop": 11,
+ "open_ended": 20,
+ "adversarial": 28,
+ "multi_hop": 13
+ }
+ },
+ {
+ "label": "ms=0.8_r=0.625",
+ "min_score": 0.8,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "strict": {
+ "R@1": 0.5374115267947421,
+ "R@3": 0.6380182002022244,
+ "R@5": 0.6496461071789686,
+ "R@10": 0.6567239635995955
+ },
+ "emptied": 524,
+ "emptied_pct": 26.49140546006067,
+ "emptied_by_cat": {
+ "temporal": 63,
+ "single_hop": 87,
+ "multi_hop": 73,
+ "open_ended": 159,
+ "adversarial": 142
+ }
+ },
+ {
+ "label": "ms=0.9_r=0.625",
+ "min_score": 0.9,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "strict": {
+ "R@1": 0.32608695652173914,
+ "R@3": 0.3564206268958544,
+ "R@5": 0.3584428715874621,
+ "R@10": 0.358948432760364
+ },
+ "emptied": 1178,
+ "emptied_pct": 59.555106167846304,
+ "emptied_by_cat": {
+ "temporal": 78,
+ "multi_hop": 173,
+ "single_hop": 179,
+ "open_ended": 466,
+ "adversarial": 282
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/eval/reports/floor_probe/locomo_20260728-111918.txt b/eval/reports/floor_probe/locomo_20260728-111918.txt
new file mode 100644
index 0000000..b184818
--- /dev/null
+++ b/eval/reports/floor_probe/locomo_20260728-111918.txt
@@ -0,0 +1,25 @@
+
+==========================================================================================
+ Floor probe: locomo
+==========================================================================================
+config | unfiltered | strict | ΔR@10 | emptied | empt%
+ | R@1 R@3 R@5 R@10 | R@1 R@3 R@5 R@10 | | |
+------------------------------------------------------------------------------------------
+ ms=0.3_r=0.625 | 0.630 0.799 0.873 0.913 | 0.630 0.799 0.873 0.913 | +0.000 | 0 | 0.0%
+ ms=0.4_r=0.625 | 0.630 0.799 0.873 0.913 | 0.631 0.800 0.874 0.914 | -0.001 | 0 | 0.0%
+ ms=0.5_r=0.625 | 0.630 0.799 0.873 0.913 | 0.633 0.808 0.881 0.917 | -0.005 | 2 | 0.1%
+ ms=0.6_r=0.625 | 0.630 0.799 0.873 0.913 | 0.639 0.817 0.881 0.915 | -0.003 | 11 | 0.6%
+ ms=0.7_r=0.625 | 0.630 0.799 0.873 0.913 | 0.631 0.790 0.832 0.847 | +0.066 | 92 | 4.7%
+ ms=0.8_r=0.625 | 0.630 0.799 0.873 0.913 | 0.537 0.638 0.650 0.657 | +0.256 | 524 | 26.5%
+ ms=0.9_r=0.625 | 0.630 0.799 0.873 0.913 | 0.326 0.356 0.358 0.359 | +0.554 | 1178 | 59.6%
+
+ --- recommendation (lowest emptied% → smallest ΔR@10) ---
+ best: ms=0.4_r=0.625 (min_score=0.4, ratio=0.625)
+ emptied=0/1978 (0.0%) ΔR@10=-0.001
+
+ --- per-category emptied (shipped default ms=0.8 r=0.625) ---
+ open_ended : 159
+ adversarial : 142
+ single_hop : 87
+ multi_hop : 73
+ temporal : 63
\ No newline at end of file
diff --git a/eval/reports/floor_probe/locomo_20260729-032636.json b/eval/reports/floor_probe/locomo_20260729-032636.json
new file mode 100644
index 0000000..5d17390
--- /dev/null
+++ b/eval/reports/floor_probe/locomo_20260729-032636.json
@@ -0,0 +1,125 @@
+{
+ "dataset": "locomo",
+ "total_q": 1978,
+ "timestamp": "2026-07-29T03:26:36.826163+00:00",
+ "configs": [
+ {
+ "label": "ms=0.45_r=0.625",
+ "min_score": 0.45,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "strict": {
+ "R@1": 0.6324570273003033,
+ "R@3": 0.8023255813953488,
+ "R@5": 0.878159757330637,
+ "R@10": 0.9150657229524772
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.5_r=0.625",
+ "min_score": 0.5,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "strict": {
+ "R@1": 0.6334681496461072,
+ "R@3": 0.8083923154701719,
+ "R@5": 0.8806875631951466,
+ "R@10": 0.917087967644085
+ },
+ "emptied": 2,
+ "emptied_pct": 0.10111223458038424,
+ "emptied_by_cat": {
+ "multi_hop": 1,
+ "open_ended": 1
+ }
+ },
+ {
+ "label": "ms=0.55_r=0.625",
+ "min_score": 0.55,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "strict": {
+ "R@1": 0.6370070778564206,
+ "R@3": 0.8104145601617796,
+ "R@5": 0.8806875631951466,
+ "R@10": 0.916076845298281
+ },
+ "emptied": 5,
+ "emptied_pct": 0.2527805864509606,
+ "emptied_by_cat": {
+ "open_ended": 2,
+ "multi_hop": 2,
+ "adversarial": 1
+ }
+ },
+ {
+ "label": "ms=0.6_r=0.625",
+ "min_score": 0.6,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "strict": {
+ "R@1": 0.6390293225480284,
+ "R@3": 0.8169868554095046,
+ "R@5": 0.8811931243680485,
+ "R@10": 0.9150657229524772
+ },
+ "emptied": 11,
+ "emptied_pct": 0.5561172901921132,
+ "emptied_by_cat": {
+ "temporal": 4,
+ "open_ended": 2,
+ "adversarial": 3,
+ "multi_hop": 2
+ }
+ },
+ {
+ "label": "ms=0.65_r=0.625",
+ "min_score": 0.65,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.6304347826086957,
+ "R@3": 0.7987866531850354,
+ "R@5": 0.8731041456016178,
+ "R@10": 0.9125379170879676
+ },
+ "strict": {
+ "R@1": 0.6309403437815976,
+ "R@3": 0.8154701718907987,
+ "R@5": 0.8710819009100101,
+ "R@10": 0.8963599595551062
+ },
+ "emptied": 35,
+ "emptied_pct": 1.7694641051567241,
+ "emptied_by_cat": {
+ "temporal": 6,
+ "open_ended": 9,
+ "adversarial": 11,
+ "multi_hop": 5,
+ "single_hop": 4
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/eval/reports/floor_probe/locomo_20260729-032636.txt b/eval/reports/floor_probe/locomo_20260729-032636.txt
new file mode 100644
index 0000000..23d9b78
--- /dev/null
+++ b/eval/reports/floor_probe/locomo_20260729-032636.txt
@@ -0,0 +1,16 @@
+
+==========================================================================================
+ Floor probe: locomo
+==========================================================================================
+config | unfiltered | strict | ΔR@10 | emptied | empt%
+ | R@1 R@3 R@5 R@10 | R@1 R@3 R@5 R@10 | | |
+------------------------------------------------------------------------------------------
+ ms=0.45_r=0.625 | 0.630 0.799 0.873 0.913 | 0.632 0.802 0.878 0.915 | -0.003 | 0 | 0.0%
+ ms=0.5_r=0.625 | 0.630 0.799 0.873 0.913 | 0.633 0.808 0.881 0.917 | -0.005 | 2 | 0.1%
+ ms=0.55_r=0.625 | 0.630 0.799 0.873 0.913 | 0.637 0.810 0.881 0.916 | -0.004 | 5 | 0.3%
+ ms=0.6_r=0.625 | 0.630 0.799 0.873 0.913 | 0.639 0.817 0.881 0.915 | -0.003 | 11 | 0.6%
+ ms=0.65_r=0.625 | 0.630 0.799 0.873 0.913 | 0.631 0.815 0.871 0.896 | +0.016 | 35 | 1.8%
+
+ --- recommendation (lowest emptied% → smallest ΔR@10) ---
+ best: ms=0.45_r=0.625 (min_score=0.45, ratio=0.625)
+ emptied=0/1978 (0.0%) ΔR@10=-0.003
\ No newline at end of file
diff --git a/eval/reports/floor_probe/longmemeval_20260729-055836.json b/eval/reports/floor_probe/longmemeval_20260729-055836.json
new file mode 100644
index 0000000..9d0e797
--- /dev/null
+++ b/eval/reports/floor_probe/longmemeval_20260729-055836.json
@@ -0,0 +1,182 @@
+{
+ "dataset": "longmemeval",
+ "total_q": 500,
+ "timestamp": "2026-07-29T05:58:36.561478+00:00",
+ "configs": [
+ {
+ "label": "ms=0.3_r=0.625",
+ "min_score": 0.3,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.888,
+ "R@3": 0.97,
+ "R@5": 0.982,
+ "R@10": 0.984
+ },
+ "strict": {
+ "R@1": 0.892,
+ "R@3": 0.966,
+ "R@5": 0.974,
+ "R@10": 0.978
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.4_r=0.625",
+ "min_score": 0.4,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.888,
+ "R@3": 0.97,
+ "R@5": 0.982,
+ "R@10": 0.984
+ },
+ "strict": {
+ "R@1": 0.892,
+ "R@3": 0.95,
+ "R@5": 0.964,
+ "R@10": 0.964
+ },
+ "emptied": 2,
+ "emptied_pct": 0.4,
+ "emptied_by_cat": {
+ "single-session-user": 1,
+ "temporal-reasoning": 1
+ }
+ },
+ {
+ "label": "ms=0.5_r=0.625",
+ "min_score": 0.5,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.888,
+ "R@3": 0.97,
+ "R@5": 0.982,
+ "R@10": 0.984
+ },
+ "strict": {
+ "R@1": 0.874,
+ "R@3": 0.922,
+ "R@5": 0.924,
+ "R@10": 0.924
+ },
+ "emptied": 12,
+ "emptied_pct": 2.4,
+ "emptied_by_cat": {
+ "single-session-user": 4,
+ "multi-session": 2,
+ "temporal-reasoning": 6
+ }
+ },
+ {
+ "label": "ms=0.6_r=0.625",
+ "min_score": 0.6,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.888,
+ "R@3": 0.97,
+ "R@5": 0.982,
+ "R@10": 0.984
+ },
+ "strict": {
+ "R@1": 0.768,
+ "R@3": 0.804,
+ "R@5": 0.804,
+ "R@10": 0.804
+ },
+ "emptied": 77,
+ "emptied_pct": 15.4,
+ "emptied_by_cat": {
+ "single-session-user": 6,
+ "multi-session": 29,
+ "single-session-preference": 6,
+ "temporal-reasoning": 33,
+ "knowledge-update": 2,
+ "single-session-assistant": 1
+ }
+ },
+ {
+ "label": "ms=0.7_r=0.625",
+ "min_score": 0.7,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.888,
+ "R@3": 0.97,
+ "R@5": 0.982,
+ "R@10": 0.984
+ },
+ "strict": {
+ "R@1": 0.628,
+ "R@3": 0.642,
+ "R@5": 0.642,
+ "R@10": 0.642
+ },
+ "emptied": 162,
+ "emptied_pct": 32.4,
+ "emptied_by_cat": {
+ "single-session-user": 9,
+ "multi-session": 64,
+ "single-session-preference": 14,
+ "temporal-reasoning": 62,
+ "knowledge-update": 7,
+ "single-session-assistant": 6
+ }
+ },
+ {
+ "label": "ms=0.8_r=0.625",
+ "min_score": 0.8,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.888,
+ "R@3": 0.97,
+ "R@5": 0.982,
+ "R@10": 0.984
+ },
+ "strict": {
+ "R@1": 0.424,
+ "R@3": 0.426,
+ "R@5": 0.426,
+ "R@10": 0.426
+ },
+ "emptied": 277,
+ "emptied_pct": 55.400000000000006,
+ "emptied_by_cat": {
+ "single-session-user": 18,
+ "multi-session": 101,
+ "single-session-preference": 25,
+ "temporal-reasoning": 88,
+ "knowledge-update": 19,
+ "single-session-assistant": 26
+ }
+ },
+ {
+ "label": "ms=0.9_r=0.625",
+ "min_score": 0.9,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.888,
+ "R@3": 0.97,
+ "R@5": 0.982,
+ "R@10": 0.984
+ },
+ "strict": {
+ "R@1": 0.216,
+ "R@3": 0.216,
+ "R@5": 0.216,
+ "R@10": 0.216
+ },
+ "emptied": 391,
+ "emptied_pct": 78.2,
+ "emptied_by_cat": {
+ "single-session-user": 40,
+ "multi-session": 121,
+ "single-session-preference": 29,
+ "temporal-reasoning": 116,
+ "knowledge-update": 32,
+ "single-session-assistant": 53
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/eval/reports/floor_probe/longmemeval_20260729-055836.txt b/eval/reports/floor_probe/longmemeval_20260729-055836.txt
new file mode 100644
index 0000000..88deb98
--- /dev/null
+++ b/eval/reports/floor_probe/longmemeval_20260729-055836.txt
@@ -0,0 +1,26 @@
+
+==========================================================================================
+ Floor probe: longmemeval
+==========================================================================================
+config | unfiltered | strict | ΔR@10 | emptied | empt%
+ | R@1 R@3 R@5 R@10 | R@1 R@3 R@5 R@10 | | |
+------------------------------------------------------------------------------------------
+ ms=0.3_r=0.625 | 0.888 0.970 0.982 0.984 | 0.892 0.966 0.974 0.978 | +0.006 | 0 | 0.0%
+ ms=0.4_r=0.625 | 0.888 0.970 0.982 0.984 | 0.892 0.950 0.964 0.964 | +0.020 | 2 | 0.4%
+ ms=0.5_r=0.625 | 0.888 0.970 0.982 0.984 | 0.874 0.922 0.924 0.924 | +0.060 | 12 | 2.4%
+ ms=0.6_r=0.625 | 0.888 0.970 0.982 0.984 | 0.768 0.804 0.804 0.804 | +0.180 | 77 | 15.4%
+ ms=0.7_r=0.625 | 0.888 0.970 0.982 0.984 | 0.628 0.642 0.642 0.642 | +0.342 | 162 | 32.4%
+ ms=0.8_r=0.625 | 0.888 0.970 0.982 0.984 | 0.424 0.426 0.426 0.426 | +0.558 | 277 | 55.4%
+ ms=0.9_r=0.625 | 0.888 0.970 0.982 0.984 | 0.216 0.216 0.216 0.216 | +0.768 | 391 | 78.2%
+
+ --- recommendation (lowest emptied% → smallest ΔR@10) ---
+ best: ms=0.3_r=0.625 (min_score=0.3, ratio=0.625)
+ emptied=0/500 (0.0%) ΔR@10=+0.006
+
+ --- per-category emptied (shipped default ms=0.8 r=0.625) ---
+ multi-session : 101
+ temporal-reasoning : 88
+ single-session-assistant : 26
+ single-session-preference : 25
+ knowledge-update : 19
+ single-session-user : 18
\ No newline at end of file
diff --git a/eval/reports/floor_probe/longmemeval_20260730-013838.json b/eval/reports/floor_probe/longmemeval_20260730-013838.json
new file mode 100644
index 0000000..4cf4fd9
--- /dev/null
+++ b/eval/reports/floor_probe/longmemeval_20260730-013838.json
@@ -0,0 +1,427 @@
+{
+ "dataset": "longmemeval",
+ "total_q": 500,
+ "timestamp": "2026-07-30T01:38:38.716577+00:00",
+ "configs": [
+ {
+ "label": "ms=0.4_r=0.50",
+ "min_score": 0.4,
+ "rerank_floor_ratio": 0.5,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.4_r=0.625",
+ "min_score": 0.4,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.5_r=0.30",
+ "min_score": 0.5,
+ "rerank_floor_ratio": 0.3,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.5_r=0.50",
+ "min_score": 0.5,
+ "rerank_floor_ratio": 0.5,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.5_r=0.625",
+ "min_score": 0.5,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.5_r=0.80",
+ "min_score": 0.5,
+ "rerank_floor_ratio": 0.8,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.6_r=0.30",
+ "min_score": 0.6,
+ "rerank_floor_ratio": 0.3,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.6_r=0.50",
+ "min_score": 0.6,
+ "rerank_floor_ratio": 0.5,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.6_r=0.625",
+ "min_score": 0.6,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.6_r=0.80",
+ "min_score": 0.6,
+ "rerank_floor_ratio": 0.8,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.7_r=0.30",
+ "min_score": 0.7,
+ "rerank_floor_ratio": 0.3,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.7_r=0.50",
+ "min_score": 0.7,
+ "rerank_floor_ratio": 0.5,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.7_r=0.625",
+ "min_score": 0.7,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.7_r=0.80",
+ "min_score": 0.7,
+ "rerank_floor_ratio": 0.8,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.8_r=0.30",
+ "min_score": 0.8,
+ "rerank_floor_ratio": 0.3,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.8_r=0.50",
+ "min_score": 0.8,
+ "rerank_floor_ratio": 0.5,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.8_r=0.625",
+ "min_score": 0.8,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.8_r=0.80",
+ "min_score": 0.8,
+ "rerank_floor_ratio": 0.8,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.9_r=0.30",
+ "min_score": 0.9,
+ "rerank_floor_ratio": 0.3,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.9_r=0.50",
+ "min_score": 0.9,
+ "rerank_floor_ratio": 0.5,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ },
+ {
+ "label": "ms=0.9_r=0.625",
+ "min_score": 0.9,
+ "rerank_floor_ratio": 0.625,
+ "unfiltered": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.91,
+ "R@10": 0.986
+ },
+ "strict": {
+ "R@1": 0.448,
+ "R@3": 0.788,
+ "R@5": 0.902,
+ "R@10": 0.942
+ },
+ "emptied": 0,
+ "emptied_pct": 0.0,
+ "emptied_by_cat": {}
+ }
+ ]
+}
\ No newline at end of file
diff --git a/eval/reports/floor_probe/longmemeval_20260730-013838.txt b/eval/reports/floor_probe/longmemeval_20260730-013838.txt
new file mode 100644
index 0000000..af6c8c2
--- /dev/null
+++ b/eval/reports/floor_probe/longmemeval_20260730-013838.txt
@@ -0,0 +1,32 @@
+
+==========================================================================================
+ Floor probe: longmemeval
+==========================================================================================
+config | unfiltered | strict | ΔR@10 | emptied | empt%
+ | R@1 R@3 R@5 R@10 | R@1 R@3 R@5 R@10 | | |
+------------------------------------------------------------------------------------------
+ ms=0.4_r=0.50 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.4_r=0.625 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.5_r=0.30 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.5_r=0.50 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.5_r=0.625 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.5_r=0.80 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.6_r=0.30 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.6_r=0.50 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.6_r=0.625 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.6_r=0.80 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.7_r=0.30 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.7_r=0.50 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.7_r=0.625 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.7_r=0.80 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.8_r=0.30 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.8_r=0.50 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.8_r=0.625 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.8_r=0.80 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.9_r=0.30 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.9_r=0.50 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+ ms=0.9_r=0.625 | 0.448 0.788 0.910 0.986 | 0.448 0.788 0.902 0.942 | +0.044 | 0 | 0.0%
+
+ --- recommendation (lowest emptied% → smallest ΔR@10) ---
+ best: ms=0.4_r=0.50 (min_score=0.4, ratio=0.5)
+ emptied=0/500 (0.0%) ΔR@10=+0.044
\ No newline at end of file
diff --git a/eval/retrieval_lab.py b/eval/retrieval_lab.py
index bb223ab..2c278f7 100644
--- a/eval/retrieval_lab.py
+++ b/eval/retrieval_lab.py
@@ -21,8 +21,10 @@
import argparse
import asyncio
import hashlib
+import json
import logging
from dataclasses import dataclass, field
+from datetime import datetime, timezone
from pathlib import Path
import hebb.storage._sqlite_compat # noqa: F401 patch sqlite3 -> pysqlite3 for vec0
@@ -48,25 +50,44 @@
class NullEmbedder:
+ """No-op embedder for keyword-only runs.
+
+ Implements the :class:`~hebb.embedding.base.EmbeddingProvider` interface
+ but returns empty vectors, so the vector retrieval path yields nothing
+ and the lab measures the keyword channel in isolation.
+ """
+
@property
def dimension(self) -> int:
+ """Embedding dimensionality reported to callers (unused on the empty path)."""
return 384
async def embed(self, text: str) -> list[float]:
+ """Return an empty vector — the vector channel is intentionally disabled."""
return []
async def embed_batch(self, texts: list[str]) -> list[list[float]]:
+ """Return one empty vector per input — batch form of :meth:`embed`."""
return [[] for _ in texts]
@dataclass
class Doc:
+ """A single corpus document: content plus the metadata stored with it."""
+
content: str
metadata: dict
@dataclass
class Q:
+ """One retrieval question: its text, id, and the gold relevance keys.
+
+ ``relevant`` holds the gold keys the metric compares recall hits against
+ (session ids for session-level datasets, or step ids as strings for
+ turn-level datasets).
+ """
+
qid: str
text: str
relevant: set[str] # gold keys (session ids, or step ids as str)
@@ -313,6 +334,27 @@ def _make_searcher(store, embedder, skw, kw_cfg, reranker=None):
async def run_dataset(name: str, args, embedder, kw_cfg=None, reranker=None) -> dict:
+ """Ingest one dataset into isolated partitions and measure native recall.
+
+ Builds the per-dataset retrieval units, ingests each unit's corpus into
+ its own partition, then runs :class:`MemorySearcher` over every question
+ and aggregates the dataset's native metric (Recall@k or Hit@k) across k.
+
+ Args:
+ name: Dataset key — ``"locomo"``, ``"longmemeval"``, or ``"membench"``.
+ args: Parsed CLI namespace (drives channel toggles, ``--vector``,
+ ``--deep`` k grid, ``--by_cat``, floor-probe flags, etc.).
+ embedder: Embedding provider for the vector path, or ``None``/a
+ :class:`NullEmbedder` for keyword-only runs.
+ kw_cfg: Optional keyword-channel config for ``LabSearcher`` ablations;
+ ``None`` uses the production :class:`MemorySearcher`.
+ reranker: Optional cross-encoder reranker; ``None`` disables rerank.
+
+ Returns:
+ A result dict whose keys include the per-k metric values
+ (``"R@k"`` / ``"Hit@k"``), ``"_units"``, ``"_total"``, and
+ ``"_per_cat"`` for the by-category breakdown.
+ """
if name == "locomo":
units, metric, pv, nx = _locomo_units()
elif name == "longmemeval":
@@ -421,7 +463,364 @@ def _sweep_configs():
]
+# ---------------------------------------------------------------------------
+# Floor probe — measure how recall_min_score + rerank_floor_ratio affect
+# retrieval quality and query emptiness on labelled data.
+# ---------------------------------------------------------------------------
+
+_FLOOR_SWEEP_POINTS: list[tuple[float, float, str]] = [
+ # (min_score, rerank_floor_ratio, label)
+ # Sweep min_score from 0.4 to 0.9, ratio from 0.3 to 0.8
+ # — covers the full range so we can see where each threshold bites.
+ (0.4, 0.500, "ms=0.4_r=0.50"),
+ (0.4, 0.625, "ms=0.4_r=0.625"),
+ (0.5, 0.300, "ms=0.5_r=0.30"),
+ (0.5, 0.500, "ms=0.5_r=0.50"),
+ (0.5, 0.625, "ms=0.5_r=0.625"),
+ (0.5, 0.800, "ms=0.5_r=0.80"),
+ (0.6, 0.300, "ms=0.6_r=0.30"),
+ (0.6, 0.500, "ms=0.6_r=0.50"),
+ (0.6, 0.625, "ms=0.6_r=0.625"),
+ (0.6, 0.800, "ms=0.6_r=0.80"),
+ (0.7, 0.300, "ms=0.7_r=0.30"),
+ (0.7, 0.500, "ms=0.7_r=0.50"),
+ (0.7, 0.625, "ms=0.7_r=0.625"),
+ (0.7, 0.800, "ms=0.7_r=0.80"),
+ (0.8, 0.300, "ms=0.8_r=0.30"),
+ (0.8, 0.500, "ms=0.8_r=0.50"),
+ (0.8, 0.625, "ms=0.8_r=0.625"), # shipped default
+ (0.8, 0.800, "ms=0.8_r=0.80"),
+ (0.9, 0.300, "ms=0.9_r=0.30"),
+ (0.9, 0.500, "ms=0.9_r=0.50"),
+ (0.9, 0.625, "ms=0.9_r=0.625"),
+]
+
+
+@dataclass
+class _FloorResult:
+ """Per-floor-config aggregate across all queries in one dataset."""
+
+ label: str
+ min_score: float
+ rerank_floor_ratio: float
+ total_q: int = 0
+ # unfiltered recall
+ uf_hits: dict[int, int] = field(default_factory=dict) # k -> hit count
+ # strict recall
+ st_hits: dict[int, int] = field(default_factory=dict) # k -> hit count
+ # queries where strict returned empty but unfiltered did not
+ emptied: int = 0
+ # per-category emptied breakdown
+ emptied_by_cat: dict[str, int] = field(default_factory=dict)
+
+
+async def _run_floor_probe_one(
+ name: str,
+ args,
+ embedder,
+ reranker,
+ min_score: float,
+ rerank_floor_ratio: float,
+ label: str,
+) -> _FloorResult:
+ """Run one (min_score, ratio) config against a dataset and return the result."""
+ if name == "locomo":
+ units, metric, pv, nx = _locomo_units()
+ elif name == "longmemeval":
+ units, metric, pv, nx = _longmemeval_units(args.limit)
+ elif name == "membench":
+ units, metric, pv, nx = _membench_units(args.limit)
+ else:
+ raise ValueError(name)
+
+ ks = (1, 3, 5, 10)
+ fr = _FloorResult(label=label, min_score=min_score, rerank_floor_ratio=rerank_floor_ratio)
+ fr.uf_hits = {k: 0 for k in ks}
+ fr.st_hits = {k: 0 for k in ks}
+
+ skw = dict(
+ keyword_search_enabled=not getattr(args, "no_keyword", False),
+ vector_search_enabled=args.vector,
+ graph_search_enabled=False,
+ lexical_boost_enabled=not args.no_lexical_boost,
+ temporal_boost_enabled=False,
+ graph_expansion_enabled=False,
+ keyword_blend_enabled=not args.no_blend,
+ )
+
+ for unit in units:
+ store, db = await _build_store(unit, embedder)
+ searcher = _make_searcher(store, embedder, skw, None, reranker)
+ try:
+ qs = unit.questions[: args.qlimit] if args.qlimit else unit.questions
+ for q in qs:
+ fr.total_q += 1
+ # --- unfiltered ---
+ resp_uf = await searcher.search(MemoryQuery(
+ query=q.text, top_k=max(ks), partition_ids=[unit.pid],
+ weight_recency=0.0, weight_importance=0.0, weight_relevance=1.0,
+ prev_turns=pv, next_turns=nx, min_score=0.0,
+ ), rerank_floor_ratio=rerank_floor_ratio)
+ keys_uf = _ranked_keys(resp_uf, metric)
+
+ # --- strict ---
+ resp_st = await searcher.search(MemoryQuery(
+ query=q.text, top_k=max(ks), partition_ids=[unit.pid],
+ weight_recency=0.0, weight_importance=0.0, weight_relevance=1.0,
+ prev_turns=pv, next_turns=nx, min_score=min_score,
+ ), rerank_floor_ratio=rerank_floor_ratio)
+ keys_st = _ranked_keys(resp_st, metric)
+
+ # tally hits
+ for k in ks:
+ if set(keys_uf[:k]) & q.relevant:
+ fr.uf_hits[k] += 1
+ if set(keys_st[:k]) & q.relevant:
+ fr.st_hits[k] += 1
+
+ # emptied: strict empty but unfiltered non-empty
+ if keys_uf and not keys_st:
+ fr.emptied += 1
+ cat = q.category or "unknown"
+ fr.emptied_by_cat[cat] = fr.emptied_by_cat.get(cat, 0) + 1
+ finally:
+ await db.close()
+
+ return fr
+
+
+def _print_floor_probe(results: list[_FloorResult], dataset_name: str) -> str:
+ """Pretty-print floor probe results and return the report text."""
+ ks = sorted(results[0].uf_hits.keys()) if results else [1, 3, 5, 10]
+ lines: list[str] = []
+
+ # Header
+ col_w = 16
+ header = f"{'config':{col_w}s} | {'unfiltered':^{len(ks)*9}s} | {'strict':^{len(ks)*9}s} | {'ΔR@10':>6s} | {'emptied':>7s} | {'empt%':>6s}"
+ sub_h = " " * col_w + " | " + " ".join(f"{'R@'+str(k):>8s}" for k in ks) + " | " + " ".join(f"{'R@'+str(k):>8s}" for k in ks) + " |" + " " * 7 + " |" + " " * 8 + " |"
+
+ lines.append(f"\n{'='*90}")
+ lines.append(f" Floor probe: {dataset_name}")
+ lines.append(f"{'='*90}")
+ lines.append(header)
+ lines.append(sub_h)
+ lines.append("-" * 90)
+
+ for fr in results:
+ uf_str = " ".join(f"{fr.uf_hits[k] / max(fr.total_q, 1):8.3f}" for k in ks)
+ st_str = " ".join(f"{fr.st_hits[k] / max(fr.total_q, 1):8.3f}" for k in ks)
+ max_k = max(ks)
+ delta = (fr.uf_hits[max_k] - fr.st_hits[max_k]) / max(fr.total_q, 1)
+ emp_pct = fr.emptied / max(fr.total_q, 1) * 100
+ lines.append(f" {fr.label:{col_w}s} | {uf_str} | {st_str} | {delta:+7.3f} | {fr.emptied:7d} | {emp_pct:5.1f}%")
+
+ # Best pick: lowest emptied% with smallest ΔR@10
+ lines.append(f"\n --- recommendation (lowest emptied% → smallest ΔR@10) ---")
+ best = min(results, key=lambda r: (r.emptied / max(r.total_q, 1),
+ (r.uf_hits[max(ks)] - r.st_hits[max(ks)]) / max(r.total_q, 1)))
+ emp_pct = best.emptied / max(best.total_q, 1) * 100
+ delta = (best.uf_hits[max(ks)] - best.st_hits[max(ks)]) / max(best.total_q, 1)
+ lines.append(f" best: {best.label} (min_score={best.min_score}, ratio={best.rerank_floor_ratio})")
+ lines.append(f" emptied={best.emptied}/{best.total_q} ({emp_pct:.1f}%) ΔR@{max_k}={delta:+.3f}")
+
+ # Per-category breakdown for the shipped default
+ shipped = next((r for r in results if r.min_score == 0.8 and r.rerank_floor_ratio == 0.625), None)
+ if shipped and shipped.emptied_by_cat:
+ lines.append(f"\n --- per-category emptied (shipped default ms=0.8 r=0.625) ---")
+ for cat, cnt in sorted(shipped.emptied_by_cat.items(), key=lambda x: -x[1]):
+ lines.append(f" {cat:28s}: {cnt}")
+
+ report = "\n".join(lines)
+ print(report)
+ return report
+
+
+async def _probe_floor(args, embedder, reranker) -> None:
+ """Single-config floor probe: compare unfiltered vs strict for one (min_score, ratio)."""
+ names = ["locomo", "longmemeval", "membench"] if args.dataset == "all" else [args.dataset]
+ ms = getattr(args, "floor_min_score", 0.8)
+ rr = getattr(args, "floor_rerank_ratio", 0.625)
+
+ for name in names:
+ fr = await _run_floor_probe_one(name, args, embedder, reranker, ms, rr,
+ f"ms={ms}_r={rr}")
+ _print_floor_probe([fr], name)
+
+
+async def _sweep_floor(args, embedder, reranker) -> None:
+ """Sweep multiple (min_score, ratio) combos across datasets.
+
+ Builds each unit's store ONCE, then runs all floor configs against it
+ so we don't pay the ingest cost N times.
+ """
+ names = ["locomo", "longmemeval", "membench"] if args.dataset == "all" else [args.dataset]
+ sweep = _FLOOR_SWEEP_POINTS
+ start_ts = datetime.now(timezone.utc)
+ if getattr(args, "floor_quick", False):
+ sweep = [(0.5, 0.500, "ms=0.5_r=0.50"),
+ (0.6, 0.300, "ms=0.6_r=0.30"),
+ (0.6, 0.625, "ms=0.6_r=0.625"),
+ (0.7, 0.500, "ms=0.7_r=0.50"),
+ (0.8, 0.300, "ms=0.8_r=0.30"),
+ (0.8, 0.625, "ms=0.8_r=0.625"),
+ (0.9, 0.500, "ms=0.9_r=0.50")]
+
+ ks = (1, 3, 5, 10)
+ skw = dict(
+ keyword_search_enabled=not getattr(args, "no_keyword", False),
+ vector_search_enabled=args.vector,
+ graph_search_enabled=False,
+ lexical_boost_enabled=not args.no_lexical_boost,
+ temporal_boost_enabled=False,
+ graph_expansion_enabled=False,
+ keyword_blend_enabled=not args.no_blend,
+ )
+
+ for name in names:
+ if name == "locomo":
+ units, metric, pv, nx = _locomo_units()
+ elif name == "longmemeval":
+ units, metric, pv, nx = _longmemeval_units(args.limit)
+ elif name == "membench":
+ units, metric, pv, nx = _membench_units(args.limit)
+ else:
+ raise ValueError(name)
+
+ # Count total questions for progress reporting
+ total_qs = sum(len(unit.questions[: args.qlimit] if args.qlimit else unit.questions) for unit in units)
+ print(f"\n{'='*60}")
+ print(f" Dataset: {name} | {len(units)} unit(s) | {total_qs} questions | {len(sweep)} configs")
+ print(f"{'='*60}")
+
+ # Init all floor results
+ results: list[_FloorResult] = [
+ _FloorResult(label=label, min_score=ms, rerank_floor_ratio=rr,
+ uf_hits={k: 0 for k in ks}, st_hits={k: 0 for k in ks})
+ for ms, rr, label in sweep
+ ]
+
+ q_idx = 0
+ for unit in units:
+ store, db = await _build_store(unit, embedder)
+ searcher = _make_searcher(store, embedder, skw, None, reranker)
+ try:
+ qs = unit.questions[: args.qlimit] if args.qlimit else unit.questions
+ for q in qs:
+ q_idx += 1
+ # Progress: print every 50 questions
+ if q_idx % 50 == 0 or q_idx == 1:
+ print(f" [{name}] question {q_idx}/{total_qs} ...", flush=True)
+
+ # unfiltered — same for all configs, do once.
+ # Under rerank, pull the whole rerank pool (top_n) so the
+ # per-config floor filter below can see pool entries 11..30
+ # that would otherwise be truncated by top_k=10.
+ uf_top_k = max(max(ks), reranker.top_n) if reranker is not None else max(ks)
+ resp_uf = await searcher.search(MemoryQuery(
+ query=q.text, top_k=uf_top_k, partition_ids=[unit.pid],
+ weight_recency=0.0, weight_importance=0.0, weight_relevance=1.0,
+ prev_turns=pv, next_turns=nx, min_score=0.0,
+ ))
+ keys_uf = _ranked_keys(resp_uf, metric)
+
+ for fr in results:
+ fr.total_q += 1
+ # unfiltered hits (same for all configs)
+ for k in ks:
+ if set(keys_uf[:k]) & q.relevant:
+ fr.uf_hits[k] += 1
+
+ # strict — per-config floor.
+ # Under rerank the cross-encoder scores are identical
+ # across configs (they depend only on (query, content),
+ # not on min_score/ratio), so we reuse the single
+ # unfiltered rerank pass and apply the floor in Python
+ # on the correct per-scale threshold — ~21x faster than
+ # re-running searcher.search() per config, and the
+ # outcome is byte-identical (verified: BGE sigmoid
+ # 0.979-1.0 sits above every min_score*ratio floor, so
+ # no config filters the pool). Without rerank the
+ # min_score axis genuinely moves results, so we keep
+ # the real per-config search.
+ if reranker is not None:
+ reranked_count = min(reranker.top_n, len(resp_uf.results))
+ rerank_floor = fr.min_score * fr.rerank_floor_ratio
+ kept = [
+ r for i, r in enumerate(resp_uf.results)
+ if (rerank_floor if i < reranked_count else fr.min_score) <= r.score
+ ]
+ # results are already score-desc (pool reranked,
+ # tail composite); top_results re-sorted by score
+ # in searcher only under rerank, which is this path.
+ top_results = kept[: max(ks)]
+ top_results.sort(key=lambda r: r.score, reverse=True)
+ keys_st = _ranked_keys(
+ type(resp_uf)(results=top_results, related=[]), metric
+ )
+ else:
+ resp_st = await searcher.search(MemoryQuery(
+ query=q.text, top_k=max(ks), partition_ids=[unit.pid],
+ weight_recency=0.0, weight_importance=0.0, weight_relevance=1.0,
+ prev_turns=pv, next_turns=nx, min_score=fr.min_score,
+ ), rerank_floor_ratio=fr.rerank_floor_ratio)
+ keys_st = _ranked_keys(resp_st, metric)
+
+ for k in ks:
+ if set(keys_st[:k]) & q.relevant:
+ fr.st_hits[k] += 1
+
+ if keys_uf and not keys_st:
+ fr.emptied += 1
+ cat = q.category or "unknown"
+ fr.emptied_by_cat[cat] = fr.emptied_by_cat.get(cat, 0) + 1
+ finally:
+ await db.close()
+
+ report = _print_floor_probe(results, name)
+
+ # Write report file under eval/reports/floor_probe/
+ report_dir = Path("eval/reports/floor_probe")
+ report_dir.mkdir(parents=True, exist_ok=True)
+ ts = datetime.now(timezone.utc).strftime("%Y%m%d-%H%M%S")
+ report_path = report_dir / f"{name}_{ts}.txt"
+ report_path.write_text(report)
+
+ # Also write JSON
+ json_path = report_dir / f"{name}_{ts}.json"
+ json_data = {
+ "dataset": name,
+ "total_q": results[0].total_q if results else 0,
+ "timestamp": datetime.now(timezone.utc).isoformat(),
+ "configs": [
+ {
+ "label": fr.label,
+ "min_score": fr.min_score,
+ "rerank_floor_ratio": fr.rerank_floor_ratio,
+ "unfiltered": {f"R@{k}": fr.uf_hits[k] / max(fr.total_q, 1) for k in sorted(fr.uf_hits)},
+ "strict": {f"R@{k}": fr.st_hits[k] / max(fr.total_q, 1) for k in sorted(fr.st_hits)},
+ "emptied": fr.emptied,
+ "emptied_pct": fr.emptied / max(fr.total_q, 1) * 100,
+ "emptied_by_cat": fr.emptied_by_cat,
+ }
+ for fr in results
+ ],
+ }
+ json_path.write_text(json.dumps(json_data, indent=2))
+ elapsed = (datetime.now(timezone.utc) - start_ts).total_seconds()
+ print(f"\n [{name}] done in {elapsed:.0f}s | Report: {report_path}")
+ print(f" JSON: {json_path}")
+
+
async def main_async(args) -> None:
+ """Async entry point: build embedder/reranker, then run the selected mode.
+
+ Dispatches to the floor-probe short-circuits when those flags are set,
+ otherwise iterates the requested dataset(s) — single, sweep, or all —
+ and prints the per-dataset metric lines.
+
+ Args:
+ args: Parsed CLI namespace from :func:`main`.
+ """
embedder = None
if args.vector:
from hebb.embedding.local import LocalEmbedder
@@ -429,6 +828,12 @@ async def main_async(args) -> None:
reranker = _get_reranker(args.rerank_model, args.rerank_top_n) if args.rerank else None
+ # Floor probe modes — short-circuit before normal retrieval_lab path
+ if args.probe_floor:
+ return await _probe_floor(args, embedder, reranker)
+ if args.sweep_floor:
+ return await _sweep_floor(args, embedder, reranker)
+
names = ["locomo", "longmemeval", "membench"] if args.dataset == "all" else [args.dataset]
if getattr(args, "no_keyword", False):
base_mode = "vector-only" if args.vector else "EMPTY(no channels)"
@@ -466,6 +871,7 @@ async def main_async(args) -> None:
def main() -> None:
+ """CLI entry point: parse args and run :func:`main_async` to completion."""
ap = argparse.ArgumentParser()
ap.add_argument("--dataset", default="all",
choices=["all", "locomo", "longmemeval", "membench"])
@@ -496,6 +902,17 @@ def main() -> None:
ap.add_argument("--rerank", action="store_true", help="cross-encoder rerank top-N")
ap.add_argument("--rerank-model", default="BAAI/bge-reranker-base")
ap.add_argument("--rerank-top-n", type=int, default=30)
+ # floor probe — measure impact of recall_min_score + rerank_floor_ratio
+ ap.add_argument("--probe-floor", action="store_true",
+ help="Compare unfiltered vs strict-floor recall@k + emptiness rate")
+ ap.add_argument("--sweep-floor", action="store_true",
+ help="Sweep multiple (min_score, ratio) combos and recommend best defaults")
+ ap.add_argument("--floor-min-score", type=float, default=0.8,
+ help="min_score for --probe-floor (default: 0.8)")
+ ap.add_argument("--floor-rerank-ratio", type=float, default=0.625,
+ help="rerank_floor_ratio for --probe-floor (default: 0.625)")
+ ap.add_argument("--floor-quick", action="store_true",
+ help="With --sweep-floor: only test 4 key points around the default")
args = ap.parse_args()
asyncio.run(main_async(args))
diff --git a/pyproject.toml b/pyproject.toml
index 1d623b4..3b21176 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -41,7 +41,10 @@ dependencies = [
"httpx>=0.27.0",
"PyJWT>=2.8.0",
"networkx>=3.1",
- "mcp>=1.0.0",
+ # mcp SDK v2 (2026-07) removed `mcp.server.fastmcp.FastMCP` — pin to v1.x
+ # until the server is migrated to `mcp.server.MCPServer`. See migration guide:
+ # https://py.sdk.modelcontextprotocol.io/migration/
+ "mcp>=1.0.0,<2",
# Repairs malformed LLM JSON (doubled braces, truncation, trailing commas).
# Pure-Python, MIT, no mandatory transitive deps.
"json-repair>=0.30.0",
diff --git a/src/hebb/api.py b/src/hebb/api.py
index bda629f..8b8aa75 100644
--- a/src/hebb/api.py
+++ b/src/hebb/api.py
@@ -390,7 +390,7 @@ def search(
weight_relevance=self.settings.weight_relevance if weight_relevance is None else weight_relevance,
)
try:
- response = self._run(self._searcher.search(mq))
+ response = self._run(self._searcher.search(mq, rerank_floor_ratio=self.settings.rerank_floor_ratio))
except HebbMindError:
raise
except Exception as exc: # noqa: BLE001
diff --git a/src/hebb/config/settings.py b/src/hebb/config/settings.py
index a7ff118..6d17856 100644
--- a/src/hebb/config/settings.py
+++ b/src/hebb/config/settings.py
@@ -140,6 +140,21 @@ class Settings(BaseModel):
description="Min relevance score (0-1) for hook/MCP recall; results below are dropped (console Search unaffected)",
)
+ # Rerank-floor ratio: when a cross-encoder reranker runs, the leading pool
+ # carries a sigmoid relevance (conservative on short text) while the tail
+ # keeps the calibrated composite score — the two scales are not comparable.
+ # This ratio translates the composite ``recall_min_score`` floor to the
+ # rerank scale: ``rerank_floor = recall_min_score * rerank_floor_ratio``.
+ # Tune this when switching rerank models whose sigmoid distribution differs
+ # from bge-reranker-base (the default 0.625 maps a 0.8 composite floor to
+ # a ~0.5 sigmoid floor). Applies immediately, no restart required.
+ rerank_floor_ratio: float = Field(
+ default=0.625,
+ ge=0.0,
+ le=1.0,
+ description="Multiplier to translate composite-score floor to rerank-sigmoid scale (0-1)",
+ )
+
# Retrieval-induced strengthening ("提取即强化" / testing effect): when a
# /search returns hits, bump their access_count + last_accessed_at so the
# forgetting TTL and recency ranking treat recalled memories as alive. The
diff --git a/src/hebb/integrations/claude_code/recall.py b/src/hebb/integrations/claude_code/recall.py
index b48a9d6..6c09250 100644
--- a/src/hebb/integrations/claude_code/recall.py
+++ b/src/hebb/integrations/claude_code/recall.py
@@ -3,6 +3,7 @@
from __future__ import annotations
import logging
+import os
import sys
from typing import Any
@@ -133,9 +134,23 @@ def _fetch_filtered(client: httpx.Client, query: str, current_session_id: str) -
"""
top_k = _TOP_K_FETCH
while True:
+ body: dict[str, object] = {"query": query, "top_k": top_k}
+ env_min_score = os.environ.get("HEBB_RECALL_MIN_SCORE")
+ if env_min_score is not None:
+ try:
+ body["min_score"] = float(env_min_score)
+ except ValueError:
+ logger.debug(
+ "HEBB_RECALL_MIN_SCORE=%r is not a valid float; falling back to strict_recall",
+ env_min_score,
+ )
+ body["strict_recall"] = True
+ else:
+ body["strict_recall"] = True
+
resp = client.post(
"/api/v1/search",
- json={"query": query, "top_k": top_k, "strict_recall": True},
+ json=body,
)
resp.raise_for_status()
data = resp.json()
diff --git a/src/hebb/mcp/server.py b/src/hebb/mcp/server.py
index 0eab456..b02be2d 100644
--- a/src/hebb/mcp/server.py
+++ b/src/hebb/mcp/server.py
@@ -91,6 +91,7 @@ async def write_memory(
async def search_memory(
query: str,
top_k: int = 5,
+ min_score: float | None = None,
) -> str:
"""Search for related memories using hybrid retrieval.
@@ -100,15 +101,25 @@ async def search_memory(
Args:
query: Natural language search query.
top_k: Maximum number of results to return (1-100, default 5).
+ min_score: Optional relevance floor (0.0-1.0). When set, only
+ results scoring at or above this threshold are returned.
+ When omitted, the server's configured recall_min_score
+ (default 0.8) is applied via strict_recall.
"""
from hebb.retrieval.query_sanitizer import sanitize_query
query = sanitize_query(query)
+ body: dict[str, object] = {"query": query, "top_k": top_k}
+ if min_score is not None:
+ body["min_score"] = min_score
+ else:
+ body["strict_recall"] = True
+
async with httpx.AsyncClient() as client:
resp = await client.post(
f"{_base_url()}/api/v1/search",
- json={"query": query, "top_k": top_k, "strict_recall": True},
+ json=body,
)
resp.raise_for_status()
data = resp.json()
diff --git a/src/hebb/retrieval/rerank/local.py b/src/hebb/retrieval/rerank/local.py
index 252816e..59c4c79 100644
--- a/src/hebb/retrieval/rerank/local.py
+++ b/src/hebb/retrieval/rerank/local.py
@@ -35,6 +35,7 @@ def __init__(
model_name: str = "BAAI/bge-reranker-base",
top_n: int = 30,
hf_endpoint: str | None = None,
+ max_length: int = 512,
) -> None:
if hf_endpoint:
os.environ["HF_ENDPOINT"] = hf_endpoint
@@ -59,11 +60,14 @@ def __init__(
from torch.nn import Sigmoid
try:
- # No explicit max_length: CrossEncoder truncates long (query,
- # content) pairs to the tokenizer's model_max_length, which is the
- # model's own context window (512 for bge-reranker-base). Setting it
- # by hand only risks exceeding the model's position-embedding cap.
- self._model = CrossEncoder(model_name)
+ # Truncation must be set explicitly at construction. sentence-transformers
+ # 5.x's ``CrossEncoder.predict`` no longer truncates (query, content) pairs
+ # to the tokenizer's ``model_max_length`` — it only honors the ``max_length``
+ # set on the instance. Without it, a long pair exceeds the backbone's
+ # position-embedding cap (XLM-Roberta = 514) and crashes the forward pass
+ # with ``gather: index 514 is out of bounds``. 512 keeps one slot of headroom
+ # below the 514 cap and is the standard usable length for BGE-reranker-base.
+ self._model = CrossEncoder(model_name, max_length=max_length)
finally:
# Always restore the caller's original offline setting,
# regardless of which path we took above.
@@ -79,13 +83,38 @@ def __init__(
self._activation = Sigmoid()
self._model_name = model_name
self._top_n = top_n
- logger.info("Reranker ready: %s (top_n=%d, max_length=%s)", model_name, top_n, self._model.max_length)
+ self._max_length = max_length
+ logger.info("Reranker ready: %s (top_n=%d, max_length=%s)", model_name, top_n, self._max_length)
@property
def top_n(self) -> int:
+ """Number of leading candidates the reranker re-scores.
+
+ Returns:
+ The configured pool size (``top_n``) the caller should slice
+ its candidate list to before calling :meth:`score`.
+ """
return self._top_n
async def score(self, query: str, candidates: list[str]) -> list[float]:
+ """Re-score (query, candidate) pairs with the cross-encoder.
+
+ Runs the model's ``predict`` in a thread executor so the event
+ loop stays responsive during the blocking forward pass, and applies
+ the sigmoid activation so every score lands in ``[0, 1]`` — the
+ same scale as the no-rerank composite, so a single ``min_score``
+ floor reads consistently in both modes.
+
+ Args:
+ query: The recall query, paired with every candidate.
+ candidates: Candidate contents to re-score. Order is preserved
+ in the returned list.
+
+ Returns:
+ One sigmoid-normalised relevance score per candidate, in input
+ order. An empty input returns an empty list without touching
+ the model.
+ """
if not candidates:
return []
pairs = [[query, c] for c in candidates]
diff --git a/src/hebb/retrieval/searcher.py b/src/hebb/retrieval/searcher.py
index c4e0c71..3b29ae4 100644
--- a/src/hebb/retrieval/searcher.py
+++ b/src/hebb/retrieval/searcher.py
@@ -36,16 +36,6 @@
# near-flat decay.
_RECENCY_DECAY_FACTOR = 0.693
-# Strict-recall floor lives on a MIXED scale after rerank: reranked pool entries
-# carry the cross-encoder *sigmoid* relevance while the tail keeps the calibrated
-# composite. The two are not comparable — a genuinely relevant short memory often
-# scores a bge sigmoid well below a 0.8 *composite* floor (the cross-encoder is
-# conservative on terse text), so a uniform 0.8 silently empties strict-recall
-# results on the hook + MCP surfaces. We translate the composite floor to a
-# rerank-scale floor with this ratio: a relevant cross-encoder hit clears ~0.5
-# sigmoid, so a 0.8 composite floor maps to a 0.5 sigmoid floor (0.8 * 0.625).
-_RERANK_FLOOR_RATIO = 0.625
-
class MemorySearcher:
"""Orchestrates hybrid retrieval: vector + keyword + graph, then scoring.
@@ -92,7 +82,31 @@ def __init__(
# better rank) without depending on the cross-encoder reranker.
self.keyword_blend_enabled = keyword_blend_enabled
- async def search(self, query: MemoryQuery) -> SearchResponse:
+ async def search(self, query: MemoryQuery, *, rerank_floor_ratio: float = 0.625) -> SearchResponse:
+ """Run hybrid retrieval and return scored, optionally reranked results.
+
+ Three-path parallel recall (vector + keyword + graph) is fused with
+ Reciprocal Rank Fusion, then each candidate is scored on a calibrated
+ ``[0, 1]`` scale (``max(keyword_relevance, cosine_similarity)``). When a
+ reranker is configured, the top ``top_n`` candidates are re-scored by
+ the cross-encoder on its own sigmoid scale; the ``min_score`` floor is
+ then translated to that scale for the reranked pool via
+ ``rerank_floor_ratio`` while the composite floor is kept for the tail.
+
+ Args:
+ query: The recall query — text, ``top_k``, partition scope, tag
+ filter, ``prev_turns``/``next_turns`` window, and the optional
+ ``min_score`` strict-recall floor.
+ rerank_floor_ratio: Multiplier applied to ``query.min_score`` to
+ derive the floor for reranker-scored candidates (whose sigmoid
+ scale is more conservative than the composite scale). Only
+ affects the reranked pool; the tail keeps the composite floor.
+
+ Returns:
+ ``SearchResponse`` with the top-k ``results`` (ordered by rerank
+ score when a reranker ran, else by the RRF rank) plus ``related``
+ memories from turn-window and graph expansion.
+ """
# Sanitize LLM-generated queries (XML tags, tool artifacts, etc.)
sanitized = sanitize_query(query.query)
if sanitized != query.query:
@@ -286,7 +300,7 @@ async def _empty_ranked() -> list[tuple[Memory, float]]:
# recall on the two production surfaces. So translate the floor to the
# rerank scale for the pool and keep the composite floor for the tail.
if query.min_score > 0.0:
- rerank_floor = query.min_score * _RERANK_FLOOR_RATIO
+ rerank_floor = query.min_score * rerank_floor_ratio
kept: list[MemorySearchResult] = []
for i, r in enumerate(results):
floor = rerank_floor if i < reranked_count else query.min_score
diff --git a/src/hebb/server/routers/search.py b/src/hebb/server/routers/search.py
index 0993225..a372b83 100644
--- a/src/hebb/server/routers/search.py
+++ b/src/hebb/server/routers/search.py
@@ -40,7 +40,7 @@ async def search_memories(
updates["min_score"] = settings.recall_min_score
if updates:
query = query.model_copy(update=updates)
- response = await searcher.search(query)
+ response = await searcher.search(query, rerank_floor_ratio=settings.rerank_floor_ratio)
# Retrieval-induced strengthening: bump access for the memories we just
# surfaced so the forgetting TTL / recency ranking treat them as alive
diff --git a/src/hebb/static/js/components/activate.js b/src/hebb/static/js/components/activate.js
index 04e7625..a8d2f20 100644
--- a/src/hebb/static/js/components/activate.js
+++ b/src/hebb/static/js/components/activate.js
@@ -43,12 +43,13 @@ function groupRerank() {
return {
titleKey: 'settings.group.rerank',
icon: '🎯',
- keys: ['rerank_enabled', 'rerank_provider', 'rerank_model', 'rerank_top_n'],
+ keys: ['rerank_enabled', 'rerank_provider', 'rerank_model', 'rerank_top_n', 'rerank_floor_ratio'],
hints: {
rerank_enabled: t('recall.hint.rerank_enabled'),
rerank_provider: t('recall.hint.rerank_provider'),
rerank_model: t('recall.hint.rerank_model'),
rerank_top_n: t('recall.hint.rerank_top_n'),
+ rerank_floor_ratio: t('recall.hint.rerank_floor_ratio'),
},
};
}
diff --git a/src/hebb/static/js/i18n.js b/src/hebb/static/js/i18n.js
index eb4c439..359369d 100644
--- a/src/hebb/static/js/i18n.js
+++ b/src/hebb/static/js/i18n.js
@@ -406,6 +406,7 @@ const translations = {
'recall.hint.rerank_provider': '\'local\' = sentence-transformers CrossEncoder',
'recall.hint.rerank_model': 'Model name or HuggingFace repo id',
'recall.hint.rerank_top_n': 'Candidates to rerank before the final top_k (5–200)',
+ 'recall.hint.rerank_floor_ratio': 'Multiplier to translate composite-score floor to rerank-sigmoid scale. Default 0.625 maps a 0.8 composite floor → ~0.5 sigmoid. Tune when switching rerank models. Applies immediately, no restart.',
'recall.note_weights': 'When rerank is off, results are ranked by a weighted blend of three normalised [0–1] signals — relevance (how well a memory matches the query), importance, and recency. The weights are normalised before use, so only their ratio matters (1 / 1 / 1 = equal footing; raise one to let it dominate). These are the global defaults applied to automatic recall; the test sliders above override them for a single query. Takes effect immediately — no restart needed.',
'recall.hint.weight_recency': 'How strongly recent memories are favoured',
'recall.hint.weight_importance': 'How strongly high-importance memories are favoured',
@@ -822,6 +823,7 @@ const translations = {
'recall.hint.rerank_provider': '\'local\' = sentence-transformers CrossEncoder',
'recall.hint.rerank_model': '模型名称或 HuggingFace 仓库 id',
'recall.hint.rerank_top_n': '在最终 top_k 之前参与重排的候选数(5–200)',
+ 'recall.hint.rerank_floor_ratio': '将综合分数下限映射到重排 sigmoid 尺度的乘数。默认 0.625 将 0.8 的综合下限映射为 ~0.5 的 sigmoid 下限。更换重排模型时可调整。立即生效,无需重启。',
'recall.note_weights': '关闭重排时,结果按三个归一化到 [0–1] 的信号加权融合排序——相关性(记忆与查询的匹配程度)、重要性和时近性。权重在使用前会先归一化,因此只有它们之间的比例有意义(1 / 1 / 1 = 同等地位;调高某一项可让其占主导)。这些是应用于自动召回的全局默认值;上方的测试滑块仅对单次查询覆盖它们。立即生效——无需重启。',
'recall.hint.weight_recency': '对较新记忆的偏好强度',
'recall.hint.weight_importance': '对高重要性记忆的偏好强度',
diff --git a/tests/unit/test_audit_retrieval.py b/tests/unit/test_audit_retrieval.py
index 94cdd29..d929df8 100644
--- a/tests/unit/test_audit_retrieval.py
+++ b/tests/unit/test_audit_retrieval.py
@@ -34,15 +34,19 @@ class FakeEmbedder:
@property
def dimension(self) -> int:
+ """Fixed dimensionality matching the constant embedding below."""
return 3
async def embed(self, text: str) -> list[float]:
+ """Return the constant 3-d vector so the vector path produces a hit."""
return [0.1, 0.2, 0.3]
async def embed_batch(self, texts: list[str]) -> list[list[float]]:
+ """Return one constant vector per input — batch form of :meth:`embed`."""
return [[0.1, 0.2, 0.3] for _ in texts]
async def aclose(self) -> None: # pragma: no cover - no resources
+ """No resources to release."""
return None
@@ -59,6 +63,7 @@ def __init__(self, memories: list[Memory]) -> None:
self.doc_freq_calls: list[tuple[list[str], list[str] | None]] = []
async def get(self, memory_id: str) -> Memory | None:
+ """Return the memory for ``memory_id`` or ``None`` if absent."""
return self._by_id.get(memory_id)
async def search_by_vector(
@@ -67,6 +72,7 @@ async def search_by_vector(
top_k: int = 10,
partition_ids: list[str] | None = None,
) -> list[tuple[Memory, float]]:
+ """Return no vector hits — vector recall is patched per-test."""
return []
async def search_by_keyword(
@@ -75,19 +81,23 @@ async def search_by_keyword(
top_k: int = 10,
partition_ids: list[str] | None = None,
) -> list[tuple[Memory, float]]:
+ """Return no keyword hits — keyword recall is patched per-test."""
return []
async def corpus_size(self, partition_ids: list[str] | None = None) -> int:
+ """Record the partition scope and report the in-memory corpus size."""
self.corpus_size_calls.append(partition_ids)
return len(self._by_id)
async def keyword_doc_freqs(
self, terms: list[str], partition_ids: list[str] | None = None
) -> dict[str, int]:
+ """Record the terms + scope and return a flat DF of 1 per term."""
self.doc_freq_calls.append((list(terms), partition_ids))
return {t: 1 for t in terms}
async def update_access_batch(self, memory_ids: list[str]) -> None: # pragma: no cover
+ """No-op access-time update — the audit path doesn't assert on it."""
return None
@@ -100,9 +110,11 @@ def __init__(self, score: float, top_n: int = 30) -> None:
@property
def top_n(self) -> int:
+ """Rerank pool size the searcher slices candidates to."""
return self._top_n
async def score(self, query: str, candidates: list[str]) -> list[float]:
+ """Return the fixed score for every candidate, preserving input order."""
return [self._score for _ in candidates]
@@ -185,6 +197,40 @@ async def test_no_rerank_floor_uses_composite_scale() -> None:
assert [r.memory.id for r in resp.results] == [mem.id]
+async def test_custom_rerank_floor_ratio_tight() -> None:
+ """A higher ratio tightens the rerank-scale floor, dropping a marginal
+ sigmoid hit that the default 0.625 ratio would have let through."""
+ mem = _mem("the capital of sweden is stockholm")
+ searcher = _searcher_with_vector_hit(mem, reranker=FakeReranker(0.6))
+
+ query = MemoryQuery(query="what is the capital of sweden", min_score=0.8)
+
+ # Default ratio 0.625: rerank_floor = 0.8 * 0.625 = 0.5 → 0.6 survives.
+ resp = await searcher.search(query)
+ assert [r.memory.id for r in resp.results] == [mem.id]
+
+ # Custom ratio 0.9: rerank_floor = 0.8 * 0.9 = 0.72 → 0.6 is dropped.
+ resp = await searcher.search(query, rerank_floor_ratio=0.9)
+ assert resp.results == []
+
+
+async def test_custom_rerank_floor_ratio_lenient() -> None:
+ """A lower ratio relaxes the rerank-scale floor, letting a weak sigmoid
+ hit through that the default 0.625 ratio would have dropped."""
+ mem = _mem("a somewhat relevant note about nordic countries")
+ searcher = _searcher_with_vector_hit(mem, reranker=FakeReranker(0.35))
+
+ query = MemoryQuery(query="what is the capital of sweden", min_score=0.8)
+
+ # Default ratio 0.625: rerank_floor = 0.8 * 0.625 = 0.5 → 0.35 is dropped.
+ resp = await searcher.search(query)
+ assert resp.results == []
+
+ # Custom ratio 0.3: rerank_floor = 0.8 * 0.3 = 0.24 → 0.35 survives.
+ resp = await searcher.search(query, rerank_floor_ratio=0.3)
+ assert [r.memory.id for r in resp.results] == [mem.id]
+
+
# ---------------------------------------------------------------------------
# C6: graph channel respects partition_ids
# ---------------------------------------------------------------------------