Rethinking Layer Relevance in Large Language Models Beyond Cosine Similarity

Cristian Hinostroza, Rodrigo Toro Icarte, Christ Devia, Andres Carvallo De Ferari, Eugenio Herrera-Berg, Denis Parra, Jorge F Silva

Introduction

Is a neural network layer "important" just because it significantly transforms its input? This paper argues—and mathematically proves—that the answer is a resounding "no."

In the quest to make Large Language Models (LLMs) smaller and faster, researchers often look for "redundant" layers to prune. The standard tool for finding these layers has been cosine similarity: if a layer’s output is nearly identical to its input (high similarity), it is assumed to be doing nothing and is labeled "irrelevant."

However, this is an assumption, not a law. This paper tackles the "proxy gap": the disconnect between how much a layer changes a vector and how much that change actually matters to the final prediction. By demonstrating that the popular cosine similarity metric is a poor proxy for actual performance, the authors propose a direct accuracy-based relevance score that enables more aggressive, effective model pruning without the typical "performance cliff."

Methodology

The authors approach the problem of layer relevance from three distinct angles:

  1. Theoretical Proof (The "Snowball Effect"): They provide a formal mathematical proof showing it is possible to construct a Transformer where a layer has an arbitrarily low transformation score (near-zero change) but remains absolutely essential. Removing it drops the model's accuracy from 100% to 0%. A tiny, subtle change in an early layer can be amplified by subsequent layers.
  2. A New Metric (AccBasedRelevance): Instead of looking at intermediate vector transformations, they look at end results. They measure the actual drop in accuracy when a specific layer is removed, normalized against a random predictor.
  3. Iterative Pruning: Unlike "one-shot" pruning (calculating all scores once and cutting the bottom percentage), they use an iterative approach. They remove the least relevant layer, re-calculate the relevance of the remaining layers, and repeat. This accounts for the interdependent nature of transformer layers.
  4. Healing: They also test "healing" by using LoRA (Low-Rank Adaptation) to fine-tune the pruned model, observing whether it can recover lost performance.

Key Insights

Cosine Similarity is a Noisy Compass Empirical evidence across models like LLaMA-3-8B, Mistral-7B, Pythia-6.9B, and OLMo-7B shows the correlation between cosine similarity and actual performance degradation is often weak to moderate. In the case of the OLMo model, the correlation coefficient was a measly -0.15.

Relevance is Task-Dependent A layer might be useless for a coding task but critical for a math task. Cosine similarity often suggests that layer relevance is "dataset-agnostic," but the authors show this is an illusion caused by the metric's insensitivity.

Heatmaps comparing Accuracy-based and Cosine Similarity-based relevance across different datasets.

As seen in the comparison above, the accuracy-based metric (left) reveals that layer importance fluctuates wildly depending on what the model is trying to solve. In contrast, the cosine similarity metric (right) paints a falsely uniform picture across all datasets.

Pruning Reasoning Tasks Previous studies suggested that complex reasoning tasks (like HellaSwag) require every single layer to function. This paper challenges that assumption, showing that with a better relevance metric, you can prune up to 22% of a model's layers while maintaining over 75% accuracy.

Key Results

  • High Misestimation Rate: Cosine similarity misestimated a layer's true relevance ranking in 93.8% of cases studied. Even when looking only at "substantial" errors, it failed over half the time (53.6%).
  • Pruning Superiority: In task-dependent pruning (optimizing a model for one specific task), the accuracy-based method consistently outperformed all baselines, including Taylor approximations and other output-based metrics.
Performance degradation across MMLU, GSM8K, and HellaSwag as pruning ratio increases.
  • Sustained Performance: As demonstrated in the pruning ratio charts above, models pruned using the accuracy-based metric maintain their performance significantly longer than those pruned using cosine similarity, delaying the inevitable "performance cliff" across diverse tasks like world knowledge, math reasoning, and common sense reasoning.
  • Healing Limits: While fine-tuning (healing) can help a pruned model recover, it cannot fix a fundamentally bad pruning strategy. At aggressive pruning ratios (50%+), the accuracy-based selection provided a significantly better foundation for recovery.

Limitations and Future Work

While the accuracy-based metric provides a far more faithful view of the model, it comes with trade-offs:

  • Computational Cost: Measuring accuracy for every layer across multiple iterations is expensive. While cosine similarity takes minutes, this method takes hours. Parallelizing this process across multiple GPUs is a vital next step.
  • Greedy Search: The current iterative process is "greedy"—it picks the best layer to remove now, but doesn't guarantee the optimal combination of layers to remove globally. Future work could explore search algorithms like A* to find better global pruning sets.
  • Calibration Sensitivity: The "task-independent" version of their metric is highly sensitive to the choice of the calibration dataset. Finding a universal calibration set that generalizes across all tasks remains an open challenge.

Summary updated

BibTeX
@inproceedings{hinostroza2026rethinking,
  author = {Cristian Hinostroza and Rodrigo Toro Icarte and Christ Devia and Andres Carvallo De Ferari and Eugenio Herrera-Berg and Denis Parra and Jorge F Silva},
  title = {{Rethinking Layer Relevance in Large Language Models Beyond Cosine Similarity}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=mRLnS8jQWt},
}
Figure