Model Intelligence Sheet
unsloth/internvl3-14b-instruct-gguf overview
[\[๐ GitHub\]](https://github.com/OpenGVLab/InternVL) [\[๐ InternVL 1.0\]](https://huggingface.co/papers/2312.14238) [\[๐ InternVL 1.5\]](https://huggingface.co/papers/2404.16821) [\[๐ InternVL 2.5\]](https://huggingface.co/papers/2412.05271) [\[๐ InternVL2.5-MPO\]](https://huggingface.co/papers/2411.10442) [\[๐ InternVL3\]](https://huggingface.co/papers/2504.10479) [\[๐ Blog\]](https://internvl.github.io/blog/) [\[๐จ๏ธ Chat Demo\]](https://internvl.opengvlab.com/) [\[๐ค HF Demo\]](https://huggingface.co/spaces/OpenGVLab/InternVL) [\[๐ Quick Start\]](#quick-start) [\[๐ Documents\]](https://internvl.readthedocs.io/en/latest/)
Downloads
435
Likes
5
Pipeline
image-text-to-text
Library
transformers
Visibility
Public
Access
Open
Repository Files & Downloads
27 files detected
Direct downloads for all repository files
| File | Type | Quantization | Size | Link |
|---|---|---|---|---|
| InternVL3-14B-Instruct-BF16.gguf | GGUF | BF16 | 27.51 GB | Download |
| InternVL3-14B-Instruct-IQ4_NL.gguf | GGUF | IQ4_NL | 7.96 GB | Download |
| InternVL3-14B-Instruct-IQ4_XS.gguf | GGUF | IQ4_XS | 7.58 GB | Download |
| InternVL3-14B-Instruct-Q2_K.gguf | GGUF | Q2_K | 5.37 GB | Download |
| InternVL3-14B-Instruct-Q2_K_L.gguf | GGUF | Q2_K_L | 5.54 GB | Download |
| InternVL3-14B-Instruct-Q3_K_M.gguf | GGUF | Q3_K_M | 6.83 GB | Download |
| InternVL3-14B-Instruct-Q3_K_S.gguf | GGUF | Q3_K_S | 6.20 GB | Download |
| InternVL3-14B-Instruct-Q4_1.gguf | GGUF | โ | 8.74 GB | Download |
| InternVL3-14B-Instruct-Q4_K_M.gguf | GGUF | Q4_K_M | 8.37 GB | Download |
| InternVL3-14B-Instruct-Q4_K_S.gguf | GGUF | Q4_K_S | 7.98 GB | Download |
| InternVL3-14B-Instruct-Q5_K_M.gguf | GGUF | Q5_K_M | 9.78 GB | Download |
| InternVL3-14B-Instruct-Q5_K_S.gguf | GGUF | Q5_K_S | 9.56 GB | Download |
| InternVL3-14B-Instruct-Q6_K.gguf | GGUF | Q6_K | 11.29 GB | Download |
| InternVL3-14B-Instruct-UD-IQ1_M.gguf | GGUF | IQ1_M | 3.76 GB | Download |
| InternVL3-14B-Instruct-UD-IQ1_S.gguf | GGUF | IQ1_S | 3.55 GB | Download |
| InternVL3-14B-Instruct-UD-IQ2_M.gguf | GGUF | IQ2_M | 5.05 GB | Download |
| InternVL3-14B-Instruct-UD-IQ2_XXS.gguf | GGUF | IQ2_XXS | 4.15 GB | Download |
| InternVL3-14B-Instruct-UD-IQ3_XXS.gguf | GGUF | IQ3_XXS | 5.59 GB | Download |
| InternVL3-14B-Instruct-UD-Q2_K_XL.gguf | GGUF | Q2_K_XL | 5.64 GB | Download |
| InternVL3-14B-Instruct-UD-Q3_K_XL.gguf | GGUF | Q3_K_XL | 7.07 GB | Download |
| InternVL3-14B-Instruct-UD-Q4_K_XL.gguf | GGUF | Q4_K_XL | 8.48 GB | Download |
| InternVL3-14B-Instruct-UD-Q5_K_XL.gguf | GGUF | Q5_K_XL | 9.80 GB | Download |
| InternVL3-14B-Instruct-UD-Q6_K_XL.gguf | GGUF | Q6_K_XL | 12.36 GB | Download |
| InternVL3-14B-Instruct-UD-Q8_K_XL.gguf | GGUF | Q8_K_XL | 17.26 GB | Download |
| mmproj-BF16.gguf | GGUF | BF16 | 672.66 MB | Download |
| mmproj-F16.gguf | GGUF | F16 | 672.66 MB | Download |
| mmproj-F32.gguf | GGUF | F32 | 1.31 GB | Download |
Model Details Live
Metadata Inspector
Normalized metadata (stored in metadata_json)
{
"metadata": {},
"card_data": {
"license": "apache-2.0",
"license_name": "qwen",
"license_link": "https://huggingface.co/Qwen/Qwen2.5-72B-Instruct/blob/main/LICENSE",
"pipeline_tag": "image-text-to-text",
"library_name": "transformers",
"base_model": [
"OpenGVLab/InternVL3-14B-Instruct"
],
"base_model_relation": "finetune",
"language": [
"multilingual"
],
"tags": [
"internvl",
"unsloth",
"custom_code"
],
"frontmatter": {
"license": "apache-2.0",
"license_name": "qwen",
"license_link": "https://huggingface.co/Qwen/Qwen2.5-72B-Instruct/blob/main/LICENSE",
"pipeline_tag": "image-text-to-text",
"library_name": "transformers",
"base_model": [
"OpenGVLab/InternVL3-14B-Instruct"
],
"base_model_relation": "finetune",
"language": [
"multilingual"
],
"tags": [
"internvl",
"unsloth",
"custom_code"
]
},
"hero_image_url": "https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png",
"summary": "[\\[๐ GitHub\\]](https://github.com/OpenGVLab/InternVL) [\\[๐ InternVL 1.0\\]](https://huggingface.co/papers/2312.14238) [\\[๐ InternVL 1.5\\]](https://huggingface.co/papers/2404.16821) [\\[๐ InternVL 2.5\\]](https://huggingface.co/papers/2412.05271) [\\[๐ InternVL2.5-MPO\\]](https://huggingface.co/papers/2411.10442) [\\[๐ InternVL3\\]](https://huggingface.co/papers/2504.10479) [\\[๐ Blog\\]](https://internvl.github.io/blog/) [\\[๐จ๏ธ Chat Demo\\]](https://internvl.opengvlab.com/) [\\[๐ค HF Demo\\]](https://huggingface.co/spaces/OpenGVLab/InternVL) [\\[๐ Quick Start\\]](#quick-start) [\\[๐ Documents\\]](https://internvl.readthedocs.io/en/latest/)",
"quick_links": [],
"benchmark_table_html": "",
"readme_markdown": "---\nlicense: apache-2.0\nlicense_name: qwen\nlicense_link: https://huggingface.co/Qwen/Qwen2.5-72B-Instruct/blob/main/LICENSE\npipeline_tag: image-text-to-text\nlibrary_name: transformers\nbase_model:\n- OpenGVLab/InternVL3-14B-Instruct\nbase_model_relation: finetune\nlanguage:\n- multilingual\ntags:\n- internvl\n- unsloth\n- custom_code\n---\n<div>\n<p style=\"margin-top: 0;margin-bottom: 0;\">\n <em><a href=\"https://docs.unsloth.ai/basics/unsloth-dynamic-v2.0-gguf\">Unsloth Dynamic 2.0</a> achieves superior accuracy & outperforms other leading quants.</em>\n </p>\n <div style=\"display: flex; gap: 5px; align-items: center; \">\n <a href=\"https://github.com/unslothai/unsloth/\">\n <img src=\"https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png\" width=\"133\">\n </a>\n <a href=\"https://discord.gg/unsloth\">\n <img src=\"https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png\" width=\"173\">\n </a>\n <a href=\"https://docs.unsloth.ai/basics/qwen3-how-to-run-and-fine-tune\">\n <img src=\"https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png\" width=\"143\">\n </a>\n </div>\n</div>\n\n\n# InternVL3-14B-Instruct\n\n[\\[๐ GitHub\\]](https://github.com/OpenGVLab/InternVL) [\\[๐ InternVL 1.0\\]](https://huggingface.co/papers/2312.14238) [\\[๐ InternVL 1.5\\]](https://huggingface.co/papers/2404.16821) [\\[๐ InternVL 2.5\\]](https://huggingface.co/papers/2412.05271) [\\[๐ InternVL2.5-MPO\\]](https://huggingface.co/papers/2411.10442) [\\[๐ InternVL3\\]](https://huggingface.co/papers/2504.10479)\n\n[\\[๐ Blog\\]](https://internvl.github.io/blog/) [\\[๐จ๏ธ Chat Demo\\]](https://internvl.opengvlab.com/) [\\[๐ค HF Demo\\]](https://huggingface.co/spaces/OpenGVLab/InternVL) [\\[๐ Quick Start\\]](#quick-start) [\\[๐ Documents\\]](https://internvl.readthedocs.io/en/latest/)\n\n<div align=\"center\">\n <img width=\"500\" alt=\"image\" src=\"https://cdn-uploads.huggingface.co/production/uploads/64006c09330a45b03605bba3/zJsd2hqd3EevgXo6fNgC-.png\">\n</div>\n\n## Introduction\n\n***This is the SFT version of InternVL3-14B, which has undergone native multimodal pre-trainin and SFT but has not undergone MPO. If you're unsure which version to use, please use the [InternVL3-14B](https://huggingface.co/OpenGVLab/InternVL3-14B) version.***\n\nWe introduce InternVL3, an advanced multimodal large language model (MLLM) series that demonstrates superior overall performance.\nCompared to InternVL 2.5, InternVL3 exhibits superior multimodal perception and reasoning capabilities, while further extending its multimodal capabilities to encompass tool usage, GUI agents, industrial image analysis, 3D vision perception, and more.\nAdditionally, we compare InternVL3 with Qwen2.5 Chat models, whose corresponding pre-trained base models are employed as the initialization of the langauge component in InternVL3. Benefitting from Native Multimodal Pre-Training, the InternVL3 series achieves even better overall text performance than the Qwen2.5 series.\n\n\n\n## InternVL3 Family\n\nIn the following table, we provide an overview of the InternVL3 series.\n\n| Model Name | Vision Part | Language Part | HF Link |\n| :-----------: | :-------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------: | :------------------------------------------------------: |\n| InternVL3-1B | [InternViT-300M-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-300M-448px-V2_5) | [Qwen2.5-0.5B](https://huggingface.co/Qwen/Qwen2.5-0.5B) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL3-1B) |\n| InternVL3-2B | [InternViT-300M-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-300M-448px-V2_5) | [Qwen2.5-1.5B](https://huggingface.co/Qwen/Qwen2.5-1.5B) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL3-2B) |\n| InternVL3-8B | [InternViT-300M-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-300M-448px-V2_5) | [Qwen2.5-7B](https://huggingface.co/Qwen/Qwen2.5-7B) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL3-8B) |\n| InternVL3-9B | [InternViT-300M-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-300M-448px-V2_5) | [internlm3-8b-instruct](https://huggingface.co/internlm/internlm3-8b-instruct) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL3-9B) |\n| InternVL3-14B | [InternViT-300M-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-300M-448px-V2_5) | [Qwen2.5-14B](https://huggingface.co/Qwen/Qwen2.5-14B) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL3-14B) |\n| InternVL3-38B | [InternViT-6B-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-6B-448px-V2_5) | [Qwen2.5-32B](https://huggingface.co/Qwen/Qwen2.5-32B) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL3-38B) |\n| InternVL3-78B | [InternViT-6B-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-6B-448px-V2_5) | [Qwen2.5-72B](https://huggingface.co/Qwen/Qwen2.5-72B) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL3-78B) |\n\n\n\n## Model Architecture\n\nAs shown in the following figure, [InternVL3](https://internvl.github.io/blog/2025-04-11-InternVL-3/) retains the same model architecture as [InternVL 2.5](https://internvl.github.io/blog/2024-12-05-InternVL-2.5/) and its predecessors, InternVL 1.5 and 2.0, following the \"ViT-MLP-LLM\" paradigm. In this new version, we integrate a newly incrementally pre-trained InternViT with various pre-trained LLMs, including InternLM 3 and Qwen 2.5, using a randomly initialized MLP projector.\n\n\n\n\nAs in the previous version, we applied a pixel unshuffle operation, reducing the number of visual tokens to one-quarter of the original. Besides, we adopted a similar dynamic resolution strategy as InternVL 1.5, dividing images into tiles of 448ร448 pixels. The key difference, starting from InternVL 2.0, is that we additionally introduced support for multi-image and video data.\n\nNotably, in InternVL3, we integrate the [Variable Visual Position Encoding (V2PE)](https://arxiv.org/abs/2412.09616), which utilizes smaller, more flexible position increments for visual tokens. Benefiting from V2PE, InternVL3 exhibits better long context understanding capabilities compared to its predecessors.\n\n## Training Strategy\n\n### Native Multimodal Pre-Training\n\nWe propose a [Native Multimodal Pre-Training](https://huggingface.co/papers/2504.10479) approach that consolidates language and vision learning into a single pre-training stage.\nIn contrast to standard paradigms that first train a language-only model and subsequently adapt it to handle additional modalities, our method interleaves multimodal data (e.g., image-text, video-text, or image-text interleaved sequences) with large-scale textual corpora. This unified training scheme allows the model to learn both linguistic and multimodal representations simultaneously, ultimately enhancing its capability to handle vision-language tasks without the need for separate alignment or bridging modules.\nPlease see [our paper](https://huggingface.co/papers/2504.10479) for more details.\n\n### Supervised Fine-Tuning\n\nIn this phase, the techniques of random JPEG compression, square loss re-weighting, and multimodal data packing proposed in [InternVL2.5](https://arxiv.org/abs/2412.05271) are also employed in the InternVL3 series.\nThe main advancement of the SFT phase in InternVL3 compared to InternVL2.5 lies in the use of higher-quality and more diverse training data.\nSpecifically, we further extend training samples for tool use, 3D scene understanding, GUI operations, long context tasks, video understanding, scientific diagrams, creative writing, and multimodal reasoning.\n\n### Mixed Preference Optimization\n\nDuring Pre-training and SFT, the model is trained to predict the next token conditioned on previous ground-truth tokens.\nHowever, during inference, the model predicts each token based on its own prior outputs. \nThis discrepancy between ground-truth tokens and model-predicted tokens introduces a distribution shift, which can impair the modelโs Chain-of-Thought (CoT) reasoning capabilities.\nTo mitigate this issue, we employ [MPO](https://arxiv.org/abs/2411.10442), which introduces additional supervision from both positive and negative samples to align the model response distribution with the ground-truth distribution, thereby improving reasoning performance.\nSpecifically, the training objective of MPO is a combination of\npreference loss \\\\(\\mathcal{L}_{\\text{p}}\\\\),\nquality loss \\\\(\\mathcal{L}_{\\text{q}}\\\\),\nand generation loss \\\\(\\mathcal{L}_{\\text{g}}\\\\),\nwhich can be formulated as follows:\n\n\n$$\n\\mathcal{L}=w_{p}\\cdot\\mathcal{L}_{\\text{p}} + w_{q}\\cdot\\mathcal{L}_{\\text{q}} + w_{g}\\cdot\\mathcal{L}_{\\text{g}},\n$$\n\n\nwhere \\\\(w_{*}\\\\) represents the weight assigned to each loss component. Please see [our paper](https://arxiv.org/abs/2411.10442) for more details about MPO.\n\n\n### Test-Time Scaling\n\nTest-Time Scaling has been shown to be an effective method to enhance the reasoning abilities of LLMs and MLLMs.\nIn this work, we use the Best-of-N evaluation strategy and employ [VisualPRM-8B](https://huggingface.co/OpenGVLab/VisualPRM-8B) as the critic model to select the best response for reasoning and mathematics evaluation.\n\n## Evaluation on Multimodal Capability\n\n### Multimodal Reasoning and Mathematics\n\n\n\n### OCR, Chart, and Document Understanding\n\n\n\n### Multi-Image & Real-World Comprehension\n\n\n\n### Comprehensive Multimodal & Hallucination Evaluation\n\n\n\n### Visual Grounding\n\n\n\n### Multimodal Multilingual Understanding\n\n\n\n### Video Understanding\n\n\n\n### GUI Grounding\n\n\n\n### Spatial Reasoning\n\n\n\n## Evaluation on Language Capability\n\nWe compare InternVL3 with Qwen2.5 Chat models, whose corresponding pre-trained base models are employed as the initialization of the langauge component in InternVL3.\nBenefitting from Native Multimodal Pre-Training, the InternVL3 series achieves even better overall text performance than the Qwen2.5 series.\nPlease note that the evaluation scores of Qwen2.5 series may differ from those officially reported, as we have adopted the prompt versions provided in the table across all datasets for OpenCompass evaluation.\n\n\n\n## Ablation Study\n\n### Native Multimodal Pre-Training\n\nWe conduct experiments on the InternVL2-8B model while keeping its architecture, initialization parameters, and training data entirely unchanged. Traditionally, InternVL2-8B employs a training pipeline that begins with an MLP warmup phase for feature alignment followed by an Instruction Tuning stage. In our experiments, we substitute the conventional MLP warmup phase with a native multimodal pre-training process. This modification isolates the contribution of native multimodal pre-training to the overall multimodal capability of the model.\n\nThe evaluation results in the Figure below shows that the model with native multimodal pre-training exhibits performance on most benchmarks that is comparable to the fully multi-stage-trained InternVL2-8B baseline. Furthermore, when followed by instruction tuning on higher-quality data, the model demonstrates further performance gains across evaluated multimodal tasks. These findings underscore the efficiency of native multimodal pre-training in imparting powerful multimodal capabilities to MLLMs.\n\n\n\n### Mixed Preference Optimization\n\nAs shown in the table below, models fine-tuned with MPO demonstrate superior reasoning performance across seven multimodal reasoning benchmarks compared to their counterparts without MPO. Specifically, InternVL3-78B and InternVL3-38B outperform their counterparts by 4.1 and 4.5 points, respectively. Notably, the training data used for MPO is a subset of that used for SFT, indicating that the performance improvements primarily stem from the training algorithm rather than the training data.\n\n\n\n### Variable Visual Position Encoding\n\nAs reported in the table below, the introduction of V2PE leads to significant performance gains across most evaluation metrics. In addition, our ablation studiesโby varying the positional increment \\\\( \\delta \\\\)โreveal that even for tasks primarily involving conventional contexts, relatively small \\\\( \\delta \\\\) values can achieve optimal performance. These findings provide important insights for future efforts aimed at refining position encoding strategies for visual tokens in MLLMs.\n\n\n\n## Quick Start\n\nWe provide an example code to run `InternVL3-14B` using `transformers`.\n\n> Please use transformers>=4.37.2 to ensure the model works normally.\n\n### Model Loading\n\n#### 16-bit (bf16 / fp16)\n\n```python\nimport torch\nfrom transformers import AutoTokenizer, AutoModel\npath = \"OpenGVLab/InternVL3-14B\"\nmodel = AutoModel.from_pretrained(\n path,\n torch_dtype=torch.bfloat16,\n low_cpu_mem_usage=True,\n use_flash_attn=True,\n trust_remote_code=True).eval().cuda()\n```\n\n#### BNB 8-bit Quantization\n\n```python\nimport torch\nfrom transformers import AutoTokenizer, AutoModel\npath = \"OpenGVLab/InternVL3-14B\"\nmodel = AutoModel.from_pretrained(\n path,\n torch_dtype=torch.bfloat16,\n load_in_8bit=True,\n low_cpu_mem_usage=True,\n use_flash_attn=True,\n trust_remote_code=True).eval()\n```\n\n#### Multiple GPUs\n\nThe reason for writing the code this way is to avoid errors that occur during multi-GPU inference due to tensors not being on the same device. By ensuring that the first and last layers of the large language model (LLM) are on the same device, we prevent such errors.\n\n```python\nimport math\nimport torch\nfrom transformers import AutoTokenizer, AutoModel\n\ndef split_model(model_name):\n device_map = {}\n world_size = torch.cuda.device_count()\n config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)\n num_layers = config.llm_config.num_hidden_layers\n # Since the first GPU will be used for ViT, treat it as half a GPU.\n num_layers_per_gpu = math.ceil(num_layers / (world_size - 0.5))\n num_layers_per_gpu = [num_layers_per_gpu] * world_size\n num_layers_per_gpu[0] = math.ceil(num_layers_per_gpu[0] * 0.5)\n layer_cnt = 0\n for i, num_layer in enumerate(num_layers_per_gpu):\n for j in range(num_layer):\n device_map[f'language_model.model.layers.{layer_cnt}'] = i\n layer_cnt += 1\n device_map['vision_model'] = 0\n device_map['mlp1'] = 0\n device_map['language_model.model.tok_embeddings'] = 0\n device_map['language_model.model.embed_tokens'] = 0\n device_map['language_model.output'] = 0\n device_map['language_model.model.norm'] = 0\n device_map['language_model.model.rotary_emb'] = 0\n device_map['language_model.lm_head'] = 0\n device_map[f'language_model.model.layers.{num_layers - 1}'] = 0\n\n return device_map\n\npath = \"OpenGVLab/InternVL3-14B\"\ndevice_map = split_model('InternVL3-14B')\nmodel = AutoModel.from_pretrained(\n path,\n torch_dtype=torch.bfloat16,\n low_cpu_mem_usage=True,\n use_flash_attn=True,\n trust_remote_code=True,\n device_map=device_map).eval()\n```\n\n### Inference with Transformers\n\n```python\nimport math\nimport numpy as np\nimport torch\nimport torchvision.transforms as T\nfrom decord import VideoReader, cpu\nfrom PIL import Image\nfrom torchvision.transforms.functional import InterpolationMode\nfrom transformers import AutoModel, AutoTokenizer\n\nIMAGENET_MEAN = (0.485, 0.456, 0.406)\nIMAGENET_STD = (0.229, 0.224, 0.225)\n\ndef build_transform(input_size):\n MEAN, STD = IMAGENET_MEAN, IMAGENET_STD\n transform = T.Compose([\n T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB' else img),\n T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC),\n T.ToTensor(),\n T.Normalize(mean=MEAN, std=STD)\n ])\n return transform\n\ndef find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size):\n best_ratio_diff = float('inf')\n best_ratio = (1, 1)\n area = width * height\n for ratio in target_ratios:\n target_aspect_ratio = ratio[0] / ratio[1]\n ratio_diff = abs(aspect_ratio - target_aspect_ratio)\n if ratio_diff < best_ratio_diff:\n best_ratio_diff = ratio_diff\n best_ratio = ratio\n elif ratio_diff == best_ratio_diff:\n if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]:\n best_ratio = ratio\n return best_ratio\n\ndef dynamic_preprocess(image, min_num=1, max_num=12, image_size=448, use_thumbnail=False):\n orig_width, orig_height = image.size\n aspect_ratio = orig_width / orig_height\n\n # calculate the existing image aspect ratio\n target_ratios = set(\n (i, j) for n in range(min_num, max_num + 1) for i in range(1, n + 1) for j in range(1, n + 1) if\n i * j <= max_num and i * j >= min_num)\n target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])\n\n # find the closest aspect ratio to the target\n target_aspect_ratio = find_closest_aspect_ratio(\n aspect_ratio, target_ratios, orig_width, orig_height, image_size)\n\n # calculate the target width and height\n target_width = image_size * target_aspect_ratio[0]\n target_height = image_size * target_aspect_ratio[1]\n blocks = target_aspect_ratio[0] * target_aspect_ratio[1]\n\n # resize the image\n resized_img = image.resize((target_width, target_height))\n processed_images = []\n for i in range(blocks):\n box = (\n (i % (target_width // image_size)) * image_size,\n (i // (target_width // image_size)) * image_size,\n ((i % (target_width // image_size)) + 1) * image_size,\n ((i // (target_width // image_size)) + 1) * image_size\n )\n # split the image\n split_img = resized_img.crop(box)\n processed_images.append(split_img)\n assert len(processed_images) == blocks\n if use_thumbnail and len(processed_images) != 1:\n thumbnail_img = image.resize((image_size, image_size))\n processed_images.append(thumbnail_img)\n return processed_images\n\ndef load_image(image_file, input_size=448, max_num=12):\n image = Image.open(image_file).convert('RGB')\n transform = build_transform(input_size=input_size)\n images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)\n pixel_values = [transform(image) for image in images]\n pixel_values = torch.stack(pixel_values)\n return pixel_values\n\ndef split_model(model_name):\n device_map = {}\n world_size = torch.cuda.device_count()\n config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)\n num_layers = config.llm_config.num_hidden_layers\n # Since the first GPU will be used for ViT, treat it as half a GPU.\n num_layers_per_gpu = math.ceil(num_layers / (world_size - 0.5))\n num_layers_per_gpu = [num_layers_per_gpu] * world_size\n num_layers_per_gpu[0] = math.ceil(num_layers_per_gpu[0] * 0.5)\n layer_cnt = 0\n for i, num_layer in enumerate(num_layers_per_gpu):\n for j in range(num_layer):\n device_map[f'language_model.model.layers.{layer_cnt}'] = i\n layer_cnt += 1\n device_map['vision_model'] = 0\n device_map['mlp1'] = 0\n device_map['language_model.model.tok_embeddings'] = 0\n device_map['language_model.model.embed_tokens'] = 0\n device_map['language_model.output'] = 0\n device_map['language_model.model.norm'] = 0\n device_map['language_model.model.rotary_emb'] = 0\n device_map['language_model.lm_head'] = 0\n device_map[f'language_model.model.layers.{num_layers - 1}'] = 0\n\n return device_map\n\n# If you set `load_in_8bit=True`, you will need two 80GB GPUs.\n# If you set `load_in_8bit=False`, you will need at least three 80GB GPUs.\npath = 'OpenGVLab/InternVL3-14B'\ndevice_map = split_model('InternVL3-14B')\nmodel = AutoModel.from_pretrained(\n path,\n torch_dtype=torch.bfloat16,\n load_in_8bit=False,\n low_cpu_mem_usage=True,\n use_flash_attn=True,\n trust_remote_code=True,\n device_map=device_map).eval()\ntokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True, use_fast=False)\n\n# set the max number of tiles in `max_num`\npixel_values = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()\ngeneration_config = dict(max_new_tokens=1024, do_sample=True)\n\n# pure-text conversation (็บฏๆๆฌๅฏน่ฏ)\nquestion = 'Hello, who are you?'\nresponse, history = model.chat(tokenizer, None, question, generation_config, history=None, return_history=True)\nprint(f'User: {question}\\nAssistant: {response}')\n\nquestion = 'Can you tell me a story?'\nresponse, history = model.chat(tokenizer, None, question, generation_config, history=history, return_history=True)\nprint(f'User: {question}\\nAssistant: {response}')\n\n# single-image single-round conversation (ๅๅพๅ่ฝฎๅฏน่ฏ)\nquestion = '<image>\\nPlease describe the image shortly.'\nresponse = model.chat(tokenizer, pixel_values, question, generation_config)\nprint(f'User: {question}\\nAssistant: {response}')\n\n# single-image multi-round conversation (ๅๅพๅค่ฝฎๅฏน่ฏ)\nquestion = '<image>\\nPlease describe the image in detail.'\nresponse, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)\nprint(f'User: {question}\\nAssistant: {response}')\n\nquestion = 'Please write a poem according to the image.'\nresponse, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)\nprint(f'User: {question}\\nAssistant: {response}')\n\n# multi-image multi-round conversation, combined images (ๅคๅพๅค่ฝฎๅฏน่ฏ๏ผๆผๆฅๅพๅ)\npixel_values1 = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()\npixel_values2 = load_image('./examples/image2.jpg', max_num=12).to(torch.bfloat16).cuda()\npixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)\n\nquestion = '<image>\\nDescribe the two images in detail.'\nresponse, history = model.chat(tokenizer, pixel_values, question, generation_config,\n history=None, return_history=True)\nprint(f'User: {question}\\nAssistant: {response}')\n\nquestion = 'What are the similarities and differences between these two images.'\nresponse, history = model.chat(tokenizer, pixel_values, question, generation_config,\n history=history, return_history=True)\nprint(f'User: {question}\\nAssistant: {response}')\n\n# multi-image multi-round conversation, separate images (ๅคๅพๅค่ฝฎๅฏน่ฏ๏ผ็ฌ็ซๅพๅ)\npixel_values1 = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()\npixel_values2 = load_image('./examples/image2.jpg', max_num=12).to(torch.bfloat16).cuda()\npixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)\nnum_patches_list = [pixel_values1.size(0), pixel_values2.size(0)]\n\nquestion = 'Image-1: <image>\\nImage-2: <image>\\nDescribe the two images in detail.'\nresponse, history = model.chat(tokenizer, pixel_values, question, generation_config,\n num_patches_list=num_patches_list,\n history=None, return_history=True)\nprint(f'User: {question}\\nAssistant: {response}')\n\nquestion = 'What are the similarities and differences between these two images.'\nresponse, history = model.chat(tokenizer, pixel_values, question, generation_config,\n num_patches_list=num_patches_list,\n history=history, return_history=True)\nprint(f'User: {question}\\nAssistant: {response}')\n\n# batch inference, single image per sample (ๅๅพๆนๅค็)\npixel_values1 = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()\npixel_values2 = load_image('./examples/image2.jpg', max_num=12).to(torch.bfloat16).cuda()\nnum_patches_list = [pixel_values1.size(0), pixel_values2.size(0)]\npixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)\n\nquestions = ['<image>\\nDescribe the image in detail.'] * len(num_patches_list)\nresponses = model.batch_chat(tokenizer, pixel_values,\n num_patches_list=num_patches_list,\n questions=questions,\n generation_config=generation_config)\nfor question, response in zip(questions, responses):\n print(f'User: {question}\\nAssistant: {response}')\n\n# video multi-round conversation (่ง้ขๅค่ฝฎๅฏน่ฏ)\ndef get_index(bound, fps, max_frame, first_idx=0, num_segments=32):\n if bound:\n start, end = bound[0], bound[1]\n else:\n start, end = -100000, 100000\n start_idx = max(first_idx, round(start * fps))\n end_idx = min(round(end * fps), max_frame)\n seg_size = float(end_idx - start_idx) / num_segments\n frame_indices = np.array([\n int(start_idx + (seg_size / 2) + np.round(seg_size * idx))\n for idx in range(num_segments)\n ])\n return frame_indices\n\ndef load_video(video_path, bound=None, input_size=448, max_num=1, num_segments=32):\n vr = VideoReader(video_path, ctx=cpu(0), num_threads=1)\n max_frame = len(vr) - 1\n fps = float(vr.get_avg_fps())\n\n pixel_values_list, num_patches_list = [], []\n transform = build_transform(input_size=input_size)\n frame_indices = get_index(bound, fps, max_frame, first_idx=0, num_segments=num_segments)\n for frame_index in frame_indices:\n img = Image.fromarray(vr[frame_index].asnumpy()).convert('RGB')\n img = dynamic_preprocess(img, image_size=input_size, use_thumbnail=True, max_num=max_num)\n pixel_values = [transform(tile) for tile in img]\n pixel_values = torch.stack(pixel_values)\n num_patches_list.append(pixel_values.shape[0])\n pixel_values_list.append(pixel_values)\n pixel_values = torch.cat(pixel_values_list)\n return pixel_values, num_patches_list\n\nvideo_path = './examples/red-panda.mp4'\npixel_values, num_patches_list = load_video(video_path, num_segments=8, max_num=1)\npixel_values = pixel_values.to(torch.bfloat16).cuda()\nvideo_prefix = ''.join([f'Frame{i+1}: <image>\\n' for i in range(len(num_patches_list))])\nquestion = video_prefix + 'What is the red panda doing?'\n# Frame1: <image>\\nFrame2: <image>\\n...\\nFrame8: <image>\\n{question}\nresponse, history = model.chat(tokenizer, pixel_values, question, generation_config,\n num_patches_list=num_patches_list, history=None, return_history=True)\nprint(f'User: {question}\\nAssistant: {response}')\n\nquestion = 'Describe this video in detail.'\nresponse, history = model.chat(tokenizer, pixel_values, question, generation_config,\n num_patches_list=num_patches_list, history=history, return_history=True)\nprint(f'User: {question}\\nAssistant: {response}')\n```\n\n#### Streaming Output\n\nBesides this method, you can also use the following code to get streamed output.\n\n```python\nfrom transformers import TextIteratorStreamer\nfrom threading import Thread\n\n# Initialize the streamer\nstreamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True, timeout=10)\n# Define the generation configuration\ngeneration_config = dict(max_new_tokens=1024, do_sample=False, streamer=streamer)\n# Start the model chat in a separate thread\nthread = Thread(target=model.chat, kwargs=dict(\n tokenizer=tokenizer, pixel_values=pixel_values, question=question,\n history=None, return_history=False, generation_config=generation_config,\n))\nthread.start()\n\n# Initialize an empty string to store the generated text\ngenerated_text = ''\n# Loop through the streamer to get the new text as it is generated\nfor new_text in streamer:\n if new_text == model.conv_template.sep:\n break\n generated_text += new_text\n print(new_text, end='', flush=True) # Print each new chunk of generated text on the same line\n```\n\n## Finetune\n\nMany repositories now support fine-tuning of the InternVL series models, including [InternVL](https://github.com/OpenGVLab/InternVL), [SWIFT](https://github.com/modelscope/ms-swift), [XTurner](https://github.com/InternLM/xtuner), and others. Please refer to their documentation for more details on fine-tuning.\n\n## Deployment\n\n### LMDeploy\n\nLMDeploy is a toolkit for compressing, deploying, and serving LLMs & VLMs.\n\n```sh\n# if lmdeploy<0.7.3, you need to explicitly set chat_template_config=ChatTemplateConfig(model_name='internvl2_5')\npip install lmdeploy>=0.7.3\n```\n\nLMDeploy abstracts the complex inference process of multi-modal Vision-Language Models (VLM) into an easy-to-use pipeline, similar to the Large Language Model (LLM) inference pipeline.\n\n#### A 'Hello, world' Example\n\n```python\nfrom lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig\nfrom lmdeploy.vl import load_image\n\nmodel = 'OpenGVLab/InternVL3-14B'\nimage = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg')\npipe = pipeline(model, backend_config=TurbomindEngineConfig(session_len=16384, tp=1), chat_template_config=ChatTemplateConfig(model_name='internvl2_5'))\nresponse = pipe(('describe this image', image))\nprint(response.text)\n```\n\nIf `ImportError` occurs while executing this case, please install the required dependency packages as prompted.\n\n#### Multi-images Inference\n\nWhen dealing with multiple images, you can put them all in one list. Keep in mind that multiple images will lead to a higher number of input tokens, and as a result, the size of the context window typically needs to be increased.\n\n```python\nfrom lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig\nfrom lmdeploy.vl import load_image\nfrom lmdeploy.vl.constants import IMAGE_TOKEN\n\nmodel = 'OpenGVLab/InternVL3-14B'\npipe = pipeline(model, backend_config=TurbomindEngineConfig(session_len=16384, tp=1), chat_template_config=ChatTemplateConfig(model_name='internvl2_5'))\n\nimage_urls=[\n 'https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg',\n 'https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/det.jpg'\n]\n\nimages = [load_image(img_url) for img_url in image_urls]\n# Numbering images improves multi-image conversations\nresponse = pipe((f'Image-1: {IMAGE_TOKEN}\\nImage-2: {IMAGE_TOKEN}\\ndescribe these two images', images))\nprint(response.text)\n```\n\n#### Batch Prompts Inference\n\nConducting inference with batch prompts is quite straightforward; just place them within a list structure:\n\n```python\nfrom lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig\nfrom lmdeploy.vl import load_image\n\nmodel = 'OpenGVLab/InternVL3-14B'\npipe = pipeline(model, backend_config=TurbomindEngineConfig(session_len=16384, tp=1), chat_template_config=ChatTemplateConfig(model_name='internvl2_5'))\n\nimage_urls=[\n \"https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg\",\n \"https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/det.jpg\"\n]\nprompts = [('describe this image', load_image(img_url)) for img_url in image_urls]\nresponse = pipe(prompts)\nprint(response)\n```\n\n#### Multi-turn Conversation\n\nThere are two ways to do the multi-turn conversations with the pipeline. One is to construct messages according to the format of OpenAI and use above introduced method, the other is to use the `pipeline.chat` interface.\n\n```python\nfrom lmdeploy import pipeline, TurbomindEngineConfig, GenerationConfig, ChatTemplateConfig\nfrom lmdeploy.vl import load_image\n\nmodel = 'OpenGVLab/InternVL3-14B'\npipe = pipeline(model, backend_config=TurbomindEngineConfig(session_len=16384, tp=1), chat_template_config=ChatTemplateConfig(model_name='internvl2_5'))\n\nimage = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg')\ngen_config = GenerationConfig(top_k=40, top_p=0.8, temperature=0.8)\nsess = pipe.chat(('describe this image', image), gen_config=gen_config)\nprint(sess.response.text)\nsess = pipe.chat('What is the woman doing?', session=sess, gen_config=gen_config)\nprint(sess.response.text)\n```\n\n#### Service\n\nLMDeploy's `api_server` enables models to be easily packed into services with a single command. The provided RESTful APIs are compatible with OpenAI's interfaces. Below are an example of service startup:\n\n```shell\nlmdeploy serve api_server OpenGVLab/InternVL3-14B --chat-template internvl2_5 --server-port 23333 --tp 1\n```\n\nTo use the OpenAI-style interface, you need to install OpenAI:\n\n```shell\npip install openai\n```\n\nThen, use the code below to make the API call:\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(api_key='YOUR_API_KEY', base_url='http://0.0.0.0:23333/v1')\nmodel_name = client.models.list().data[0].id\nresponse = client.chat.completions.create(\n model=model_name,\n messages=[{\n 'role':\n 'user',\n 'content': [{\n 'type': 'text',\n 'text': 'describe this image',\n }, {\n 'type': 'image_url',\n 'image_url': {\n 'url':\n 'https://modelscope.oss-cn-beijing.aliyuncs.com/resource/tiger.jpeg',\n },\n }],\n }],\n temperature=0.8,\n top_p=0.8)\nprint(response)\n```\n\n## License\n\nThis project is released under the MIT License. This project uses the pre-trained Qwen2.5 as a component, which is licensed under the Apache-2.0 License.\n\n## Citation\n\nIf you find this project useful in your research, please consider citing:\n\n```BibTeX\n@article{chen2024expanding,\n title={Expanding Performance Boundaries of Open-Source Multimodal Models with Model, Data, and Test-Time Scaling},\n author={Chen, Zhe and Wang, Weiyun and Cao, Yue and Liu, Yangzhou and Gao, Zhangwei and Cui, Erfei and Zhu, Jinguo and Ye, Shenglong and Tian, Hao and Liu, Zhaoyang and others},\n journal={arXiv preprint arXiv:2412.05271},\n year={2024}\n}\n@article{wang2024mpo,\n title={Enhancing the Reasoning Ability of Multimodal Large Language Models via Mixed Preference Optimization},\n author={Wang, Weiyun and Chen, Zhe and Wang, Wenhai and Cao, Yue and Liu, Yangzhou and Gao, Zhangwei and Zhu, Jinguo and Zhu, Xizhou and Lu, Lewei and Qiao, Yu and Dai, Jifeng},\n journal={arXiv preprint arXiv:2411.10442},\n year={2024}\n}\n@article{chen2024far,\n title={How Far Are We to GPT-4V? Closing the Gap to Commercial Multimodal Models with Open-Source Suites},\n author={Chen, Zhe and Wang, Weiyun and Tian, Hao and Ye, Shenglong and Gao, Zhangwei and Cui, Erfei and Tong, Wenwen and Hu, Kongzhi and Luo, Jiapeng and Ma, Zheng and others},\n journal={arXiv preprint arXiv:2404.16821},\n year={2024}\n}\n@inproceedings{chen2024internvl,\n title={Internvl: Scaling up vision foundation models and aligning for generic visual-linguistic tasks},\n author={Chen, Zhe and Wu, Jiannan and Wang, Wenhai and Su, Weijie and Chen, Guo and Xing, Sen and Zhong, Muyan and Zhang, Qinglong and Zhu, Xizhou and Lu, Lewei and others},\n booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},\n pages={24185--24198},\n year={2024}\n}\n```",
"related_quantizations": []
},
"tags": [
"transformers",
"gguf",
"internvl_chat",
"feature-extraction",
"internvl",
"unsloth",
"custom_code",
"image-text-to-text",
"multilingual",
"arxiv:2312.14238",
"arxiv:2404.16821",
"arxiv:2412.05271",
"arxiv:2411.10442",
"arxiv:2504.10479",
"arxiv:2412.09616",
"base_model:OpenGVLab/InternVL3-14B-Instruct",
"base_model:finetune:OpenGVLab/InternVL3-14B-Instruct",
"license:apache-2.0",
"endpoints_compatible",
"region:us",
"conversational"
],
"likes": 5,
"downloads": 435,
"gated": false,
"private": false,
"last_modified": "2025-05-19T03:17:53.000Z",
"created_at": "2025-05-19T02:56:19.000Z",
"pipeline_tag": "image-text-to-text",
"library_name": "transformers"
}
Source payload excerpt (from Hugging Face API)
{
"_id": "682a9dd3b8fc5288f8aa9a3e",
"id": "unsloth/InternVL3-14B-Instruct-GGUF",
"modelId": "unsloth/InternVL3-14B-Instruct-GGUF",
"sha": "a1d2011c6313d656493b21a0480027993520f29c",
"createdAt": "2025-05-19T02:56:19.000Z",
"lastModified": "2025-05-19T03:17:53.000Z",
"author": "unsloth",
"downloads": 435,
"likes": 5,
"gated": false,
"private": false,
"pipeline_tag": "image-text-to-text",
"library_name": "transformers",
"siblings_count": 31
}