Skip to content

feat: support Jina AI v5 Matryoshka embedding models (nano + small) #134

@metaphorics

Description

@metaphorics

Goal

Add support for Jina AI's v5 Matryoshka text-embedding models (jina-embeddings-v5-text-{nano,small}-retrieval) as selectable backends in ICM, with full plumbing for Matryoshka truncation, asymmetric retrieval, and auto re-embed when the active model's dimension changes.

Jina v5 lifts MTEB English v2 to ~71 (small 1024d, nano 768d) and ships ONNX exports with Matryoshka representation learning (truncate dims down to 32) and asymmetric retrieval.query: / retrieval.passage: instruction prefixes.

License caveat

Jina v5 weights are CC BY-NC 4.0 (non-commercial). Surfaced clearly in README, config/default.toml, and icm config show. Default backend remains fastembed (Apache-2.0).

Slice plan (all DONE locally — see PR)

  • S-store — refactor schema migration to return MigrationStatus (decouples store from embedder)
  • S-1Embedder trait extension (embed_query, embed_document, model_name, license) + JinaV5NanoEmbedder via ort + tokenizers + hf-hub
  • S-2JinaV5SmallEmbedder (Qwen3-based, dim 1024)
  • S-3 — auto re-embed on dim change with --no-auto-reembed opt-out flag
  • S-4 — asymmetric retrieval prefixes (retrieval.query: / retrieval.passage: ) via internal TextEncoder DI for testability
  • S-5 — docs/UX/license disclosure (README, config/default.toml, icm config show, recall header, CHANGELOG)

Verification

  • cargo test --features "embeddings jina-v5" — 310 passed (8 suites)
  • cargo clippy --features "embeddings jina-v5" -- -D warnings — clean
  • All Codex spec + quality reviews PASS per slice

Upstream Track 2

A registration-only patch for Anush008/fastembed-rs adding EmbeddingModel::JinaEmbeddingsV5TextNano is being submitted in parallel (separate PR upstream). The v5-small Qwen3-decoder path is blocked on upstream architecture (closed PR #236 attempted it); ICM ships its own ort integration in icm-core for the local consumer use case.

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions