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
Preferred dtype: bfloat16 or float16?
What's the preferred dtype for this model? Readme mentions bfloat16 in the table but the transformers demo uses float16 at model initialization.
I tested both on some small test datasets and interestingly they seemed to be very similar in performance, but would still be interested to have an answer!
Hi @mihaidusmanu , yes both bf16 and fp16 perform similarly. fp16 is more widely supported, which is why we suggest it in the demo. It also provides higher precision and greater consistency across different configurations (hardware, batch size, etc). The main weights are given in bf16, as this was used during training and is preferable for quantization or further fine-tuning.