Skip to content

Commit 50dab7b

Browse files
committed
Added granite-embedding-{97m,311m}-multilingual-r2 to the converter code
* Added the hashes for the granite embedding multilingual R2 models * Set the hidden_activation in the GGUF if the field is present in config.json (such as for the granite embedding models)
1 parent 64c65c2 commit 50dab7b

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

conversion/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,12 @@ def get_vocab_base_pre(self, tokenizer) -> str:
16571657
if chkhsh == "36f3066e97b7f3994b379aaacde306c1444c6ae84e81a5ae3cd2b7ed3b8c42d4":
16581658
# ref: https://huggingface.co/openbmb/MiniCPM5-1B
16591659
res = "minicpm5"
1660+
if chkhsh == "f241072145675bf8322086f115aebad05e9f869557a238bf2150a2a417d1bf60":
1661+
# ref: https://huggingface.co/ibm-granite/granite-embedding-97m-multilingual-r2
1662+
res = "granite-embed-multi-97m"
1663+
if chkhsh == "789696f5946cc0fc59371f39f6097cafed196b3acded6140432f26bbb1ae1669":
1664+
# ref: https://huggingface.co/ibm-granite/granite-embedding-311m-multilingual-r2
1665+
res = "granite-embed-multi-311m"
16601666

16611667
if res is None:
16621668
logger.warning("\n")

conversion/bert.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,12 @@ def set_gguf_parameters(self):
603603
self.gguf_writer.add_sliding_window_pattern(sliding_window_pattern)
604604
self.gguf_writer.add_rope_scaling_type(gguf.RopeScalingType.NONE)
605605
self.gguf_writer.add_vocab_size(self.hparams["vocab_size"])
606+
# FFN activation: ModernBert uses a GLU pair (ffn_up output is 2*n_ff). The
607+
# original ModernBERT uses GELU (-> GeGLU); some derivatives such as IBM
608+
# Granite Embedding 97m R2 use SiLU (-> SwiGLU). Persist this so the
609+
# llama.cpp graph can pick the matching activation.
610+
if hidden_act := self.hparams.get("hidden_activation"):
611+
self.gguf_writer.add_hidden_act(hidden_act)
606612

607613
@classmethod
608614
def filter_tensors(cls, item: tuple[str, Callable[[], Tensor]]) -> tuple[str, Callable[[], Tensor]] | None:

0 commit comments

Comments
 (0)