Views
No views yet
pip install mlx tokenizers huggingface_hub1from huggingface_hub import snapshot_download
2from utils import load_model
3
4model_dir = snapshot_download("jinaai/jina-embeddings-v5-text-small-mlx")
5model = load_model(model_dir)
6
7# Retrieval
8model.switch_task("retrieval")
9q_emb = model.encode(["What is machine learning?"], task_type="retrieval.query")
10d_emb = model.encode(["Machine learning is a branch of AI."], task_type="retrieval.passage")
11
12# Switch task (about 20ms, in-place, no extra memory)
13model.switch_task("clustering")
14emb = model.encode(["Group this document."])| Task | task_type | Description |
|---|---|---|
| retrieval | retrieval.query / retrieval.passage | Semantic search |
| text-matching | text-matching | Similarity comparison |
| clustering | clustering | Document grouping |
| classification | classification | Text classification |
mx.fast.scaled_dot_product_attention, mx.fast.rope1@article{mohr2025jina,
2 title={Jina Embeddings v5: Universal Embeddings for Any Task, Length, and Language},
3 author={Mohr, Isabella and Wang, Bo and G{\"u}nther, Michael and Sturua, Saba and Wang, Yanlong and Mastrapas, Georgios and Wang, Isabelle and Lange, Lennart and Xiao, Han},
4 journal={arXiv preprint arXiv:2602.15547},
5 year={2025}
6}