# Data-Adaptive Mahalanobis Metric Learning for Cross-Head Attention in Transformers

*Zhenke Duan, Xin Li, Jiqun Pan, Xiaofei Dong, Hanwen Ning, Xinyuan Song*

[NeurIPS page](https://neurips.cc/virtual/2026/poster/151478) · [OpenReview](https://openreview.net/forum?id=aK0LiJE4IQ) · [Open on the map](../papers.html#p151478)

Category: [Efficient LLM Inference & Training](../pcat/14.md) › [Linear Attention Memory Mechanisms](../pgroup/24.md) · Type: new method · Keywords: cross-head attention, Mahalanobis metric learning, data-adaptive attention, Transformer efficiency, inter-head interaction

Areas: [Model Architectures & Sequence Modeling](../areas/architectures.md) › Language Model Architectures › Efficient Attention

## Summary
DAMCHA introduces a data-adaptive Mahalanobis metric learning approach for cross-head attention, enabling Transformers to capture inter-head interactions and dynamically adapt attention geometry while remaining computationally efficient.

## Explained to a 5-year-old
Transformers are like machines that pay attention to words. Usually each part of the machine looks at words separately. This paper makes the parts talk to each other, so they can share information. It also lets the machine change how it looks at words depending on what they mean. This helps the machine understand better without needing a lot of extra computer power.

## Explained to a 5-year-old, longer
A transformer is a computer program that reads text by paying attention to each word. It splits the work into several small helpers called heads. In the usual way, each head looks at words on its own. This can miss important connections between different heads. The new idea makes the heads talk to each other, so they can share what they see. It also lets the way the heads look at words change depending on the sentence. This means the program can learn better patterns from the data. The changes are done in a way that keeps the computer usage low. The method can be used in many existing transformer models without big changes. It works like a drop-in replacement for the old attention method. Experiments show it works better on many tasks. Overall, it gives a smarter and more efficient way to read and understand language.

## For a technical reader
Standard multi-head attention in Transformers treats each head independently, using a fixed Euclidean similarity. The paper proposes learning a full cross-head metric that captures interactions between heads, making the similarity more expressive. This metric is made data-dependent, so the attention geometry adapts to the input distribution. Regularization such as stack-wise parameter sharing keeps the model efficient and stable. The result is a drop-in replacement that improves performance while using comparable or fewer computational resources.

## Problem
Standard multi-head attention uses a static, head-wise Euclidean similarity that discards interactions between heads, limiting the expressive power of Transformers. This restricts the ability of attention to adapt to the underlying data structure.

## Method
The approach learns a full cross-head metric matrix that captures inter-head interactions and parameterizes this matrix as an input-dependent function, allowing the attention geometry to adapt to data structure. It also employs regularization such as stack-wise parameter sharing to maintain computational efficiency and stable training.

## Results
The approach achieves superior performance compared to competing baselines on multiple benchmark tasks.

## Contributions
It introduces a full cross-head metric learning formulation that captures inter-head interactions and makes the metric input-dependent, along with regularization techniques for efficiency. These contributions enable a drop-in replacement for standard multi-head attention with improved expressive power.

## Practical relevance
It enables practitioners to upgrade existing Transformer models with richer attention at little extra cost, improving performance on a variety of tasks.

## Research questions this paper is counted under

- [How can transformer attention be made more expressive and adaptive to input and representation dynamics?](../q/422.md)

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. [Suggest a correction](../feedback/?on=p/151478)
