Indexing & Ranking (L2) β
L2 uses a hybrid approach combining sparse filters, lightweight vector retrieval, and precomputed features.
Indexing β
- Sparse: inverted index over keywords, entities, and tags
- Filters:
project_id
,type
,freshness
,pinned
- Vector (optional): small embedding over
title+summary
from L1 - Precompute features into CurationIndex for fast scoring
Ranking features (examples) β
entity_overlap
(0..1)recency_days
(lower is better)source_reliability
(0..1)query_term_match
(BM25-lite)pin_boost
(pinned items get a fixed uplift)
Scoring outline β
text
score = w1*entity_overlap + w2*query_term_match + w3*(1 - min(1, recency_days/30)) + w4*source_reliability + pin_boost
Weights are configured per project via ENV/provider config. Default top_k
limited by L2_TOP_K_MAX
.
Hot set policies β
- Pin: maintain a small curated set of golden items
- Compress: store compact summaries for low-signal tail
- Evict: remove stale items by recency and zero-usage
Budgets and degradation β
- Time budget:
L2_TIME_MS_BUDGET
(default 8 ms) - Degradation path:
- Reduce
top_k
- Drop vector stage, keep sparse+features
- Return metadata-only items
- Reduce
Evaluation hooks (L8) β
- Track Recall@K, MRR@n per query class
- Emit evaluation events with
request_id
,project_id
,t_ms
, and chosen features