A Picture Costs a Thousand Words — Literally

· Source: LLM on Medium · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Cloud Computing & IT Infrastructure · Depth: Intermediate, medium

Summary

Vision Transformers (ViTs) consume a high number of tokens for images, significantly increasing costs in multimodal AI models. ViTs process images by dividing them into 16x16 pixel patches, treating each as a token. The self-attention mechanism then incurs a quadratic cost (N²) based on the token count (N), meaning a 1024x1024 image with 16-pixel patches generates 4,096 tokens and roughly 16.8 million token pairs for attention. Major AI providers—OpenAI, Anthropic, and Google's Gemini—employ distinct billing models for image tokens, resulting in up to a 2.7x cost difference for an identical 4032x3024 phone photo. Research, exemplified by LLaVA-PruMerge, reveals that up to 95% of visual tokens often carry minimal information. This has spurred development of token reduction strategies, including larger patches, dynamic merging (Qwen2-VL), on-the-fly pruning (FastV, PruMerge), fixed-budget encoders (BLIP-2, Flamingo), and windowed attention (Swin Transformer), all aimed at making image processing more efficient.

Key takeaway

For AI Engineers and ML Architects optimizing multimodal model costs, understanding visual token consumption is critical. Your image processing strategy directly impacts billing, with a 2.7x cost spread possible for identical inputs across providers. Downscale and crop images before uploading, and avoid re-sending them in multi-turn chats. Consider OCR for documents to significantly reduce token expenses. This proactive management of visual input can substantially lower operational costs and improve model efficiency.

Key insights

Vision Transformers' quadratic attention cost for image tokens drives high expense, despite most visual tokens being redundant.

Principles

Method

Researchers reduce visual token costs via larger patches, dynamic merging, on-the-fly pruning, fixed-budget encoders like Q-Former, or windowed attention to break the N² wall.

In practice

Topics

Best for: AI Engineer, Machine Learning Engineer, AI Architect

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by LLM on Medium.