Skip to main content

Module ranking

Module ranking 

Source
Expand description

Alpha auto-detection and query-driven boosting.

Port of ~/src/semble/src/semble/ranking/weighting.py and ~/src/semble/src/semble/ranking/boosting.py.

Three public entry points:

  • resolve_alpha — picks the semantic/BM25 blend weight from the query shape: 0.3 for bare-symbol queries (lean BM25), 0.5 for natural-language queries (balanced).
  • apply_query_boost — adds query-type boosts on top of a score map. Returns a new map; callers re-rank afterwards.
  • boost_multi_chunk_files — file-coherence boost; promotes the top chunk of files whose chunks collectively score high.

Where Python keys combined_scores by Chunk, this port uses HashMap<usize, f32> (chunk index → score) plus &[CodeChunk] for lookups. Same shape as crate::encoder::ripvec::penalties::rerank_topk.

Constants§

ALPHA_NL
Semantic blend weight for natural-language queries. Balanced.
ALPHA_SYMBOL
Semantic blend weight for symbol-shaped queries. Lean BM25.

Functions§

apply_query_boost
Apply query-type boosts to candidate scores.
boost_multi_chunk_files
Promote files with multiple high-scoring chunks by boosting their top chunk in place. Mirrors boost_multi_chunk_files.
is_prose_path
Return true when path is a prose / documentation file (markdown, rst, plain text, asciidoc, org).
is_symbol_query
Return true when the query looks like a bare symbol or namespace-qualified identifier (Foo::Bar, module.Class, _x, getX, XMLParser, etc.).
resolve_alpha
Return the semantic blend weight, optionally overriding by caller.