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
use super::*;

#[test]
fn keeps_cls_row_false_drops_the_classification_row() {
  let model = head(
    Tensor::eye(2, DType::F32, &Device::Cpu).unwrap(),
    HashSet::new(),
    2,
    false,
    true,
  );
  let hidden = Tensor::new(
    &[[[1f32, 0.0], [0.0, 1.0], [1.0, 1.0], [1.0, -1.0]]],
    &Device::Cpu,
  )
  .unwrap();
  let ids = vec![vec![2u32, 16, 4, 3]];
  let rows = model.select_document_rows(&hidden, &ids, &[4]).unwrap();
  assert_eq!(
    rows[0].row_count(),
    3,
    "keeps_cls_row false must drop position 0"
  );
}

/// `diag(3, 4)` applied to `[1, 1]` must stay `[3, 4]`, neither renormalized nor biased.
#[test]
fn normalize_false_and_no_bias_leave_the_raw_projection_unchanged() {
  let weight = Tensor::new(&[[3f32, 0.0], [0.0, 4.0]], &Device::Cpu).unwrap();
  let model = JinaColbert {
    encoder: dummy_encoder(2),
    weight,
    bias: None,
    punctuation_ids: HashSet::new(),
    dim: 2,
    normalize: false,
    keeps_cls_row: true,
    attends_to_mask_tokens: true,
  };
  let hidden = Tensor::new(&[[[1f32, 1.0]]], &Device::Cpu).unwrap();
  let projected = model.project(&hidden).unwrap();
  assert!(
    (projected[0][0][0] - 3.0).abs() < 1e-6 && (projected[0][0][1] - 4.0).abs() < 1e-6,
    "with normalize:false and no bias, [1,1] through diag(3,4) must stay [3,4]: {:?}",
    projected[0][0]
  );
}