Rethinking Layer Relevance in Large Language Models Beyond Cosine Similarity

TL;DR

Proposes accuracy drop as a layer relevance metric, outperforming cosine similarity in large language models.

cs.LG 🔴 Advanced 2026-05-14 65 views
Cristian Hinostroza Rodrigo Toro Icarte Christ Devia Andres Carvallo De Ferari Eugenio Herrera-Berg Denis Parra Jorge F Silva
interpretability pruning layer importance cosine similarity performance evaluation

Key Findings

Methodology

Through theoretical proofs and extensive experiments on models like LLaMA-3-8B and Mistral-7B, the authors demonstrate the unreliability of cosine similarity for layer importance. They introduce an accuracy-based metric, measuring performance degradation after layer removal, validated across multiple datasets (HellaSwag, MMLU). The approach involves constructing worst-case scenarios, analyzing correlation coefficients, and applying iterative pruning guided by the new metric, showing superior preservation of task performance compared to traditional methods.

Key Results

  • Layers with near-zero cosine similarity (e.g., 0.01) can cause performance drops of 66% when removed, indicating their critical role. Conversely, layers with high cosine similarity (e.g., 0.9) often have negligible impact. Across models and tasks, correlation between cosine similarity and actual performance change remains weak (-0.15 to -0.46), with over 90% misclassification in relevance ranking.
  • Using accuracy drop as the metric, pruning strategies maintain over 75% of original performance while removing 20% of layers in LLaMA-3-8B, outperforming cosine-based pruning. This demonstrates the metric’s robustness and practical utility in model compression.
  • In structured pruning experiments, the accuracy-based approach achieves state-of-the-art results, reducing model size significantly without sacrificing task accuracy. It outperforms Taylor expansion, perplexity-based, and cosine similarity methods, confirming its effectiveness.

Significance

This work fundamentally challenges the reliance on cosine similarity for interpretability and pruning, offering a more reliable, performance-aligned metric. It advances understanding of layer contributions, enabling more effective model compression and transparency, crucial for deploying large models efficiently in real-world scenarios. The approach bridges the gap between theoretical analysis and practical optimization, fostering development of leaner, interpretable AI systems.

Technical Contribution

The paper introduces a formal proof showing that layers with low cosine similarity can still be crucial, and develops an accuracy-based relevance score. It combines theoretical guarantees with empirical validation across multiple models and datasets, establishing a new standard for layer importance evaluation. The iterative pruning method guided by this metric significantly improves model compression while maintaining performance, opening avenues for future research in scalable interpretability.

Novelty

This is the first comprehensive study to critique cosine similarity as a layer importance proxy, providing rigorous theoretical backing and empirical evidence. It proposes a performance-based metric that directly correlates with downstream task accuracy, representing a significant innovation over prior proxy-based methods. The integration of this metric into structured pruning workflows marks a novel contribution to model compression and interpretability.

Limitations

  • The accuracy-based metric requires multiple model evaluations after layer removal, incurring high computational costs, especially for very large models. Approximate or surrogate methods are needed for scalability.
  • Task and dataset dependency may limit the metric’s generalizability; different tasks might require tailored calibration. Further validation across diverse domains is necessary.
  • In some cases, performance drops may be affected by noise or data variability, complicating interpretation. Combining multiple metrics could mitigate this issue.

Future Work

Future research should focus on developing efficient approximation algorithms for the accuracy-based metric, enabling real-time or large-scale applications. Extending the framework to multi-task and multi-modal models, exploring robustness across tasks, and integrating with automated pruning pipelines will further enhance its practical impact.

AI Executive Summary

Transformers have revolutionized natural language processing, yet understanding their internal mechanisms remains a challenge. Traditional methods, such as cosine similarity, have been widely used to evaluate layer relevance, assuming that layers causing minimal change in internal representations are less important. However, this assumption oversimplifies the complex dynamics within these models. The current study rigorously demonstrates both theoretically and empirically that cosine similarity is a poor proxy for actual layer importance. It can mislead interpretations, as layers with low cosine similarity can still be critical, and vice versa.

To address this, the authors propose an alternative metric based on the actual drop in model accuracy after layer removal. This performance-oriented approach directly measures the impact on task performance, capturing the intricate dependencies among layers. The methodology involves constructing worst-case scenarios, mathematically proving the existence of layers with low cosine similarity but high importance, and validating these findings across multiple models and datasets.

Experimental results show that the new metric significantly outperforms cosine similarity in identifying crucial layers. For instance, in LLaMA-3-8B, pruning guided by accuracy drop maintains over 75% of the original performance while removing 20% of layers, a feat that cosine-based methods struggle to achieve. These findings have profound implications for model compression, interpretability, and deployment efficiency.

The study also explores practical applications, such as structured pruning, demonstrating that the accuracy-based metric leads to state-of-the-art compression results. Despite higher computational costs, this approach offers a more faithful understanding of model internals, paving the way for more transparent and efficient AI systems. Future directions include developing scalable approximation techniques and extending the framework to multi-task and multimodal models, promising a new era of interpretable and lightweight large language models.

Deep Dive

Glossary

Transformer (变换器)

一种基于注意力机制的深度学习架构,处理序列数据,广泛应用于NLP。

分析模型各层的重要性。

余弦相似性 (Cosine Similarity)

衡量两个向量夹角余弦值的指标,反映相似程度,范围-1到1。

作为传统层重要性评估工具。

性能下降 (Performance Drop)

删除某层后模型在任务中的准确率或效果的减少。

用以衡量层的实际贡献。

结构剪枝 (Structured Pruning)

有目的地删除模型中的层或参数以减小规模。

论文中用新指标指导剪枝。

雪崩效应 (Snowball Effect)

微小变化在后续层中被放大,导致输出巨大变化。

理论分析中说明低余弦相似层的关键性。

Open Questions Unanswered questions from this research

  • 1 如何设计更高效的性能评估算法,减少计算成本?
  • 2 指标在不同任务和模型中的通用性和鲁棒性如何保证?
  • 3 能否结合多指标形成更全面的层重要性评估体系?

Applications

Immediate Applications

模型剪枝优化

利用准确率下降指标,指导大模型结构剪枝,减少参数,加快推理。

机制解释

帮助理解模型内部层的功能,提升透明度。

Long-term Vision

高效可解释AI

推动构建透明、可压缩的AI模型,实现更广泛应用。

Abstract

Large language models (LLMs) have revolutionized natural language processing. Understanding their internal mechanisms is crucial for developing more interpretable and optimized architectures. Mechanistic interpretability has led to the development of various methods for assessing layer relevance, with cosine similarity being a widely used tool in the field. On this work, we demonstrate that cosine similarity is a poor proxy for the actual performance degradation caused by layer removal. Our theoretical analysis shows that a layer can exhibit an arbitrarily low cosine similarity score while still being crucial to the model's performance. On the other hand, empirical evidence from a range of LLMs confirms that the correlation between cosine similarity and actual performance degradation is often weak or moderate, leading to misleading interpretations of a transformer's internal mechanisms. We propose a more robust metric for assessing layer relevance: the actual drop in model accuracy resulting from the removal of a layer. Even though it is a computationally costly metric, this approach offers a more accurate picture of layer importance, allowing for more informed pruning strategies and lightweight models. Our findings have significant implications for the development of interpretable LLMs and highlight the need to move beyond cosine similarity in assessing layer relevance.

cs.LG cs.CL