chore: update retrieval components

This commit is contained in:
2026-02-08 18:14:02 +08:00
parent 8fdce7b9a1
commit 8226c48624
3 changed files with 116 additions and 229 deletions

View File

@@ -48,17 +48,15 @@ export function createMetrics() {
// L3 Evidence Assembly
l3: {
floorsFromL0: 0,
// 候选规模rerank 前)
l1Total: 0,
l1AfterCoarse: 0,
chunksInRange: 0,
chunksInRangeByType: { l0Virtual: 0, l1Real: 0 },
// 最终注入rerank + sparse 后)
chunksSelected: 0,
chunksSelectedByType: { l0Virtual: 0, l1Real: 0 },
// 上下文配对
contextPairsAdded: 0,
tokens: 0,
assemblyTime: 0,
// Rerank 相关
rerankApplied: false,
beforeRerank: 0,
afterRerank: 0,
@@ -80,7 +78,6 @@ export function createMetrics() {
breakdown: {
constraints: 0,
events: 0,
entities: 0,
chunks: 0,
recentOrphans: 0,
arcs: 0,
@@ -204,8 +201,15 @@ export function formatMetricsLog(metrics) {
lines.push('[L3] Evidence Assembly');
lines.push(`├─ floors_from_l0: ${m.l3.floorsFromL0}`);
// 候选规模
lines.push(`├─ chunks_in_range: ${m.l3.chunksInRange}`);
// L1 粗筛信息
if (m.l3.l1Total > 0) {
lines.push(`├─ l1_coarse_filter:`);
lines.push(`│ ├─ total: ${m.l3.l1Total}`);
lines.push(`│ ├─ after: ${m.l3.l1AfterCoarse}`);
lines.push(`│ └─ filtered: ${m.l3.l1Total - m.l3.l1AfterCoarse}`);
}
lines.push(`├─ chunks_merged: ${m.l3.chunksInRange}`);
if (m.l3.chunksInRangeByType) {
const cir = m.l3.chunksInRangeByType;
lines.push(`│ ├─ l0_virtual: ${cir.l0Virtual || 0}`);
@@ -226,7 +230,6 @@ export function formatMetricsLog(metrics) {
lines.push(`├─ rerank_applied: false`);
}
// 最终注入规模
lines.push(`├─ chunks_selected: ${m.l3.chunksSelected}`);
if (m.l3.chunksSelectedByType) {
const cs = m.l3.chunksSelectedByType;
@@ -341,6 +344,14 @@ export function detectIssues(metrics) {
issues.push('L0 atoms not matched - may need to generate anchors');
}
// L1 粗筛问题
if (m.l3.l1Total > 0 && m.l3.l1AfterCoarse > 0) {
const coarseFilterRatio = 1 - (m.l3.l1AfterCoarse / m.l3.l1Total);
if (coarseFilterRatio > 0.9) {
issues.push(`Very high L1 coarse filter ratio (${(coarseFilterRatio * 100).toFixed(0)}%) - query may be too specific`);
}
}
// Rerank 相关问题
if (m.l3.rerankApplied) {
if (m.l3.beforeRerank > 0 && m.l3.afterRerank > 0) {
@@ -365,7 +376,7 @@ export function detectIssues(metrics) {
}
}
// 证据密度问题(基于 selected 的构成)
// 证据密度问题
if (m.l3.chunksSelected > 0 && m.l3.chunksSelectedByType) {
const l1Real = m.l3.chunksSelectedByType.l1Real || 0;
const density = l1Real / m.l3.chunksSelected;