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
//! What `TextCrossEncoderBuilder::build` decides from the descriptor alone, kept apart so each decision is tested
//! without a download: the head's conventions and the architecture key.

use std::path::Path;

use crate::error::Result;
use crate::loader;
use crate::models::RerankConventions;
use crate::models::xlm_roberta_flash;
use crate::registry::Family;
use crate::registry::rerank::RerankDescriptor;

/// Copies the descriptor's head, activation, ALiBi variant and position scheme into `RerankConventions`.
pub(super) fn conventions_from_descriptor(descriptor: &RerankDescriptor) -> RerankConventions {
  RerankConventions {
    head: descriptor.head,
    score_activation: descriptor.score_activation,
    alibi_variant: descriptor.alibi_variant,
    position_scheme: descriptor.position_scheme,
  }
}

/// The key `models::load_rerank` dispatches on: `config.json`'s architecture, or `xlm_roberta_flash::ARCHITECTURE`
/// for a flash entry, whose checkpoints publish no `model_type`.
pub(super) fn architecture(descriptor: &RerankDescriptor, config: &Path) -> Result<String> {
  if descriptor.family == Family::XlmRobertaFlash {
    return Ok(xlm_roberta_flash::ARCHITECTURE.to_string());
  }
  loader::read_architecture(config)
}

#[cfg(test)]
mod tests;