Skip to content

Commit 26fa510

Browse files
authored
add offline modeling for model jinaai/jina-embeddings-v2-base-code to avoid auto_map to other repository (#612)
Signed-off-by: Liu, Kaixuan <[email protected]>
1 parent cf423d1 commit 26fa510

File tree

2 files changed

+552
-1
lines changed

2 files changed

+552
-1
lines changed

backends/python/server/text_embeddings_server/models/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from text_embeddings_server.models.masked_model import MaskedLanguageModel
1212
from text_embeddings_server.models.default_model import DefaultModel
1313
from text_embeddings_server.models.classification_model import ClassificationModel
14+
from text_embeddings_server.models.jinaBert_model import FlashJinaBert
1415
from text_embeddings_server.models.flash_mistral import FlashMistral
1516
from text_embeddings_server.utils.device import get_device, use_ipex
1617

@@ -45,7 +46,16 @@ def get_model(model_path: Path, dtype: Optional[str], pool: str):
4546
logger.info(f"backend device: {device}")
4647

4748
config = AutoConfig.from_pretrained(model_path, trust_remote_code=TRUST_REMOTE_CODE)
48-
if config.model_type == "bert":
49+
if (
50+
hasattr(config, "auto_map")
51+
and isinstance(config.auto_map, dict)
52+
and "AutoModel" in config.auto_map
53+
and config.auto_map["AutoModel"]
54+
== "jinaai/jina-bert-v2-qk-post-norm--modeling_bert.JinaBertModel"
55+
):
56+
# Add specific offline modeling for model "jinaai/jina-embeddings-v2-base-code" which uses "autoMap" to reference code in other repository
57+
return FlashJinaBert(model_path, config, device, datatype, pool)
58+
elif config.model_type == "bert":
4959
config: BertConfig
5060
if (
5161
use_ipex()

0 commit comments

Comments
 (0)