OpenGVLab/InternVL2_5-38B-AWQ
934
1---2license: mit3pipeline_tag: image-text-to-text4library_name: transformers5base_model: OpenGVLab/InternVL2_5-38B6base_model_relation: quantized7language:8 - multilingual9tags:10 - internvl11 - custom_code12---13 14# InternVL2_5-38B-AWQ15 16[\[๐ GitHub\]](https://github.com/OpenGVLab/InternVL) [\[๐ InternVL 1.0\]](https://huggingface.co/papers/2312.14238) [\[๐ InternVL 1.5\]](https://huggingface.co/papers/2404.16821) [\[๐ Mini-InternVL\]](https://arxiv.org/abs/2410.16261) [\[๐ InternVL 2.5\]](https://huggingface.co/papers/2412.05271)17 18[\[๐ 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/)19 20<div align="center">21 <img width="500" alt="image" src="https://cdn-uploads.huggingface.co/production/uploads/64006c09330a45b03605bba3/zJsd2hqd3EevgXo6fNgC-.png">22</div>23 24## Introduction25 26We are excited to introduce **InternVL 2.5**, an advanced multimodal large language model (MLLM) series that builds upon InternVL 2.0, maintaining its core model architecture while introducing significant enhancements in training and testing strategies as well as data quality.27 2829 30## InternVL 2.5 Family31 32In the following table, we provide an overview of the InternVL 2.5 series.33 34| Model Name | Vision Part | Language Part | HF Link |35| :-------------: | :-------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------: | :---------------------------------------------------------: |36| InternVL2_5-1B | [InternViT-300M-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-300M-448px-V2_5) | [Qwen2.5-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL2_5-1B) |37| InternVL2_5-2B | [InternViT-300M-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-300M-448px-V2_5) | [internlm2_5-1_8b-chat](https://huggingface.co/internlm/internlm2_5-1_8b-chat) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL2_5-2B) |38| InternVL2_5-4B | [InternViT-300M-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-300M-448px-V2_5) | [Qwen2.5-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL2_5-4B) |39| InternVL2_5-8B | [InternViT-300M-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-300M-448px-V2_5) | [internlm2_5-7b-chat](https://huggingface.co/internlm/internlm2_5-7b-chat) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL2_5-8B) |40| InternVL2_5-26B | [InternViT-6B-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-6B-448px-V2_5) | [internlm2_5-20b-chat](https://huggingface.co/internlm/internlm2_5-20b-chat) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL2_5-26B) |41| InternVL2_5-38B | [InternViT-6B-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-6B-448px-V2_5) | [Qwen2.5-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-32B-Instruct) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL2_5-38B) |42| InternVL2_5-78B | [InternViT-6B-448px-V2_5](https://huggingface.co/OpenGVLab/InternViT-6B-448px-V2_5) | [Qwen2.5-72B-Instruct](https://huggingface.co/Qwen/Qwen2.5-72B-Instruct) | [๐ค link](https://huggingface.co/OpenGVLab/InternVL2_5-78B) |43 44## Model Architecture45 46As shown in the following figure, InternVL 2.5 retains the same model architecture as 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 2.5 and Qwen 2.5, using a randomly initialized MLP projector.47 4849 50As 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.51 52## Deployment53 54### LMDeploy55 56LMDeploy is a toolkit for compressing, deploying, and serving LLMs & VLMs.57 58```sh59pip install lmdeploy>=0.6.460```61 62LMDeploy 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.63 64#### A 'Hello, world' Example65 66```python67from lmdeploy import pipeline, TurbomindEngineConfig68from lmdeploy.vl import load_image69 70model = 'OpenGVLab/InternVL2_5-38B-AWQ'71image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg')72pipe = pipeline(model, backend_config=TurbomindEngineConfig(session_len=8192, tp=2))73response = pipe(('describe this image', image))74print(response.text)75```76 77If `ImportError` occurs while executing this case, please install the required dependency packages as prompted.78 79#### Multi-images Inference80 81When 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.82 83```python84from lmdeploy import pipeline, TurbomindEngineConfig85from lmdeploy.vl import load_image86from lmdeploy.vl.constants import IMAGE_TOKEN87 88model = 'OpenGVLab/InternVL2_5-38B-AWQ'89pipe = pipeline(model, backend_config=TurbomindEngineConfig(session_len=8192, tp=2))90 91image_urls=[92 'https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg',93 'https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/det.jpg'94]95 96images = [load_image(img_url) for img_url in image_urls]97# Numbering images improves multi-image conversations98response = pipe((f'Image-1: {IMAGE_TOKEN}\nImage-2: {IMAGE_TOKEN}\ndescribe these two images', images))99print(response.text)100```101 102#### Batch Prompts Inference103 104Conducting inference with batch prompts is quite straightforward; just place them within a list structure:105 106```python107from lmdeploy import pipeline, TurbomindEngineConfig108from lmdeploy.vl import load_image109 110model = 'OpenGVLab/InternVL2_5-38B-AWQ'111pipe = pipeline(model, backend_config=TurbomindEngineConfig(session_len=8192, tp=2))112 113image_urls=[114 "https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg",115 "https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/det.jpg"116]117prompts = [('describe this image', load_image(img_url)) for img_url in image_urls]118response = pipe(prompts)119print(response)120```121 122#### Multi-turn Conversation123 124There 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.125 126```python127from lmdeploy import pipeline, TurbomindEngineConfig, GenerationConfig128from lmdeploy.vl import load_image129 130model = 'OpenGVLab/InternVL2_5-38B-AWQ'131pipe = pipeline(model, backend_config=TurbomindEngineConfig(session_len=8192, tp=2))132 133image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg')134gen_config = GenerationConfig(top_k=40, top_p=0.8, temperature=0.8)135sess = pipe.chat(('describe this image', image), gen_config=gen_config)136print(sess.response.text)137sess = pipe.chat('What is the woman doing?', session=sess, gen_config=gen_config)138print(sess.response.text)139```140 141#### Service142 143LMDeploy'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:144 145```shell146lmdeploy serve api_server OpenGVLab/InternVL2_5-38B-AWQ --server-port 23333 --tp 2147```148 149To use the OpenAI-style interface, you need to install OpenAI:150 151```shell152pip install openai153```154 155Then, use the code below to make the API call:156 157```python158from openai import OpenAI159 160client = OpenAI(api_key='YOUR_API_KEY', base_url='http://0.0.0.0:23333/v1')161model_name = client.models.list().data[0].id162response = client.chat.completions.create(163 model=model_name,164 messages=[{165 'role':166 'user',167 'content': [{168 'type': 'text',169 'text': 'describe this image',170 }, {171 'type': 'image_url',172 'image_url': {173 'url':174 'https://modelscope.oss-cn-beijing.aliyuncs.com/resource/tiger.jpeg',175 },176 }],177 }],178 temperature=0.8,179 top_p=0.8)180print(response)181```182 183## License184 185This project is released under the MIT License. This project uses the pre-trained Qwen2.5-32B-Instruct as a component, which is licensed under the Apache License 2.0.186 187## Citation188 189If you find this project useful in your research, please consider citing:190 191```BibTeX192@article{chen2024expanding,193 title={Expanding Performance Boundaries of Open-Source Multimodal Models with Model, Data, and Test-Time Scaling},194 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},195 journal={arXiv preprint arXiv:2412.05271},196 year={2024}197}198@article{gao2024mini,199 title={Mini-internvl: A flexible-transfer pocket multimodal model with 5\% parameters and 90\% performance},200 author={Gao, Zhangwei and Chen, Zhe and Cui, Erfei and Ren, Yiming and Wang, Weiyun and Zhu, Jinguo and Tian, Hao and Ye, Shenglong and He, Junjun and Zhu, Xizhou and others},201 journal={arXiv preprint arXiv:2410.16261},202 year={2024}203}204@article{chen2024far,205 title={How Far Are We to GPT-4V? Closing the Gap to Commercial Multimodal Models with Open-Source Suites},206 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},207 journal={arXiv preprint arXiv:2404.16821},208 year={2024}209}210@inproceedings{chen2024internvl,211 title={Internvl: Scaling up vision foundation models and aligning for generic visual-linguistic tasks},212 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},213 booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},214 pages={24185--24198},215 year={2024}216}217```218 