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

/// All six declare `"model_type": "bert"` and reach this family only through `"position_embedding_type": "alibi"`.
#[test]
fn every_jina_entry_holds_the_jina_bert_family_and_the_common_fields() {
  let jina: Vec<_> = all()
    .into_iter()
    .filter(|d| d.family == Family::JinaBert)
    .collect();
  assert_eq!(
    jina.len(),
    6,
    "all three block shapes are registered: four base, one QK-norm, one split-norm"
  );
  for d in &jina {
    assert!(d.id.starts_with("jinaai/jina-embeddings-v2-"), "{}", d.id);
    assert_eq!(d.pooling, Pooling::Mean, "{}", d.id);
    assert_eq!(
      d.default_max_length, 8192,
      "{}: the repository's own sentence_bert_config.json value",
      d.id
    );
    assert_eq!(d.default_dtype, DType::F32, "{}", d.id);
    assert_eq!(d.license, "Apache-2.0", "{}", d.id);
    assert!(
      d.query_template.is_none() && d.passage_template.is_none(),
      "{}",
      d.id
    );
    assert!(
      d.default_instruction.is_none() && !d.mrl && !d.gated,
      "{}",
      d.id
    );
    assert!(d.dense_dirs.is_empty(), "{}", d.id);
    assert_eq!(
      weights_format(&d.id),
      WeightsFormat::Safetensors,
      "{}",
      d.id
    );
  }
}

/// `small-en` is 65 388 544 bytes against `base-en`'s 274 757 256 and the multilingual models' about 321.7 M.
#[test]
fn the_small_english_model_is_the_only_512_wide_one() {
  assert_eq!(
    lookup("jinaai/jina-embeddings-v2-small-en").unwrap().dim,
    512
  );
  for id in [
    "jinaai/jina-embeddings-v2-base-en",
    "jinaai/jina-embeddings-v2-base-de",
    "jinaai/jina-embeddings-v2-base-zh",
    "jinaai/jina-embeddings-v2-base-es",
    "jinaai/jina-embeddings-v2-base-code",
  ] {
    assert_eq!(lookup(id).unwrap().dim, 768, "{id}");
  }
}

/// These two publish no `Normalize` module, yet every catalog entry returns unit vectors.
#[test]
fn a_repository_without_a_normalize_module_is_still_described_as_normalizing() {
  for id in [
    "jinaai/jina-embeddings-v2-small-en",
    "jinaai/jina-embeddings-v2-base-code",
  ] {
    assert!(lookup(id).unwrap().normalize, "{id}");
  }
}