Preprint
Multimodal AI

Papers Explained 187c: Llama 3.1 — Multimodal Experiments

July 1, 2024

0

Citations

0

Influential Citations

Venue

2024

Year

Abstract

Additional experiments of adding multimodal capabilities to Llama3.

Analysis

Why This Paper Matters

The Llama 3.1 multimodal experiments represent a significant step toward unifying vision, video, and speech understanding within a single foundation model architecture. By using a compositional approach with cross-attention adapters, the authors show that powerful language models can be extended to multiple modalities without catastrophic forgetting or massive retraining. This is particularly important for practitioners who want to add multimodal capabilities to existing LLMs efficiently.

How It Works

The core innovation is a modular adapter framework that connects pre-trained encoders to Llama 3 via trainable cross-attention layers. For vision, a ViT-H/14 image encoder (630M parameters) is augmented with additional gated self-attention layers and multi-layer feature extraction from layers 4, 8, 16, 24, and 31, resulting in an 850M parameter encoder. Cross-attention layers using grouped-query attention (GQA) are inserted after every fourth self-attention layer in the language model.

Illustration of the compositional approach to adding multimodal capabilities to Llama3.

Training proceeds in two stages: initial pre-training on ~6B image-text pairs with images resized to fit within four 336×336 tiles, followed by annealing on ~500M higher-quality images at increased resolution. The annealing dataset is carefully curated through n-gram resampling and augmented with visual grounding, screenshot parsing, QA pairs, synthetic captions, and synthetically generated structured images (charts, tables, math equations).

For video, the model processes up to 64 uniformly sampled frames. A temporal aggregator (perceiver resampler) merges 32 consecutive frames into one, and additional video cross-attention layers are added before every fourth image cross-attention layer. During pre-training, 16 frames are aggregated to 1, but this is increased to 64 frames with aggregation factor 32 during supervised fine-tuning.

Post-training involves supervised fine-tuning (SFT) and preference optimization. For SFT, the language model weights are frozen while only the vision adapter is trained, using hyperparameter sweeps and weight averaging of top-K models. Preference data includes human-annotated comparisons with 7-scale ratings and synthetic pairs generated by text-only LLMs that introduce subtle errors. Direct Preference Optimization (DPO) is applied with an exponential moving average of the reference model updated every k steps, which improves human evaluation scores.

For speech, an encoder-adapter architecture is used with a system prompt to switch between modes: general-purpose spoken dialogue or specific tasks. The dialogue history is maintained in text form.

Results

Image understanding performance of the vision module attached to Llama 3.

The Llama 3-V 405B model outperforms GPT-4V on all image understanding benchmarks, including document understanding tasks where it shows particular strength. It is slightly behind Gemini 1.5 Pro and Claude 3.5 Sonnet on some benchmarks but remains highly competitive.

Video understanding performance of the vision module attached to Llama 3.

For video, even the 8B and 70B models achieve strong results. The model excels on PerceptionTest, indicating robust temporal reasoning capabilities. On ActivityNet-QA, which involves long-form activity understanding, Llama 3 obtains competitive results despite processing only 64 frames from a 3-minute video (one frame every 3 seconds).

Significance

This work provides a practical blueprint for adding multimodal capabilities to large language models. The compositional approach means that practitioners can leverage existing pre-trained encoders and LLMs, training only the adapter layers, which is computationally efficient. The careful data curation pipeline—including quality filtering, perceptual deduplication, and n-gram resampling—offers a template for building high-quality multimodal datasets. The use of rejection sampling to generate chain-of-thought explanations for reasoning tasks is a notable technique that could improve generalization in other multimodal systems. Overall, Llama 3.1's multimodal experiments demonstrate that a unified model can handle text, image, video, and speech tasks effectively, paving the way for more versatile AI assistants.