mirror of
https://github.com/openai/codex.git
synced 2026-10-28 18:58:46 +00:00
## What changed - Add shadow selectors that fuse recently invoked skills with character routing-card matches using reciprocal rank fusion. - Add a second variant that also incorporates weighted lexical matches. - Record both variants in the existing shadow-selection experiment, capped at 50 candidates. ## Testing - Cover cold starts, duplicate removal, short exact matches, deterministic ranking, result limits, and truncation metadata. - Extend the skills integration test to verify both selectors recover a skill invoked on an earlier turn. GitOrigin-RevId: 4ff9e91da8cb49ecbce54ab8e760820616e1a1d3
59 lines
2.2 KiB
Rust
59 lines
2.2 KiB
Rust
mod character_ngram;
|
|
mod character_routing_card;
|
|
mod fielded_bm25;
|
|
mod lru;
|
|
mod lru_plus_character_routing;
|
|
mod lru_plus_lexical;
|
|
mod multi_query_lexical;
|
|
mod routing_card_lexical;
|
|
mod rrf_lexical_char;
|
|
mod weighted_lexical;
|
|
pub(crate) use character_ngram::CharacterNgramSkillSelector;
|
|
pub(crate) use character_routing_card::CharacterRoutingCardSkillSelector;
|
|
use codex_skills::SkillDependencies;
|
|
pub(crate) use fielded_bm25::FieldedBm25SkillSelector;
|
|
pub(crate) use lru::LruSkillSelector;
|
|
pub(crate) use lru_plus_character_routing::LruPlusCharacterRoutingSkillSelector;
|
|
pub(crate) use lru_plus_character_routing::LruPlusLexicalCharacterRoutingSkillSelector;
|
|
pub(crate) use lru_plus_lexical::LruPlusLexicalSkillSelector;
|
|
pub(crate) use multi_query_lexical::MultiQueryLexicalSkillSelector;
|
|
pub(crate) use routing_card_lexical::RoutingCardLexicalSkillSelector;
|
|
pub(crate) use rrf_lexical_char::RrfLexicalCharSkillSelector;
|
|
pub(crate) use weighted_lexical::WeightedLexicalSkillSelector;
|
|
|
|
/// Metadata searched by a cheap skill selector.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub(crate) struct SkillSelectionDocument<'a> {
|
|
/// Caller-owned identifier returned in [`CheapSkillSelection::candidate_ids`].
|
|
pub id: usize,
|
|
pub name: &'a str,
|
|
pub short_description: Option<&'a str>,
|
|
pub description: &'a str,
|
|
pub dependencies: Option<&'a SkillDependencies>,
|
|
}
|
|
|
|
/// Bounded output from one cheap skill-selection method.
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
|
pub(crate) struct CheapSkillSelection {
|
|
pub candidate_ids: Vec<usize>,
|
|
pub query_term_count: usize,
|
|
pub query_truncated: bool,
|
|
pub candidate_set_truncated: bool,
|
|
}
|
|
|
|
/// Selects likely-relevant skills without changing the model-visible catalog.
|
|
///
|
|
/// Implementations must be deterministic, side-effect free, and cheap enough to run in shadow
|
|
/// mode on every turn. Callers must validate returned IDs against the supplied documents.
|
|
pub(crate) trait CheapSkillSelector: Send + Sync {
|
|
/// Low-cardinality identifier suitable for experiment metrics.
|
|
fn method(&self) -> &'static str;
|
|
|
|
fn select(
|
|
&self,
|
|
query: &str,
|
|
documents: &[SkillSelectionDocument<'_>],
|
|
limit: usize,
|
|
) -> CheapSkillSelection;
|
|
}
|