Instructions to use jinaai/jina-embeddings-v4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jinaai/jina-embeddings-v4 with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("jinaai/jina-embeddings-v4", trust_remote_code=True, dtype="auto") - ColPali
How to use jinaai/jina-embeddings-v4 with ColPali:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- sentence-transformers
How to use jinaai/jina-embeddings-v4 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("jinaai/jina-embeddings-v4", trust_remote_code=True) sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
no apply_rotary_emb function
Running the model on Windows with installed flash_attn==2.7.1.post4 and transformers==4.56.0.dev0 I get the error
from transformers.modeling_flash_attention_utils import apply_rotary_emb, flash_attn_varlen_func
ImportError: cannot import name 'apply_rotary_emb' from 'transformers.modeling_flash_attention_utils'
Actually I double checked the transformers package and do not exists into transformers.modeling_flash_attention_utils
I'm forced to uninstall flash_attn to make the code working
Thank you for reporting the issue. This might be due to some recent changes in the transformers library. We will investigate this, we when we find the time for it. Meanwhile you could try it with an older version, e.g., 4.52.0 still had the apply_rotary_emb function: https://github.com/huggingface/transformers/blob/113424bcd53b92600f77d82f48add0a60fb41556/src/transformers/modeling_flash_attention_utils.py#L38
It should be fixed now: https://huggingface.co/jinaai/jina-embeddings-v4/discussions/67 Can you try it again?