Commit 3cb2942
committed
fix(consolidation): eliminate duplicate observations
Consolidation produced duplicate observations two ways: (1) the cross-encoder
reranker demoted a near-identical existing observation below the recall budget,
hiding it from the LLM; (2) even when shown the twin, the model emitted an
identical CREATE anyway (often while also UPDATE-ing it).
Changes:
- recall: add a 'rerank' flag; consolidation recall ranks by RRF (rerank=False)
so a near-identical existing observation stays near the top instead of being
demoted by the cross-encoder. Default recall path is unchanged.
- consolidation: drop a CREATE whose normalized text exactly matches an
observation shown to the LLM, or the text of an UPDATE issued in the same
response (exact match => no information loss). See _duplicate_create_target;
dropped creates are logged at WARNING.
- add a 'reason' field to consolidation create/update/delete actions so the
model explains its choices (surfaced when a duplicate create is dropped).
- tests/eval: deterministic unit test for the dedup guard
(test_consolidation_dedup.py); the duplicate-observation rate is tracked by a
new quality benchmark (hindsight-dev/benchmarks/obs) over a synthetic
herb-garden transcript and the real PII-free hermes session that surfaced the
bug, reusing the obs-dedup tool — instead of a flaky real-LLM pytest.1 parent 92bd42c commit 3cb2942
10 files changed
Lines changed: 599 additions & 16 deletions
File tree
- hindsight-api-slim
- hindsight_api/engine
- consolidation
- tests
- hindsight-dev/benchmarks/obs
- datasets
- scripts/benchmarks
Lines changed: 66 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 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 | + | |
49 | 75 | | |
50 | 76 | | |
51 | 77 | | |
| |||
167 | 193 | | |
168 | 194 | | |
169 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
170 | 199 | | |
171 | 200 | | |
172 | 201 | | |
| |||
178 | 207 | | |
179 | 208 | | |
180 | 209 | | |
| 210 | + | |
181 | 211 | | |
182 | 212 | | |
183 | 213 | | |
| |||
187 | 217 | | |
188 | 218 | | |
189 | 219 | | |
| 220 | + | |
190 | 221 | | |
191 | 222 | | |
192 | 223 | | |
| |||
1104 | 1135 | | |
1105 | 1136 | | |
1106 | 1137 | | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
1107 | 1149 | | |
1108 | 1150 | | |
1109 | 1151 | | |
1110 | 1152 | | |
1111 | 1153 | | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
1112 | 1171 | | |
1113 | 1172 | | |
1114 | 1173 | | |
1115 | 1174 | | |
1116 | | - | |
| 1175 | + | |
1117 | 1176 | | |
1118 | 1177 | | |
1119 | 1178 | | |
| |||
1398 | 1457 | | |
1399 | 1458 | | |
1400 | 1459 | | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
1401 | 1466 | | |
1402 | 1467 | | |
1403 | 1468 | | |
| |||
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
| 96 | + | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
Lines changed: 33 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| 245 | + | |
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
| |||
3141 | 3142 | | |
3142 | 3143 | | |
3143 | 3144 | | |
| 3145 | + | |
3144 | 3146 | | |
3145 | 3147 | | |
3146 | 3148 | | |
| |||
3297 | 3299 | | |
3298 | 3300 | | |
3299 | 3301 | | |
| 3302 | + | |
3300 | 3303 | | |
3301 | 3304 | | |
3302 | 3305 | | |
| |||
3428 | 3431 | | |
3429 | 3432 | | |
3430 | 3433 | | |
| 3434 | + | |
3431 | 3435 | | |
3432 | 3436 | | |
3433 | 3437 | | |
| |||
3791 | 3795 | | |
3792 | 3796 | | |
3793 | 3797 | | |
| 3798 | + | |
3794 | 3799 | | |
3795 | | - | |
3796 | | - | |
3797 | | - | |
3798 | | - | |
3799 | | - | |
| 3800 | + | |
| 3801 | + | |
3800 | 3802 | | |
3801 | 3803 | | |
3802 | | - | |
3803 | 3804 | | |
3804 | 3805 | | |
3805 | 3806 | | |
3806 | 3807 | | |
3807 | | - | |
3808 | | - | |
| 3808 | + | |
| 3809 | + | |
| 3810 | + | |
| 3811 | + | |
| 3812 | + | |
| 3813 | + | |
| 3814 | + | |
| 3815 | + | |
| 3816 | + | |
| 3817 | + | |
| 3818 | + | |
| 3819 | + | |
| 3820 | + | |
| 3821 | + | |
| 3822 | + | |
| 3823 | + | |
| 3824 | + | |
| 3825 | + | |
| 3826 | + | |
| 3827 | + | |
| 3828 | + | |
3809 | 3829 | | |
3810 | 3830 | | |
3811 | 3831 | | |
3812 | 3832 | | |
3813 | | - | |
| 3833 | + | |
| 3834 | + | |
3814 | 3835 | | |
3815 | 3836 | | |
3816 | 3837 | | |
| |||
3825 | 3846 | | |
3826 | 3847 | | |
3827 | 3848 | | |
3828 | | - | |
| 3849 | + | |
| 3850 | + | |
3829 | 3851 | | |
3830 | 3852 | | |
3831 | 3853 | | |
| |||
3845 | 3867 | | |
3846 | 3868 | | |
3847 | 3869 | | |
3848 | | - | |
| 3870 | + | |
3849 | 3871 | | |
3850 | 3872 | | |
3851 | 3873 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments