Instructions to use jinaai/jina-clip-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jinaai/jina-clip-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="jinaai/jina-clip-v2", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("jinaai/jina-clip-v2", trust_remote_code=True, dtype="auto") - sentence-transformers
How to use jinaai/jina-clip-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("jinaai/jina-clip-v2", 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] - Transformers.js
How to use jinaai/jina-clip-v2 with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('feature-extraction', 'jinaai/jina-clip-v2'); - Notebooks
- Google Colab
- Kaggle
how to load jina-clip-implementation by local path ?
I have downloaded the model weights for jinaai/jina-clip-v2 on a machine with internet access. Now, I need to run jinaai/jina-clip-v2 on a server that has no internet connection. When loading the model, it tries to download jina-clip-implementation. How can I specify a local path for jina-clip-implementation to avoid downloading it?
Hey @lzw1992 ! You can try the following:
- Clear your HF cache
rm -rf ~/.cache/huggingface/ - Download the model from huggingface hub
python -c "from transformers import AutoModel;AutoModel.from_pretrained('jinaai/jina-clip-v2', trust_remote_code=True)" - Now your cache folder will contain everything required to load the model, code + weights and nothing else
- Copy your cache folder to the server
scp -r ~/.cache/huggingface/ user@host:/home/user/.cache/ - Try loading on the server
python -c "from transformers import AutoModel;AutoModel.from_pretrained('jinaai/jina-clip-v2', trust_remote_code=True)"
Thanks, I got it !
When I download the model file and run the model locally, do I need other pre-trained models?
@zhanbaohang no you don't need, this repo contains the pre-trained model weights of jina-clip, this includes both text tower and image tower.