LayerIF: Estimating Layer Quality for Large Language Models using Influence Functions

Hadi Askari, Shivanshu Gupta, Fei Wang, Anshuman Chhabra, Muhao Chen

Introduction

Modern Large Language Models (LLMs) are characterized by their massive scale and depth. However, research indicates that not all layers contribute equally to a model's performance; some are highly specialized and crucial, while others may be redundant or under-optimized. Identifying these "quality" variations is essential for efficient model compression (pruning) and scaling (Mixture-of-Experts, MoE). Traditionally, engineers have relied on model-centric heuristics, such as spectral density or activation outliers, to estimate layer importance. These methods, however, ignore the critical role of data. Since a model's behavior is intrinsically linked to its training and fine-tuning tasks, a data-agnostic approach leaves a significant gap in understanding layer specialization.

Methodology: The LayerIF Framework

LayerIF addresses this gap by introducing a data-centric framework based on Influence Functions (IFs). Influence Functions are a classic technique used to quantify how specific training samples affect model predictions. LayerIF adapts this concept to the layer-wise architecture of Transformers.

The LayerIF workflow compared to pre-existing model-centric methods. LayerIF uses layer-wise gradients and dataset information to compute IF scores, which then guide expert allocation and sparsity mapping.

The framework operates through three primary stages:

  1. Layer-wise Isolation: IF scores are computed locally for each Transformer block rather than for the model as a whole.
  2. Sensitivity Analysis: The method aggregates "positive influence" scores—samples that effectively reduce validation loss. The core hypothesis is that mature, well-trained layers exhibit lower sensitivity to data perturbations, whereas high sensitivity indicates instability or under-training.
  3. Task-Specific Mapping: These scores are smoothed using a Savitzky-Golay filter and mapped to downstream applications. In LoRA-MoE, more experts are allocated to layers identified as needing more capacity. In Pruning, higher sparsity budgets are assigned to less stable layers, preserving the "mature" components.

Experimental Setup

The authors evaluated LayerIF using Mistral-7B-v0.1 and Gemma-7B across a variety of benchmarks. For expert allocation, tasks included GLUE (MRPC, CoLA), ScienceQA, and CommonsenseQA. For pruning, the evaluation spanned zero-shot benchmarks like BoolQ, Hellaswag, and ARC.

Results and Discussion

LayerIF demonstrates superior performance across both MoE and pruning tasks, validating the importance of data-centric layer evaluation.

LLM Pruning

In pruning experiments using SparseGPT at 50% sparsity, LayerIF-guided allocation improved zero-shot accuracy by 0.90% over the AlphaPruning baseline and 1.03% over OWL. The method maintained its performance edge across various pruning ratios and algorithms (Magnitude, Wanda, and SparseGPT).

LoRA-MoE Expert Allocation

For expert allocation, LayerIF outperformed state-of-the-art strategies like AlphaLora and MoLA, achieving a 1.61% relative accuracy increase. This suggests that dynamic, task-specific expert distribution based on layer sensitivity is more effective than static or uniform allocation.

Key Insights

  • Dynamic Specialization: Layer importance is not static; layers specialize differently depending on the downstream task.
  • Sensitivity as a Quality Metric: High sensitivity to training data is a reliable indicator of layer "immaturity" or lack of generalization.
  • Second-Order Information: Capturing meaningful layer-wise quality requires Hessian-based IF approximations (like DataInf); first-order methods often fail to provide a sufficient signal.

Conclusion and Future Work

LayerIF provides a robust, zero-inference-overhead diagnostic tool for optimizing LLMs. While it relies on computational-intensive Hessian inversions and a convexity assumption, its empirical success highlights the value of data-centric metrics. Future work will focus on faster IF estimators and adaptive thresholding techniques to further refine layer quality estimation.

Summary updated

BibTeX
@inproceedings{askari2025layerif,
  author = {Hadi Askari and Shivanshu Gupta and Fei Wang and Anshuman Chhabra and Muhao Chen},
  title = {{LayerIF: Estimating Layer Quality for Large Language Models using Influence Functions}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=JgtCg08aZk},
}
Figure