Instructions to use AI4Industry/MoonViT-V2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AI4Industry/MoonViT-V2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="AI4Industry/MoonViT-V2", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AI4Industry/MoonViT-V2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download configuration_moonvit_v2.py from AI4Industry/MoonViT-V2: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/AI4Industry/MoonViT-V2/resolve/main/configuration_moonvit_v2.py
- Command line
-
hf download hf://AI4Industry/MoonViT-V2/configuration_moonvit_v2.py
-
curl -L -o configuration_moonvit_v2.py https://huggingface.co/AI4Industry/MoonViT-V2/resolve/main/configuration_moonvit_v2.py
2.46 kB
| # Copyright 2025-2026 The Moonshot AI Team and HuggingFace Inc. team. All rights reserved. | |
| # | |
| # Extracted from moonshotai/Kimi-K3 for standalone MoonViT-V2 use. | |
| # Licensed under the Kimi K3 License (see LICENSE in this repository). | |
| from transformers.configuration_utils import PretrainedConfig | |
| class MoonViTV2Config(PretrainedConfig): | |
| r""" | |
| Configuration class for MoonViT-V2, the native-resolution vision encoder of Kimi K3. | |
| MoonViT-V2 is a ~0.4B-parameter Vision Transformer (27 layers, 12 heads, patch size 14) | |
| trained from scratch jointly with the language model (not initialized from SigLIP). | |
| """ | |
| model_type = "moonvit_v2" | |
| def __init__( | |
| self, | |
| patch_size: int = 14, | |
| init_pos_emb_height: int = 64, | |
| init_pos_emb_width: int = 64, | |
| init_pos_emb_time: int = 4, | |
| pos_emb_type: str = "divided_fixed", | |
| pos_emb_interpolation_mode: str = "bilinear", | |
| num_attention_heads: int = 12, | |
| num_hidden_layers: int = 27, | |
| hidden_size: int = 1024, | |
| intermediate_size: int = 4096, | |
| qkv_hidden_size: int = 1536, | |
| merge_kernel_size: tuple[int, int] = (2, 2), | |
| merge_type: str = "sd2_tpool", | |
| norm_type: str = "rmsnorm", | |
| mlp_type: str = "mlp2", | |
| attn_bias: bool = False, | |
| linear_bias: bool = False, | |
| patch_embed_proj_bias: bool = False, | |
| activation_func: str = "gelu_pytorch_tanh", | |
| **kwargs, | |
| ): | |
| super().__init__(**kwargs) | |
| self.patch_size = patch_size | |
| self.init_pos_emb_height = init_pos_emb_height | |
| self.init_pos_emb_width = init_pos_emb_width | |
| self.init_pos_emb_time = init_pos_emb_time | |
| self.pos_emb_type = pos_emb_type | |
| self.pos_emb_interpolation_mode = pos_emb_interpolation_mode | |
| self.num_attention_heads = num_attention_heads | |
| self.num_hidden_layers = num_hidden_layers | |
| self.hidden_size = hidden_size | |
| self.intermediate_size = intermediate_size | |
| self.qkv_hidden_size = qkv_hidden_size | |
| self.merge_kernel_size = list(merge_kernel_size) if not isinstance(merge_kernel_size, list) else merge_kernel_size | |
| self.merge_type = merge_type | |
| self.norm_type = norm_type | |
| self.mlp_type = mlp_type | |
| self.attn_bias = attn_bias | |
| self.linear_bias = linear_bias | |
| self.patch_embed_proj_bias = patch_embed_proj_bias | |
| self.activation_func = activation_func | |