Skip to content

Commit e988bd1

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 d8294eb commit e988bd1

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
@@ -1652,6 +1652,12 @@ def get_vocab_base_pre(self, tokenizer) -> str:
16521652
if chkhsh == "36f3066e97b7f3994b379aaacde306c1444c6ae84e81a5ae3cd2b7ed3b8c42d4":
16531653
# ref: https://huggingface.co/openbmb/MiniCPM5-1B
16541654
res = "minicpm5"
1655+
if chkhsh == "f241072145675bf8322086f115aebad05e9f869557a238bf2150a2a417d1bf60":
1656+
# ref: https://huggingface.co/ibm-granite/granite-embedding-97m-multilingual-r2
1657+
res = "granite-embed-multi-97m"
1658+
if chkhsh == "789696f5946cc0fc59371f39f6097cafed196b3acded6140432f26bbb1ae1669":
1659+
# ref: https://huggingface.co/ibm-granite/granite-embedding-311m-multilingual-r2
1660+
res = "granite-embed-multi-311m"
16551661

16561662
if res is None:
16571663
logger.warning("\n")

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)