Text Classification
Transformers
Safetensors
sentence-transformers
multilingual
qwen2_vl
feature-extraction
vidore
reranker
custom_code
🇪🇺 Region: EU
Instructions to use jinaai/jina-reranker-m0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jinaai/jina-reranker-m0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="jinaai/jina-reranker-m0", trust_remote_code=True)# Load model directly from transformers import AutoProcessor, AutoModel processor = AutoProcessor.from_pretrained("jinaai/jina-reranker-m0", trust_remote_code=True) model = AutoModel.from_pretrained("jinaai/jina-reranker-m0", trust_remote_code=True, device_map="auto") - sentence-transformers
How to use jinaai/jina-reranker-m0 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("jinaai/jina-reranker-m0", 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
draft support image query
#3
by numb3r3 - opened
- modeling.py +17 -3
modeling.py
CHANGED
|
@@ -183,10 +183,24 @@ class JinaVLForRanking(Qwen2VLForConditionalGeneration):
|
|
| 183 |
batch_inputs.append(formatting_prompts_func(q, d, query_type=query_type, doc_type=doc_type))
|
| 184 |
|
| 185 |
batch_images = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
if doc_type == 'image':
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
batch = self._processor(
|
| 192 |
text=batch_inputs,
|
|
|
|
| 183 |
batch_inputs.append(formatting_prompts_func(q, d, query_type=query_type, doc_type=doc_type))
|
| 184 |
|
| 185 |
batch_images = None
|
| 186 |
+
# if doc_type == 'image':
|
| 187 |
+
# batch_images = load_images([d for (q, d) in mini_batch])
|
| 188 |
+
# elif query_type == 'image':
|
| 189 |
+
# batch_images = load_images([q for (q, d) in mini_batch])
|
| 190 |
+
|
| 191 |
+
doc_images = []
|
| 192 |
+
query_images = []
|
| 193 |
if doc_type == 'image':
|
| 194 |
+
doc_images = load_images([d for (q, d) in mini_batch])
|
| 195 |
+
if query_type == 'image':
|
| 196 |
+
query_images = load_images([q for (q, d) in mini_batch])
|
| 197 |
+
|
| 198 |
+
if len(doc_images) == len(query_images) and len(doc_images) > 0:
|
| 199 |
+
batch_images = [[d, q] for q, d in zip(query_images, doc_images)]
|
| 200 |
+
elif len(doc_images) > 0:
|
| 201 |
+
batch_images = doc_images
|
| 202 |
+
elif len(query_images) > 0:
|
| 203 |
+
batch_images = query_images
|
| 204 |
|
| 205 |
batch = self._processor(
|
| 206 |
text=batch_inputs,
|