Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-attention weights don't always sum to 1 #14

Open
DennisHaijma opened this issue Mar 13, 2022 · 2 comments
Open

Self-attention weights don't always sum to 1 #14

DennisHaijma opened this issue Mar 13, 2022 · 2 comments

Comments

@DennisHaijma
Copy link

DennisHaijma commented Mar 13, 2022

Hi all,

Nice work. I have a question however. I see with in my problem setting that the self-attention (SA) weights don't always sum to ~1 (row-wise). I assume this is due to the out-of-sample approximation and structural properties of the true SA matrix. Are there ways to reduce the error and obtain a more accurate approximation or other ways to account for this? I myself will try with more landmarks and see how the dynamics change.

Thanks in advance,

Dennis

@mlpen
Copy link
Owner

mlpen commented Mar 21, 2022

Hi Dennis,

The algorithm guarantees the convergence of approximation as number of landmarks increases, and the error of approximation is bounded in terms of matrix norm.

If you want the self-attention weights to sum up 1, you can perform a renormalization after the nystrom approximation.

@DennisHaijma
Copy link
Author

DennisHaijma commented Apr 25, 2022

Thanks for your reply. I witness artefacts when calculating approximated weighted attention distances for each instance using its row-vector of attention weights. Whether my computation is right or wrong and given my lack of advanced linear algebra knowledge, would you suggest using the self-attention matrix for such task given the out-of-sample approximation and its implications?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants