Frozen Transformers in Language Models Are Effective Visual Encoder Layers

Ziqi Pang, Ziyang Xie, Yunze Man, Yu-Xiong Wang

TL;DR

Researchers have discovered that large language models (LLMs) like LLaMA and OPT contain "frozen" transformer blocks that are surprisingly effective at processing purely visual data. By simply plugging a single frozen LLM layer into a standard vision pipeline, models achieve significant performance gains across 2D images, 3D point clouds, and video—even without any language prompts or text inputs.

Introduction

Traditionally, the "vision" and "language" domains of AI have been treated as distinct modalities. When we use LLMs for computer vision (as in GPT-4V or LLaVA), we typically rely on a "Vision-Language" setup where the model receives both an image and a text prompt.

This paper asks a more fundamental question: Can the internal machinery of an LLM—trained exclusively on text—help with tasks that have absolutely nothing to do with language? For example, can a LLaMA block help a model classify a point cloud or predict the trajectory of a car? The authors tackle the challenge of leveraging the structural "intelligence" of LLMs for purely visual encoding, moving beyond the need for multi-modal prompts.

Methods

The authors propose a remarkably simple architectural change. Instead of building a massive multi-modal bridge, they take a standard visual encoder (like a Vision Transformer or ViT) and modify it as follows:

  1. Extract: Pick a single transformer block from a pre-trained, frozen LLM (e.g., LLaMA-7B).
  2. Insert: Append this block to the end of the visual encoder.
  3. Align: Add two small, trainable linear layers—one before the LLM block to "up-project" visual features to the LLM's hidden dimension, and one after to project them back.
  4. Freeze: Keep the LLM block's weights completely frozen during training. Only the original encoder, the projection layers, and the task head are updated.
Architecture of the proposed model, integrating a frozen LLM transformer block into a standard visual encoder.

Crucially, they remove the LLM's original positional embeddings and causal (auto-regressive) masks, treating the visual tokens as a bidirectional set of features.

Datasets

The study is impressively broad, testing the "LLM-as-encoder" theory on:

  • 2D Image Classification: ImageNet-1k and its robustness variants (ImageNet-C, A, SK, R).
  • 3D Point Cloud: ScanObjectNN and ModelNet40.
  • Action Recognition (Video): Something-Something-v2 (SSv2).
  • Motion Forecasting: Argoverse (predicting vehicle trajectories).
  • Vision-Language Tasks: VQAv2 (2D), Flickr30k (Retrieval), and SQA3D (3D Question Answering).

Key Insights and Ideas

  • The Information Filtering Hypothesis: The authors propose that LLM blocks act as a "filter." Because they are trained to find complex patterns in text, they are naturally good at discerning which visual tokens are "informative" (like a foreground object) and which are "noise" (like a blurry background).
  • Emergent Segmentation: One of the most striking findings is qualitative. When visualizing the "attention" of the model, the versions with the LLM block show a much sharper focus on the actual objects in a scene. It’s as if the LLM block provides a "free" segmentation effect that standard supervised ViTs lack.
Feature activation and attention scores demonstrating the LLM block's ability to filter information and focus on relevant objects.
  • Weights Matter: They ran an ablation where they replaced the frozen LLaMA block with a randomly initialized MLP of the same size. The random MLP performed significantly worse, proving that the pre-trained linguistic weights are doing the heavy lifting, not just the added parameter count.
  • Freezing is Mandatory: Interestingly, fine-tuning the LLM block actually decreased performance on long-term training. The authors suggest that fine-tuning causes the model to overfit and lose the generalized pattern-recognition capabilities it gained during language pre-training.

Key Results

  • ImageNet: Adding a LLaMA block to a ViT-Base model boosted accuracy from 80.6% to 81.7%. More importantly, it significantly improved robustness; on ImageNet-A (adversarial images), accuracy jumped from 23.4% to 26.9%.
  • 3D Recognition: On the ScanObjectNN benchmark, the LLaMA-enhanced model outperformed the baseline across all categories (Background, Object, and Clipped).
  • Motion Forecasting: Even in non-semantic tasks like predicting car movements, the LLM block reduced the Average Displacement Error (ADE) and Final Displacement Error (FDE).
  • Generality: The effect was consistent whether they used LLaMA or OPT, and across different depths of the LLM, though the very last layers of the LLM tended to be the most effective.

Limitations and Future Work

While the results are compelling, the authors note a few "black box" areas:

  • Layer Specificity: They found that different layers of the LLM have different "preferences" for visual features (some prefer magnitude, others frequency), but they don't yet have a mathematical framework to predict which layer is best for which task.
  • Scaling Constraints: Due to computational limits, they haven't yet explored using multiple LLM blocks or scaling to the largest 70B+ models.
  • The "Why": While the "Information Filtering" hypothesis is supported by visualizations, the exact mechanism of how a model trained on "The cat sat on the mat" learns to identify the geometry of a 3D chair remains a fascinating mystery for future research.

Summary updated

BibTeX
@inproceedings{pang2024frozen,
  author = {Ziqi Pang and Ziyang Xie and Yunze Man and Yu-Xiong Wang},
  title = {{Frozen Transformers in Language Models Are Effective Visual Encoder Layers}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=t0FI3Q66K5},
}
Figure