Downloads · 30 days
91
100% of all-time downloads
PerRing/InternVL-MoonViT-V2-LFM2.5-2.6B-HF
InternVL-MoonViT-V2-LFM2.5-2.6B-HF is a image-text-to-text model from PerRing. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for transformers.
This model combines the MoonViT V2 vision encoder from Kimi K3 with the LFM2.5-2.6B language model.
Downloads · 30 days
91
100% of all-time downloads
All-time downloads
91
Public
Parameters
3.1B
6.2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors6.2 GB · 100%
From the Hugging Face model README
This model combines the MoonViT V2 vision encoder from Kimi K3 with the LFM2.5-2.6B language model.
The multimodal projector (MLP) was not trained. Please keep this in mind when evaluating or using the model.
lm_head tied to the input embeddings)Both towers are copied bit-for-bit from their source checkpoints. The tokenizer adds the InternVL special
tokens (<img>, </img>, <IMG_CONTEXT>, <quad>, </quad>, <ref>, </ref>, <box>, </box>),
and the chat template renders one <IMG_CONTEXT> placeholder per image, which the processor expands to
that image's token count. MoonViT performs the 2x2 patch merge itself, so an image of h x w patches
becomes (h // 2) * (w // 2) image tokens, capped by the processor's in_token_limit (25600 patches).
import torch
from transformers import AutoModelForImageTextToText, AutoProcessor
model_id = "PerRing/InternVL-MoonViT-V2-LFM2.5-2.6B-HF"
processor = AutoProcessor.from_pretrained(
model_id,
trust_remote_code=True,
)
model = AutoModelForImageTextToText.from_pretrained(
model_id,
dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
).eval()
The vision tower also supports FlashAttention-2, either from the flash-attn package
(attn_implementation="flash_attention_2") or from the Hub kernel
(attn_implementation="kernels-community/flash-attn2").
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
{"type": "text", "text": "What animal is on the candy?"},
],
},
]
inputs = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
with torch.inference_mode():
outputs = model.generate(**inputs, max_new_tokens=64, do_sample=False)
print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
Note: This repository uses custom modeling and processing code, so
trust_remote_code=Trueis required.