Skip to content

Commit 4c5f07e

Browse files
pockers21CISC
authored andcommitted
Simplify Jina BERT v3 detection logic
Remove unnecessary try/except Jina text hparams. Co-authored-by: Sigbjørn Skjæret <[email protected]>
1 parent 7ea1e82 commit 4c5f07e

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

convert_hf_to_gguf.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5558,17 +5558,13 @@ def __init__(self, dir_model: Path, ftype: gguf.LlamaFileType, fname_out: Path,
55585558
if lora_names := hparams.get("lora_adaptations"):
55595559
self._lora_names = lora_names
55605560

5561-
try:
5562-
text_cfg = hparams.get("text_config", {}) if isinstance(hparams.get("text_config", {}), dict) else {}
5563-
pe_type = (text_cfg.get("position_embedding_type") or hparams.get("position_embedding_type") or "").lower()
5564-
rope_base = text_cfg.get("rotary_emb_base", hparams.get("rotary_emb_base"))
5565-
name_path = (hparams.get("_name_or_path") or "").lower()
5566-
is_vx = ("jina" in name_path and ("v2" in name_path or "v3" in name_path))
5567-
is_v3 = (pe_type == "rotary" or rope_base is not None) and is_vx
5568-
if (is_v3) or self._lora_names:
5569-
self.model_arch = gguf.MODEL_ARCH.JINA_BERT_V3
5570-
except Exception:
5571-
pass
5561+
pe_type = (hparams.get("position_embedding_type") or "").lower()
5562+
rope_base = hparams.get("rotary_emb_base")
5563+
name_path = (hparams.get("_name_or_path") or "").lower()
5564+
is_vx = ("jina" in name_path and ("v2" in name_path or "v3" in name_path))
5565+
is_v3 = (pe_type == "rotary" or rope_base is not None) and is_vx
5566+
if is_v3 or self._lora_names:
5567+
self.model_arch = gguf.MODEL_ARCH.JINA_BERT_V3
55725568

55735569
super().__init__(dir_model, ftype, fname_out, hparams=hparams, **kwargs)
55745570
self._xlmroberta_tokenizer_init()

0 commit comments

Comments
 (0)