Image-Text-to-Text
Transformers
PyTorch
multilingual
internvl_chat
feature-extraction
internvl
custom_code
conversational
Run this model with HF Jobs
Run OpenGVLab/InternVL2-40B-AWQ on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/OpenGVLab/InternVL2-40B-AWQ. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/OpenGVLab/InternVL2-40B-AWQ on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/OpenGVLab/InternVL2-40B-AWQ. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Instructions to use OpenGVLab/InternVL2-40B-AWQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenGVLab/InternVL2-40B-AWQ with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenGVLab/InternVL2-40B-AWQ", trust_remote_code=True) 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?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("OpenGVLab/InternVL2-40B-AWQ", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OpenGVLab/InternVL2-40B-AWQ with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenGVLab/InternVL2-40B-AWQ" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenGVLab/InternVL2-40B-AWQ", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/OpenGVLab/InternVL2-40B-AWQ
- SGLang
How to use OpenGVLab/InternVL2-40B-AWQ with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "OpenGVLab/InternVL2-40B-AWQ" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenGVLab/InternVL2-40B-AWQ", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "OpenGVLab/InternVL2-40B-AWQ" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenGVLab/InternVL2-40B-AWQ", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use OpenGVLab/InternVL2-40B-AWQ with Docker Model Runner:
docker model run hf.co/OpenGVLab/InternVL2-40B-AWQ
fix compatibility issue for transformers 4.46+
Browse filesFiles changed (4)
12 unmodified lines131415161718192021222318 unmodified lines4243444546474874 unmodified lines12312412512612712812 unmodified lines- custom_codebase_model: OpenGVLab/InternVL2-40Bbase_model_relation: quantized---# InternVL2-40B-AWQ[\[π GitHub\]](https://github.com/OpenGVLab/InternVL) [\[π Blog\]](https://internvl.github.io/blog/) [\[π InternVL 1.0 Paper\]](https://arxiv.org/abs/2312.14238) [\[π InternVL 1.5 Report\]](https://arxiv.org/abs/2404.16821)[\[π¨οΈ Chat Demo\]](https://internvl.opengvlab.com/) [\[π€ HF Demo\]](https://huggingface.co/spaces/OpenGVLab/InternVL) [\[π Quick Start\]](#quick-start) [\[π δΈζθ§£θ―»\]](https://zhuanlan.zhihu.com/p/706547971) [\[π Documents\]](https://internvl.readthedocs.io/en/latest/)18 unmodified linesBefore proceeding with the quantization and inference, please ensure that lmdeploy is installed.```shellpip install lmdeploy==0.5.3```This article comprises the following sections:74 unmodified linesIf you find this project useful in your research, please consider citing:```BibTeX@article{chen2023internvl,title={InternVL: Scaling up Vision Foundation Models and Aligning for Generic Visual-Linguistic Tasks},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 Li, Bin and Luo, Ping and Lu, Tong and Qiao, Yu and Dai, Jifeng},12 unmodified lines13141516171819202122232418 unmodified lines4344454647484974 unmodified lines12412512612712812913013113213313413512 unmodified lines- custom_codebase_model: OpenGVLab/InternVL2-40Bbase_model_relation: quantizednew_version: OpenGVLab/InternVL2_5-40B-AWQ---# InternVL2-40B-AWQ[\[π GitHub\]](https://github.com/OpenGVLab/InternVL) [\[π Blog\]](https://internvl.github.io/blog/) [\[π InternVL 1.0\]](https://arxiv.org/abs/2312.14238) [\[π InternVL 1.5\]](https://arxiv.org/abs/2404.16821) [\[π Mini-InternVL\]](https://arxiv.org/abs/2410.16261)[\[π¨οΈ Chat Demo\]](https://internvl.opengvlab.com/) [\[π€ HF Demo\]](https://huggingface.co/spaces/OpenGVLab/InternVL) [\[π Quick Start\]](#quick-start) [\[π δΈζθ§£θ―»\]](https://zhuanlan.zhihu.com/p/706547971) [\[π Documents\]](https://internvl.readthedocs.io/en/latest/)18 unmodified linesBefore proceeding with the quantization and inference, please ensure that lmdeploy is installed.```shellpip install lmdeploy>=0.5.3```This article comprises the following sections:74 unmodified linesIf you find this project useful in your research, please consider citing:```BibTeX@article{gao2024mini,title={Mini-internvl: A flexible-transfer pocket multimodal model with 5\% parameters and 90\% performance},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},journal={arXiv preprint arXiv:2410.16261},year={2024}}@article{chen2023internvl,title={InternVL: Scaling up Vision Foundation Models and Aligning for Generic Visual-Linguistic Tasks},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 Li, Bin and Luo, Ping and Lu, Tong and Qiao, Yu and Dai, Jifeng},
16 unmodified lines17181920212223242516 unmodified lines"architectures": ["LlamaForCausalLM"],"attention_bias": false,"attention_dropout": 0.0,"attn_implementation": "eager","bad_words_ids": null,"begin_suppress_tokens": null,"bos_token_id": 1,16 unmodified lines17181920212223242516 unmodified lines"architectures": ["LlamaForCausalLM"],"attn_implementation": "eager","attention_bias": false,"attention_dropout": 0.0,"bad_words_ids": null,"begin_suppress_tokens": null,"bos_token_id": 1,
37 unmodified lines383940414243444546474837 unmodified linessuper().__init__(**kwargs)if vision_config is None:vision_config = {}logger.info('vision_config is None. Initializing the InternVisionConfig with default values.')if llm_config is None:llm_config = {}logger.info('llm_config is None. Initializing the LlamaConfig config with default values (`LlamaConfig`).')self.vision_config = InternVisionConfig(**vision_config)37 unmodified lines383940414243444546474837 unmodified linessuper().__init__(**kwargs)if vision_config is None:vision_config = {'architectures': ['InternVisionModel']}logger.info('vision_config is None. Initializing the InternVisionConfig with default values.')if llm_config is None:llm_config = {'architectures': ['LlamaForCausalLM']}logger.info('llm_config is None. Initializing the LlamaConfig config with default values (`LlamaConfig`).')self.vision_config = InternVisionConfig(**vision_config)
2 unmodified lines3456782 unmodified lines# Copyright (c) 2024 OpenGVLab# Licensed under The MIT License [see LICENSE for details]# --------------------------------------------------------from typing import Optional, Tuple, Unionimport torch2 unmodified lines34567892 unmodified lines# Copyright (c) 2024 OpenGVLab# Licensed under The MIT License [see LICENSE for details]# --------------------------------------------------------from typing import Optional, Tuple, Unionimport torch
README.md+9-2
config.json+1-1
configuration_internvl_chat.py+2-2
modeling_intern_vit.py+1