candding 0.1.0

Pure candle embeddings for Rust with no ONNX: dense, sparse, multi-vector and rerank models today, image models on the roadmap
Documentation
//! The rerank catalog: `all`, `lookup` and `by_phase` over its entries, each a `RerankDescriptor`.

mod bge_reranker_base;
mod bge_reranker_v2_m3;
mod entry;
mod input;
mod jina_reranker_v1_tiny;
mod jina_reranker_v2;
mod ms_marco;
mod qwen3_reranker;

use bge_reranker_base::BGE_RERANKER_BASE;
use bge_reranker_v2_m3::BGE_RERANKER_V2_M3;
use candle_core::DType;
pub use entry::RerankDescriptor;
use entry::RerankEntry;
pub use input::RerankInput;
use jina_reranker_v1_tiny::JINA_RERANKER_V1_TINY_EN;
use jina_reranker_v2::JINA_RERANKER_V2_BASE_MULTILINGUAL;
use ms_marco::MS_MARCO_MINILM_L6_V2;
use qwen3_reranker::QWEN3_RERANKER_0_6B;
use qwen3_reranker::QWEN3_RERANKER_4B;
use qwen3_reranker::QWEN3_RERANKER_8B;

/// Entries land already proven: `registry::tests::verified` fails for an entry with no `Verified` cell.
pub(super) const ENTRIES: &[RerankEntry] = &[
  MS_MARCO_MINILM_L6_V2,
  JINA_RERANKER_V1_TINY_EN,
  BGE_RERANKER_BASE,
  BGE_RERANKER_V2_M3,
  QWEN3_RERANKER_0_6B,
  QWEN3_RERANKER_4B,
  QWEN3_RERANKER_8B,
  JINA_RERANKER_V2_BASE_MULTILINGUAL,
];

/// Every registered rerank entry, in registration order.
pub fn all() -> Vec<RerankDescriptor> {
  ENTRIES.iter().map(RerankEntry::descriptor).collect()
}

fn entry_for(id: &str) -> Option<&'static RerankEntry> {
  ENTRIES
    .iter()
    .find(|entry| entry.id.eq_ignore_ascii_case(id))
}

/// This registry's own spelling of an id it carries, for `registry::canonical_id`.
pub(crate) fn canonical_id(id: &str) -> Option<&'static str> {
  entry_for(id).map(|entry| entry.id)
}

/// Case-insensitive lookup by repository id.
pub fn lookup(id: &str) -> Option<RerankDescriptor> {
  entry_for(id).map(RerankEntry::descriptor)
}

/// Every registered rerank entry for a phase, in registration order.
pub fn by_phase(phase: u8) -> Vec<RerankDescriptor> {
  ENTRIES
    .iter()
    .filter(|entry| entry.phase == phase)
    .map(RerankEntry::descriptor)
    .collect()
}

/// Whether a registered rerank id computes `dtype` correctly only on an accelerator, read from the row its builder
/// refuses from, cell exceptions included; `false` for an id outside the rerank catalog.
pub fn dtype_needs_accelerator(id: &str, dtype: DType) -> bool {
  entry_for(id).is_some_and(|entry| entry.needs_accelerator(dtype))
}

#[cfg(test)]
mod tests;