Multi-Headed Attention: Exploring the Power of Multiple Queries
This document analyzes a simple version of multi-headed attention, where two query vectors (q1 and q2) are used to generate a pair of output vectors (c1 and c2), each derived from single-headed attention with its respective query. The final output of the multi-headed attention is the average of these vectors, 0.5(c1 + c2). We explore the behavior of this system when key vectors {k1, ..., kn} are randomly sampled with known means µi but unknown covariances Σi. The means are mutually orthogonal (µ⊤i µj = 0 if i ̸= j) and have unit norm (∥µi∥ = 1).
i. Scenario: Covariance Matrices with Small α
Assuming Σi = αI for vanishingly small α, we aim to design q1 and q2 so that c ≈ 0.5(va + vb). To achieve this, we set q1 = µa and q2 = µb. This ensures that q1 attends to key vectors close to µa, resulting in c1 ≈ va, while q2 attends to key vectors close to µb, leading to c2 ≈ vb. Since the means are orthogonal, key vectors close to µa are far from µb and vice versa. Therefore, averaging c1 and c2 yields c ≈ 0.5(va + vb).
ii. Scenario: Covariance Matrix with Correlation for µa
Considering Σa = αI + 0.5(µaµ⊤a) for small α and Σi = αI for all i ̸= a, we utilize the same q1 and q2 as designed in part i. Due to the added term in Σa, key vectors close to µa become correlated. This means that attending to one key vector near µa may also attend to other nearby key vectors. As a result, c will not only attend to va but also to other key vectors close to µa, potentially making c more spread out and less focused on va. However, the other key vectors with Σi = αI remain uncorrelated, so attending to them will not be affected by the correlation near µa. Consequently, c will still be approximately 0.5(va + vb) but may exhibit greater spread and reduced focus on va. We ignore cases where ka⊤qi < 0.
AI 优化版
原文地址:https://www.cveoy.top/t/topic/oOHS 著作权归作者所有。请勿转载和采集!