Skip to content

Commit 6a472cf

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 852629b commit 6a472cf

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
@@ -1592,6 +1592,12 @@ def get_vocab_base_pre(self, tokenizer) -> str:
15921592
if chkhsh == "53e325976a6e142379c19b09afcae354f2f496f147afa8f9e189a33fe4e3024e":
15931593
# ref: https://huggingface.co/ibm-granite/granite-docling-258M
15941594
res = "granite-docling"
1595+
if chkhsh == "789696f5946cc0fc59371f39f6097cafed196b3acded6140432f26bbb1ae1669":
1596+
# ref: https://huggingface.co/ibm-granite/granite-embedding-311m-multilingual-r2
1597+
res = "granite-embed-multi-311m"
1598+
if chkhsh == "f241072145675bf8322086f115aebad05e9f869557a238bf2150a2a417d1bf60":
1599+
# ref: https://huggingface.co/ibm-granite/granite-embedding-97m-multilingual-r2
1600+
res = "granite-embed-multi-97m"
15951601
if chkhsh == "f4f37b6c8eb9ea29b3eac6bb8c8487c5ab7885f8d8022e67edc1c68ce8403e95":
15961602
# ref: https://huggingface.co/MiniMaxAI/MiniMax-M2
15971603
res = "minimax-m2"

conversion/bert.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,12 @@ def set_gguf_parameters(self):
594594
self.gguf_writer.add_sliding_window_pattern(sliding_window_pattern)
595595
self.gguf_writer.add_rope_scaling_type(gguf.RopeScalingType.NONE)
596596
self.gguf_writer.add_vocab_size(self.hparams["vocab_size"])
597+
# FFN activation: ModernBert uses a GLU pair (ffn_up output is 2*n_ff). The
598+
# original ModernBERT uses GELU (-> GeGLU); some derivatives such as IBM
599+
# Granite Embedding 97m R2 use SiLU (-> SwiGLU). Persist this so the
600+
# llama.cpp graph can pick the matching activation.
601+
if hidden_act := self.hparams.get("hidden_activation"):
602+
self.gguf_writer.add_hidden_act(hidden_act)
597603

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

0 commit comments

Comments
 (0)