From cb7934c52ca8710994b2ecc19775ebefcfdb8d01 Mon Sep 17 00:00:00 2001 From: Tarek Dakhran Date: Sat, 3 Oct 2026 08:44:45 +0200 Subject: [PATCH] model : Add LFM2.5-Encoder-350M and LFM2.5-Encoder-230M (#29862) Register `Lfm2BidirectionalForMaskedLM` architecture for LFM2.5-Encoder models. --- conversion/__init__.py | 1 + conversion/lfm2.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/conversion/__init__.py b/conversion/__init__.py index 6d8ae9c1a5..051ddf99dc 100644 --- a/conversion/__init__.py +++ b/conversion/__init__.py @@ -155,6 +155,7 @@ TEXT_MODEL_MAP: dict[str, str] = { "LevModel": "lev", "NimbleModel": "lev", "Lfm25AudioTokenizer": "lfm2", + "Lfm2BidirectionalForMaskedLM": "lfm2", "Lfm2BidirectionalModel": "lfm2", "Lfm2ForCausalLM": "lfm2", "Lfm2Model": "lfm2", diff --git a/conversion/lfm2.py b/conversion/lfm2.py index 984f444806..e50bbdd0fe 100644 --- a/conversion/lfm2.py +++ b/conversion/lfm2.py @@ -65,19 +65,21 @@ class LFM2Model(TextModel): yield from super().modify_tensors(data_torch, name, bid) -@ModelBase.register("Lfm2Model", "Lfm2BidirectionalModel") -@ModelBase.example("LiquidAI/LFM2.5-ColBERT-350M", "LiquidAI/LFM2.5-Embedding-350M") +@ModelBase.register("Lfm2Model", "Lfm2BidirectionalModel", "Lfm2BidirectionalForMaskedLM") +@ModelBase.example("LiquidAI/LFM2.5-ColBERT-350M", "LiquidAI/LFM2.5-Embedding-350M", "LiquidAI/LFM2.5-Encoder-350M", "LiquidAI/LFM2.5-Encoder-230M") class LFM2ColBertModel(LFM2Model): model_arch = gguf.MODEL_ARCH.LFM2 dense_tensor_name = "dense_2" def set_gguf_parameters(self): super().set_gguf_parameters() - if self.hf_arch == "Lfm2BidirectionalModel": + if self.hf_arch in ("Lfm2BidirectionalModel", "Lfm2BidirectionalForMaskedLM"): self.gguf_writer.add_causal_attention(False) self._try_set_pooling_type() def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iterable[tuple[str, Tensor]]: + # masked LM checkpoints use "lfm2." prefix + name = name.removeprefix("lfm2.") if not name.startswith(self.dense_tensor_name): name = "model." + name