mod answerai_colbert_small;
mod bge_m3;
mod colbertv2;
mod conventions;
mod entry;
mod jina_colbert_v2;
use answerai_colbert_small::ANSWERAI_COLBERT_SMALL_MULTI_VECTOR;
use bge_m3::BGE_M3_MULTI_VECTOR;
use candle_core::DType;
use colbertv2::COLBERTV2_MULTI_VECTOR;
pub use entry::MultiVectorDescriptor;
pub(super) use entry::MultiVectorEntry;
use jina_colbert_v2::JINA_COLBERT_V2_MULTI_VECTOR;
pub(super) const ENTRIES: &[MultiVectorEntry] = &[
BGE_M3_MULTI_VECTOR,
COLBERTV2_MULTI_VECTOR,
ANSWERAI_COLBERT_SMALL_MULTI_VECTOR,
JINA_COLBERT_V2_MULTI_VECTOR,
];
pub fn all() -> Vec<MultiVectorDescriptor> {
ENTRIES.iter().map(MultiVectorEntry::descriptor).collect()
}
fn entry_for(id: &str) -> Option<&'static MultiVectorEntry> {
ENTRIES
.iter()
.find(|entry| entry.id.eq_ignore_ascii_case(id))
}
pub(crate) fn canonical_id(id: &str) -> Option<&'static str> {
entry_for(id).map(|entry| entry.id)
}
pub fn lookup(id: &str) -> Option<MultiVectorDescriptor> {
entry_for(id).map(MultiVectorEntry::descriptor)
}
pub fn by_phase(phase: u8) -> Vec<MultiVectorDescriptor> {
ENTRIES
.iter()
.filter(|entry| entry.phase == phase)
.map(MultiVectorEntry::descriptor)
.collect()
}
pub fn dtype_needs_accelerator(id: &str, dtype: DType) -> bool {
entry_for(id).is_some_and(|entry| {
entry
.descriptor()
.dtype_backends
.row(dtype)
.needs_accelerator()
})
}
#[cfg(test)]
mod tests;