[Model][VLM] Support JinaVL Reranker (#20260)

Signed-off-by: shineran96 <shinewang96@gmail.com>
This commit is contained in:
shineran96
2025-07-10 10:43:43 -07:00
committed by GitHub
parent b140416abf
commit 4bed167768
15 changed files with 991 additions and 131 deletions
+57
View File
@@ -9,6 +9,7 @@ import torch
from torch import Tensor
from typing_extensions import Self, TypeIs
from vllm.inputs import TokensPrompt
from vllm.logger import init_logger
from vllm.model_executor.layers.quantization.base_config import (
QuantizationConfig)
@@ -141,6 +142,62 @@ def supports_multimodal(
return isinstance(model, SupportsMultiModal)
@runtime_checkable
class SupportsScoreTemplate(Protocol):
"""The interface required for all models that support score template."""
supports_score_template: ClassVar[Literal[True]] = True
"""
A flag that indicates this model supports score template.
Note:
There is no need to redefine this flag if this class is in the
MRO of your model class.
"""
@classmethod
def get_score_template(cls, query: str, document: str) -> Optional[str]:
"""
Generate a full prompt by populating the score template with query and document content.
""" # noqa: E501
...
@classmethod
def post_process_tokens(cls, prompt: TokensPrompt) -> None:
"""
Perform architecture-specific manipulations on the input tokens.
"""
...
# We can't use runtime_checkable with ClassVar for issubclass checks
# so we need to treat the class as an instance and use isinstance instead
@runtime_checkable
class _SupportsScoreTemplateType(Protocol):
supports_score_template: Literal[True]
@overload
def supports_score_template(
model: type[object]) -> TypeIs[type[SupportsScoreTemplate]]:
...
@overload
def supports_score_template(model: object) -> TypeIs[SupportsScoreTemplate]:
...
def supports_score_template(
model: Union[type[object], object],
) -> Union[TypeIs[type[SupportsScoreTemplate]], TypeIs[SupportsScoreTemplate]]:
if isinstance(model, type):
return isinstance(model, _SupportsScoreTemplateType)
return isinstance(model, SupportsScoreTemplate)
@runtime_checkable
class SupportsLoRA(Protocol):
"""The interface required for all models that support LoRA."""