Skip to content

Commit 83bc2f2

Browse files
model : add text-only support for Kimi-VL (and find special tokens in text_config) (#15051)
* basic kimi-vl textmodel conversion * check config["text_config"] for special tokens
1 parent 6c7a441 commit 83bc2f2

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

convert_hf_to_gguf.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6059,6 +6059,7 @@ def prepare_tensors(self):
60596059

60606060
@ModelBase.register("DeepseekV2ForCausalLM")
60616061
@ModelBase.register("DeepseekV3ForCausalLM")
6062+
@ModelBase.register("KimiVLForConditionalGeneration")
60626063
class DeepseekV2Model(TextModel):
60636064
model_arch = gguf.MODEL_ARCH.DEEPSEEK2
60646065

@@ -6161,6 +6162,13 @@ def set_gguf_parameters(self):
61616162
_experts: list[dict[str, Tensor]] | None = None
61626163

61636164
def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iterable[tuple[str, Tensor]]:
6165+
# skip vision tensors and remove "language_model." for Kimi-VL
6166+
if "vision_tower" in name or "multi_modal_projector" in name:
6167+
return []
6168+
6169+
if name.startswith("language_model."):
6170+
name = name.replace("language_model.", "")
6171+
61646172
# rename e_score_correction_bias tensors
61656173
if name.endswith("e_score_correction_bias"):
61666174
name = name.replace("e_score_correction_bias", "e_score_correction.bias")

gguf-py/gguf/vocab.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,11 @@ def _try_load_from_config_json(self, path: Path) -> bool:
312312
with open(config_file, encoding = 'utf-8') as f:
313313
config = json.load(f)
314314
for typ in self.special_token_types:
315-
self._set_special_token(typ, config.get(f'{typ}_token_id'))
315+
token_id = config.get(f'{typ}_token_id')
316+
# If not found at root, check in text_config (for multimodal models like Kimi-VL)
317+
if token_id is None and 'text_config' in config:
318+
token_id = config['text_config'].get(f'{typ}_token_id')
319+
self._set_special_token(typ, token_id)
316320
return True
317321

318322

0 commit comments

Comments
 (0)