Views
No views yet
S = 1 - CosineSim(X_A, Y_A)X_A is the hidden state entering the attention sublayer (captured before input_layernorm) and Y_A is the hidden state after the attention computation and its residual connection (X_A + Attention(LayerNorm(X_A))).| Subset | Weight | Samples |
|---|---|---|
| stories | 0.300 | 120 |
| web_samples_v2 | 0.200 | 80 |
| web_samples_v1 | 0.150 | 60 |
| wikihow | 0.150 | 60 |
| openstax | 0.125 | 50 |
| stanford | 0.075 | 30 |
Layer Score
------ ----------
21 0.009053 ← dropped
22 0.010405 ← dropped
23 0.012417 ← dropped
20 0.012783 ← dropped
18 0.014297 ← dropped
24 0.014580 ← dropped
25 0.015039
19 0.019702
...
1 0.139336
0 0.287197LlamaDecoderLayer, self_attn and input_layernorm are deleted and the layer's forward() is patched to route hidden states directly to the MLP block:1def forward_no_attn(self, hidden_states, ...):
2 residual = hidden_states
3 hidden_states = self.post_attention_layernorm(hidden_states)
4 hidden_states = self.mlp(hidden_states)
5 hidden_states = residual + hidden_states
6 return hidden_states1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model = AutoModelForCausalLM.from_pretrained(
5 "oopere/llama-3.2-3b-attn-drop-6",
6 torch_dtype=torch.float16,
7 device_map="auto",
8 trust_remote_code=True,
9)
10tokenizer = AutoTokenizer.from_pretrained("oopere/llama-3.2-3b-attn-drop-6")Note: This model was developed and tested on a Google Colab T4 GPU (free tier). Usetorch.float16on T4; switch totorch.bfloat16on Ampere-class GPUs or newer.
| Benchmark | Metric | Baseline | Pruned | Δ |
|---|---|---|---|---|
| ARC Easy | acc_norm | 0.7180 | 0.7197 | +0.24% |
| HellaSwag | acc_norm | 0.7405 | 0.7254 | -2.04% |
| LAMBADA OpenAI | accuracy | 0.6969 | 0.5639 | -19.08% |
| PIQA | acc_norm | 0.7813 | 0.7715 | -1.25% |
| WinoGrande | accuracy | 0.6961 | 0.6827 | -1.93% |
NUM_LAYERS_TO_DROP=6 — throughput: 9.27 tok/s