feat: avoid validating return_multivector
Browse files
modeling_jina_embeddings_v4.py
CHANGED
@@ -357,7 +357,6 @@ class JinaEmbeddingsV4Model(Qwen2_5_VLForConditionalGeneration):
|
|
357 |
|
358 |
def _validate_encoding_params(
|
359 |
self,
|
360 |
-
return_multivector: Optional[bool] = None,
|
361 |
truncate_dim: Optional[int] = None,
|
362 |
prompt_name: Optional[str] = None,
|
363 |
) -> Dict[str, Any]:
|
@@ -374,9 +373,6 @@ class JinaEmbeddingsV4Model(Qwen2_5_VLForConditionalGeneration):
|
|
374 |
else PREFIX_DICT["query"]
|
375 |
)
|
376 |
|
377 |
-
return_multivector = return_multivector or False
|
378 |
-
encode_kwargs["return_multivector"] = return_multivector
|
379 |
-
|
380 |
truncate_dim = truncate_dim or self.config.truncate_dim
|
381 |
if truncate_dim is not None and truncate_dim not in self.config.matryoshka_dims:
|
382 |
raise ValueError(
|
@@ -429,9 +425,7 @@ class JinaEmbeddingsV4Model(Qwen2_5_VLForConditionalGeneration):
|
|
429 |
List of text embeddings as tensors or numpy arrays when encoding multiple texts, or single text embedding as tensor when encoding a single text
|
430 |
"""
|
431 |
prompt_name = prompt_name or "query"
|
432 |
-
encode_kwargs = self._validate_encoding_params(
|
433 |
-
return_multivector=return_multivector, truncate_dim=truncate_dim, prompt_name=prompt_name
|
434 |
-
)
|
435 |
|
436 |
task = self._validate_task(task)
|
437 |
|
@@ -449,6 +443,7 @@ class JinaEmbeddingsV4Model(Qwen2_5_VLForConditionalGeneration):
|
|
449 |
processor_fn=processor_fn,
|
450 |
desc="Encoding texts...",
|
451 |
task_label=task,
|
|
|
452 |
return_numpy=return_numpy,
|
453 |
batch_size=batch_size,
|
454 |
**encode_kwargs,
|
@@ -499,7 +494,7 @@ class JinaEmbeddingsV4Model(Qwen2_5_VLForConditionalGeneration):
|
|
499 |
self.processor.image_processor.max_pixels = (
|
500 |
max_pixels # change during encoding
|
501 |
)
|
502 |
-
encode_kwargs = self._validate_encoding_params(
|
503 |
task = self._validate_task(task)
|
504 |
|
505 |
# Convert single image to list
|
@@ -513,6 +508,7 @@ class JinaEmbeddingsV4Model(Qwen2_5_VLForConditionalGeneration):
|
|
513 |
desc="Encoding images...",
|
514 |
task_label=task,
|
515 |
batch_size=batch_size,
|
|
|
516 |
return_numpy=return_numpy,
|
517 |
**encode_kwargs,
|
518 |
)
|
|
|
357 |
|
358 |
def _validate_encoding_params(
|
359 |
self,
|
|
|
360 |
truncate_dim: Optional[int] = None,
|
361 |
prompt_name: Optional[str] = None,
|
362 |
) -> Dict[str, Any]:
|
|
|
373 |
else PREFIX_DICT["query"]
|
374 |
)
|
375 |
|
|
|
|
|
|
|
376 |
truncate_dim = truncate_dim or self.config.truncate_dim
|
377 |
if truncate_dim is not None and truncate_dim not in self.config.matryoshka_dims:
|
378 |
raise ValueError(
|
|
|
425 |
List of text embeddings as tensors or numpy arrays when encoding multiple texts, or single text embedding as tensor when encoding a single text
|
426 |
"""
|
427 |
prompt_name = prompt_name or "query"
|
428 |
+
encode_kwargs = self._validate_encoding_params(truncate_dim=truncate_dim, prompt_name=prompt_name)
|
|
|
|
|
429 |
|
430 |
task = self._validate_task(task)
|
431 |
|
|
|
443 |
processor_fn=processor_fn,
|
444 |
desc="Encoding texts...",
|
445 |
task_label=task,
|
446 |
+
return_multivector=return_multivector,
|
447 |
return_numpy=return_numpy,
|
448 |
batch_size=batch_size,
|
449 |
**encode_kwargs,
|
|
|
494 |
self.processor.image_processor.max_pixels = (
|
495 |
max_pixels # change during encoding
|
496 |
)
|
497 |
+
encode_kwargs = self._validate_encoding_params(truncate_dim=truncate_dim)
|
498 |
task = self._validate_task(task)
|
499 |
|
500 |
# Convert single image to list
|
|
|
508 |
desc="Encoding images...",
|
509 |
task_label=task,
|
510 |
batch_size=batch_size,
|
511 |
+
return_multivector=return_multivector,
|
512 |
return_numpy=return_numpy,
|
513 |
**encode_kwargs,
|
514 |
)
|