Skip to main content

filter_top_candidates

Function filter_top_candidates 

Source
pub fn filter_top_candidates(
    query: &str,
    candidates: &IndexMap<String, String>,
    config: &CoarseToFineConfig,
    scorer: &impl CoarseScorer,
) -> Result<FilteredCandidates>
Expand description

大規模候補群から Top-M 件を抽出し、ネガティブ候補を保護した部分マップを生成する。

§計算量とタイブレーク

  • select_nth_unstable_by による $O(K)$ クイックセレクトを採用。
  • 類似度スコアが同等の場合は、元の Criteria 内の出現順序 (インデックス昇順) でタイブレークを行い、決定論的再現性を担保する。
  • 最終的な候補マップは元の出現順序を維持して再構成される。

§引数

  • query: 照会クエリテキスト (State + Instructions)。
  • candidates: 全候補の順序付きマップ。
  • config: 粗密探索設定。
  • scorer: 類似度スコアラー。