Simplify Jina BERT v3 detection logic

Remove unnecessary try/except Jina text hparams.

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
This commit is contained in:
pockers21 2025-11-14 18:13:43 +08:00 committed by liyang
parent 463f536695
commit 06f50ded46
1 changed files with 7 additions and 11 deletions

View File

@ -5636,17 +5636,13 @@ class XLMRobertaModel(BertModel):
if lora_names := hparams.get("lora_adaptations"):
self._lora_names = lora_names
try:
text_cfg = hparams.get("text_config", {}) if isinstance(hparams.get("text_config", {}), dict) else {}
pe_type = (text_cfg.get("position_embedding_type") or hparams.get("position_embedding_type") or "").lower()
rope_base = text_cfg.get("rotary_emb_base", hparams.get("rotary_emb_base"))
name_path = (hparams.get("_name_or_path") or "").lower()
is_vx = ("jina" in name_path and ("v2" in name_path or "v3" in name_path))
is_v3 = (pe_type == "rotary" or rope_base is not None) and is_vx
if (is_v3) or self._lora_names:
self.model_arch = gguf.MODEL_ARCH.JINA_BERT_V3
except Exception:
pass
pe_type = (hparams.get("position_embedding_type") or "").lower()
rope_base = hparams.get("rotary_emb_base")
name_path = (hparams.get("_name_or_path") or "").lower()
is_vx = ("jina" in name_path and ("v2" in name_path or "v3" in name_path))
is_v3 = (pe_type == "rotary" or rope_base is not None) and is_vx
if is_v3 or self._lora_names:
self.model_arch = gguf.MODEL_ARCH.JINA_BERT_V3
super().__init__(dir_model, ftype, fname_out, hparams=hparams, **kwargs)
self._xlmroberta_tokenizer_init()