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 the jina-clip-v2 model offline? help me plz!!
I want to know how to load the jina-clip-v2 model offline, beacuse the server I use cannot connect to the Internet. . .
I have done this:
- Download https://huggingface.co/jinaai/jina-clip-implementation to the local computer and save it to the folder my_jina_clip
- Download https://huggingface.co/jinaai/jina-clip-v2 to the local computer and save it to the folder jina-clip-v2
- Run the code:
from my_jina_clip.modeling_clip import JinaCLIPModel
model=JinaCLIPModel.from_pretrained("./jina-clip-v2")
But in the HFTextEncoder of hf_model.py, you still need to set trust_remote_code=True to load it remotely.
Please help me, thank you very much! !
@gmastrapas Hello, I have a Windows network environment, so I cannot directly use the method in #16. Is there any other way to solve this problem in an offline environment。
I have resolved the issue by modifying the configuration file config.json, changing the model loading address to a local relative path, thanks.