Awesome
<p align="center"> <img src="demo_images/nvila-logo.png" width="20%"/> </p>NVILA: Efficient Frontier Visual Language Models
NVILA arXiv / NVILA Demo / NVILA Models (coming soon) / Subscribe
๐ก Introduction
NVILA is a family of open VLMs designed to optimize both efficiency and accuracy for efficient video understanding and multi-image understanding . Building on top of VILA, we improve its model architecture by first scaling up the spatial and temporal resolutions, and then compressing visual tokens. This "scale-then-compress" approach enables NVILA to efficiently process high-resolution images and long videos. We also conduct a systematic investigation to enhance the efficiency of NVILA throughout its entire lifecycle, from training and fine-tuning to deployment. NVILA matches or surpasses the accuracy of many leading open and proprietary VLMs across a wide range of image and video benchmarks. At the same time, it reduces training costs by 4.5ร, fine-tuning memory usage by 3.4ร, pre-filling latency by 1.6-2.2ร, and decoding latency by 1.2-2.8ร. We make our code and models available to facilitate reproducibility.
๐ก News
- [2024/12] We release NVILA (a.k.a VILA2.0) that explores the full stack efficiency of multi-modal design, achieving cheaper training, faster deployment and better performance.
- [2024/12] We release LongVILA that supports long video understanding, with long-context VLM with more than 1M context length and multi-modal sequence parallel system.
- [2024/10] VILA-M3, a SOTA medical VLM finetuned on VILA1.5 is released! VILA-M3 significantly outperforms Llava-Med and on par w/ Med-Gemini and is fully opensourced! code model
- [2024/10] We release VILA-U: a Unified foundation model that integrates Video, Image, Language understanding and generation.
- [2024/07] VILA1.5 also ranks 1st place (OSS model) on MLVU test leaderboard.
- [2024/06] VILA1.5 is now the best open sourced VLM on MMMU leaderboard and Video-MME leaderboard!
- [2024/05] We release VILA-1.5, which offers video understanding capability. VILA-1.5 comes with four model sizes: 3B/8B/13B/40B.
- [2024/05] We release AWQ-quantized 4bit VILA-1.5 models. VILA-1.5 is efficiently deployable on diverse NVIDIA GPUs (A100, 4090, 4070 Laptop, Orin, Orin Nano) by TinyChat and TensorRT-LLM backends.
- [2024/03] VILA has been accepted by CVPR 2024!
- [2024/02] We release AWQ-quantized 4bit VILA models, deployable on Jetson Orin and laptops through TinyChat and TinyChatEngine.
- [2024/02] VILA is released. We propose interleaved image-text pretraining that enables multi-image VLM. VILA comes with impressive in-context learning capabilities. We open source everything: including training code, evaluation code, datasets, model ckpts.
- [2023/12] Paper is on Arxiv!
Performance
Image Benchmarks
Video Benchmarks
Efficient Deployments
<sup>NOTE: Measured using the TinyChat backend at batch size = 1.</sup>
Inference Performance
Decoding Throughput ( Token/sec )
$~~~~~~$ | A100 | 4090 | Orin |
---|---|---|---|
NVILA-3B-Baseline | 140.6 | 190.5 | 42.7 |
NVILA-3B-TinyChat | 184.3 | 230.5 | 45.0 |
NVILA-Lite-3B-Baseline | 142.3 | 190.0 | 41.3 |
NVILA-Lite-3B-TinyChat | 186.0 | 233.9 | 44.9 |
NVILA-8B-Baseline | 82.1 | 61.9 | 11.6 |
NVILA-8B-TinyChat | 186.8 | 162.7 | 28.1 |
NVILA-Lite-8B-Baseline | 84.0 | 62.0 | 11.6 |
NVILA-Lite-8B-TinyChat | 181.8 | 167.5 | 32.8 |
NVILA-Video-8B-Baseline * | 73.2 | 58.4 | 10.9 |
NVILA-Video-8B-TinyChat * | 151.8 | 145.0 | 32.3 |
TTFT (Time-To-First-Token) ( Sec )
$~~~~~~$ | A100 | 4090 | Orin |
---|---|---|---|
NVILA-3B-Baseline | 0.0329 | 0.0269 | 0.1173 |
NVILA-3B-TinyChat | 0.0260 | 0.0188 | 0.1359 |
NVILA-Lite-3B-Baseline | 0.0318 | 0.0274 | 0.1195 |
NVILA-Lite-3B-TinyChat | 0.0314 | 0.0191 | 0.1241 |
NVILA-8B-Baseline | 0.0434 | 0.0573 | 0.4222 |
NVILA-8B-TinyChat | 0.0452 | 0.0356 | 0.2748 |
NVILA-Lite-8B-Baseline | 0.0446 | 0.0458 | 0.2507 |
NVILA-Lite-8B-TinyChat | 0.0391 | 0.0297 | 0.2097 |
NVILA-Video-8B-Baseline * | 0.7190 | 0.8840 | 5.8236 |
NVILA-Video-8B-TinyChat * | 0.6692 | 0.6815 | 5.8425 |
<sup>NOTE: Measured using the TinyChat backend at batch size = 1, dynamic_s2 disabled, and num_video_frames = 64. We use W4A16 LLM and W8A8 Vision Tower for Tinychat and the baseline precision is FP16.</sup>
<sup>*: Measured with video captioning task. Otherwise, measured with image captioning task.</sup>
VILA Examples
Image
<img src="demo_images/demo_img.png" height="750">Video
https://github.com/Efficient-Large-Model/VILA/assets/156256291/c9520943-2478-4f97-bc95-121d625018a6
Prompt: Elaborate on the visual and narrative elements of the video in detail.
Response: The video features a person with red nail polish meticulously working on a piece of fabric with a black and white checkered pattern. The individual is dressed in a black top with a red inner layer. The setting includes a white table where various tools such as a ruler, a pencil, and a pin are placed. The person is seen folding the fabric in a precise manner, creating a triangular shape. The background includes a greenish cabinet with drawers, adding a contrasting color to the scene. Throughout the video, the text 'Country Sampler' is visible in the bottom right corner, indicating the source or brand associated with the content. The video emphasizes the careful and detailed process of fabric folding, showcasing the person's skill and attention to detail.
VILA on Jetson Orin
https://github.com/Efficient-Large-Model/VILA/assets/7783214/6079374c-0787-4bc4-b9c6-e1524b4c9dc4
VILA on RTX 4090
https://github.com/Efficient-Large-Model/VILA/assets/7783214/80c47742-e873-4080-ad7d-d17c4700539f
Installation
./environment_setup.sh vila
Training
VILA training contains three steps, for specific hyperparameters, please check out the scripts/v1_5 folder:
Step-1: Alignment
We utilize LLaVA-CC3M-Pretrain-595K dataset to align the textual and visual modalities.
The stage 1 script takes in two parameters and it can run on a single 8xA100 node.
bash scripts/NVILA-Lite/align.sh Efficient-Large-Model/Qwen2-VL-7B-Instruct <alias to data>
and the trained models will be saved to runs/train/nvila-8b-align
.
Step-1.5:
bash scripts/NVILA-Lite/stage15.sh runs/train/nvila-8b-align/model <alias to data>
and the trained models will be saved to runs/train/nvila-8b-align-1.5
.
Step-2: Pretraining
We use MMC4 and Coyo dataset to train VLM with interleaved image-text pairs.
bash scripts/NVILA-Lite/pretrain.sh runs/train/nvila-8b-align-1.5 <alias to data>
and the trained models will be saved to runs/train/nvila-8b-pretraining
.
Step-3: Supervised fine-tuning
This is the last stage of VILA training, in which we tune the model to follow multimodal instructions on a subset of M3IT, FLAN and ShareGPT4V. This stage runs on a 8xA100 node.
bash scripts/NVILA-Lite/sft.sh runs/train/nvila-8b-pretraining <alias to data>
and the trained models will be saved to runs/train/nvila-8b-SFT
.
Evaluations
We have introduce vila-eval
command to simplify the evaluation. Once the data is prepared, the evaluation can be launched via
MODEL_NAME=NVILA-15B
MODEL_ID=Efficient-Large-Model/$MODEL_NAME
huggingface-cli download $MODEL_ID
vila-eval \
--model-name $MODEL_NAME \
--model-path $MODEL_ID \
--conv-mode auto \
--tags-include local
it will launch all evaluations and return a summarized result.
Inference
We provide vila-infer
for quick inference with user prompts and images.
# image description
vila-infer \
--model-path Efficient-Large-Model/NVILA-15B \
--conv-mode auto \
--text "Please describe the image" \
--media inference_test/test_data/caption_meat.jpeg
# video description
vila-infer \
--model-path Efficient-Large-Model/NVILA-15B \
--conv-mode auto \
--text "Please describe the video" \
--media https://huggingface.co/datasets/Efficient-Large-Model/VILA-inference-demos/resolve/main/OAI-sora-tokyo-walk.mp4
<sup>NOTE: vila-infer
is also compatible with VILA-1.5 models. You may find the usage example in tests/bash/test_inference.sh.</sup>
Quantization and Deployment
Our VILA models are quantized by AWQ into 4 bits for efficient inference on the edge. We provide a push-the-button script to quantize VILA with AWQ.
Running VILA on desktop GPUs and edge GPUs
We support AWQ-quantized 4bit VILA on GPU platforms via TinyChat. We provide a tutorial to run the model with TinyChat after quantization. We also provide an instruction to launch a Gradio server (powered by TinyChat and AWQ) to serve 4-bit quantized VILA models.
Running VILA on laptops
We further support our AWQ-quantized 4bit VILA models on various CPU platforms with both x86 and ARM architectures with our TinyChatEngine. We also provide a detailed tutorial to help the users deploy VILA on different CPUs.
Running VILA API server
A simple API server has been provided to serve VILA models. The server is built on top of FastAPI and Huggingface Transformers. The server can be run with the following command:
With CLI
python -W ignore server.py \
--port 8000 \
--model-path Efficient-Large-Model/NVILA-15B \
--conv-mode auto
With Docker
docker build -t vila-server:latest .
docker run --gpus all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 \
-v ./hub:/root/.cache/huggingface/hub \
-it --rm -p 8000:8000 \
-e VILA_MODEL_PATH=Efficient-Large-Model/NVILA-15B \
-e VILA_CONV_MODE=auto \
vila-server:latest
Then you can call the endpoint with the OpenAI SDK as follows:
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000",
api_key="fake-key",
)
response = client.chat.completions.create(
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "Whatโs in this image?"},
{
"type": "image_url",
"image_url": {
"url": "https://blog.logomyway.com/wp-content/uploads/2022/01/NVIDIA-logo.jpg",
# Or you can pass in a base64 encoded image
# "url": "data:image/png;base64,<base64_encoded_image>",
},
},
],
}
],
model="NVILA-15B",
)
print(response.choices[0].message.content)
<sup>NOTE: This API server is intended for evaluation purposes only and has not been optimized for production use. SGLang support is coming on the way.</sup>
Checkpoints
We release the following models:
- NVILA-8B / NVILA-8B-Lite
- NVILA-15B / NVILA-15B-Lite
๐ License
- The code is released under the Apache 2.0 license as found in the LICENSE file.
- The pretrained weights are released under the CC-BY-NC-SA-4.0 license.
- The service is a research preview intended for non-commercial use only, and is subject to the following licenses and terms:
- Model License of LLaMA. For LLAMA3-VILA checkpoints terms of use, please refer to the LLAMA3 License for additional details.
- Terms of Use of the data generated by OpenAI
- Dataset Licenses for each one used during training.
Team
NVILA Core contributors: Zhijian Liu, Ligeng Zhu, Baifeng Shi, Zhuoyang Zhang, Yuming Lou, Shang Yang, Haocheng Xi, Shiyi Cao, Yuxian Gu, Dacheng Li, Xiuyu Li, Yunhao Fang, Yukang Chen, Cheng-Yu Hsieh, De-An Huang, An-Chieh Cheng, Vishwesh Nath, Jinyi Hu, Sifei Liu, Ranjay Krishna, Daguang Xu, Xiaolong Wang, Pavlo Molchanov, Jan Kautz, Hongxu Yin, Song Han, Yao Lu
LongVILA contributors: Yukang Chen, Fuzhao Xue, Dacheng Li, Qinghao Hu, Ligeng Zhu, Xiuyu Li, Yunhao Fang, Haotian Tang, Shang Yang, Zhijian Liu, Ethan He, Hongxu Yin, Pavlo Molchanov, Jan Kautz, Linxi Fan, Yuke Zhu, Yao Lu, Song Han
<details> <summary> VILA-1.5 contributors </summary>*Yao Lu: Nvidia, *Hongxu Yin: Nvidia, *Ji Lin: OpenAI (work done at Nvidia and MIT), Wei Ping: Nvidia, Pavlo Molchanov: Nvidia, Andrew Tao: Nvidia, Haotian Tang: MIT, Shang Yang: MIT, Ligeng Zhu: Nvidia, MIT, Wei-Chen Wang: MIT, Fuzhao Xue: Nvidia, NUS, Yunhao Fang: Nvidia, UCSD, Yukang Chen: Nvidia, Zhuoyang Zhang: Nvidia, Yue Shen: Nvidia, Wei-Ming Chen: Nvidia, Huizi Mao: Nvidia, Baifeng Shi: Nvidia, UC Berkeley, Jan Kautz: Nvidia, Mohammad Shoeybi: Nvidia, Song Han: Nvidia, MIT
</details>Citations
@misc{liu2024nvila,
title={NVILA: Efficient Frontier Visual Language Models},
author={Zhijian Liu and Ligeng Zhu and Baifeng Shi and Zhuoyang Zhang and Yuming Lou and Shang Yang and Haocheng Xi and Shiyi Cao and Yuxian Gu and Dacheng Li and Xiuyu Li and Yunhao Fang and Yukang Chen and Cheng-Yu Hsieh and De-An Huang and An-Chieh Cheng and Vishwesh Nath and Jinyi Hu and Sifei Liu and Ranjay Krishna and Daguang Xu and Xiaolong Wang and Pavlo Molchanov and Jan Kautz and Hongxu Yin and Song Han and Yao Lu},
year={2024},
eprint={2412.04468},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2412.04468},
}
@misc{chen2024longvila,
title={LongVILA: Scaling Long-Context Visual Language Models for Long Videos},
author={Yukang Chen and Fuzhao Xue and Dacheng Li and Qinghao Hu and Ligeng Zhu and Xiuyu Li and Yunhao Fang and Haotian Tang and Shang Yang and Zhijian Liu and Ethan He and Hongxu Yin and Pavlo Molchanov and Jan Kautz and Linxi Fan and Yuke Zhu and Yao Lu and Song Han},
year={2024},
eprint={2408.10188},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
@misc{lin2023vila,
title={VILA: On Pre-training for Visual Language Models},
author={Ji Lin and Hongxu Yin and Wei Ping and Yao Lu and Pavlo Molchanov and Andrew Tao and Huizi Mao and Jan Kautz and Mohammad Shoeybi and Song Han},
year={2023},
eprint={2312.07533},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
Acknowledgement
- LLaVA: the codebase we built upon. Thanks for their wonderful work.
- InternVL: for open-sourcing InternViT (used in VILA1.5-40b) and the InternVL-SFT data blend (inspired by LLaVA-1.6) used in all VILA1.5 models.
- Vicuna: the amazing open-sourced large language model!
- Video-ChatGPT: we borrowed video evaluation script from this repository.
- MMC4, COYO-700M, M3IT, OpenORCA/FLAN, ShareGPT4V, WIT, GSM8K-ScRel, VisualGenome, VCR, ScienceQA, Shot2Story, Youcook2, Vatex, ShareGPT-Video for providing datasets used in this research.