LLaMA-VID: An Image is Worth 2 Tokens in Large Language Models

Yanwei Li, Chengyao Wang, Jiaya Jia · DOI

Abstract

Large Language Models (LLMs) face a "token explosion" when processing video data, as traditional Vision Language Models (VLMs) represent frames with hundreds of tokens. We present LLaMA-VID, a novel VLM that represents each video frame using only two tokens: an instruction-guided context token and a visually-enriched content token. This approach enables the model to support hour-long videos while maintaining high efficiency and state-of-the-art performance on both image and video benchmarks.

Introduction

The integration of visual capabilities into Large Language Models (LLMs) has primarily focused on images, where a single image is typically represented by 256 or more tokens. Applying this paradigm to video leads to a prohibitive computational cost; for instance, a 10,000-frame video would require millions of tokens, far exceeding current context windows. LLaMA-VID addresses this challenge by introducing a dual-token strategy that drastically compresses visual information without losing the context necessary for complex reasoning.

Methodology

The LLaMA-VID architecture employs a dual-token representation to distill each frame into a highly efficient format for the LLM (Vicuna).

The LLaMA-VID architecture featuring the dual-token generation process: a context token guided by user instructions and a content token for general visual environment.

The system consists of three primary components:

  1. Context Token: Generated via a "Context Attention" module, this token uses a text decoder to spotlight visual features relevant to the user's specific instruction.
  2. Content Token: This token captures the broader visual environment. For long videos, adaptive pooling is used to condense frame features into a single representative token.
  3. Visual Encoder and Projectors: A pre-trained ViT (EVA-G) extracts features, which are then mapped into the LLM's input space through linear projectors.

Training is conducted in three stages: Modality Alignment, Instruction Tuning, and a specialized Long Video Tuning stage using a newly curated dataset of 15K long-form QA pairs based on movie scripts.

Results and Discussion

LLaMA-VID demonstrates superior performance across a wide range of benchmarks, proving that instruction-guided compression can be more effective than high-token-count representations.

Comparison of LLaMA-VID against state-of-the-art models across multiple image and video benchmarks.

On the MSVD-QA video benchmark, LLaMA-VID (7B) achieved 69.7% accuracy, significantly outperforming Video-ChatGPT (64.9%). Remarkably, despite its optimization for video, the model also exceeds the performance of LLaVA-1.5 on image-centric benchmarks such as GQA and MME. The 2-token-per-frame efficiency allows LLaMA-VID to process videos exceeding three hours in length within a standard 64K token window, a feat previously unattainable for most VLMs.

Conclusion

LLaMA-VID provides a scalable solution to the token burden in video understanding. By focusing on query-relevant visual information, it achieves a "sweet spot" between computational efficiency and reasoning capability. While the extreme compression may limit performance in tasks requiring minute spatial precision, it opens new possibilities for long-form video analysis and accessible VLM training.

Summary updated

BibTeX
@inproceedings{li2024llama,
  author = {Yanwei Li and Chengyao Wang and Jiaya Jia},
  title = {{LLaMA-VID: An Image is Worth 2 Tokens in Large Language Models}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72952-2\_19},
}
Figure