Instructions to use jinaai/jina-embeddings-v3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jinaai/jina-embeddings-v3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="jinaai/jina-embeddings-v3", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("jinaai/jina-embeddings-v3", trust_remote_code=True, device_map="auto") - sentence-transformers
How to use jinaai/jina-embeddings-v3 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("jinaai/jina-embeddings-v3", 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
Adapter selection for training with retrieval data
model = SentenceTransformer("jinaai/jina-embeddings-v3", trust_remote_code=True, model_kwargs={'default_task': 'classification'})
For retrieval task, when initializing can the task be "retrieval" or i must fine tuning one model for query and one for passage, thank you
Hi @hail75 , for retrieval, both the query and passage adapters were fine-tuned together, one to encode queries and the other to encode passages. Unfortunately, this kind of fine-tuning isn't currently supported in SentenceTransformers. So I would recommend selecting either the query or passage adapter and fine-tuning just that adapter for your retrieval task.
So you mean i need fine tune two seperate adapter for each task when infer right?. Thanks
No, fine-tuning both adapters for retrieval isn't possible without custom training code, so you might consider tuning just one adapter for both queries and passages. This approach should work well, our experiments showed that the two-adapter setup was only slightly better than using a single adapter.
Hi there, is there an example somewhere of how the above can be accomplished?
Cheers!