SPIN

SParsifying and INtegrating internal neurons for text classification

  • Text classification
  • Large language models
  • Interpretability

Difan Jiao* · Yilun Liu* · Zhenwei Tang · Daniel Matter · Jürgen Pfeffer · Ashton Anderson

Motivation

When this study began in 2023, competitive text classifiers were typically task-specific encoders or language models fine-tuned separately for each task. We ask whether a frozen pretrained language model already contains useful classification information in its intermediate representations, and whether selecting and combining that information across layers is more effective than reading only the final hidden state.

Method: sparse neuron selection and cross-layer integration

Interactive comparison of a final-layer classifier and SPIN The final-layer baseline pools the terminal hidden state. SPIN selects salient neurons within each layer and concatenates their activations into a cross-layer representation. SPIN integrates selected neuron activations across the frozen model’s layers.

Layer-wise sparse probing

SPIN fits an L1-regularized logistic-regression probe to each layer’s pooled activations.

Salient neuron selection

Neurons are ranked by absolute probe-weight magnitude, and the smallest set that reaches the cumulative contribution threshold is retained.

Cross-layer integration

The selected activations are concatenated, and a final classification head is trained on the resulting representation.

Experiments and results

We evaluate eight pretrained language models on IMDb, SST-2, and EDOS. For each model and dataset, SPIN is compared with a classification head trained on the final hidden state of the same frozen backbone.

24 / 24 model × dataset improved
+24.97% largest relative lift
0 backbone weights updated
1.67× inference speedup
SPIN versus final-layer classification across 24 comparisons Three paired slope charts compare terminal-state classifiers with SPIN on IMDb, SST-2, and EDOS. SPIN improves all eight models on each dataset. Final-layer and SPIN results across eight models and three datasets.

SPIN’s sparse cross-layer representation outperformed the terminal-state classifier in every pretrained comparison. The strongest result reached 99.91% of the published fine-tuned state of the art on IMDb, and applying SPIN after fine-tuning produced further gains.

View all 24 results
BackboneIMDb accuracySST-2 accuracyEDOS macro-F1
FinalSPINFinalSPINFinalSPIN
DistilBERT86.9589.7881.8883.9465.0975.79
RoBERTa89.6793.6184.0690.5968.8173.50
GPT287.7291.9485.8987.7368.5776.08
GPT2-M88.5993.9286.1290.2571.1775.74
GPT2-XL91.8694.9290.0293.2372.5676.79
Flan-T5-S84.0891.1577.1788.9959.6274.51
Flan-T590.0194.1478.2692.3266.6478.04
Flan-T5-XL90.5096.1284.7595.6470.0881.48

What, which, and where?

What does sparsification retain?

η sets the cumulative share of normalized absolute probe-weight mass to retain. SPIN ranks neurons by this importance score and selects the smallest set that reaches the threshold.

At η = 0.4, SPIN selects about 3% of neurons per layer. At η = 0.8, selection remains below one quarter of the layer.

3%kept

Which pooling function represents the sequence?

The paper compares a single-token embedding, feature-wise max pooling, and mean pooling over the sequence.

Max pooling retains the strongest activation for each feature across the sequence.

Where can layer integration stop?

The plot reports IMDb accuracy after integrating the first 20%, 40%, 60%, 80%, or 100% of layers for each backbone.

60% of GPT2-XL’s layers retained 99.8% of its full-depth result.
94.73accuracy
99.8%of full-depth result

The sparsification and pooling panels are schematics; the early-exit panel reports measured IMDb results from the paper.

Token-level attribution

The classifier trained on complete reviews is applied at each token position to visualize how the cumulative sentiment decision changes across the sequence.

negative contribution positive contribution

Positive signal: profound exploration then Negative signal: clichéd plot twists yet Positive signal: moments of brilliance despite Negative signal: its predictability nonetheless Negative signal: agreeing with its detractors and still Positive signal: a monument in movie history

Color shows direction, not a synthetic score.