Exact-Solution Volume and Length Generalization in Transformers
Organizations: University of Notre Dame
Abstract
Research on transformer expressivity shows whether a transformer is capable of solving a given task, but gives little indication of whether the solution, if learned, is generalizable to longer input lengths. We study this question through normalized exact-solution volume (NESV): the fraction of a bounded parameter region that achieves an exact solution on every input of length . For fixed-width, single-layer transformers with -scaled attention, we establish asymptotic bounds on NESV for four tasks: FIRST (), MAJORITY (), INDEX (), and PARITY (). These results are consistent with previous empirical results: the faster the exact-solution volume decays with input length, the harder it is to length-generalize on that task. Looking deeper into INDEX, our volume analysis reveals two error sources that grow with . Consequently, we study a transformer model that would structurally eliminate one of the terms, theoretically improving the NESV bound to , and empirically achieving 85% accuracy when tested at the training length, compared with the 60% accuracy of the original model. We conclude that volume analysis may be a useful approach to identify concrete sources of length sensitivity and thus provide insights into task-specific model refinements.
Figures & tables
| Task | Model | |||||||
|---|---|---|---|---|---|---|---|---|
| Positional ( ) | General ( ) | Sinusoidal ( ) | Normalized ( ) | |||||
| NESV | Acc. (%) | NESV | Acc. (%) | NESV | Acc. (%) | NESV | Acc. (%) | |
| First | 100.0 | 51.12 | 55.06 | 100.0 | ||||
| Majority | — | 92.7 | 82.6 | 87.5 | — | 92.7 | ||
| Index | 59.6 | 51.9 | 50.2 | 85.1 | ||||
| Parity | — | — | — | — | ||||
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| First ( ) | Majority ( ) | Index ( ) | Index ( ) | ||
|---|---|---|---|---|---|
| 11 | 111 | 100.0 (100.0–100.0) | 83.8 (78.0–89.4) | 57.2 (55.9–58.6) | 63.4 (62.7–64.1) |
| 21 | 211 | 100.0 (100.0–100.0) | 91.3 (86.2–95.3) | 55.2 (54.1–56.5) | 74.1 (68.8–79.9) |
| 31 | 311 | 100.0 (100.0–100.0) | 87.1 (82.6–91.5) | 59.2 (58.3–60.0) | 90.6 (85.6–95.4) |
| 41 | 411 | 100.0 (100.0–100.0) | 88.5 (84.2–92.2) | 55.1 (54.5–55.8) | 84.4 (78.1–90.6) |
| 51 | 511 | 100.0 (100.0–100.0) | 82.6 (77.6–87.5) | 59.6 (58.6–60.6) | 85.1 (80.2–90.1) |
| NoPE General | Sinusoidal General | |
|---|---|---|
| 11 | 91.6 (88.1–95.0) | 95.3 (93.6–96.8) |
| 21 | 95.1 (91.8–97.6) | 93.8 (91.5–95.9) |
| 31 | 92.9 (90.0–95.6) | 91.2 (88.2–94.0) |
| 41 | 93.4 (90.6–95.8) | 91.5 (88.7–94.1) |
| 51 | 89.8 (86.2–92.9) | 92.9 (90.0–95.6) |