TensorLens: End-to-End Transformer Analysis via High-Order Attention Tensors
Attention matrices are fundamental to transformer research, supporting a broad range of applications including interpretability, visualization, manipulation, and distillation. Yet, most existing analyses focus on individual attention heads or layers, failing to account for the model's global behavior. While prior efforts have extended attention formulations across multiple heads via averaging and matrix multiplications or incorporated components such as normalization and FFNs, a unified and complete representation that encapsulates all transformer blocks is still lacking. We address this gap by introducing TensorLens, a novel formulation that captures the entire transformer as a single, input-dependent linear operator expressed through a high-order attention-interaction tensor. This tensor jointly encodes attention, FFNs, activations, normalizations, and residual connections, offering a theoretically coherent and expressive linear representation of the model's computation. TensorLens is theoretically grounded and our empirical validation shows that it yields richer representations than previous attention-aggregation methods. Our experiments demonstrate that the attention tensor can serve as a powerful foundation for developing tools aimed at interpretability and model understanding. Our code is attached as a supplementary.
69789211026bdf047311705b
Ido Andrew Atad
69789211026bdf047311705c
Itamar Zimerman
admin_assigned
2026-01-27T14:38:50.723Z
65376feed325b3f02fb92c69
/avatars/e952918cf434d5302e9b1a404eccaf0e.svg
Itamar Zimerman
ItamarZ
user
ItamarZ
69789211026bdf047311705d
Shahar Katz
admin_assigned
2026-01-27T14:38:56.741Z
641051dcf52d7eb22e050f98
/avatars/dcc2e51552b4443c0352a6632d8a1001.svg
Shahar Katz
shaharkatz
user
shaharkatz
69789211026bdf047311705e
Lior Wolf
admin_assigned
2026-01-27T14:39:03.768Z
62f9f170363251ee40a08046
/avatars/67ad459db44b605be0c1f6bd33363d6e.svg
Lior Wolf
liorwolf
user
liorwolf
TensorLens: End-to-End Transformer Analysis via High-Order Attention Tensors
Attention matrices are fundamental to transformer research, supporting a broad range of applications including interpretability, visualization, manipulation, and distillation. Yet, most existing analyses focus on individual attention heads or layers, failing to account for the model's global behavior. While prior efforts have extended attention formulations across multiple heads via averaging and matrix multiplications or incorporated components such as normalization and FFNs, a unified and complete representation that encapsulates all transformer blocks is still lacking. We address this gap by introducing TensorLens, a novel formulation that captures the entire transformer as a single, input-dependent linear operator expressed through a high-order attention-interaction tensor. This tensor jointly encodes attention, FFNs, activations, normalizations, and residual connections, offering a theoretically coherent and expressive linear representation of the model's computation. TensorLens is theoretically grounded and our empirical validation shows that it yields richer representations than previous attention-aggregation methods. Our experiments demonstrate that the attention tensor can serve as a powerful foundation for developing tools aimed at interpretability and model understanding. Our code is attached as a supplementary.
TensorLens presents a novel mathematical framework that represents the complete transformer architecture as a single input-dependent linear operator using high-order tensors, enabling comprehensive analysis of attention mechanisms and model components.
attention matrices transformers attention heads attention formulation attention-aggregation methods high-order attention-interaction tensor linear operator model interpretability model understanding residual connections feedforward networks normalization